Implement most of Irs
This commit is contained in:
parent
f05f05b466
commit
ba9aa61cc3
23 changed files with 431 additions and 149 deletions
|
@ -15,32 +15,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||||
|
|
||||||
public IIrSensorServer(ServiceCtx context) { }
|
public IIrSensorServer(ServiceCtx context) { }
|
||||||
|
|
||||||
[CommandCmif(302)]
|
|
||||||
// ActivateIrsensor(nn::applet::AppletResourceUserId, pid)
|
|
||||||
public ResultCode ActivateIrsensor(ServiceCtx context)
|
|
||||||
{
|
|
||||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
|
||||||
|
|
||||||
// NOTE: This seems to initialize the shared memory for irs service.
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId });
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(303)]
|
|
||||||
// DeactivateIrsensor(nn::applet::AppletResourceUserId, pid)
|
|
||||||
public ResultCode DeactivateIrsensor(ServiceCtx context)
|
|
||||||
{
|
|
||||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
|
||||||
|
|
||||||
// NOTE: This seems to deinitialize the shared memory for irs service.
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId });
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(304)]
|
[CommandCmif(304)]
|
||||||
// GetIrsensorSharedMemoryHandle(nn::applet::AppletResourceUserId, pid) -> handle<copy>
|
// GetIrsensorSharedMemoryHandle(nn::applet::AppletResourceUserId, pid) -> handle<copy>
|
||||||
public ResultCode GetIrsensorSharedMemoryHandle(ServiceCtx context)
|
public ResultCode GetIrsensorSharedMemoryHandle(ServiceCtx context)
|
||||||
|
@ -61,67 +35,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandCmif(305)]
|
|
||||||
// StopImageProcessor(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId)
|
|
||||||
public ResultCode StopImageProcessor(ServiceCtx context)
|
|
||||||
{
|
|
||||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
|
||||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
|
||||||
|
|
||||||
CheckCameraHandle(irCameraHandle);
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType });
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(306)]
|
|
||||||
// RunMomentProcessor(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, PackedMomentProcessorConfig)
|
|
||||||
public ResultCode RunMomentProcessor(ServiceCtx context)
|
|
||||||
{
|
|
||||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
|
||||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
|
||||||
var packedMomentProcessorConfig = context.RequestData.ReadStruct<PackedMomentProcessorConfig>();
|
|
||||||
|
|
||||||
CheckCameraHandle(irCameraHandle);
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, packedMomentProcessorConfig.ExposureTime });
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(307)]
|
|
||||||
// RunClusteringProcessor(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, PackedClusteringProcessorConfig)
|
|
||||||
public ResultCode RunClusteringProcessor(ServiceCtx context)
|
|
||||||
{
|
|
||||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
|
||||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
|
||||||
var packedClusteringProcessorConfig = context.RequestData.ReadStruct<PackedClusteringProcessorConfig>();
|
|
||||||
|
|
||||||
CheckCameraHandle(irCameraHandle);
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, packedClusteringProcessorConfig.ExposureTime });
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(308)]
|
|
||||||
// RunImageTransferProcessor(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, PackedImageTransferProcessorConfig, u64 TransferMemorySize, TransferMemoryHandle)
|
|
||||||
public ResultCode RunImageTransferProcessor(ServiceCtx context)
|
|
||||||
{
|
|
||||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
|
||||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
|
||||||
var packedImageTransferProcessorConfig = context.RequestData.ReadStruct<PackedImageTransferProcessorConfig>();
|
|
||||||
|
|
||||||
CheckCameraHandle(irCameraHandle);
|
|
||||||
|
|
||||||
// TODO: Handle the Transfer Memory.
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, packedImageTransferProcessorConfig.ExposureTime });
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(309)]
|
[CommandCmif(309)]
|
||||||
// GetImageTransferProcessorState(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId)
|
// GetImageTransferProcessorState(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId)
|
||||||
public ResultCode GetImageTransferProcessorState(ServiceCtx context)
|
public ResultCode GetImageTransferProcessorState(ServiceCtx context)
|
||||||
|
@ -189,20 +102,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandCmif(314)] // 3.0.0+
|
|
||||||
// CheckFirmwareVersion(nn::irsensor::IrCameraHandle, nn::irsensor::PackedMcuVersion, nn::applet::AppletResourceUserId, pid)
|
|
||||||
public ResultCode CheckFirmwareVersion(ServiceCtx context)
|
|
||||||
{
|
|
||||||
int irCameraHandle = context.RequestData.ReadInt32();
|
|
||||||
short packedMcuVersionMajor = context.RequestData.ReadInt16();
|
|
||||||
short packedMcuVersionMinor = context.RequestData.ReadInt16();
|
|
||||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, irCameraHandle, packedMcuVersionMajor, packedMcuVersionMinor });
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(318)] // 4.0.0+
|
[CommandCmif(318)] // 4.0.0+
|
||||||
// StopImageProcessorAsync(nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, pid)
|
// StopImageProcessorAsync(nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, pid)
|
||||||
public ResultCode StopImageProcessorAsync(ServiceCtx context)
|
public ResultCode StopImageProcessorAsync(ServiceCtx context)
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
|
||||||
{
|
|
||||||
[Service("irs:sys")]
|
|
||||||
class IIrSensorSystemServer : IpcService
|
|
||||||
{
|
|
||||||
public IIrSensorSystemServer(ServiceCtx context) { }
|
|
||||||
}
|
|
||||||
}
|
|
47
src/Ryujinx.Horizon/Hid/HidIpcServer.cs
Normal file
47
src/Ryujinx.Horizon/Hid/HidIpcServer.cs
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||||
|
using Ryujinx.Horizon.Sdk.Sm;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Hid
|
||||||
|
{
|
||||||
|
class HidIpcServer
|
||||||
|
{
|
||||||
|
// TODO: RE These values
|
||||||
|
private const int MaxSessionsCount = 30;
|
||||||
|
|
||||||
|
private const int PointerBufferSize = 0xB40;
|
||||||
|
private const int MaxDomains = 0;
|
||||||
|
private const int MaxDomainObjects = 0;
|
||||||
|
private const int MaxPortsCount = 1;
|
||||||
|
|
||||||
|
private static readonly ManagerOptions _options = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
|
||||||
|
|
||||||
|
private SmApi _sm;
|
||||||
|
private ServerManager _serverManager;
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
HeapAllocator allocator = new();
|
||||||
|
|
||||||
|
_sm = new SmApi();
|
||||||
|
_sm.Initialize().AbortOnFailure();
|
||||||
|
|
||||||
|
_serverManager = new ServerManager(allocator, _sm, MaxPortsCount, _options, MaxSessionsCount);
|
||||||
|
|
||||||
|
// _serverManager.RegisterObjectForServer(, ServiceName.Encode("hid"), MaxSessionsCount);
|
||||||
|
// _serverManager.RegisterObjectForServer(, ServiceName.Encode("hidbus"), MaxSessionsCount);
|
||||||
|
// _serverManager.RegisterObjectForServer(, ServiceName.Encode("hid:sys"), MaxSessionsCount);
|
||||||
|
// _serverManager.RegisterObjectForServer(, ServiceName.Encode("hid:dbg"), MaxSessionsCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ServiceRequests()
|
||||||
|
{
|
||||||
|
_serverManager.ServiceRequests();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Shutdown()
|
||||||
|
{
|
||||||
|
_serverManager.Dispose();
|
||||||
|
_sm.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
src/Ryujinx.Horizon/Hid/HidMain.cs
Normal file
17
src/Ryujinx.Horizon/Hid/HidMain.cs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
namespace Ryujinx.Horizon.Hid
|
||||||
|
{
|
||||||
|
class HidMain : IService
|
||||||
|
{
|
||||||
|
public static void Main(ServiceTable serviceTable)
|
||||||
|
{
|
||||||
|
HidIpcServer ipcServer = new();
|
||||||
|
|
||||||
|
ipcServer.Initialize();
|
||||||
|
|
||||||
|
serviceTable.SignalServiceReady();
|
||||||
|
|
||||||
|
ipcServer.ServiceRequests();
|
||||||
|
ipcServer.Shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
203
src/Ryujinx.Horizon/Irs/IrSensorServer.cs
Normal file
203
src/Ryujinx.Horizon/Irs/IrSensorServer.cs
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
using Ryujinx.Horizon.Sdk.Applet;
|
||||||
|
using Ryujinx.Horizon.Sdk.Hid.Npad;
|
||||||
|
using Ryujinx.Horizon.Sdk.Irs;
|
||||||
|
using Ryujinx.Horizon.Sdk.Sf;
|
||||||
|
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Irs
|
||||||
|
{
|
||||||
|
class IrSensorServer : IIrSensorServer
|
||||||
|
{
|
||||||
|
[CmifCommand(302)]
|
||||||
|
public Result ActivateIrsensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
// NOTE: This seems to initialize the shared memory for irs service.
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id });
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(303)]
|
||||||
|
public Result DeactivateIrsensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
// NOTE: This seems to deinitialize the shared memory for irs service.
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id });
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(304)]
|
||||||
|
public Result GetIrsensorSharedMemoryHandle([CopyHandle] out int arg0, AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
// NOTE: Shared memory should use the appletResourceUserId.
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(305)]
|
||||||
|
public Result StopImageProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType });
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(306)]
|
||||||
|
public Result RunMomentProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedMomentProcessorConfig config, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, config.ExposureTime });
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(307)]
|
||||||
|
public Result RunClusteringProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedClusteringProcessorConfig config, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, config.ExposureTime });
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(308)]
|
||||||
|
public Result RunImageTransferProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedImageTransferProcessorConfig config, [CopyHandle] int arg3, ulong arg4, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
// TODO: Handle the Transfer Memory.
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, config.ExposureTime });
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(309)]
|
||||||
|
public Result GetImageTransferProcessorState(AppletResourceUserId appletResourceUserId, out ImageTransferProcessorState arg1, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<byte> arg2, IrCameraHandle irCameraHandle, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(310)]
|
||||||
|
public Result RunTeraPluginProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedTeraPluginProcessorConfig config, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(311)]
|
||||||
|
public Result GetNpadIrCameraHandle(out IrCameraHandle irCameraHandle, NpadIdType npadIdType)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(312)]
|
||||||
|
public Result RunPointingProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedPointingProcessorConfig config, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(313)]
|
||||||
|
public Result SuspendImageProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(314)]
|
||||||
|
public Result CheckFirmwareVersion(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedMcuVersion mcuVersion, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, mcuVersion.MajorVersion, mcuVersion.MinorVersion });
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(315)]
|
||||||
|
public Result SetFunctionLevel(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedFunctionLevel functionLevel, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(316)]
|
||||||
|
public Result RunImageTransferExProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedImageTransferProcessorExConfig config, int arg3, ulong arg4, ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(317)]
|
||||||
|
public Result RunIrLedProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedIrLedProcessorConfig config, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(318)]
|
||||||
|
public Result StopImageProcessorAsync(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
CheckCameraHandle(irCameraHandle);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(319)]
|
||||||
|
public Result ActivateIrsensorWithFunctionLevel(AppletResourceUserId appletResourceUserId, PackedFunctionLevel arg1, [ClientProcessId] ulong pid)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Result CheckCameraHandle(IrCameraHandle irCameraHandle)
|
||||||
|
{
|
||||||
|
if (irCameraHandle.DeviceType == 1 || (PlayerIndex)irCameraHandle.PlayerNumber >= PlayerIndex.Unknown)
|
||||||
|
{
|
||||||
|
// InvalidCameraHandle
|
||||||
|
return new Result(204);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
43
src/Ryujinx.Horizon/Irs/IrSensorSystemServer.cs
Normal file
43
src/Ryujinx.Horizon/Irs/IrSensorSystemServer.cs
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
using Ryujinx.Horizon.Sdk.Applet;
|
||||||
|
using Ryujinx.Horizon.Sdk.Irs;
|
||||||
|
using Ryujinx.Horizon.Sdk.Sf;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Irs
|
||||||
|
{
|
||||||
|
class IrSensorSystemServer : IIrSensorSystemServer
|
||||||
|
{
|
||||||
|
[CmifCommand(500)]
|
||||||
|
public Result SetAppletResourceUserId(AppletResourceUserId appletResourceUserId)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id });
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(501)]
|
||||||
|
public Result RegisterAppletResourceUserId(AppletResourceUserId appletResourceUserId, bool arg1)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, arg1 });
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(502)]
|
||||||
|
public Result UnregisterAppletResourceUserId(AppletResourceUserId appletResourceUserId)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id });
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CmifCommand(503)]
|
||||||
|
public Result EnableAppletToGetInput(AppletResourceUserId appletResourceUserId, bool arg1)
|
||||||
|
{
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, arg1 });
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
45
src/Ryujinx.Horizon/Irs/IrsIpcServer.cs
Normal file
45
src/Ryujinx.Horizon/Irs/IrsIpcServer.cs
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||||
|
using Ryujinx.Horizon.Sdk.Sm;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Irs
|
||||||
|
{
|
||||||
|
class IrsIpcServer
|
||||||
|
{
|
||||||
|
// TODO: RE These values
|
||||||
|
private const int MaxSessionsCount = 30;
|
||||||
|
|
||||||
|
private const int PointerBufferSize = 0xB40;
|
||||||
|
private const int MaxDomains = 0;
|
||||||
|
private const int MaxDomainObjects = 0;
|
||||||
|
private const int MaxPortsCount = 1;
|
||||||
|
|
||||||
|
private static readonly ManagerOptions _options = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
|
||||||
|
|
||||||
|
private SmApi _sm;
|
||||||
|
private ServerManager _serverManager;
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
HeapAllocator allocator = new();
|
||||||
|
|
||||||
|
_sm = new SmApi();
|
||||||
|
_sm.Initialize().AbortOnFailure();
|
||||||
|
|
||||||
|
_serverManager = new ServerManager(allocator, _sm, MaxPortsCount, _options, MaxSessionsCount);
|
||||||
|
|
||||||
|
_serverManager.RegisterObjectForServer(new IrSensorServer(), ServiceName.Encode("irs"), MaxSessionsCount);
|
||||||
|
_serverManager.RegisterObjectForServer(new IrSensorSystemServer(), ServiceName.Encode("irs:sys"), MaxSessionsCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ServiceRequests()
|
||||||
|
{
|
||||||
|
_serverManager.ServiceRequests();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Shutdown()
|
||||||
|
{
|
||||||
|
_serverManager.Dispose();
|
||||||
|
_sm.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
src/Ryujinx.Horizon/Irs/IrsMain.cs
Normal file
17
src/Ryujinx.Horizon/Irs/IrsMain.cs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
namespace Ryujinx.Horizon.Irs
|
||||||
|
{
|
||||||
|
class IrsMain : IService
|
||||||
|
{
|
||||||
|
public static void Main(ServiceTable serviceTable)
|
||||||
|
{
|
||||||
|
IrsIpcServer ipcServer = new();
|
||||||
|
|
||||||
|
ipcServer.Initialize();
|
||||||
|
|
||||||
|
serviceTable.SignalServiceReady();
|
||||||
|
|
||||||
|
ipcServer.ServiceRequests();
|
||||||
|
ipcServer.Shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
src/Ryujinx.Horizon/Sdk/Irs/IIrSensorServer.cs
Normal file
30
src/Ryujinx.Horizon/Sdk/Irs/IIrSensorServer.cs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
using Ryujinx.Horizon.Sdk.Applet;
|
||||||
|
using Ryujinx.Horizon.Sdk.Hid.Npad;
|
||||||
|
using Ryujinx.Horizon.Sdk.Sf;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
|
{
|
||||||
|
interface IIrSensorServer : IServiceObject
|
||||||
|
{
|
||||||
|
Result ActivateIrsensor(AppletResourceUserId appletResourceUserId, ulong pid);
|
||||||
|
Result DeactivateIrsensor(AppletResourceUserId appletResourceUserId, ulong pid);
|
||||||
|
Result GetIrsensorSharedMemoryHandle(out int arg0, AppletResourceUserId appletResourceUserId, ulong pid);
|
||||||
|
Result StopImageProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, ulong pid);
|
||||||
|
Result RunMomentProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedMomentProcessorConfig config, ulong pid);
|
||||||
|
Result RunClusteringProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedClusteringProcessorConfig config, ulong pid);
|
||||||
|
Result RunImageTransferProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedImageTransferProcessorConfig config, int arg3, ulong arg4, ulong pid);
|
||||||
|
Result GetImageTransferProcessorState(AppletResourceUserId appletResourceUserId, out ImageTransferProcessorState arg1, Span<byte> arg2, IrCameraHandle irCameraHandle, ulong pid);
|
||||||
|
Result RunTeraPluginProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedTeraPluginProcessorConfig config, ulong pid);
|
||||||
|
Result GetNpadIrCameraHandle(out IrCameraHandle irCameraHandle, NpadIdType npadIdType);
|
||||||
|
Result RunPointingProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedPointingProcessorConfig config, ulong pid);
|
||||||
|
Result SuspendImageProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, ulong pid);
|
||||||
|
Result CheckFirmwareVersion(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedMcuVersion mcuVersion, ulong pid);
|
||||||
|
Result SetFunctionLevel(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedFunctionLevel functionLevel, ulong pid);
|
||||||
|
Result RunImageTransferExProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedImageTransferProcessorExConfig config, int arg3, ulong arg4, ulong pid);
|
||||||
|
Result RunIrLedProcessor(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, PackedIrLedProcessorConfig config, ulong pid);
|
||||||
|
Result StopImageProcessorAsync(AppletResourceUserId appletResourceUserId, IrCameraHandle irCameraHandle, ulong pid);
|
||||||
|
Result ActivateIrsensorWithFunctionLevel(AppletResourceUserId appletResourceUserId, PackedFunctionLevel arg1, ulong pid);
|
||||||
|
}
|
||||||
|
}
|
14
src/Ryujinx.Horizon/Sdk/Irs/IIrSensorSystemServer.cs
Normal file
14
src/Ryujinx.Horizon/Sdk/Irs/IIrSensorSystemServer.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using Ryujinx.Horizon.Common;
|
||||||
|
using Ryujinx.Horizon.Sdk.Applet;
|
||||||
|
using Ryujinx.Horizon.Sdk.Sf;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
|
{
|
||||||
|
interface IIrSensorSystemServer : IServiceObject
|
||||||
|
{
|
||||||
|
Result SetAppletResourceUserId(AppletResourceUserId appletResourceUserId);
|
||||||
|
Result RegisterAppletResourceUserId(AppletResourceUserId appletResourceUserId, bool arg1);
|
||||||
|
Result UnregisterAppletResourceUserId(AppletResourceUserId appletResourceUserId);
|
||||||
|
Result EnableAppletToGetInput(AppletResourceUserId appletResourceUserId, bool arg1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||||
struct ImageTransferProcessorState
|
struct ImageTransferProcessorState
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x4)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x4)]
|
||||||
struct IrCameraHandle
|
struct IrCameraHandle
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x28)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x28)]
|
||||||
struct PackedClusteringProcessorConfig
|
struct PackedClusteringProcessorConfig
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x4)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x4)]
|
||||||
struct PackedFunctionLevel
|
struct PackedFunctionLevel
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x18)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x18)]
|
||||||
struct PackedImageTransferProcessorConfig
|
struct PackedImageTransferProcessorConfig
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||||
struct PackedImageTransferProcessorExConfig
|
struct PackedImageTransferProcessorExConfig
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x8)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x8)]
|
||||||
struct PackedIrLedProcessorConfig
|
struct PackedIrLedProcessorConfig
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x4)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x4)]
|
||||||
public struct PackedMcuVersion
|
public struct PackedMcuVersion
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||||
struct PackedMomentProcessorConfig
|
struct PackedMomentProcessorConfig
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||||
struct PackedPointingProcessorConfig
|
struct PackedPointingProcessorConfig
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
namespace Ryujinx.Horizon.Sdk.Irs
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x8)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x8)]
|
||||||
struct PackedTeraPluginProcessorConfig
|
struct PackedTeraPluginProcessorConfig
|
|
@ -1,29 +0,0 @@
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using Ryujinx.Horizon.Sdk.Applet;
|
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Sdk.Irsensor
|
|
||||||
{
|
|
||||||
interface IIrSensorServer : IServiceObject
|
|
||||||
{
|
|
||||||
Result ActivateIrsensor(AppletResourceUserId arg0, ulong pid);
|
|
||||||
Result DeactivateIrsensor(AppletResourceUserId arg0, ulong pid);
|
|
||||||
Result GetIrsensorSharedMemoryHandle(out int arg0, AppletResourceUserId arg1, ulong pid);
|
|
||||||
Result StopImageProcessor(AppletResourceUserId arg0, IrCameraHandle arg1, ulong pid);
|
|
||||||
Result RunMomentProcessor(AppletResourceUserId arg0, IrCameraHandle arg1, PackedMomentProcessorConfig arg2, ulong pid);
|
|
||||||
Result RunClusteringProcessor(AppletResourceUserId arg0, IrCameraHandle arg1, PackedClusteringProcessorConfig arg2, ulong pid);
|
|
||||||
Result RunImageTransferProcessor(AppletResourceUserId arg0, IrCameraHandle arg1, PackedImageTransferProcessorConfig arg2, int arg3, ulong arg4, ulong pid);
|
|
||||||
Result GetImageTransferProcessorState(AppletResourceUserId arg0, out ImageTransferProcessorState arg1, Span<byte> arg2, IrCameraHandle arg3, ulong pid);
|
|
||||||
Result RunTeraPluginProcessor(AppletResourceUserId arg0, IrCameraHandle arg1, PackedTeraPluginProcessorConfig arg2, ulong pid);
|
|
||||||
Result GetNpadIrCameraHandle(out IrCameraHandle arg0, uint arg1);
|
|
||||||
Result RunPointingProcessor(AppletResourceUserId arg0, IrCameraHandle arg1, PackedPointingProcessorConfig arg2, ulong pid);
|
|
||||||
Result SuspendImageProcessor(AppletResourceUserId arg0, IrCameraHandle arg1, ulong pid);
|
|
||||||
Result CheckFirmwareVersion(AppletResourceUserId arg0, IrCameraHandle arg1, PackedMcuVersion arg2, ulong pid);
|
|
||||||
Result SetFunctionLevel(AppletResourceUserId arg0, IrCameraHandle arg1, PackedFunctionLevel arg2, ulong pid);
|
|
||||||
Result RunImageTransferExProcessor(AppletResourceUserId arg0, IrCameraHandle arg1, PackedImageTransferProcessorExConfig arg2, int arg3, ulong arg4, ulong pid);
|
|
||||||
Result RunIrLedProcessor(AppletResourceUserId arg0, IrCameraHandle arg1, PackedIrLedProcessorConfig arg2, ulong pid);
|
|
||||||
Result StopImageProcessorAsync(AppletResourceUserId arg0, IrCameraHandle arg1, ulong pid);
|
|
||||||
Result ActivateIrsensorWithFunctionLevel(AppletResourceUserId arg0, PackedFunctionLevel arg1, ulong pid);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,8 +2,10 @@ using Ryujinx.Horizon.Arp;
|
||||||
using Ryujinx.Horizon.Audio;
|
using Ryujinx.Horizon.Audio;
|
||||||
using Ryujinx.Horizon.Bcat;
|
using Ryujinx.Horizon.Bcat;
|
||||||
using Ryujinx.Horizon.Friends;
|
using Ryujinx.Horizon.Friends;
|
||||||
|
using Ryujinx.Horizon.Hid;
|
||||||
using Ryujinx.Horizon.Hshl;
|
using Ryujinx.Horizon.Hshl;
|
||||||
using Ryujinx.Horizon.Ins;
|
using Ryujinx.Horizon.Ins;
|
||||||
|
using Ryujinx.Horizon.Irs;
|
||||||
using Ryujinx.Horizon.Lbl;
|
using Ryujinx.Horizon.Lbl;
|
||||||
using Ryujinx.Horizon.LogManager;
|
using Ryujinx.Horizon.LogManager;
|
||||||
using Ryujinx.Horizon.MmNv;
|
using Ryujinx.Horizon.MmNv;
|
||||||
|
@ -58,6 +60,8 @@ namespace Ryujinx.Horizon
|
||||||
RegisterService<TsMain>();
|
RegisterService<TsMain>();
|
||||||
RegisterService<UsbMain>();
|
RegisterService<UsbMain>();
|
||||||
RegisterService<WlanMain>();
|
RegisterService<WlanMain>();
|
||||||
|
RegisterService<HidMain>();
|
||||||
|
RegisterService<IrsMain>();
|
||||||
|
|
||||||
_totalServices = entries.Count;
|
_totalServices = entries.Count;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue