2018-08-16 18:47:36 -05:00
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
2018-12-17 23:33:36 -06:00
|
|
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Memory;
|
2018-09-23 13:11:46 -05:00
|
|
|
using System;
|
2018-02-09 18:14:55 -06:00
|
|
|
|
2018-08-16 18:47:36 -05:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Hid
|
2018-02-09 18:14:55 -06:00
|
|
|
{
|
2018-03-19 13:58:46 -05:00
|
|
|
class IAppletResource : IpcService
|
2018-02-09 18:14:55 -06:00
|
|
|
{
|
2018-12-06 05:16:24 -06:00
|
|
|
private KSharedMemory _hidSharedMem;
|
2018-02-09 18:14:55 -06:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
public IAppletResource(KSharedMemory hidSharedMem)
|
2018-02-09 18:14:55 -06:00
|
|
|
{
|
2018-12-06 05:16:24 -06:00
|
|
|
_hidSharedMem = hidSharedMem;
|
2018-02-09 18:14:55 -06:00
|
|
|
}
|
|
|
|
|
2019-07-11 20:13:43 -05:00
|
|
|
[Command(0)]
|
|
|
|
// GetSharedMemoryHandle() -> handle<copy>
|
2019-07-14 14:04:38 -05:00
|
|
|
public ResultCode GetSharedMemoryHandle(ServiceCtx context)
|
2018-02-09 18:14:55 -06:00
|
|
|
{
|
2018-12-06 05:16:24 -06:00
|
|
|
if (context.Process.HandleTable.GenerateHandle(_hidSharedMem, out int handle) != KernelResult.Success)
|
2018-09-23 13:11:46 -05:00
|
|
|
{
|
|
|
|
throw new InvalidOperationException("Out of handles!");
|
|
|
|
}
|
2018-03-11 23:04:52 -05:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
2018-02-09 18:14:55 -06:00
|
|
|
|
2019-07-14 14:04:38 -05:00
|
|
|
return ResultCode.Success;
|
2018-02-09 18:14:55 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|