2018-10-17 19:15:50 +02:00
|
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
2019-04-20 04:23:13 +02:00
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
2019-06-27 18:02:41 +02:00
|
|
|
|
using Ryujinx.HLE.Input;
|
2019-04-20 03:56:55 +02:00
|
|
|
|
using System;
|
2018-10-07 17:12:11 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2019-06-27 18:02:41 +02:00
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
2018-10-07 17:12:11 +02:00
|
|
|
|
{
|
|
|
|
|
class IIrSensorServer : IpcService
|
|
|
|
|
{
|
2019-06-27 18:02:41 +02:00
|
|
|
|
private int _irsensorSharedMemoryHandle = 0;
|
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
|
private Dictionary<int, ServiceProcessRequest> _commands;
|
2018-10-07 17:12:11 +02:00
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
2018-10-07 17:12:11 +02:00
|
|
|
|
|
2019-06-27 18:02:41 +02:00
|
|
|
|
public IIrSensorServer()
|
2018-10-07 17:12:11 +02:00
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
|
_commands = new Dictionary<int, ServiceProcessRequest>
|
2018-10-07 17:12:11 +02:00
|
|
|
|
{
|
2019-04-25 15:03:00 +02:00
|
|
|
|
{ 302, ActivateIrsensor },
|
|
|
|
|
{ 303, DeactivateIrsensor },
|
|
|
|
|
{ 304, GetIrsensorSharedMemoryHandle },
|
2019-06-27 18:02:41 +02:00
|
|
|
|
//{ 305, StopImageProcessor },
|
|
|
|
|
//{ 306, RunMomentProcessor },
|
|
|
|
|
//{ 307, RunClusteringProcessor },
|
|
|
|
|
//{ 308, RunImageTransferProcessor },
|
|
|
|
|
//{ 309, GetImageTransferProcessorState },
|
|
|
|
|
//{ 310, RunTeraPluginProcessor },
|
2019-04-25 15:03:00 +02:00
|
|
|
|
{ 311, GetNpadIrCameraHandle },
|
2019-06-27 18:02:41 +02:00
|
|
|
|
//{ 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+
|
2018-10-07 17:12:11 +02:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ActivateIrsensor(nn::applet::AppletResourceUserId, pid)
|
2018-12-06 12:16:24 +01:00
|
|
|
|
public long ActivateIrsensor(ServiceCtx context)
|
2018-10-07 17:12:11 +02:00
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
|
long appletResourceUserId = context.RequestData.ReadInt64();
|
2018-10-07 17:12:11 +02:00
|
|
|
|
|
2019-01-11 01:11:46 +01:00
|
|
|
|
Logger.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId });
|
2018-10-07 17:12:11 +02:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeactivateIrsensor(nn::applet::AppletResourceUserId, pid)
|
2018-12-06 12:16:24 +01:00
|
|
|
|
public long DeactivateIrsensor(ServiceCtx context)
|
2018-10-07 17:12:11 +02:00
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
|
long appletResourceUserId = context.RequestData.ReadInt64();
|
2018-10-07 17:12:11 +02:00
|
|
|
|
|
2019-01-11 01:11:46 +01:00
|
|
|
|
Logger.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId });
|
2018-10-07 17:12:11 +02:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2019-04-20 03:56:55 +02:00
|
|
|
|
|
2019-04-20 04:23:13 +02:00
|
|
|
|
// GetIrsensorSharedMemoryHandle(nn::applet::AppletResourceUserId, pid) -> handle<copy>
|
|
|
|
|
public long GetIrsensorSharedMemoryHandle(ServiceCtx context)
|
|
|
|
|
{
|
2019-06-27 18:02:41 +02:00
|
|
|
|
if (_irsensorSharedMemoryHandle == 0)
|
2019-04-20 04:23:13 +02:00
|
|
|
|
{
|
2019-06-27 18:02:41 +02:00
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(context.Device.System.IirsSharedMem, out _irsensorSharedMemoryHandle) != KernelResult.Success)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Out of handles!");
|
|
|
|
|
}
|
2019-04-20 04:23:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-27 18:02:41 +02:00
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_irsensorSharedMemoryHandle);
|
2019-04-20 04:23:13 +02:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-20 03:56:55 +02:00
|
|
|
|
// GetNpadIrCameraHandle(u32) -> nn::irsensor::IrCameraHandle
|
|
|
|
|
public long GetNpadIrCameraHandle(ServiceCtx context)
|
|
|
|
|
{
|
2019-06-27 18:02:41 +02:00
|
|
|
|
NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();
|
2019-04-20 03:56:55 +02:00
|
|
|
|
|
2019-06-27 18:02:41 +02:00
|
|
|
|
if (npadIdType > NpadIdType.Player8 &&
|
|
|
|
|
npadIdType != NpadIdType.Unknown &&
|
|
|
|
|
npadIdType != NpadIdType.Handheld)
|
2019-04-20 03:56:55 +02:00
|
|
|
|
{
|
2019-06-27 18:02:41 +02:00
|
|
|
|
return ErrorCode.MakeError(ErrorModule.Irsensor, IrsError.NpadIdOutOfRange);
|
2019-04-20 03:56:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-27 18:02:41 +02:00
|
|
|
|
HidControllerId irCameraHandle = HidUtils.GetIndexFromNpadIdType(npadIdType);
|
2019-04-20 03:56:55 +02:00
|
|
|
|
|
2019-06-27 18:02:41 +02:00
|
|
|
|
context.ResponseData.Write((int)irCameraHandle);
|
2019-04-20 03:56:55 +02:00
|
|
|
|
|
2019-06-27 18:02:41 +02:00
|
|
|
|
// NOTE: If the irCameraHandle pointer is null this error is returned, Doesn't occur in our case.
|
|
|
|
|
// return ErrorCode.MakeError(ErrorModule.Irsensor, IrsError.HandlePointerIsNull);
|
2019-04-20 03:56:55 +02:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-25 15:03:00 +02:00
|
|
|
|
// ActivateIrsensorWithFunctionLevel(nn::applet::AppletResourceUserId, nn::irsensor::PackedFunctionLevel, pid)
|
|
|
|
|
public long ActivateIrsensorWithFunctionLevel(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
long appletResourceUserId = context.RequestData.ReadInt64();
|
|
|
|
|
long packedFunctionLevel = context.RequestData.ReadInt64();
|
|
|
|
|
|
|
|
|
|
Logger.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, packedFunctionLevel });
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2018-10-07 17:12:11 +02:00
|
|
|
|
}
|
|
|
|
|
}
|