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> _commands;
  10. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  11. private KSharedMemory _hidSharedMem;
  12. public IAppletResource(KSharedMemory hidSharedMem)
  13. {
  14. _commands = new Dictionary<int, ServiceProcessRequest>
  15. {
  16. { 0, GetSharedMemoryHandle }
  17. };
  18. _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. }