Finish Irs
This commit is contained in:
parent
ba9aa61cc3
commit
b7239a6e3e
4 changed files with 46 additions and 170 deletions
|
@ -1,139 +0,0 @@
|
|||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Services.Hid.HidServer;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Hid.Npad;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||
{
|
||||
[Service("irs")]
|
||||
class IIrSensorServer : IpcService
|
||||
{
|
||||
private int _irsensorSharedMemoryHandle = 0;
|
||||
|
||||
public IIrSensorServer(ServiceCtx context) { }
|
||||
|
||||
[CommandCmif(304)]
|
||||
// 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) != Result.Success)
|
||||
{
|
||||
throw new InvalidOperationException("Out of handles!");
|
||||
}
|
||||
}
|
||||
|
||||
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_irsensorSharedMemoryHandle);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(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;
|
||||
}
|
||||
|
||||
[CommandCmif(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;
|
||||
}
|
||||
|
||||
[CommandCmif(311)]
|
||||
// GetNpadIrCameraHandle(u32) -> nn::irsensor::IrCameraHandle
|
||||
public ResultCode GetNpadIrCameraHandle(ServiceCtx context)
|
||||
{
|
||||
NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();
|
||||
|
||||
if (npadIdType > NpadIdType.Player8 &&
|
||||
npadIdType != NpadIdType.Unknown &&
|
||||
npadIdType != NpadIdType.Handheld)
|
||||
{
|
||||
return ResultCode.NpadIdOutOfRange;
|
||||
}
|
||||
|
||||
PlayerIndex irCameraHandle = HidUtils.GetIndexFromNpadIdType(npadIdType);
|
||||
|
||||
context.ResponseData.Write((int)irCameraHandle);
|
||||
|
||||
// NOTE: If the irCameraHandle pointer is null this error is returned, Doesn't occur in our case.
|
||||
// return ResultCode.HandlePointerIsNull;
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(318)] // 4.0.0+
|
||||
// StopImageProcessorAsync(nn::irsensor::IrCameraHandle, nn::applet::AppletResourceUserId, pid)
|
||||
public ResultCode StopImageProcessorAsync(ServiceCtx context)
|
||||
{
|
||||
int irCameraHandle = context.RequestData.ReadInt32();
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, irCameraHandle });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(319)] // 4.0.0+
|
||||
// ActivateIrsensorWithFunctionLevel(nn::applet::AppletResourceUserId, nn::irsensor::PackedFunctionLevel, pid)
|
||||
public ResultCode ActivateIrsensorWithFunctionLevel(ServiceCtx context)
|
||||
{
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
long packedFunctionLevel = context.RequestData.ReadInt64();
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, packedFunctionLevel });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private ResultCode CheckCameraHandle(IrCameraHandle irCameraHandle)
|
||||
{
|
||||
if (irCameraHandle.DeviceType == 1 || (PlayerIndex)irCameraHandle.PlayerNumber >= PlayerIndex.Unknown)
|
||||
{
|
||||
return ResultCode.InvalidCameraHandle;
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||
{
|
||||
public enum ResultCode
|
||||
{
|
||||
ModuleId = 205,
|
||||
ErrorCodeShift = 9,
|
||||
|
||||
Success = 0,
|
||||
|
||||
InvalidCameraHandle = (204 << ErrorCodeShift) | ModuleId,
|
||||
InvalidBufferSize = (207 << ErrorCodeShift) | ModuleId,
|
||||
HandlePointerIsNull = (212 << ErrorCodeShift) | ModuleId,
|
||||
NpadIdOutOfRange = (709 << ErrorCodeShift) | ModuleId,
|
||||
}
|
||||
}
|
|
@ -35,8 +35,11 @@ namespace Ryujinx.Horizon.Irs
|
|||
public Result GetIrsensorSharedMemoryHandle([CopyHandle] out int arg0, AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
|
||||
{
|
||||
// NOTE: Shared memory should use the appletResourceUserId.
|
||||
// TODO: Update when HorizonStatic has support for CreateSharedMemory
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||
arg0 = 0;
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
@ -84,11 +87,24 @@ namespace Ryujinx.Horizon.Irs
|
|||
}
|
||||
|
||||
[CmifCommand(309)]
|
||||
public Result GetImageTransferProcessorState(AppletResourceUserId appletResourceUserId, out ImageTransferProcessorState arg1, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<byte> arg2, IrCameraHandle irCameraHandle, [ClientProcessId] ulong pid)
|
||||
public Result GetImageTransferProcessorState(AppletResourceUserId appletResourceUserId, out ImageTransferProcessorState imageTransferProcessorState, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<byte> imageTransferBuffer, IrCameraHandle irCameraHandle, [ClientProcessId] ulong pid)
|
||||
{
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||
// TODO: Uses the buffer to copy the JoyCon IR data (by using a JoyCon driver) and update the following struct.
|
||||
imageTransferProcessorState = new ImageTransferProcessorState
|
||||
{
|
||||
SamplingNumber = 0,
|
||||
AmbientNoiseLevel = 0
|
||||
};
|
||||
|
||||
if (imageTransferBuffer.Length == 0)
|
||||
{
|
||||
// InvalidBufferSize
|
||||
return new Result(207);
|
||||
}
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
@ -98,7 +114,7 @@ namespace Ryujinx.Horizon.Irs
|
|||
{
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, config.RequiredMcuVersion });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
@ -106,7 +122,21 @@ namespace Ryujinx.Horizon.Irs
|
|||
[CmifCommand(311)]
|
||||
public Result GetNpadIrCameraHandle(out IrCameraHandle irCameraHandle, NpadIdType npadIdType)
|
||||
{
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||
if (npadIdType > NpadIdType.Player8 &&
|
||||
npadIdType != NpadIdType.Unknown &&
|
||||
npadIdType != NpadIdType.Handheld)
|
||||
{
|
||||
// NpadIdOutOfRange
|
||||
irCameraHandle = new IrCameraHandle();
|
||||
return new Result(709);
|
||||
}
|
||||
|
||||
irCameraHandle = new IrCameraHandle
|
||||
{
|
||||
PlayerNumber = (byte)npadIdType
|
||||
};
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { npadIdType });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
@ -116,7 +146,7 @@ namespace Ryujinx.Horizon.Irs
|
|||
{
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, config.RequiredMcuVersion });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
@ -126,7 +156,7 @@ namespace Ryujinx.Horizon.Irs
|
|||
{
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
@ -136,7 +166,7 @@ namespace Ryujinx.Horizon.Irs
|
|||
{
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, mcuVersion.MajorVersion, mcuVersion.MinorVersion });
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, mcuVersion });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
@ -146,7 +176,7 @@ namespace Ryujinx.Horizon.Irs
|
|||
{
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, functionLevel.IrSensorFunctionLevel });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
@ -156,7 +186,7 @@ namespace Ryujinx.Horizon.Irs
|
|||
{
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, config.ExposureTime, arg3, arg4 });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
@ -166,7 +196,7 @@ namespace Ryujinx.Horizon.Irs
|
|||
{
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType, config.RequiredMcuVersion });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
@ -176,15 +206,15 @@ namespace Ryujinx.Horizon.Irs
|
|||
{
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, irCameraHandle.PlayerNumber, irCameraHandle.DeviceType });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(319)]
|
||||
public Result ActivateIrsensorWithFunctionLevel(AppletResourceUserId appletResourceUserId, PackedFunctionLevel arg1, [ClientProcessId] ulong pid)
|
||||
public Result ActivateIrsensorWithFunctionLevel(AppletResourceUserId appletResourceUserId, PackedFunctionLevel functionLevel, [ClientProcessId] ulong pid)
|
||||
{
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs);
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId.Id, functionLevel.IrSensorFunctionLevel });
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Ryujinx.Horizon.Sdk.Irs
|
|||
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 GetImageTransferProcessorState(AppletResourceUserId appletResourceUserId, out ImageTransferProcessorState imageTransferProcessorState, Span<byte> imageTransferBuffer, 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);
|
||||
|
@ -25,6 +25,6 @@ namespace Ryujinx.Horizon.Sdk.Irs
|
|||
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);
|
||||
Result ActivateIrsensorWithFunctionLevel(AppletResourceUserId appletResourceUserId, PackedFunctionLevel functionLevel, ulong pid);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue