Little rewrite of HID input (#723)

* change hid sharedmem writing to use structures
This commit is contained in:
emmauss 2019-07-22 20:15:46 +03:00 committed by GitHub
parent 1f3a34dd7a
commit d254548548
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 682 additions and 409 deletions

View file

@ -5,39 +5,39 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{
static class HidUtils
{
public static HidControllerId GetIndexFromNpadIdType(NpadIdType npadIdType)
public static ControllerId GetIndexFromNpadIdType(NpadIdType npadIdType)
{
switch (npadIdType)
{
case NpadIdType.Player1: return HidControllerId.ControllerPlayer1;
case NpadIdType.Player2: return HidControllerId.ControllerPlayer2;
case NpadIdType.Player3: return HidControllerId.ControllerPlayer3;
case NpadIdType.Player4: return HidControllerId.ControllerPlayer4;
case NpadIdType.Player5: return HidControllerId.ControllerPlayer5;
case NpadIdType.Player6: return HidControllerId.ControllerPlayer6;
case NpadIdType.Player7: return HidControllerId.ControllerPlayer7;
case NpadIdType.Player8: return HidControllerId.ControllerPlayer8;
case NpadIdType.Handheld: return HidControllerId.ControllerHandheld;
case NpadIdType.Unknown: return HidControllerId.ControllerUnknown;
case NpadIdType.Player1: return ControllerId.ControllerPlayer1;
case NpadIdType.Player2: return ControllerId.ControllerPlayer2;
case NpadIdType.Player3: return ControllerId.ControllerPlayer3;
case NpadIdType.Player4: return ControllerId.ControllerPlayer4;
case NpadIdType.Player5: return ControllerId.ControllerPlayer5;
case NpadIdType.Player6: return ControllerId.ControllerPlayer6;
case NpadIdType.Player7: return ControllerId.ControllerPlayer7;
case NpadIdType.Player8: return ControllerId.ControllerPlayer8;
case NpadIdType.Handheld: return ControllerId.ControllerHandheld;
case NpadIdType.Unknown: return ControllerId.ControllerUnknown;
default: throw new ArgumentOutOfRangeException(nameof(npadIdType));
}
}
public static NpadIdType GetNpadIdTypeFromIndex(HidControllerId index)
public static NpadIdType GetNpadIdTypeFromIndex(ControllerId index)
{
switch (index)
{
case HidControllerId.ControllerPlayer1: return NpadIdType.Player1;
case HidControllerId.ControllerPlayer2: return NpadIdType.Player2;
case HidControllerId.ControllerPlayer3: return NpadIdType.Player3;
case HidControllerId.ControllerPlayer4: return NpadIdType.Player4;
case HidControllerId.ControllerPlayer5: return NpadIdType.Player5;
case HidControllerId.ControllerPlayer6: return NpadIdType.Player6;
case HidControllerId.ControllerPlayer7: return NpadIdType.Player7;
case HidControllerId.ControllerPlayer8: return NpadIdType.Player8;
case HidControllerId.ControllerHandheld: return NpadIdType.Handheld;
case HidControllerId.ControllerUnknown: return NpadIdType.Unknown;
case ControllerId.ControllerPlayer1: return NpadIdType.Player1;
case ControllerId.ControllerPlayer2: return NpadIdType.Player2;
case ControllerId.ControllerPlayer3: return NpadIdType.Player3;
case ControllerId.ControllerPlayer4: return NpadIdType.Player4;
case ControllerId.ControllerPlayer5: return NpadIdType.Player5;
case ControllerId.ControllerPlayer6: return NpadIdType.Player6;
case ControllerId.ControllerPlayer7: return NpadIdType.Player7;
case ControllerId.ControllerPlayer8: return NpadIdType.Player8;
case ControllerId.ControllerHandheld: return NpadIdType.Handheld;
case ControllerId.ControllerUnknown: return NpadIdType.Unknown;
default: throw new ArgumentOutOfRangeException(nameof(index));
}

View file

@ -569,8 +569,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// SetSupportedNpadIdType(nn::applet::AppletResourceUserId, array<NpadIdType, 9>)
public ResultCode SetSupportedNpadIdType(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
HidControllerId npadIdType = (HidControllerId)context.RequestData.ReadInt64();
long appletResourceUserId = context.RequestData.ReadInt64();
ControllerId npadIdType = (ControllerId)context.RequestData.ReadInt64();
Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, npadIdType });
@ -687,8 +687,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// SetNpadJoyAssignmentModeSingleByDefault(uint HidControllerId, nn::applet::AppletResourceUserId)
public ResultCode SetNpadJoyAssignmentModeSingleByDefault(ServiceCtx context)
{
HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
ControllerId hidControllerId = (ControllerId)context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
_npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Single;
@ -701,7 +701,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// SetNpadJoyAssignmentModeSingle(uint HidControllerId, nn::applet::AppletResourceUserId, long HidNpadJoyDeviceType)
public ResultCode SetNpadJoyAssignmentModeSingle(ServiceCtx context)
{
HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32();
ControllerId hidControllerId = (ControllerId)context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
HidNpadJoyDeviceType hidNpadJoyDeviceType = (HidNpadJoyDeviceType)context.RequestData.ReadInt64();
@ -716,8 +716,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// SetNpadJoyAssignmentModeDual(uint HidControllerId, nn::applet::AppletResourceUserId)
public ResultCode SetNpadJoyAssignmentModeDual(ServiceCtx context)
{
HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
ControllerId hidControllerId = (ControllerId)context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
_npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Dual;
@ -830,7 +830,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// SetNpadJoyAssignmentModeSingleWithDestination(uint HidControllerId, long HidNpadJoyDeviceType, nn::applet::AppletResourceUserId) -> bool Unknown0, uint Unknown1
public ResultCode SetNpadJoyAssignmentModeSingleWithDestination(ServiceCtx context)
{
HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32();
ControllerId hidControllerId = (ControllerId)context.RequestData.ReadInt32();
HidNpadJoyDeviceType hidNpadJoyDeviceType = (HidNpadJoyDeviceType)context.RequestData.ReadInt64();
long appletResourceUserId = context.RequestData.ReadInt64();

View file

@ -65,7 +65,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
return ResultCode.NpadIdOutOfRange;
}
HidControllerId irCameraHandle = HidUtils.GetIndexFromNpadIdType(npadIdType);
ControllerId irCameraHandle = HidUtils.GetIndexFromNpadIdType(npadIdType);
context.ResponseData.Write((int)irCameraHandle);

View file

@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
public DeviceState State = DeviceState.Unavailable;
public HidControllerId Handle;
public NpadIdType NpadIdType;
public ControllerId Handle;
public NpadIdType NpadIdType;
}
}