IAppletResource.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Ryujinx.HLE.HOS.Ipc;
  2. using Ryujinx.HLE.HOS.Kernel.Common;
  3. using Ryujinx.HLE.HOS.Kernel.Memory;
  4. using System;
  5. namespace Ryujinx.HLE.HOS.Services.Hid.HidServer
  6. {
  7. class IAppletResource : IpcService
  8. {
  9. private KSharedMemory _hidSharedMem;
  10. private int _hidSharedMemHandle;
  11. public IAppletResource(KSharedMemory hidSharedMem)
  12. {
  13. _hidSharedMem = hidSharedMem;
  14. }
  15. [CommandHipc(0)]
  16. // GetSharedMemoryHandle() -> handle<copy>
  17. public ResultCode GetSharedMemoryHandle(ServiceCtx context)
  18. {
  19. if (_hidSharedMemHandle == 0)
  20. {
  21. if (context.Process.HandleTable.GenerateHandle(_hidSharedMem, out _hidSharedMemHandle) != KernelResult.Success)
  22. {
  23. throw new InvalidOperationException("Out of handles!");
  24. }
  25. }
  26. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_hidSharedMemHandle);
  27. return ResultCode.Success;
  28. }
  29. }
  30. }