Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  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.  
  7. namespace Ryujinx.HLE.OsHle.Services.Nfp
  8. {
  9. class IUser : IpcService
  10. {
  11. private Dictionary<int, ServiceProcessRequest> m_Commands;
  12.  
  13. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  14.  
  15. private const HidControllerId NpadId = HidControllerId.CONTROLLER_PLAYER_1;
  16.  
  17. private State State = State.NonInitialized;
  18.  
  19. private DeviceState DeviceState = DeviceState.Initialized;
  20.  
  21. private KEvent ActivateEvent;
  22.  
  23. private KEvent DeactivateEvent;
  24.  
  25. private KEvent AvailabilityChangeEvent;
  26.  
  27. public IUser()
  28. {
  29. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  30. {
  31. { 0, Initialize },
  32. { 2, Unknown },
  33. { 17, AttachActivateEvent },
  34. { 18, AttachDeactivateEvent },
  35. { 19, GetState },
  36. { 20, GetDeviceState },
  37. { 21, GetNpadId },
  38. { 23, AttachAvailabilityChangeEvent }
  39. };
  40.  
  41. ActivateEvent = new KEvent();
  42. DeactivateEvent = new KEvent();
  43. AvailabilityChangeEvent = new KEvent();
  44. }
  45.  
  46. public long Unknown(ServiceCtx Context)
  47. {
  48. return 0;
  49. }
  50.  
  51. public long Initialize(ServiceCtx Context)
  52. {
  53. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  54.  
  55. State = State.Initialized;
  56.  
  57. return 0;
  58. }
  59.  
  60. public long AttachActivateEvent(ServiceCtx Context)
  61. {
  62. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  63.  
  64. int Handle = Context.Process.HandleTable.OpenHandle(ActivateEvent);
  65.  
  66. Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
  67.  
  68. return 0;
  69. }
  70.  
  71. public long AttachDeactivateEvent(ServiceCtx Context)
  72. {
  73. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  74.  
  75. int Handle = Context.Process.HandleTable.OpenHandle(DeactivateEvent);
  76.  
  77. Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
  78.  
  79. return 0;
  80. }
  81.  
  82. public long GetState(ServiceCtx Context)
  83. {
  84. Context.ResponseData.Write((int)State);
  85.  
  86. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  87.  
  88. return 0;
  89. }
  90.  
  91. public long GetDeviceState(ServiceCtx Context)
  92. {
  93. Context.ResponseData.Write((int)DeviceState);
  94.  
  95. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  96.  
  97. return 0;
  98. }
  99.  
  100. public long GetNpadId(ServiceCtx Context)
  101. {
  102. Context.ResponseData.Write((int)NpadId);
  103.  
  104. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  105.  
  106. return 0;
  107. }
  108.  
  109. public long AttachAvailabilityChangeEvent(ServiceCtx Context)
  110. {
  111. Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");
  112.  
  113. int Handle = Context.Process.HandleTable.OpenHandle(AvailabilityChangeEvent);
  114.  
  115. Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
  116.  
  117. return 0;
  118. }
  119. }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement