IAppletResource.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Ryujinx.HLE.HOS.Ipc;
  2. using Ryujinx.HLE.HOS.Kernel;
  3. using System;
  4. using System.Collections.Generic;
  5. namespace Ryujinx.HLE.HOS.Services.Hid
  6. {
  7. class IAppletResource : IpcService
  8. {
  9. private Dictionary<int, ServiceProcessRequest> m_Commands;
  10. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  11. private KSharedMemory HidSharedMem;
  12. public IAppletResource(KSharedMemory HidSharedMem)
  13. {
  14. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  15. {
  16. { 0, GetSharedMemoryHandle }
  17. };
  18. this.HidSharedMem = HidSharedMem;
  19. }
  20. public long GetSharedMemoryHandle(ServiceCtx Context)
  21. {
  22. if (Context.Process.HandleTable.GenerateHandle(HidSharedMem, out int Handle) != KernelResult.Success)
  23. {
  24. throw new InvalidOperationException("Out of handles!");
  25. }
  26. Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
  27. return 0;
  28. }
  29. }
  30. }