IUser.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using Ryujinx.HLE.Input;
  2. using Ryujinx.HLE.Logging;
  3. using Ryujinx.HLE.OsHle.Handles;
  4. using Ryujinx.HLE.OsHle.Ipc;
  5. using System.Collections.Generic;
  6. namespace Ryujinx.HLE.OsHle.Services.Nfp
  7. {
  8. class IUser : IpcService
  9. {
  10. private Dictionary<int, ServiceProcessRequest> m_Commands;
  11. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  12. private const HidControllerId NpadId = HidControllerId.CONTROLLER_PLAYER_1;
  13. private State State = State.NonInitialized;
  14. private DeviceState DeviceState = DeviceState.Initialized;
  15. private KEvent ActivateEvent;
  16. private KEvent DeactivateEvent;
  17. private KEvent AvailabilityChangeEvent;
  18. public IUser()
  19. {
  20. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  21. {
  22. { 0, Initialize },
  23. { 17, AttachActivateEvent },
  24. { 18, AttachDeactivateEvent },
  25. { 19, GetState },
  26. { 20, GetDeviceState },
  27. { 21, GetNpadId },
  28. { 23, AttachAvailabilityChangeEvent }
  29. };
  30. ActivateEvent = new KEvent();
  31. DeactivateEvent = new KEvent();
  32. AvailabilityChangeEvent = new KEvent();
  33. }
  34. public long Initialize(ServiceCtx Context)
  35. {
  36. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  37. State = State.Initialized;
  38. return 0;
  39. }
  40. public long AttachActivateEvent(ServiceCtx Context)
  41. {
  42. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  43. int Handle = Context.Process.HandleTable.OpenHandle(ActivateEvent);
  44. Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);;
  45. return 0;
  46. }
  47. public long AttachDeactivateEvent(ServiceCtx Context)
  48. {
  49. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  50. int Handle = Context.Process.HandleTable.OpenHandle(DeactivateEvent);
  51. Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
  52. return 0;
  53. }
  54. public long GetState(ServiceCtx Context)
  55. {
  56. Context.ResponseData.Write((int)State);
  57. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  58. return 0;
  59. }
  60. public long GetDeviceState(ServiceCtx Context)
  61. {
  62. Context.ResponseData.Write((int)DeviceState);
  63. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  64. return 0;
  65. }
  66. public long GetNpadId(ServiceCtx Context)
  67. {
  68. Context.ResponseData.Write((int)NpadId);
  69. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  70. return 0;
  71. }
  72. public long AttachAvailabilityChangeEvent(ServiceCtx Context)
  73. {
  74. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  75. int Handle = Context.Process.HandleTable.OpenHandle(AvailabilityChangeEvent);
  76. Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
  77. return 0;
  78. }
  79. }
  80. }