irs: Little service cleanup
This commit is contained in:
parent
36f62cbe72
commit
64fbacf127
4 changed files with 61 additions and 37 deletions
25
Ryujinx.HLE/HOS/Services/Hid/HidUtils.cs
Normal file
25
Ryujinx.HLE/HOS/Services/Hid/HidUtils.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Hid
|
||||||
|
{
|
||||||
|
static class HidUtils
|
||||||
|
{
|
||||||
|
public static int GetNpadTypeId(uint npadId)
|
||||||
|
{
|
||||||
|
switch (npadId)
|
||||||
|
{
|
||||||
|
case 0: return 0;
|
||||||
|
case 1: return 1;
|
||||||
|
case 2: return 2;
|
||||||
|
case 3: return 3;
|
||||||
|
case 4: return 4;
|
||||||
|
case 5: return 5;
|
||||||
|
case 6: return 6;
|
||||||
|
case 7: return 7;
|
||||||
|
case 32: return 8;
|
||||||
|
case 16: return 9;
|
||||||
|
default: throw new ArgumentOutOfRangeException(nameof(npadId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,33 +1,42 @@
|
||||||
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.Memory;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.Irs
|
namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||||
{
|
{
|
||||||
class IIrSensorServer : IpcService
|
class IIrSensorServer : IpcService
|
||||||
{
|
{
|
||||||
|
private int _irsensorSharedMemoryHandle = 0;
|
||||||
|
|
||||||
private Dictionary<int, ServiceProcessRequest> _commands;
|
private Dictionary<int, ServiceProcessRequest> _commands;
|
||||||
|
|
||||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||||
|
|
||||||
private KSharedMemory _irsSharedMem;
|
public IIrSensorServer()
|
||||||
|
|
||||||
public IIrSensorServer(KSharedMemory irsSharedMem)
|
|
||||||
{
|
{
|
||||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||||
{
|
{
|
||||||
{ 302, ActivateIrsensor },
|
{ 302, ActivateIrsensor },
|
||||||
{ 303, DeactivateIrsensor },
|
{ 303, DeactivateIrsensor },
|
||||||
{ 304, GetIrsensorSharedMemoryHandle },
|
{ 304, GetIrsensorSharedMemoryHandle },
|
||||||
|
//{ 305, StopImageProcessor },
|
||||||
|
//{ 306, RunMomentProcessor },
|
||||||
|
//{ 307, RunClusteringProcessor },
|
||||||
|
//{ 308, RunImageTransferProcessor },
|
||||||
|
//{ 309, GetImageTransferProcessorState },
|
||||||
|
//{ 310, RunTeraPluginProcessor },
|
||||||
{ 311, GetNpadIrCameraHandle },
|
{ 311, GetNpadIrCameraHandle },
|
||||||
{ 319, ActivateIrsensorWithFunctionLevel }
|
//{ 312, RunPointingProcessor },
|
||||||
|
//{ 313, SuspendImageProcessor },
|
||||||
|
//{ 314, CheckFirmwareVersion }, // 3.0.0+
|
||||||
|
//{ 315, SetFunctionLevel }, // 4.0.0+
|
||||||
|
//{ 316, RunImageTransferExProcessor }, // 4.0.0+
|
||||||
|
//{ 317, RunIrLedProcessor }, // 4.0.0+
|
||||||
|
//{ 318, StopImageProcessorAsync }, // 4.0.0+
|
||||||
|
{ 319, ActivateIrsensorWithFunctionLevel }, // 4.0.0+
|
||||||
};
|
};
|
||||||
|
|
||||||
_irsSharedMem = irsSharedMem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActivateIrsensor(nn::applet::AppletResourceUserId, pid)
|
// ActivateIrsensor(nn::applet::AppletResourceUserId, pid)
|
||||||
|
@ -53,14 +62,15 @@ namespace Ryujinx.HLE.HOS.Services.Irs
|
||||||
// GetIrsensorSharedMemoryHandle(nn::applet::AppletResourceUserId, pid) -> handle<copy>
|
// GetIrsensorSharedMemoryHandle(nn::applet::AppletResourceUserId, pid) -> handle<copy>
|
||||||
public long GetIrsensorSharedMemoryHandle(ServiceCtx context)
|
public long GetIrsensorSharedMemoryHandle(ServiceCtx context)
|
||||||
{
|
{
|
||||||
var handleTable = context.Process.HandleTable;
|
if (_irsensorSharedMemoryHandle == 0)
|
||||||
|
|
||||||
if (handleTable.GenerateHandle(_irsSharedMem, out int handle) != KernelResult.Success)
|
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Out of handles!");
|
if (context.Process.HandleTable.GenerateHandle(context.Device.System.IirsSharedMem, out _irsensorSharedMemoryHandle) != KernelResult.Success)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Out of handles!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_irsensorSharedMemoryHandle);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -72,39 +82,21 @@ namespace Ryujinx.HLE.HOS.Services.Irs
|
||||||
|
|
||||||
if (npadId >= 8 && npadId != 16 && npadId != 32)
|
if (npadId >= 8 && npadId != 16 && npadId != 32)
|
||||||
{
|
{
|
||||||
return ErrorCode.MakeError(ErrorModule.Hid, 0x2c5);
|
return ErrorCode.MakeError(ErrorModule.Hid, IrsError.NpadIdOutOfRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((1 << (int)npadId) & 0x1000100FF) == 0)
|
if (((1 << (int)npadId) & 0x1000100FF) == 0)
|
||||||
{
|
{
|
||||||
return ErrorCode.MakeError(ErrorModule.Hid, 0x2c5);
|
return ErrorCode.MakeError(ErrorModule.Hid, IrsError.NpadIdOutOfRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
int npadTypeId = GetNpadTypeId(npadId);
|
int npadTypeId = HidUtils.GetNpadTypeId(npadId);
|
||||||
|
|
||||||
context.ResponseData.Write(npadTypeId);
|
context.ResponseData.Write(npadTypeId);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetNpadTypeId(uint npadId)
|
|
||||||
{
|
|
||||||
switch(npadId)
|
|
||||||
{
|
|
||||||
case 0: return 0;
|
|
||||||
case 1: return 1;
|
|
||||||
case 2: return 2;
|
|
||||||
case 3: return 3;
|
|
||||||
case 4: return 4;
|
|
||||||
case 5: return 5;
|
|
||||||
case 6: return 6;
|
|
||||||
case 7: return 7;
|
|
||||||
case 32: return 8;
|
|
||||||
case 16: return 9;
|
|
||||||
default: throw new ArgumentOutOfRangeException(nameof(npadId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActivateIrsensorWithFunctionLevel(nn::applet::AppletResourceUserId, nn::irsensor::PackedFunctionLevel, pid)
|
// ActivateIrsensorWithFunctionLevel(nn::applet::AppletResourceUserId, nn::irsensor::PackedFunctionLevel, pid)
|
||||||
public long ActivateIrsensorWithFunctionLevel(ServiceCtx context)
|
public long ActivateIrsensorWithFunctionLevel(ServiceCtx context)
|
||||||
{
|
{
|
7
Ryujinx.HLE/HOS/Services/Hid/Irs/IrsError.cs
Normal file
7
Ryujinx.HLE/HOS/Services/Hid/Irs/IrsError.cs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||||
|
{
|
||||||
|
static class IrsError
|
||||||
|
{
|
||||||
|
public const int NpadIdOutOfRange = 709;
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ using Ryujinx.HLE.HOS.Services.Caps;
|
||||||
using Ryujinx.HLE.HOS.Services.Es;
|
using Ryujinx.HLE.HOS.Services.Es;
|
||||||
using Ryujinx.HLE.HOS.Services.FspSrv;
|
using Ryujinx.HLE.HOS.Services.FspSrv;
|
||||||
using Ryujinx.HLE.HOS.Services.Hid;
|
using Ryujinx.HLE.HOS.Services.Hid;
|
||||||
using Ryujinx.HLE.HOS.Services.Irs;
|
using Ryujinx.HLE.HOS.Services.Hid.Irs;
|
||||||
using Ryujinx.HLE.HOS.Services.Ldr;
|
using Ryujinx.HLE.HOS.Services.Ldr;
|
||||||
using Ryujinx.HLE.HOS.Services.Lm;
|
using Ryujinx.HLE.HOS.Services.Lm;
|
||||||
using Ryujinx.HLE.HOS.Services.Mm;
|
using Ryujinx.HLE.HOS.Services.Mm;
|
||||||
|
@ -112,7 +112,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||||
return new IHidServer(system);
|
return new IHidServer(system);
|
||||||
|
|
||||||
case "irs":
|
case "irs":
|
||||||
return new IIrSensorServer(system.IirsSharedMem);
|
return new IIrSensorServer();
|
||||||
|
|
||||||
case "ldr:ro":
|
case "ldr:ro":
|
||||||
return new IRoInterface();
|
return new IRoInterface();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue