IHidServer.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. using Ryujinx.HLE.HOS.Ipc;
  2. using Ryujinx.HLE.HOS.Kernel;
  3. using Ryujinx.HLE.Input;
  4. using Ryujinx.HLE.Logging;
  5. using System;
  6. using System.Collections.Generic;
  7. namespace Ryujinx.HLE.HOS.Services.Hid
  8. {
  9. class IHidServer : IpcService, IDisposable
  10. {
  11. private Dictionary<int, ServiceProcessRequest> m_Commands;
  12. private KEvent NpadStyleSetUpdateEvent;
  13. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  14. public IHidServer()
  15. {
  16. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  17. {
  18. { 0, CreateAppletResource },
  19. { 1, ActivateDebugPad },
  20. { 11, ActivateTouchScreen },
  21. { 21, ActivateMouse },
  22. { 31, ActivateKeyboard },
  23. { 66, StartSixAxisSensor },
  24. { 79, SetGyroscopeZeroDriftMode },
  25. { 100, SetSupportedNpadStyleSet },
  26. { 101, GetSupportedNpadStyleSet },
  27. { 102, SetSupportedNpadIdType },
  28. { 103, ActivateNpad },
  29. { 106, AcquireNpadStyleSetUpdateEventHandle },
  30. { 108, GetPlayerLedPattern },
  31. { 120, SetNpadJoyHoldType },
  32. { 121, GetNpadJoyHoldType },
  33. { 122, SetNpadJoyAssignmentModeSingleByDefault },
  34. { 123, SetNpadJoyAssignmentModeSingle },
  35. { 124, SetNpadJoyAssignmentModeDual },
  36. { 125, MergeSingleJoyAsDualJoy },
  37. { 128, SetNpadHandheldActivationMode },
  38. { 200, GetVibrationDeviceInfo },
  39. { 201, SendVibrationValue },
  40. { 203, CreateActiveVibrationDeviceList },
  41. { 206, SendVibrationValues }
  42. };
  43. NpadStyleSetUpdateEvent = new KEvent();
  44. }
  45. public long CreateAppletResource(ServiceCtx Context)
  46. {
  47. MakeObject(Context, new IAppletResource(Context.Device.System.HidSharedMem));
  48. return 0;
  49. }
  50. public long ActivateDebugPad(ServiceCtx Context)
  51. {
  52. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  53. return 0;
  54. }
  55. public long ActivateTouchScreen(ServiceCtx Context)
  56. {
  57. long AppletResourceUserId = Context.RequestData.ReadInt64();
  58. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  59. return 0;
  60. }
  61. public long ActivateMouse(ServiceCtx Context)
  62. {
  63. long AppletResourceUserId = Context.RequestData.ReadInt64();
  64. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  65. return 0;
  66. }
  67. public long ActivateKeyboard(ServiceCtx Context)
  68. {
  69. long AppletResourceUserId = Context.RequestData.ReadInt64();
  70. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  71. return 0;
  72. }
  73. public long StartSixAxisSensor(ServiceCtx Context)
  74. {
  75. int Handle = Context.RequestData.ReadInt32();
  76. long AppletResourceUserId = Context.RequestData.ReadInt64();
  77. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  78. return 0;
  79. }
  80. public long SetGyroscopeZeroDriftMode(ServiceCtx Context)
  81. {
  82. int Handle = Context.RequestData.ReadInt32();
  83. int Unknown = Context.RequestData.ReadInt32();
  84. long AppletResourceUserId = Context.RequestData.ReadInt64();
  85. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  86. return 0;
  87. }
  88. public long AcquireNpadStyleSetUpdateEventHandle(ServiceCtx Context)
  89. {
  90. int Handle = Context.Process.HandleTable.OpenHandle(NpadStyleSetUpdateEvent);
  91. Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
  92. return 0;
  93. }
  94. public long GetSupportedNpadStyleSet(ServiceCtx Context)
  95. {
  96. Context.ResponseData.Write(0);
  97. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  98. return 0;
  99. }
  100. public long SetSupportedNpadStyleSet(ServiceCtx Context)
  101. {
  102. long Unknown0 = Context.RequestData.ReadInt64();
  103. long Unknown8 = Context.RequestData.ReadInt64();
  104. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  105. return 0;
  106. }
  107. public long SetSupportedNpadIdType(ServiceCtx Context)
  108. {
  109. long Unknown = Context.RequestData.ReadInt64();
  110. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  111. return 0;
  112. }
  113. public long ActivateNpad(ServiceCtx Context)
  114. {
  115. long Unknown = Context.RequestData.ReadInt64();
  116. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  117. return 0;
  118. }
  119. public long GetPlayerLedPattern(ServiceCtx Context)
  120. {
  121. long Unknown = Context.RequestData.ReadInt32();
  122. Context.ResponseData.Write(0L);
  123. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  124. return 0;
  125. }
  126. public long SetNpadJoyHoldType(ServiceCtx Context)
  127. {
  128. long Unknown0 = Context.RequestData.ReadInt64();
  129. long Unknown8 = Context.RequestData.ReadInt64();
  130. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  131. return 0;
  132. }
  133. public long GetNpadJoyHoldType(ServiceCtx Context)
  134. {
  135. Context.ResponseData.Write(0L);
  136. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  137. return 0;
  138. }
  139. public long SetNpadJoyAssignmentModeSingleByDefault(ServiceCtx Context)
  140. {
  141. HidControllerId HidControllerId = (HidControllerId)Context.RequestData.ReadInt32();
  142. long AppletUserResourceId = Context.RequestData.ReadInt64();
  143. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  144. return 0;
  145. }
  146. public long SetNpadJoyAssignmentModeSingle(ServiceCtx Context)
  147. {
  148. HidControllerId HidControllerId = (HidControllerId)Context.RequestData.ReadInt32();
  149. long AppletUserResourceId = Context.RequestData.ReadInt64();
  150. long NpadJoyDeviceType = Context.RequestData.ReadInt64();
  151. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  152. return 0;
  153. }
  154. public long SetNpadJoyAssignmentModeDual(ServiceCtx Context)
  155. {
  156. HidControllerId HidControllerId = (HidControllerId)Context.RequestData.ReadInt32();
  157. long AppletUserResourceId = Context.RequestData.ReadInt64();
  158. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  159. return 0;
  160. }
  161. public long MergeSingleJoyAsDualJoy(ServiceCtx Context)
  162. {
  163. long Unknown0 = Context.RequestData.ReadInt32();
  164. long Unknown8 = Context.RequestData.ReadInt32();
  165. long AppletUserResourceId = Context.RequestData.ReadInt64();
  166. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  167. return 0;
  168. }
  169. public long SetNpadHandheldActivationMode(ServiceCtx Context)
  170. {
  171. long AppletUserResourceId = Context.RequestData.ReadInt64();
  172. long Unknown = Context.RequestData.ReadInt64();
  173. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  174. return 0;
  175. }
  176. public long GetVibrationDeviceInfo(ServiceCtx Context)
  177. {
  178. int VibrationDeviceHandle = Context.RequestData.ReadInt32();
  179. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  180. Context.ResponseData.Write(0L); //VibrationDeviceInfoForIpc
  181. return 0;
  182. }
  183. public long SendVibrationValue(ServiceCtx Context)
  184. {
  185. int VibrationDeviceHandle = Context.RequestData.ReadInt32();
  186. int VibrationValue1 = Context.RequestData.ReadInt32();
  187. int VibrationValue2 = Context.RequestData.ReadInt32();
  188. int VibrationValue3 = Context.RequestData.ReadInt32();
  189. int VibrationValue4 = Context.RequestData.ReadInt32();
  190. long AppletUserResourceId = Context.RequestData.ReadInt64();
  191. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  192. return 0;
  193. }
  194. public long CreateActiveVibrationDeviceList(ServiceCtx Context)
  195. {
  196. MakeObject(Context, new IActiveApplicationDeviceList());
  197. return 0;
  198. }
  199. public long SendVibrationValues(ServiceCtx Context)
  200. {
  201. Context.Device.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");
  202. return 0;
  203. }
  204. public void Dispose()
  205. {
  206. Dispose(true);
  207. }
  208. protected virtual void Dispose(bool Disposing)
  209. {
  210. if (Disposing)
  211. {
  212. NpadStyleSetUpdateEvent.Dispose();
  213. }
  214. }
  215. }
  216. }