0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs
Mary 0746b83edf
Initial support for the new 12.x IPC system (#2182)
* Rename CommandAttribute as CommandHIpcAttribute to prepare for 12.x changes

* Implement inital support for TIPC and adds SM command ids

* *Ipc to *ipc

* Missed a ref in last commit...

* CommandAttributeTIpc to CommandAttributeTipc

* Addresses comment and fixes some bugs around

TIPC doesn't have any padding requirements as buffer C isn't a thing
Fix for RegisterService inverting two argument only on TIPC
2021-04-14 00:01:24 +02:00

90 lines
No EOL
3.2 KiB
C#

using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Services.Hid.HidServer;
using System;
namespace Ryujinx.HLE.HOS.Services.Hid.Irs
{
[Service("irs")]
class IIrSensorServer : IpcService
{
private int _irsensorSharedMemoryHandle = 0;
public IIrSensorServer(ServiceCtx context) { }
[CommandHipc(302)]
// ActivateIrsensor(nn::applet::AppletResourceUserId, pid)
public ResultCode ActivateIrsensor(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandHipc(303)]
// DeactivateIrsensor(nn::applet::AppletResourceUserId, pid)
public ResultCode DeactivateIrsensor(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandHipc(304)]
// GetIrsensorSharedMemoryHandle(nn::applet::AppletResourceUserId, pid) -> handle<copy>
public ResultCode GetIrsensorSharedMemoryHandle(ServiceCtx context)
{
if (_irsensorSharedMemoryHandle == 0)
{
if (context.Process.HandleTable.GenerateHandle(context.Device.System.IirsSharedMem, out _irsensorSharedMemoryHandle) != KernelResult.Success)
{
throw new InvalidOperationException("Out of handles!");
}
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_irsensorSharedMemoryHandle);
return ResultCode.Success;
}
[CommandHipc(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;
}
[CommandHipc(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;
}
}
}