aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2021-09-29 00:10:10 +0200
committerGitHub <noreply@github.com>2021-09-29 00:10:10 +0200
commit79c854dd2e68f96f802bbb42568e4c52e31fc80e (patch)
tree9094b04e836375772d3a7a0d2cfcbfc75987dd5f /Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs
parent83bdafccdab01322af8503e9ad21f52981e646c1 (diff)
irs: Stub some service calls (#2665)
This PR stubs some irs service calls which are needed to get some games playable or at least bootable since we don't support IR data throught real JoyCon for now. - Stubs `IIrSensorServer` `StopImageProcessor`, `RunMomentProcessor`, `RunClusteringProcessor`, `RunImageTransferProcessor`, `GetImageTransferProcessorState`, `RunTeraPluginProcessor`. All calls are a bit checked by RE. Closes #2267, #2248, #2126 Night Vision and SpyAlarm are now bootable (but still unplayable due to the lack of the IR data):
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs')
-rw-r--r--Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs128
1 files changed, 126 insertions, 2 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs b/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs
index e47a7d1c..9efb679a 100644
--- a/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs
+++ b/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs
@@ -1,7 +1,9 @@
+using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Services.Hid.HidServer;
+using Ryujinx.HLE.HOS.Services.Hid.Irs.Types;
using System;
namespace Ryujinx.HLE.HOS.Services.Hid.Irs
@@ -17,7 +19,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
// ActivateIrsensor(nn::applet::AppletResourceUserId, pid)
public ResultCode ActivateIrsensor(ServiceCtx context)
{
- long appletResourceUserId = context.RequestData.ReadInt64();
+ ulong appletResourceUserId = context.RequestData.ReadUInt64();
+
+ // NOTE: This seems to initialize the shared memory for irs service.
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId });
@@ -28,7 +32,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
// DeactivateIrsensor(nn::applet::AppletResourceUserId, pid)
public ResultCode DeactivateIrsensor(ServiceCtx context)
{
- long appletResourceUserId = context.RequestData.ReadInt64();
+ ulong appletResourceUserId = context.RequestData.ReadUInt64();
+
+ // NOTE: This seems to deinitialize the shared memory for irs service.
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId });
@@ -39,6 +45,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
// GetIrsensorSharedMemoryHandle(nn::applet::AppletResourceUserId, pid) -> handle<copy>
public ResultCode GetIrsensorSharedMemoryHandle(ServiceCtx context)
{
+ // NOTE: Shared memory should use the appletResourceUserId.
+ // ulong appletResourceUserId = context.RequestData.ReadUInt64();
+
if (_irsensorSharedMemoryHandle == 0)
{
if (context.Process.HandleTable.GenerateHandle(context.Device.System.IirsSharedMem, out _irsensorSharedMemoryHandle) != KernelResult.Success)
@@ -52,6 +61,111 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
return ResultCode.Success;
}
+ [CommandHipc(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;
+ }
+
+ [CommandHipc(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;
+ }
+
+ [CommandHipc(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;
+ }
+
+ [CommandHipc(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;
+ }
+
+ [CommandHipc(309)]
+ // GetImageTransferProcessorState(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId)
+ public ResultCode GetImageTransferProcessorState(ServiceCtx context)
+ {
+ IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
+ ulong appletResourceUserId = context.RequestData.ReadUInt64();
+
+ // ulong imageTransferBufferAddress = context.Request.ReceiveBuff[0].Position;
+ ulong imageTransferBufferSize = context.Request.ReceiveBuff[0].Size;
+
+ if (imageTransferBufferSize == 0)
+ {
+ return ResultCode.InvalidBufferSize;
+ }
+
+ CheckCameraHandle(irCameraHandle);
+
+ Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType });
+
+ // TODO: Uses the buffer to copy the JoyCon IR data (by using a JoyCon driver) and update the following struct.
+ context.ResponseData.WriteStruct(new ImageTransferProcessorState()
+ {
+ SamplingNumber = 0,
+ AmbientNoiseLevel = 0
+ });
+
+ return ResultCode.Success;
+ }
+
+ [CommandHipc(310)]
+ // RunTeraPluginProcessor(pid, nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, PackedTeraPluginProcessorConfig)
+ public ResultCode RunTeraPluginProcessor(ServiceCtx context)
+ {
+ IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
+ ulong appletResourceUserId = context.RequestData.ReadUInt64();
+ var packedTeraPluginProcessorConfig = context.RequestData.ReadStruct<PackedTeraPluginProcessorConfig>();
+
+ CheckCameraHandle(irCameraHandle);
+
+ Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, packedTeraPluginProcessorConfig.RequiredMcuVersion });
+
+ return ResultCode.Success;
+ }
+
[CommandHipc(311)]
// GetNpadIrCameraHandle(u32) -> nn::irsensor::IrCameraHandle
public ResultCode GetNpadIrCameraHandle(ServiceCtx context)
@@ -100,5 +214,15 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
return ResultCode.Success;
}
+
+ private ResultCode CheckCameraHandle(IrCameraHandle irCameraHandle)
+ {
+ if (irCameraHandle.DeviceType == 1 || (PlayerIndex)irCameraHandle.PlayerNumber >= PlayerIndex.Unknown)
+ {
+ return ResultCode.InvalidCameraHandle;
+ }
+
+ return ResultCode.Success;
+ }
}
} \ No newline at end of file