more cleanup
This commit is contained in:
parent
64fbacf127
commit
e7367ca13a
4 changed files with 42 additions and 24 deletions
|
@ -1,24 +1,26 @@
|
||||||
using System;
|
using Ryujinx.HLE.Input;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.Hid
|
namespace Ryujinx.HLE.HOS.Services.Hid
|
||||||
{
|
{
|
||||||
static class HidUtils
|
static class HidUtils
|
||||||
{
|
{
|
||||||
public static int GetNpadTypeId(uint npadId)
|
public static HidControllerId GetIndexFromNpadIdType(NpadIdType npadIdType)
|
||||||
{
|
{
|
||||||
switch (npadId)
|
switch (npadIdType)
|
||||||
{
|
{
|
||||||
case 0: return 0;
|
case NpadIdType.Player1: return HidControllerId.ControllerPlayer1;
|
||||||
case 1: return 1;
|
case NpadIdType.Player2: return HidControllerId.ControllerPlayer2;
|
||||||
case 2: return 2;
|
case NpadIdType.Player3: return HidControllerId.ControllerPlayer3;
|
||||||
case 3: return 3;
|
case NpadIdType.Player4: return HidControllerId.ControllerPlayer4;
|
||||||
case 4: return 4;
|
case NpadIdType.Player5: return HidControllerId.ControllerPlayer5;
|
||||||
case 5: return 5;
|
case NpadIdType.Player6: return HidControllerId.ControllerPlayer6;
|
||||||
case 6: return 6;
|
case NpadIdType.Player7: return HidControllerId.ControllerPlayer7;
|
||||||
case 7: return 7;
|
case NpadIdType.Player8: return HidControllerId.ControllerPlayer8;
|
||||||
case 32: return 8;
|
case NpadIdType.Handheld: return HidControllerId.ControllerHandheld;
|
||||||
case 16: return 9;
|
case NpadIdType.Unknown: return HidControllerId.ControllerUnknown;
|
||||||
default: throw new ArgumentOutOfRangeException(nameof(npadId));
|
|
||||||
|
default: throw new ArgumentOutOfRangeException(nameof(npadIdType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
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.Input;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
@ -78,21 +79,19 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||||
// GetNpadIrCameraHandle(u32) -> nn::irsensor::IrCameraHandle
|
// GetNpadIrCameraHandle(u32) -> nn::irsensor::IrCameraHandle
|
||||||
public long GetNpadIrCameraHandle(ServiceCtx context)
|
public long GetNpadIrCameraHandle(ServiceCtx context)
|
||||||
{
|
{
|
||||||
uint npadId = context.RequestData.ReadUInt32();
|
NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();
|
||||||
|
|
||||||
if (npadId >= 8 && npadId != 16 && npadId != 32)
|
if (npadIdType >= NpadIdType.Player8 && npadIdType != NpadIdType.Unknown && npadIdType != NpadIdType.Handheld)
|
||||||
{
|
{
|
||||||
return ErrorCode.MakeError(ErrorModule.Hid, IrsError.NpadIdOutOfRange);
|
return ErrorCode.MakeError(ErrorModule.Irsensor, IrsError.NpadIdOutOfRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((1 << (int)npadId) & 0x1000100FF) == 0)
|
HidControllerId irCameraHandle = HidUtils.GetIndexFromNpadIdType(npadIdType);
|
||||||
{
|
|
||||||
return ErrorCode.MakeError(ErrorModule.Hid, IrsError.NpadIdOutOfRange);
|
|
||||||
}
|
|
||||||
|
|
||||||
int npadTypeId = HidUtils.GetNpadTypeId(npadId);
|
context.ResponseData.Write((int)irCameraHandle);
|
||||||
|
|
||||||
context.ResponseData.Write(npadTypeId);
|
// NOTE: If the irCameraHandle pointer is null this error is returned, Doesn't occur in our case.
|
||||||
|
// return ErrorCode.MakeError(ErrorModule.Irsensor, IrsError.HandlePointerIsNull);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
{
|
{
|
||||||
static class IrsError
|
static class IrsError
|
||||||
{
|
{
|
||||||
public const int NpadIdOutOfRange = 709;
|
public const int HandlePointerIsNull = 212;
|
||||||
|
public const int NpadIdOutOfRange = 709;
|
||||||
}
|
}
|
||||||
}
|
}
|
16
Ryujinx.HLE/HOS/Services/Hid/NpadIdType.cs
Normal file
16
Ryujinx.HLE/HOS/Services/Hid/NpadIdType.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Hid
|
||||||
|
{
|
||||||
|
public enum NpadIdType
|
||||||
|
{
|
||||||
|
Player1 = 0,
|
||||||
|
Player2 = 1,
|
||||||
|
Player3 = 2,
|
||||||
|
Player4 = 3,
|
||||||
|
Player5 = 4,
|
||||||
|
Player6 = 5,
|
||||||
|
Player7 = 6,
|
||||||
|
Player8 = 7,
|
||||||
|
Unknown = 16,
|
||||||
|
Handheld = 32
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue