This commit is contained in:
Ac_K 2019-06-28 04:22:35 +02:00
commit 1957690f34
3 changed files with 128 additions and 31 deletions

View file

@ -24,9 +24,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
} }
} }
public static NpadIdType GetNpadIdTypeFromIndex(HidControllerId Index) public static NpadIdType GetNpadIdTypeFromIndex(HidControllerId index)
{ {
switch (Index) switch (index)
{ {
case HidControllerId.ControllerPlayer1: return NpadIdType.Player1; case HidControllerId.ControllerPlayer1: return NpadIdType.Player1;
case HidControllerId.ControllerPlayer2: return NpadIdType.Player2; case HidControllerId.ControllerPlayer2: return NpadIdType.Player2;
@ -39,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
case HidControllerId.ControllerHandheld: return NpadIdType.Handheld; case HidControllerId.ControllerHandheld: return NpadIdType.Handheld;
case HidControllerId.ControllerUnknown: return NpadIdType.Unknown; case HidControllerId.ControllerUnknown: return NpadIdType.Unknown;
default: throw new ArgumentOutOfRangeException(nameof(Index)); default: throw new ArgumentOutOfRangeException(nameof(index));
} }
} }
} }

View file

@ -7,10 +7,10 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
class Device class Device
{ {
public KEvent ActivateEvent; public KEvent ActivateEvent;
public int ActivateEventHandle = 0; public int ActivateEventHandle;
public KEvent DeactivateEvent; public KEvent DeactivateEvent;
public int DeactivateEventHandle = 0; public int DeactivateEventHandle;
public DeviceState State = DeviceState.Unavailable; public DeviceState State = DeviceState.Unavailable;

View file

@ -1,4 +1,5 @@
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.HLE.Exceptions;
using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Threading; using Ryujinx.HLE.HOS.Kernel.Threading;
@ -28,28 +29,28 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
{ 0, Initialize }, { 0, Initialize },
{ 1, Finalize }, { 1, Finalize },
{ 2, ListDevices }, { 2, ListDevices },
//{ 3, StartDetection }, { 3, StartDetection },
//{ 4, StopDetection }, { 4, StopDetection },
//{ 5, Mount }, { 5, Mount },
//{ 6, Unmount }, { 6, Unmount },
//{ 7, OpenApplicationArea }, { 7, OpenApplicationArea },
//{ 8, GetApplicationArea }, { 8, GetApplicationArea },
//{ 9, SetApplicationArea }, { 9, SetApplicationArea },
//{ 10, Flush }, { 10, Flush },
//{ 11, Restore }, { 11, Restore },
//{ 12, CreateApplicationArea }, { 12, CreateApplicationArea },
//{ 13, GetTagInfo }, { 13, GetTagInfo },
//{ 14, GetRegisterInfo }, { 14, GetRegisterInfo },
//{ 15, GetCommonInfo }, { 15, GetCommonInfo },
//{ 16, GetModelInfo }, { 16, GetModelInfo },
{ 17, AttachActivateEvent }, { 17, AttachActivateEvent },
{ 18, AttachDeactivateEvent }, { 18, AttachDeactivateEvent },
{ 19, GetState }, { 19, GetState },
{ 20, GetDeviceState }, { 20, GetDeviceState },
{ 21, GetNpadId }, { 21, GetNpadId },
//{ 22, GetApplicationAreaSize }, { 22, GetApplicationAreaSize },
{ 23, AttachAvailabilityChangeEvent }, // 3.0.0+ { 23, AttachAvailabilityChangeEvent }, // 3.0.0+
//{ 24, RecreateApplicationArea }, // 3.0.0+ { 24, RecreateApplicationArea }, // 3.0.0+
}; };
} }
@ -72,14 +73,14 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
// Add an instance of nn::nfc::server::SaveData when it will be implemented. // Add an instance of nn::nfc::server::SaveData when it will be implemented.
// TODO: When we will be able to add multiple controllers add one entry by controller here. // TODO: When we will be able to add multiple controllers add one entry by controller here.
Device Device1 = new Device Device device1 = new Device
{ {
NpadIdType = NpadIdType.Player1, NpadIdType = NpadIdType.Player1,
Handle = HidUtils.GetIndexFromNpadIdType(NpadIdType.Player1), Handle = HidUtils.GetIndexFromNpadIdType(NpadIdType.Player1),
State = DeviceState.Initialized State = DeviceState.Initialized
}; };
_devices.Add(Device1); _devices.Add(device1);
_state = State.Initialized; _state = State.Initialized;
@ -126,14 +127,98 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
return 0; return 0;
} }
// StartDetection(bytes<8, 4>)
public long StartDetection(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// StopDetection(bytes<8, 4>)
public long StopDetection(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// Mount(bytes<8, 4>, u32, u32)
public long Mount(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// Unmount(bytes<8, 4>)
public long Unmount(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// OpenApplicationArea(bytes<8, 4>, u32)
public long OpenApplicationArea(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// GetApplicationArea(bytes<8, 4>) -> (u32, buffer<unknown, 6>)
public long GetApplicationArea(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// SetApplicationArea(bytes<8, 4>, buffer<unknown, 5>)
public long SetApplicationArea(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// Flush(bytes<8, 4>)
public long Flush(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// Restore(bytes<8, 4>)
public long Restore(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// CreateApplicationArea(bytes<8, 4>, u32, buffer<unknown, 5>)
public long CreateApplicationArea(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// GetTagInfo(bytes<8, 4>) -> buffer<unknown<0x58>, 0x1a>
public long GetTagInfo(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// GetRegisterInfo(bytes<8, 4>) -> buffer<unknown<0x100>, 0x1a>
public long GetRegisterInfo(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// GetCommonInfo(bytes<8, 4>) -> buffer<unknown<0x40>, 0x1a>
public long GetCommonInfo(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// GetModelInfo(bytes<8, 4>) -> buffer<unknown<0x40>, 0x1a>
public long GetModelInfo(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// AttachActivateEvent(bytes<8, 4>) -> handle<copy> // AttachActivateEvent(bytes<8, 4>) -> handle<copy>
public long AttachActivateEvent(ServiceCtx context) public long AttachActivateEvent(ServiceCtx context)
{ {
uint DeviceHandle = context.RequestData.ReadUInt32(); uint deviceHandle = context.RequestData.ReadUInt32();
for (int i = 0; i < _devices.Count; i++) for (int i = 0; i < _devices.Count; i++)
{ {
if ((uint)_devices[i].Handle == DeviceHandle) if ((uint)_devices[i].Handle == deviceHandle)
{ {
if (_devices[i].ActivateEventHandle == 0) if (_devices[i].ActivateEventHandle == 0)
{ {
@ -157,11 +242,11 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
// AttachDeactivateEvent(bytes<8, 4>) -> handle<copy> // AttachDeactivateEvent(bytes<8, 4>) -> handle<copy>
public long AttachDeactivateEvent(ServiceCtx context) public long AttachDeactivateEvent(ServiceCtx context)
{ {
uint DeviceHandle = context.RequestData.ReadUInt32(); uint deviceHandle = context.RequestData.ReadUInt32();
for (int i = 0; i < _devices.Count; i++) for (int i = 0; i < _devices.Count; i++)
{ {
if ((uint)_devices[i].Handle == DeviceHandle) if ((uint)_devices[i].Handle == deviceHandle)
{ {
if (_devices[i].DeactivateEventHandle == 0) if (_devices[i].DeactivateEventHandle == 0)
{ {
@ -193,11 +278,11 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
// GetDeviceState(bytes<8, 4>) -> u32 // GetDeviceState(bytes<8, 4>) -> u32
public long GetDeviceState(ServiceCtx context) public long GetDeviceState(ServiceCtx context)
{ {
uint DeviceHandle = context.RequestData.ReadUInt32(); uint deviceHandle = context.RequestData.ReadUInt32();
for (int i = 0; i < _devices.Count; i++) for (int i = 0; i < _devices.Count; i++)
{ {
if ((uint)_devices[i].Handle == DeviceHandle) if ((uint)_devices[i].Handle == deviceHandle)
{ {
context.ResponseData.Write((uint)_devices[i].State); context.ResponseData.Write((uint)_devices[i].State);
@ -213,11 +298,11 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
// GetNpadId(bytes<8, 4>) -> u32 // GetNpadId(bytes<8, 4>) -> u32
public long GetNpadId(ServiceCtx context) public long GetNpadId(ServiceCtx context)
{ {
uint DeviceHandle = context.RequestData.ReadUInt32(); uint deviceHandle = context.RequestData.ReadUInt32();
for (int i = 0; i < _devices.Count; i++) for (int i = 0; i < _devices.Count; i++)
{ {
if ((uint)_devices[i].Handle == DeviceHandle) if ((uint)_devices[i].Handle == deviceHandle)
{ {
context.ResponseData.Write((uint)HidUtils.GetNpadIdTypeFromIndex(_devices[i].Handle)); context.ResponseData.Write((uint)HidUtils.GetNpadIdTypeFromIndex(_devices[i].Handle));
@ -228,6 +313,12 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
return ErrorCode.MakeError(ErrorModule.Nfp, NfpError.DeviceNotFound); return ErrorCode.MakeError(ErrorModule.Nfp, NfpError.DeviceNotFound);
} }
// GetApplicationAreaSize(bytes<8, 4>) -> u32
public long GetApplicationAreaSize(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
// AttachAvailabilityChangeEvent() -> handle<copy> // AttachAvailabilityChangeEvent() -> handle<copy>
public long AttachAvailabilityChangeEvent(ServiceCtx context) public long AttachAvailabilityChangeEvent(ServiceCtx context)
{ {
@ -245,5 +336,11 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
return 0; return 0;
} }
// RecreateApplicationArea(bytes<8, 4>, u32, buffer<unknown, 5>)
public long RecreateApplicationArea(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
} }
} }