IHidServer.cs 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Ipc;
  3. using Ryujinx.HLE.HOS.Kernel.Common;
  4. using Ryujinx.HLE.HOS.Kernel.Threading;
  5. using Ryujinx.HLE.Input;
  6. using System;
  7. using System.Collections.Generic;
  8. namespace Ryujinx.HLE.HOS.Services.Hid
  9. {
  10. class IHidServer : IpcService
  11. {
  12. private Dictionary<int, ServiceProcessRequest> _commands;
  13. private KEvent _npadStyleSetUpdateEvent;
  14. private KEvent _xpadIdEvent;
  15. private KEvent _palmaOperationCompleteEvent;
  16. private int _xpadIdEventHandle;
  17. private bool _sixAxisSensorFusionEnabled;
  18. private bool _unintendedHomeButtonInputProtectionEnabled;
  19. private bool _vibrationPermitted;
  20. private bool _usbFullKeyControllerEnabled;
  21. private HidNpadJoyHoldType _npadJoyHoldType;
  22. private HidNpadStyle _npadStyleSet;
  23. private HidNpadJoyAssignmentMode _npadJoyAssignmentMode;
  24. private HidNpadHandheldActivationMode _npadHandheldActivationMode;
  25. private HidGyroscopeZeroDriftMode _gyroscopeZeroDriftMode;
  26. private long _npadCommunicationMode;
  27. private uint _accelerometerPlayMode;
  28. private long _vibrationGcErmCommand;
  29. private float _sevenSixAxisSensorFusionStrength;
  30. private HidSensorFusionParameters _sensorFusionParams;
  31. private HidAccelerometerParameters _accelerometerParams;
  32. private HidVibrationValue _vibrationValue;
  33. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  34. public IHidServer(Horizon system)
  35. {
  36. _commands = new Dictionary<int, ServiceProcessRequest>
  37. {
  38. { 0, CreateAppletResource },
  39. { 1, ActivateDebugPad },
  40. { 11, ActivateTouchScreen },
  41. { 21, ActivateMouse },
  42. { 31, ActivateKeyboard },
  43. { 40, AcquireXpadIdEventHandle },
  44. { 41, ReleaseXpadIdEventHandle },
  45. { 51, ActivateXpad },
  46. { 55, GetXpadIds },
  47. { 56, ActivateJoyXpad },
  48. { 58, GetJoyXpadLifoHandle },
  49. { 59, GetJoyXpadIds },
  50. { 60, ActivateSixAxisSensor },
  51. { 61, DeactivateSixAxisSensor },
  52. { 62, GetSixAxisSensorLifoHandle },
  53. { 63, ActivateJoySixAxisSensor },
  54. { 64, DeactivateJoySixAxisSensor },
  55. { 65, GetJoySixAxisSensorLifoHandle },
  56. { 66, StartSixAxisSensor },
  57. { 67, StopSixAxisSensor },
  58. { 68, IsSixAxisSensorFusionEnabled },
  59. { 69, EnableSixAxisSensorFusion },
  60. { 70, SetSixAxisSensorFusionParameters },
  61. { 71, GetSixAxisSensorFusionParameters },
  62. { 72, ResetSixAxisSensorFusionParameters },
  63. { 73, SetAccelerometerParameters },
  64. { 74, GetAccelerometerParameters },
  65. { 75, ResetAccelerometerParameters },
  66. { 76, SetAccelerometerPlayMode },
  67. { 77, GetAccelerometerPlayMode },
  68. { 78, ResetAccelerometerPlayMode },
  69. { 79, SetGyroscopeZeroDriftMode },
  70. { 80, GetGyroscopeZeroDriftMode },
  71. { 81, ResetGyroscopeZeroDriftMode },
  72. { 82, IsSixAxisSensorAtRest },
  73. { 91, ActivateGesture },
  74. { 100, SetSupportedNpadStyleSet },
  75. { 101, GetSupportedNpadStyleSet },
  76. { 102, SetSupportedNpadIdType },
  77. { 103, ActivateNpad },
  78. { 104, DeactivateNpad },
  79. { 106, AcquireNpadStyleSetUpdateEventHandle },
  80. { 107, DisconnectNpad },
  81. { 108, GetPlayerLedPattern },
  82. { 109, ActivateNpadWithRevision },
  83. { 120, SetNpadJoyHoldType },
  84. { 121, GetNpadJoyHoldType },
  85. { 122, SetNpadJoyAssignmentModeSingleByDefault },
  86. { 123, SetNpadJoyAssignmentModeSingle },
  87. { 124, SetNpadJoyAssignmentModeDual },
  88. { 125, MergeSingleJoyAsDualJoy },
  89. { 126, StartLrAssignmentMode },
  90. { 127, StopLrAssignmentMode },
  91. { 128, SetNpadHandheldActivationMode },
  92. { 129, GetNpadHandheldActivationMode },
  93. { 130, SwapNpadAssignment },
  94. { 131, IsUnintendedHomeButtonInputProtectionEnabled },
  95. { 132, EnableUnintendedHomeButtonInputProtection },
  96. { 133, SetNpadJoyAssignmentModeSingleWithDestination },
  97. { 200, GetVibrationDeviceInfo },
  98. { 201, SendVibrationValue },
  99. { 202, GetActualVibrationValue },
  100. { 203, CreateActiveVibrationDeviceList },
  101. { 204, PermitVibration },
  102. { 205, IsVibrationPermitted },
  103. { 206, SendVibrationValues },
  104. { 207, SendVibrationGcErmCommand },
  105. { 208, GetActualVibrationGcErmCommand },
  106. { 209, BeginPermitVibrationSession },
  107. { 210, EndPermitVibrationSession },
  108. { 300, ActivateConsoleSixAxisSensor },
  109. { 301, StartConsoleSixAxisSensor },
  110. { 302, StopConsoleSixAxisSensor },
  111. { 303, ActivateSevenSixAxisSensor },
  112. { 304, StartSevenSixAxisSensor },
  113. { 305, StopSevenSixAxisSensor },
  114. { 306, InitializeSevenSixAxisSensor },
  115. { 307, FinalizeSevenSixAxisSensor },
  116. { 308, SetSevenSixAxisSensorFusionStrength },
  117. { 309, GetSevenSixAxisSensorFusionStrength },
  118. { 400, IsUsbFullKeyControllerEnabled },
  119. { 401, EnableUsbFullKeyController },
  120. { 402, IsUsbFullKeyControllerConnected },
  121. { 403, HasBattery },
  122. { 404, HasLeftRightBattery },
  123. { 405, GetNpadInterfaceType },
  124. { 406, GetNpadLeftRightInterfaceType },
  125. { 500, GetPalmaConnectionHandle },
  126. { 501, InitializePalma },
  127. { 502, AcquirePalmaOperationCompleteEvent },
  128. { 503, GetPalmaOperationInfo },
  129. { 504, PlayPalmaActivity },
  130. { 505, SetPalmaFrModeType },
  131. { 506, ReadPalmaStep },
  132. { 507, EnablePalmaStep },
  133. { 508, SuspendPalmaStep },
  134. { 509, ResetPalmaStep },
  135. { 510, ReadPalmaApplicationSection },
  136. { 511, WritePalmaApplicationSection },
  137. { 512, ReadPalmaUniqueCode },
  138. { 513, SetPalmaUniqueCodeInvalid },
  139. { 1000, SetNpadCommunicationMode },
  140. { 1001, GetNpadCommunicationMode }
  141. };
  142. _npadStyleSetUpdateEvent = new KEvent(system);
  143. _xpadIdEvent = new KEvent(system);
  144. _palmaOperationCompleteEvent = new KEvent(system);
  145. _npadJoyHoldType = HidNpadJoyHoldType.Vertical;
  146. _npadStyleSet = HidNpadStyle.FullKey | HidNpadStyle.Dual | HidNpadStyle.Left | HidNpadStyle.Right | HidNpadStyle.Handheld;
  147. _npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Dual;
  148. _npadHandheldActivationMode = HidNpadHandheldActivationMode.Dual;
  149. _gyroscopeZeroDriftMode = HidGyroscopeZeroDriftMode.Standard;
  150. _sensorFusionParams = new HidSensorFusionParameters();
  151. _accelerometerParams = new HidAccelerometerParameters();
  152. _vibrationValue = new HidVibrationValue();
  153. // TODO: signal event at right place
  154. _xpadIdEvent.ReadableEvent.Signal();
  155. }
  156. // CreateAppletResource(nn::applet::AppletResourceUserId) -> object<nn::hid::IAppletResource>
  157. public long CreateAppletResource(ServiceCtx context)
  158. {
  159. long appletResourceUserId = context.RequestData.ReadInt64();
  160. MakeObject(context, new IAppletResource(context.Device.System.HidSharedMem));
  161. return 0;
  162. }
  163. // ActivateDebugPad(nn::applet::AppletResourceUserId)
  164. public long ActivateDebugPad(ServiceCtx context)
  165. {
  166. long appletResourceUserId = context.RequestData.ReadInt64();
  167. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  168. return 0;
  169. }
  170. // ActivateTouchScreen(nn::applet::AppletResourceUserId)
  171. public long ActivateTouchScreen(ServiceCtx context)
  172. {
  173. long appletResourceUserId = context.RequestData.ReadInt64();
  174. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  175. return 0;
  176. }
  177. // ActivateMouse(nn::applet::AppletResourceUserId)
  178. public long ActivateMouse(ServiceCtx context)
  179. {
  180. long appletResourceUserId = context.RequestData.ReadInt64();
  181. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  182. return 0;
  183. }
  184. // ActivateKeyboard(nn::applet::AppletResourceUserId)
  185. public long ActivateKeyboard(ServiceCtx context)
  186. {
  187. long appletResourceUserId = context.RequestData.ReadInt64();
  188. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  189. return 0;
  190. }
  191. // AcquireXpadIdEventHandle(ulong XpadId) -> nn::sf::NativeHandle
  192. public long AcquireXpadIdEventHandle(ServiceCtx context)
  193. {
  194. long xpadId = context.RequestData.ReadInt64();
  195. if (context.Process.HandleTable.GenerateHandle(_xpadIdEvent.ReadableEvent, out _xpadIdEventHandle) != KernelResult.Success)
  196. {
  197. throw new InvalidOperationException("Out of handles!");
  198. }
  199. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_xpadIdEventHandle);
  200. Logger.PrintStub(LogClass.ServiceHid, new { xpadId });
  201. return 0;
  202. }
  203. // ReleaseXpadIdEventHandle(ulong XpadId)
  204. public long ReleaseXpadIdEventHandle(ServiceCtx context)
  205. {
  206. long xpadId = context.RequestData.ReadInt64();
  207. context.Process.HandleTable.CloseHandle(_xpadIdEventHandle);
  208. Logger.PrintStub(LogClass.ServiceHid, new { xpadId });
  209. return 0;
  210. }
  211. // ActivateXpad(nn::hid::BasicXpadId, nn::applet::AppletResourceUserId)
  212. public long ActivateXpad(ServiceCtx context)
  213. {
  214. int basicXpadId = context.RequestData.ReadInt32();
  215. long appletResourceUserId = context.RequestData.ReadInt64();
  216. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, basicXpadId });
  217. return 0;
  218. }
  219. // GetXpadIds() -> long IdsCount, buffer<array<nn::hid::BasicXpadId>, type: 0xa>
  220. public long GetXpadIds(ServiceCtx context)
  221. {
  222. // There is any Xpad, so we return 0 and write nothing inside the type-0xa buffer.
  223. context.ResponseData.Write(0L);
  224. Logger.PrintStub(LogClass.ServiceHid);
  225. return 0;
  226. }
  227. // ActivateJoyXpad(nn::hid::JoyXpadId)
  228. public long ActivateJoyXpad(ServiceCtx context)
  229. {
  230. int joyXpadId = context.RequestData.ReadInt32();
  231. Logger.PrintStub(LogClass.ServiceHid, new { joyXpadId });
  232. return 0;
  233. }
  234. // GetJoyXpadLifoHandle(nn::hid::JoyXpadId) -> nn::sf::NativeHandle
  235. public long GetJoyXpadLifoHandle(ServiceCtx context)
  236. {
  237. int joyXpadId = context.RequestData.ReadInt32();
  238. int handle = 0;
  239. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  240. Logger.PrintStub(LogClass.ServiceHid, new { joyXpadId });
  241. return 0;
  242. }
  243. // GetJoyXpadIds() -> long IdsCount, buffer<array<nn::hid::JoyXpadId>, type: 0xa>
  244. public long GetJoyXpadIds(ServiceCtx context)
  245. {
  246. // There is any JoyXpad, so we return 0 and write nothing inside the type-0xa buffer.
  247. context.ResponseData.Write(0L);
  248. Logger.PrintStub(LogClass.ServiceHid);
  249. return 0;
  250. }
  251. // ActivateSixAxisSensor(nn::hid::BasicXpadId)
  252. public long ActivateSixAxisSensor(ServiceCtx context)
  253. {
  254. int basicXpadId = context.RequestData.ReadInt32();
  255. Logger.PrintStub(LogClass.ServiceHid, new { basicXpadId });
  256. return 0;
  257. }
  258. // DeactivateSixAxisSensor(nn::hid::BasicXpadId)
  259. public long DeactivateSixAxisSensor(ServiceCtx context)
  260. {
  261. int basicXpadId = context.RequestData.ReadInt32();
  262. Logger.PrintStub(LogClass.ServiceHid, new { basicXpadId });
  263. return 0;
  264. }
  265. // GetSixAxisSensorLifoHandle(nn::hid::BasicXpadId) -> nn::sf::NativeHandle
  266. public long GetSixAxisSensorLifoHandle(ServiceCtx context)
  267. {
  268. int basicXpadId = context.RequestData.ReadInt32();
  269. int handle = 0;
  270. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  271. Logger.PrintStub(LogClass.ServiceHid, new { basicXpadId });
  272. return 0;
  273. }
  274. // ActivateJoySixAxisSensor(nn::hid::JoyXpadId)
  275. public long ActivateJoySixAxisSensor(ServiceCtx context)
  276. {
  277. int joyXpadId = context.RequestData.ReadInt32();
  278. Logger.PrintStub(LogClass.ServiceHid, new { joyXpadId });
  279. return 0;
  280. }
  281. // DeactivateJoySixAxisSensor(nn::hid::JoyXpadId)
  282. public long DeactivateJoySixAxisSensor(ServiceCtx context)
  283. {
  284. int joyXpadId = context.RequestData.ReadInt32();
  285. Logger.PrintStub(LogClass.ServiceHid, new { joyXpadId });
  286. return 0;
  287. }
  288. // GetJoySixAxisSensorLifoHandle(nn::hid::JoyXpadId) -> nn::sf::NativeHandle
  289. public long GetJoySixAxisSensorLifoHandle(ServiceCtx context)
  290. {
  291. int joyXpadId = context.RequestData.ReadInt32();
  292. int handle = 0;
  293. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  294. Logger.PrintStub(LogClass.ServiceHid, new { joyXpadId });
  295. return 0;
  296. }
  297. // StartSixAxisSensor(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId)
  298. public long StartSixAxisSensor(ServiceCtx context)
  299. {
  300. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  301. long appletResourceUserId = context.RequestData.ReadInt64();
  302. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle });
  303. return 0;
  304. }
  305. // StopSixAxisSensor(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId)
  306. public long StopSixAxisSensor(ServiceCtx context)
  307. {
  308. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  309. long appletResourceUserId = context.RequestData.ReadInt64();
  310. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle });
  311. return 0;
  312. }
  313. // IsSixAxisSensorFusionEnabled(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> bool IsEnabled
  314. public long IsSixAxisSensorFusionEnabled(ServiceCtx context)
  315. {
  316. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  317. long appletResourceUserId = context.RequestData.ReadInt64();
  318. context.ResponseData.Write(_sixAxisSensorFusionEnabled);
  319. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _sixAxisSensorFusionEnabled });
  320. return 0;
  321. }
  322. // EnableSixAxisSensorFusion(bool Enabled, nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId)
  323. public long EnableSixAxisSensorFusion(ServiceCtx context)
  324. {
  325. _sixAxisSensorFusionEnabled = context.RequestData.ReadBoolean();
  326. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  327. long appletResourceUserId = context.RequestData.ReadInt64();
  328. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _sixAxisSensorFusionEnabled });
  329. return 0;
  330. }
  331. // SetSixAxisSensorFusionParameters(nn::hid::SixAxisSensorHandle, float RevisePower, float ReviseRange, nn::applet::AppletResourceUserId)
  332. public long SetSixAxisSensorFusionParameters(ServiceCtx context)
  333. {
  334. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  335. _sensorFusionParams = new HidSensorFusionParameters
  336. {
  337. RevisePower = context.RequestData.ReadInt32(),
  338. ReviseRange = context.RequestData.ReadInt32()
  339. };
  340. long appletResourceUserId = context.RequestData.ReadInt64();
  341. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _sensorFusionParams.RevisePower, _sensorFusionParams.ReviseRange });
  342. return 0;
  343. }
  344. // GetSixAxisSensorFusionParameters(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> float RevisePower, float ReviseRange)
  345. public long GetSixAxisSensorFusionParameters(ServiceCtx context)
  346. {
  347. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  348. long appletResourceUserId = context.RequestData.ReadInt64();
  349. context.ResponseData.Write(_sensorFusionParams.RevisePower);
  350. context.ResponseData.Write(_sensorFusionParams.ReviseRange);
  351. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _sensorFusionParams.RevisePower, _sensorFusionParams.ReviseRange });
  352. return 0;
  353. }
  354. // ResetSixAxisSensorFusionParameters(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId)
  355. public long ResetSixAxisSensorFusionParameters(ServiceCtx context)
  356. {
  357. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  358. long appletResourceUserId = context.RequestData.ReadInt64();
  359. _sensorFusionParams.RevisePower = 0;
  360. _sensorFusionParams.ReviseRange = 0;
  361. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _sensorFusionParams.RevisePower, _sensorFusionParams.ReviseRange });
  362. return 0;
  363. }
  364. // SetAccelerometerParameters(nn::hid::SixAxisSensorHandle, float X, float Y, nn::applet::AppletResourceUserId)
  365. public long SetAccelerometerParameters(ServiceCtx context)
  366. {
  367. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  368. _accelerometerParams = new HidAccelerometerParameters
  369. {
  370. X = context.RequestData.ReadInt32(),
  371. Y = context.RequestData.ReadInt32()
  372. };
  373. long appletResourceUserId = context.RequestData.ReadInt64();
  374. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerParams.X, _accelerometerParams.Y });
  375. return 0;
  376. }
  377. // GetAccelerometerParameters(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> float X, float Y
  378. public long GetAccelerometerParameters(ServiceCtx context)
  379. {
  380. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  381. long appletResourceUserId = context.RequestData.ReadInt64();
  382. context.ResponseData.Write(_accelerometerParams.X);
  383. context.ResponseData.Write(_accelerometerParams.Y);
  384. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerParams.X, _accelerometerParams.Y });
  385. return 0;
  386. }
  387. // ResetAccelerometerParameters(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId)
  388. public long ResetAccelerometerParameters(ServiceCtx context)
  389. {
  390. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  391. long appletResourceUserId = context.RequestData.ReadInt64();
  392. _accelerometerParams.X = 0;
  393. _accelerometerParams.Y = 0;
  394. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerParams.X, _accelerometerParams.Y });
  395. return 0;
  396. }
  397. // SetAccelerometerPlayMode(nn::hid::SixAxisSensorHandle, uint PlayMode, nn::applet::AppletResourceUserId)
  398. public long SetAccelerometerPlayMode(ServiceCtx context)
  399. {
  400. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  401. _accelerometerPlayMode = context.RequestData.ReadUInt32();
  402. long appletResourceUserId = context.RequestData.ReadInt64();
  403. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerPlayMode });
  404. return 0;
  405. }
  406. // GetAccelerometerPlayMode(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> uint PlayMode
  407. public long GetAccelerometerPlayMode(ServiceCtx context)
  408. {
  409. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  410. long appletResourceUserId = context.RequestData.ReadInt64();
  411. context.ResponseData.Write(_accelerometerPlayMode);
  412. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerPlayMode });
  413. return 0;
  414. }
  415. // ResetAccelerometerPlayMode(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId)
  416. public long ResetAccelerometerPlayMode(ServiceCtx context)
  417. {
  418. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  419. long appletResourceUserId = context.RequestData.ReadInt64();
  420. _accelerometerPlayMode = 0;
  421. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerPlayMode });
  422. return 0;
  423. }
  424. // SetGyroscopeZeroDriftMode(nn::hid::SixAxisSensorHandle, uint GyroscopeZeroDriftMode, nn::applet::AppletResourceUserId)
  425. public long SetGyroscopeZeroDriftMode(ServiceCtx context)
  426. {
  427. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  428. _gyroscopeZeroDriftMode = (HidGyroscopeZeroDriftMode)context.RequestData.ReadInt32();
  429. long appletResourceUserId = context.RequestData.ReadInt64();
  430. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _gyroscopeZeroDriftMode });
  431. return 0;
  432. }
  433. // GetGyroscopeZeroDriftMode(nn::applet::AppletResourceUserId, nn::hid::SixAxisSensorHandle) -> int GyroscopeZeroDriftMode
  434. public long GetGyroscopeZeroDriftMode(ServiceCtx context)
  435. {
  436. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  437. long appletResourceUserId = context.RequestData.ReadInt64();
  438. context.ResponseData.Write((int)_gyroscopeZeroDriftMode);
  439. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _gyroscopeZeroDriftMode });
  440. return 0;
  441. }
  442. // ResetGyroscopeZeroDriftMode(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId)
  443. public long ResetGyroscopeZeroDriftMode(ServiceCtx context)
  444. {
  445. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  446. long appletResourceUserId = context.RequestData.ReadInt64();
  447. _gyroscopeZeroDriftMode = HidGyroscopeZeroDriftMode.Standard;
  448. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _gyroscopeZeroDriftMode });
  449. return 0;
  450. }
  451. // IsSixAxisSensorAtRest(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> bool IsAsRest
  452. public long IsSixAxisSensorAtRest(ServiceCtx context)
  453. {
  454. int sixAxisSensorHandle = context.RequestData.ReadInt32();
  455. long appletResourceUserId = context.RequestData.ReadInt64();
  456. bool isAtRest = true;
  457. context.ResponseData.Write(isAtRest);
  458. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, isAtRest });
  459. return 0;
  460. }
  461. // ActivateGesture(nn::applet::AppletResourceUserId, int Unknown0)
  462. public long ActivateGesture(ServiceCtx context)
  463. {
  464. long appletResourceUserId = context.RequestData.ReadInt64();
  465. int unknown0 = context.RequestData.ReadInt32();
  466. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknown0 });
  467. return 0;
  468. }
  469. // SetSupportedNpadStyleSet(nn::applet::AppletResourceUserId, nn::hid::NpadStyleTag)
  470. public long SetSupportedNpadStyleSet(ServiceCtx context)
  471. {
  472. _npadStyleSet = (HidNpadStyle)context.RequestData.ReadInt32();
  473. long appletResourceUserId = context.RequestData.ReadInt64();
  474. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _npadStyleSet });
  475. _npadStyleSetUpdateEvent.ReadableEvent.Signal();
  476. return 0;
  477. }
  478. // GetSupportedNpadStyleSet(nn::applet::AppletResourceUserId) -> uint nn::hid::NpadStyleTag
  479. public long GetSupportedNpadStyleSet(ServiceCtx context)
  480. {
  481. long appletResourceUserId = context.RequestData.ReadInt64();
  482. context.ResponseData.Write((int)_npadStyleSet);
  483. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _npadStyleSet });
  484. return 0;
  485. }
  486. // SetSupportedNpadIdType(nn::applet::AppletResourceUserId, array<NpadIdType, 9>)
  487. public long SetSupportedNpadIdType(ServiceCtx context)
  488. {
  489. long appletResourceUserId = context.RequestData.ReadInt64();
  490. HidControllerId npadIdType = (HidControllerId)context.RequestData.ReadInt64();
  491. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, npadIdType });
  492. return 0;
  493. }
  494. // ActivateNpad(nn::applet::AppletResourceUserId)
  495. public long ActivateNpad(ServiceCtx context)
  496. {
  497. long appletResourceUserId = context.RequestData.ReadInt64();
  498. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  499. return 0;
  500. }
  501. // DeactivateNpad(nn::applet::AppletResourceUserId)
  502. public long DeactivateNpad(ServiceCtx context)
  503. {
  504. long appletResourceUserId = context.RequestData.ReadInt64();
  505. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  506. return 0;
  507. }
  508. // AcquireNpadStyleSetUpdateEventHandle(nn::applet::AppletResourceUserId, uint, ulong) -> nn::sf::NativeHandle
  509. public long AcquireNpadStyleSetUpdateEventHandle(ServiceCtx context)
  510. {
  511. long appletResourceUserId = context.RequestData.ReadInt64();
  512. int npadId = context.RequestData.ReadInt32();
  513. long npadStyleSet = context.RequestData.ReadInt64();
  514. if (context.Process.HandleTable.GenerateHandle(_npadStyleSetUpdateEvent.ReadableEvent, out int handle) != KernelResult.Success)
  515. {
  516. throw new InvalidOperationException("Out of handles!");
  517. }
  518. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  519. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, npadId, npadStyleSet });
  520. return 0;
  521. }
  522. // DisconnectNpad(nn::applet::AppletResourceUserId, uint NpadIdType)
  523. public long DisconnectNpad(ServiceCtx context)
  524. {
  525. long appletResourceUserId = context.RequestData.ReadInt64();
  526. int npadIdType = context.RequestData.ReadInt32();
  527. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, npadIdType });
  528. return 0;
  529. }
  530. // GetPlayerLedPattern(uint NpadId) -> ulong LedPattern
  531. public long GetPlayerLedPattern(ServiceCtx context)
  532. {
  533. int npadId = context.RequestData.ReadInt32();
  534. long ledPattern = 0;
  535. context.ResponseData.Write(ledPattern);
  536. Logger.PrintStub(LogClass.ServiceHid, new { npadId, ledPattern });
  537. return 0;
  538. }
  539. // ActivateNpadWithRevision(nn::applet::AppletResourceUserId, int Unknown)
  540. public long ActivateNpadWithRevision(ServiceCtx context)
  541. {
  542. long appletResourceUserId = context.RequestData.ReadInt64();
  543. int unknown = context.RequestData.ReadInt32();
  544. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknown });
  545. return 0;
  546. }
  547. // SetNpadJoyHoldType(nn::applet::AppletResourceUserId, long NpadJoyHoldType)
  548. public long SetNpadJoyHoldType(ServiceCtx context)
  549. {
  550. long appletResourceUserId = context.RequestData.ReadInt64();
  551. _npadJoyHoldType = (HidNpadJoyHoldType)context.RequestData.ReadInt64();
  552. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _npadJoyHoldType });
  553. return 0;
  554. }
  555. // GetNpadJoyHoldType(nn::applet::AppletResourceUserId) -> long NpadJoyHoldType
  556. public long GetNpadJoyHoldType(ServiceCtx context)
  557. {
  558. long appletResourceUserId = context.RequestData.ReadInt64();
  559. context.ResponseData.Write((long)_npadJoyHoldType);
  560. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _npadJoyHoldType });
  561. return 0;
  562. }
  563. // SetNpadJoyAssignmentModeSingleByDefault(uint HidControllerId, nn::applet::AppletResourceUserId)
  564. public long SetNpadJoyAssignmentModeSingleByDefault(ServiceCtx context)
  565. {
  566. HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32();
  567. long appletResourceUserId = context.RequestData.ReadInt64();
  568. _npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Single;
  569. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, hidControllerId, _npadJoyAssignmentMode });
  570. return 0;
  571. }
  572. // SetNpadJoyAssignmentModeSingle(uint HidControllerId, nn::applet::AppletResourceUserId, long HidNpadJoyDeviceType)
  573. public long SetNpadJoyAssignmentModeSingle(ServiceCtx context)
  574. {
  575. HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32();
  576. long appletResourceUserId = context.RequestData.ReadInt64();
  577. HidNpadJoyDeviceType hidNpadJoyDeviceType = (HidNpadJoyDeviceType)context.RequestData.ReadInt64();
  578. _npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Single;
  579. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, hidControllerId, hidNpadJoyDeviceType, _npadJoyAssignmentMode });
  580. return 0;
  581. }
  582. // SetNpadJoyAssignmentModeDual(uint HidControllerId, nn::applet::AppletResourceUserId)
  583. public long SetNpadJoyAssignmentModeDual(ServiceCtx context)
  584. {
  585. HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32();
  586. long appletResourceUserId = context.RequestData.ReadInt64();
  587. _npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Dual;
  588. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, hidControllerId, _npadJoyAssignmentMode });
  589. return 0;
  590. }
  591. // MergeSingleJoyAsDualJoy(uint SingleJoyId0, uint SingleJoyId1, nn::applet::AppletResourceUserId)
  592. public long MergeSingleJoyAsDualJoy(ServiceCtx context)
  593. {
  594. long singleJoyId0 = context.RequestData.ReadInt32();
  595. long singleJoyId1 = context.RequestData.ReadInt32();
  596. long appletResourceUserId = context.RequestData.ReadInt64();
  597. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, singleJoyId0, singleJoyId1 });
  598. return 0;
  599. }
  600. // StartLrAssignmentMode(nn::applet::AppletResourceUserId)
  601. public long StartLrAssignmentMode(ServiceCtx context)
  602. {
  603. long appletResourceUserId = context.RequestData.ReadInt64();
  604. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  605. return 0;
  606. }
  607. // StopLrAssignmentMode(nn::applet::AppletResourceUserId)
  608. public long StopLrAssignmentMode(ServiceCtx context)
  609. {
  610. long appletResourceUserId = context.RequestData.ReadInt64();
  611. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  612. return 0;
  613. }
  614. // SetNpadHandheldActivationMode(nn::applet::AppletResourceUserId, long HidNpadHandheldActivationMode)
  615. public long SetNpadHandheldActivationMode(ServiceCtx context)
  616. {
  617. long appletResourceUserId = context.RequestData.ReadInt64();
  618. _npadHandheldActivationMode = (HidNpadHandheldActivationMode)context.RequestData.ReadInt64();
  619. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _npadHandheldActivationMode });
  620. return 0;
  621. }
  622. // GetNpadHandheldActivationMode(nn::applet::AppletResourceUserId) -> long HidNpadHandheldActivationMode
  623. public long GetNpadHandheldActivationMode(ServiceCtx context)
  624. {
  625. long appletResourceUserId = context.RequestData.ReadInt64();
  626. context.ResponseData.Write((long)_npadHandheldActivationMode);
  627. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _npadHandheldActivationMode });
  628. return 0;
  629. }
  630. // SwapNpadAssignment(uint OldNpadAssignment, uint NewNpadAssignment, nn::applet::AppletResourceUserId)
  631. public long SwapNpadAssignment(ServiceCtx context)
  632. {
  633. int oldNpadAssignment = context.RequestData.ReadInt32();
  634. int newNpadAssignment = context.RequestData.ReadInt32();
  635. long appletResourceUserId = context.RequestData.ReadInt64();
  636. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, oldNpadAssignment, newNpadAssignment });
  637. return 0;
  638. }
  639. // IsUnintendedHomeButtonInputProtectionEnabled(uint Unknown0, nn::applet::AppletResourceUserId) -> bool IsEnabled
  640. public long IsUnintendedHomeButtonInputProtectionEnabled(ServiceCtx context)
  641. {
  642. uint unknown0 = context.RequestData.ReadUInt32();
  643. long appletResourceUserId = context.RequestData.ReadInt64();
  644. context.ResponseData.Write(_unintendedHomeButtonInputProtectionEnabled);
  645. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknown0, _unintendedHomeButtonInputProtectionEnabled });
  646. return 0;
  647. }
  648. // EnableUnintendedHomeButtonInputProtection(bool Enable, uint Unknown0, nn::applet::AppletResourceUserId)
  649. public long EnableUnintendedHomeButtonInputProtection(ServiceCtx context)
  650. {
  651. _unintendedHomeButtonInputProtectionEnabled = context.RequestData.ReadBoolean();
  652. uint unknown0 = context.RequestData.ReadUInt32();
  653. long appletResourceUserId = context.RequestData.ReadInt64();
  654. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknown0, _unintendedHomeButtonInputProtectionEnabled });
  655. return 0;
  656. }
  657. // SetNpadJoyAssignmentModeSingleWithDestination(uint HidControllerId, long HidNpadJoyDeviceType, nn::applet::AppletResourceUserId) -> bool Unknown0, uint Unknown1
  658. public long SetNpadJoyAssignmentModeSingleWithDestination(ServiceCtx context)
  659. {
  660. HidControllerId hidControllerId = (HidControllerId)context.RequestData.ReadInt32();
  661. HidNpadJoyDeviceType hidNpadJoyDeviceType = (HidNpadJoyDeviceType)context.RequestData.ReadInt64();
  662. long appletResourceUserId = context.RequestData.ReadInt64();
  663. _npadJoyAssignmentMode = HidNpadJoyAssignmentMode.Single;
  664. context.ResponseData.Write(0); //Unknown0
  665. context.ResponseData.Write(0); //Unknown1
  666. Logger.PrintStub(LogClass.ServiceHid, new {
  667. appletResourceUserId,
  668. hidControllerId,
  669. hidNpadJoyDeviceType,
  670. _npadJoyAssignmentMode,
  671. Unknown0 = 0,
  672. Unknown1 = 0
  673. });
  674. return 0;
  675. }
  676. // GetVibrationDeviceInfo(nn::hid::VibrationDeviceHandle) -> nn::hid::VibrationDeviceInfo
  677. public long GetVibrationDeviceInfo(ServiceCtx context)
  678. {
  679. int vibrationDeviceHandle = context.RequestData.ReadInt32();
  680. HidVibrationDeviceValue deviceInfo = new HidVibrationDeviceValue
  681. {
  682. DeviceType = HidVibrationDeviceType.None,
  683. Position = HidVibrationDevicePosition.None
  684. };
  685. context.ResponseData.Write((int)deviceInfo.DeviceType);
  686. context.ResponseData.Write((int)deviceInfo.Position);
  687. Logger.PrintStub(LogClass.ServiceHid, new { vibrationDeviceHandle, deviceInfo.DeviceType, deviceInfo.Position });
  688. return 0;
  689. }
  690. // SendVibrationValue(nn::hid::VibrationDeviceHandle, nn::hid::VibrationValue, nn::applet::AppletResourceUserId)
  691. public long SendVibrationValue(ServiceCtx context)
  692. {
  693. int vibrationDeviceHandle = context.RequestData.ReadInt32();
  694. _vibrationValue = new HidVibrationValue
  695. {
  696. AmplitudeLow = context.RequestData.ReadSingle(),
  697. FrequencyLow = context.RequestData.ReadSingle(),
  698. AmplitudeHigh = context.RequestData.ReadSingle(),
  699. FrequencyHigh = context.RequestData.ReadSingle()
  700. };
  701. long appletResourceUserId = context.RequestData.ReadInt64();
  702. Logger.PrintStub(LogClass.ServiceHid, new {
  703. appletResourceUserId,
  704. vibrationDeviceHandle,
  705. _vibrationValue.AmplitudeLow,
  706. _vibrationValue.FrequencyLow,
  707. _vibrationValue.AmplitudeHigh,
  708. _vibrationValue.FrequencyHigh
  709. });
  710. return 0;
  711. }
  712. // GetActualVibrationValue(nn::hid::VibrationDeviceHandle, nn::applet::AppletResourceUserId) -> nn::hid::VibrationValue
  713. public long GetActualVibrationValue(ServiceCtx context)
  714. {
  715. int vibrationDeviceHandle = context.RequestData.ReadInt32();
  716. long appletResourceUserId = context.RequestData.ReadInt64();
  717. context.ResponseData.Write(_vibrationValue.AmplitudeLow);
  718. context.ResponseData.Write(_vibrationValue.FrequencyLow);
  719. context.ResponseData.Write(_vibrationValue.AmplitudeHigh);
  720. context.ResponseData.Write(_vibrationValue.FrequencyHigh);
  721. Logger.PrintStub(LogClass.ServiceHid, new {
  722. appletResourceUserId,
  723. vibrationDeviceHandle,
  724. _vibrationValue.AmplitudeLow,
  725. _vibrationValue.FrequencyLow,
  726. _vibrationValue.AmplitudeHigh,
  727. _vibrationValue.FrequencyHigh
  728. });
  729. return 0;
  730. }
  731. // CreateActiveVibrationDeviceList() -> object<nn::hid::IActiveVibrationDeviceList>
  732. public long CreateActiveVibrationDeviceList(ServiceCtx context)
  733. {
  734. MakeObject(context, new IActiveApplicationDeviceList());
  735. return 0;
  736. }
  737. // PermitVibration(bool Enable)
  738. public long PermitVibration(ServiceCtx context)
  739. {
  740. _vibrationPermitted = context.RequestData.ReadBoolean();
  741. Logger.PrintStub(LogClass.ServiceHid, new { _vibrationPermitted });
  742. return 0;
  743. }
  744. // IsVibrationPermitted() -> bool IsEnabled
  745. public long IsVibrationPermitted(ServiceCtx context)
  746. {
  747. context.ResponseData.Write(_vibrationPermitted);
  748. Logger.PrintStub(LogClass.ServiceHid, new { _vibrationPermitted });
  749. return 0;
  750. }
  751. // SendVibrationValues(nn::applet::AppletResourceUserId, buffer<array<nn::hid::VibrationDeviceHandle>, type: 9>, buffer<array<nn::hid::VibrationValue>, type: 9>)
  752. public long SendVibrationValues(ServiceCtx context)
  753. {
  754. long appletResourceUserId = context.RequestData.ReadInt64();
  755. byte[] vibrationDeviceHandleBuffer = context.Memory.ReadBytes(
  756. context.Request.PtrBuff[0].Position,
  757. context.Request.PtrBuff[0].Size);
  758. byte[] vibrationValueBuffer = context.Memory.ReadBytes(
  759. context.Request.PtrBuff[1].Position,
  760. context.Request.PtrBuff[1].Size);
  761. //Todo: Read all handles and values from buffer.
  762. Logger.PrintStub(LogClass.ServiceHid, new {
  763. appletResourceUserId,
  764. VibrationDeviceHandleBufferLength = vibrationDeviceHandleBuffer.Length,
  765. VibrationValueBufferLength = vibrationValueBuffer.Length
  766. });
  767. return 0;
  768. }
  769. // SendVibrationGcErmCommand(nn::hid::VibrationDeviceHandle, nn::hid::VibrationGcErmCommand, nn::applet::AppletResourceUserId)
  770. public long SendVibrationGcErmCommand(ServiceCtx context)
  771. {
  772. int vibrationDeviceHandle = context.RequestData.ReadInt32();
  773. long vibrationGcErmCommand = context.RequestData.ReadInt64();
  774. long appletResourceUserId = context.RequestData.ReadInt64();
  775. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, vibrationDeviceHandle, vibrationGcErmCommand });
  776. return 0;
  777. }
  778. // GetActualVibrationGcErmCommand(nn::hid::VibrationDeviceHandle, nn::applet::AppletResourceUserId) -> nn::hid::VibrationGcErmCommand
  779. public long GetActualVibrationGcErmCommand(ServiceCtx context)
  780. {
  781. int vibrationDeviceHandle = context.RequestData.ReadInt32();
  782. long appletResourceUserId = context.RequestData.ReadInt64();
  783. context.ResponseData.Write(_vibrationGcErmCommand);
  784. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, vibrationDeviceHandle, _vibrationGcErmCommand });
  785. return 0;
  786. }
  787. // BeginPermitVibrationSession(nn::applet::AppletResourceUserId)
  788. public long BeginPermitVibrationSession(ServiceCtx context)
  789. {
  790. long appletResourceUserId = context.RequestData.ReadInt64();
  791. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  792. return 0;
  793. }
  794. // EndPermitVibrationSession()
  795. public long EndPermitVibrationSession(ServiceCtx context)
  796. {
  797. Logger.PrintStub(LogClass.ServiceHid);
  798. return 0;
  799. }
  800. // ActivateConsoleSixAxisSensor(nn::applet::AppletResourceUserId)
  801. public long ActivateConsoleSixAxisSensor(ServiceCtx context)
  802. {
  803. long appletResourceUserId = context.RequestData.ReadInt64();
  804. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  805. return 0;
  806. }
  807. // StartConsoleSixAxisSensor(nn::hid::ConsoleSixAxisSensorHandle, nn::applet::AppletResourceUserId)
  808. public long StartConsoleSixAxisSensor(ServiceCtx context)
  809. {
  810. int consoleSixAxisSensorHandle = context.RequestData.ReadInt32();
  811. long appletResourceUserId = context.RequestData.ReadInt64();
  812. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, consoleSixAxisSensorHandle });
  813. return 0;
  814. }
  815. // StopConsoleSixAxisSensor(nn::hid::ConsoleSixAxisSensorHandle, nn::applet::AppletResourceUserId)
  816. public long StopConsoleSixAxisSensor(ServiceCtx context)
  817. {
  818. int consoleSixAxisSensorHandle = context.RequestData.ReadInt32();
  819. long appletResourceUserId = context.RequestData.ReadInt64();
  820. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, consoleSixAxisSensorHandle });
  821. return 0;
  822. }
  823. // ActivateSevenSixAxisSensor(nn::applet::AppletResourceUserId)
  824. public long ActivateSevenSixAxisSensor(ServiceCtx context)
  825. {
  826. long appletResourceUserId = context.RequestData.ReadInt64();
  827. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  828. return 0;
  829. }
  830. // StartSevenSixAxisSensor(nn::applet::AppletResourceUserId)
  831. public long StartSevenSixAxisSensor(ServiceCtx context)
  832. {
  833. long appletResourceUserId = context.RequestData.ReadInt64();
  834. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  835. return 0;
  836. }
  837. // StopSevenSixAxisSensor(nn::applet::AppletResourceUserId)
  838. public long StopSevenSixAxisSensor(ServiceCtx context)
  839. {
  840. long appletResourceUserId = context.RequestData.ReadInt64();
  841. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  842. return 0;
  843. }
  844. // InitializeSevenSixAxisSensor(array<nn::sf::NativeHandle>, ulong Counter0, array<nn::sf::NativeHandle>, ulong Counter1, nn::applet::AppletResourceUserId)
  845. public long InitializeSevenSixAxisSensor(ServiceCtx context)
  846. {
  847. long appletResourceUserId = context.RequestData.ReadInt64();
  848. long counter0 = context.RequestData.ReadInt64();
  849. long counter1 = context.RequestData.ReadInt64();
  850. // Todo: Determine if array<nn::sf::NativeHandle> is a buffer or not...
  851. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, counter0, counter1 });
  852. return 0;
  853. }
  854. // FinalizeSevenSixAxisSensor(nn::applet::AppletResourceUserId)
  855. public long FinalizeSevenSixAxisSensor(ServiceCtx context)
  856. {
  857. long appletResourceUserId = context.RequestData.ReadInt64();
  858. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
  859. return 0;
  860. }
  861. // SetSevenSixAxisSensorFusionStrength(float Strength, nn::applet::AppletResourceUserId)
  862. public long SetSevenSixAxisSensorFusionStrength(ServiceCtx context)
  863. {
  864. _sevenSixAxisSensorFusionStrength = context.RequestData.ReadSingle();
  865. long appletResourceUserId = context.RequestData.ReadInt64();
  866. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _sevenSixAxisSensorFusionStrength });
  867. return 0;
  868. }
  869. // GetSevenSixAxisSensorFusionStrength(nn::applet::AppletResourceUserId) -> float Strength
  870. public long GetSevenSixAxisSensorFusionStrength(ServiceCtx context)
  871. {
  872. long appletResourceUserId = context.RequestData.ReadInt64();
  873. context.ResponseData.Write(_sevenSixAxisSensorFusionStrength);
  874. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _sevenSixAxisSensorFusionStrength });
  875. return 0;
  876. }
  877. // IsUsbFullKeyControllerEnabled() -> bool IsEnabled
  878. public long IsUsbFullKeyControllerEnabled(ServiceCtx context)
  879. {
  880. context.ResponseData.Write(_usbFullKeyControllerEnabled);
  881. Logger.PrintStub(LogClass.ServiceHid, new { _usbFullKeyControllerEnabled });
  882. return 0;
  883. }
  884. // EnableUsbFullKeyController(bool Enable)
  885. public long EnableUsbFullKeyController(ServiceCtx context)
  886. {
  887. _usbFullKeyControllerEnabled = context.RequestData.ReadBoolean();
  888. Logger.PrintStub(LogClass.ServiceHid, new { _usbFullKeyControllerEnabled });
  889. return 0;
  890. }
  891. // IsUsbFullKeyControllerConnected(uint Unknown0) -> bool Connected
  892. public long IsUsbFullKeyControllerConnected(ServiceCtx context)
  893. {
  894. int unknown0 = context.RequestData.ReadInt32();
  895. context.ResponseData.Write(true); //FullKeyController is always connected ?
  896. Logger.PrintStub(LogClass.ServiceHid, new { unknown0, Connected = true });
  897. return 0;
  898. }
  899. // HasBattery(uint NpadId) -> bool HasBattery
  900. public long HasBattery(ServiceCtx context)
  901. {
  902. int npadId = context.RequestData.ReadInt32();
  903. context.ResponseData.Write(true); //Npad always got a battery ?
  904. Logger.PrintStub(LogClass.ServiceHid, new { npadId, HasBattery = true });
  905. return 0;
  906. }
  907. // HasLeftRightBattery(uint NpadId) -> bool HasLeftBattery, bool HasRightBattery
  908. public long HasLeftRightBattery(ServiceCtx context)
  909. {
  910. int npadId = context.RequestData.ReadInt32();
  911. context.ResponseData.Write(true); //Npad always got a left battery ?
  912. context.ResponseData.Write(true); //Npad always got a right battery ?
  913. Logger.PrintStub(LogClass.ServiceHid, new { npadId, HasLeftBattery = true, HasRightBattery = true });
  914. return 0;
  915. }
  916. // GetNpadInterfaceType(uint NpadId) -> uchar InterfaceType
  917. public long GetNpadInterfaceType(ServiceCtx context)
  918. {
  919. int npadId = context.RequestData.ReadInt32();
  920. context.ResponseData.Write((byte)0);
  921. Logger.PrintStub(LogClass.ServiceHid, new { npadId, NpadInterfaceType = 0 });
  922. return 0;
  923. }
  924. // GetNpadLeftRightInterfaceType(uint NpadId) -> uchar LeftInterfaceType, uchar RightInterfaceType
  925. public long GetNpadLeftRightInterfaceType(ServiceCtx context)
  926. {
  927. int npadId = context.RequestData.ReadInt32();
  928. context.ResponseData.Write((byte)0);
  929. context.ResponseData.Write((byte)0);
  930. Logger.PrintStub(LogClass.ServiceHid, new { npadId, LeftInterfaceType = 0, RightInterfaceType = 0 });
  931. return 0;
  932. }
  933. // GetPalmaConnectionHandle(uint Unknown0, nn::applet::AppletResourceUserId) -> nn::hid::PalmaConnectionHandle
  934. public long GetPalmaConnectionHandle(ServiceCtx context)
  935. {
  936. int unknown0 = context.RequestData.ReadInt32();
  937. long appletResourceUserId = context.RequestData.ReadInt64();
  938. int palmaConnectionHandle = 0;
  939. context.ResponseData.Write(palmaConnectionHandle);
  940. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId , unknown0, palmaConnectionHandle });
  941. return 0;
  942. }
  943. // InitializePalma(nn::hid::PalmaConnectionHandle)
  944. public long InitializePalma(ServiceCtx context)
  945. {
  946. int palmaConnectionHandle = context.RequestData.ReadInt32();
  947. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
  948. _palmaOperationCompleteEvent.ReadableEvent.Signal();
  949. return 0;
  950. }
  951. // AcquirePalmaOperationCompleteEvent(nn::hid::PalmaConnectionHandle) -> nn::sf::NativeHandle
  952. public long AcquirePalmaOperationCompleteEvent(ServiceCtx context)
  953. {
  954. int palmaConnectionHandle = context.RequestData.ReadInt32();
  955. if (context.Process.HandleTable.GenerateHandle(_palmaOperationCompleteEvent.ReadableEvent, out int handle) != KernelResult.Success)
  956. {
  957. throw new InvalidOperationException("Out of handles!");
  958. }
  959. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  960. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
  961. return 0;
  962. }
  963. // GetPalmaOperationInfo(nn::hid::PalmaConnectionHandle) -> long Unknown0, buffer<Unknown>
  964. public long GetPalmaOperationInfo(ServiceCtx context)
  965. {
  966. int palmaConnectionHandle = context.RequestData.ReadInt32();
  967. long unknown0 = 0; //Counter?
  968. context.ResponseData.Write(unknown0);
  969. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0 });
  970. return 0;
  971. }
  972. // PlayPalmaActivity(nn::hid::PalmaConnectionHandle, ulong Unknown0)
  973. public long PlayPalmaActivity(ServiceCtx context)
  974. {
  975. int palmaConnectionHandle = context.RequestData.ReadInt32();
  976. long unknown0 = context.RequestData.ReadInt64();
  977. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0 });
  978. _palmaOperationCompleteEvent.ReadableEvent.Signal();
  979. return 0;
  980. }
  981. // SetPalmaFrModeType(nn::hid::PalmaConnectionHandle, ulong FrModeType)
  982. public long SetPalmaFrModeType(ServiceCtx context)
  983. {
  984. int palmaConnectionHandle = context.RequestData.ReadInt32();
  985. long frModeType = context.RequestData.ReadInt64();
  986. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, frModeType });
  987. _palmaOperationCompleteEvent.ReadableEvent.Signal();
  988. return 0;
  989. }
  990. // ReadPalmaStep(nn::hid::PalmaConnectionHandle)
  991. public long ReadPalmaStep(ServiceCtx context)
  992. {
  993. int palmaConnectionHandle = context.RequestData.ReadInt32();
  994. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
  995. return 0;
  996. }
  997. // EnablePalmaStep(nn::hid::PalmaConnectionHandle, bool Enable)
  998. public long EnablePalmaStep(ServiceCtx context)
  999. {
  1000. int palmaConnectionHandle = context.RequestData.ReadInt32();
  1001. bool enabledPalmaStep = context.RequestData.ReadBoolean();
  1002. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, enabledPalmaStep });
  1003. _palmaOperationCompleteEvent.ReadableEvent.Signal();
  1004. return 0;
  1005. }
  1006. // SuspendPalmaStep(nn::hid::PalmaConnectionHandle)
  1007. public long SuspendPalmaStep(ServiceCtx context)
  1008. {
  1009. int palmaConnectionHandle = context.RequestData.ReadInt32();
  1010. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
  1011. _palmaOperationCompleteEvent.ReadableEvent.Signal();
  1012. return 0;
  1013. }
  1014. // ResetPalmaStep(nn::hid::PalmaConnectionHandle)
  1015. public long ResetPalmaStep(ServiceCtx context)
  1016. {
  1017. int palmaConnectionHandle = context.RequestData.ReadInt32();
  1018. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
  1019. _palmaOperationCompleteEvent.ReadableEvent.Signal();
  1020. return 0;
  1021. }
  1022. // ReadPalmaApplicationSection(nn::hid::PalmaConnectionHandle, ulong Unknown0, ulong Unknown1)
  1023. public long ReadPalmaApplicationSection(ServiceCtx context)
  1024. {
  1025. int palmaConnectionHandle = context.RequestData.ReadInt32();
  1026. long unknown0 = context.RequestData.ReadInt64();
  1027. long unknown1 = context.RequestData.ReadInt64();
  1028. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0, unknown1 });
  1029. return 0;
  1030. }
  1031. // WritePalmaApplicationSection(nn::hid::PalmaConnectionHandle, ulong Unknown0, ulong Unknown1, nn::hid::PalmaApplicationSectionAccessBuffer)
  1032. public long WritePalmaApplicationSection(ServiceCtx context)
  1033. {
  1034. int palmaConnectionHandle = context.RequestData.ReadInt32();
  1035. long unknown0 = context.RequestData.ReadInt64();
  1036. long unknown1 = context.RequestData.ReadInt64();
  1037. // nn::hid::PalmaApplicationSectionAccessBuffer cast is unknown
  1038. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0, unknown1 });
  1039. _palmaOperationCompleteEvent.ReadableEvent.Signal();
  1040. return 0;
  1041. }
  1042. // ReadPalmaUniqueCode(nn::hid::PalmaConnectionHandle)
  1043. public long ReadPalmaUniqueCode(ServiceCtx context)
  1044. {
  1045. int palmaConnectionHandle = context.RequestData.ReadInt32();
  1046. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
  1047. return 0;
  1048. }
  1049. // SetPalmaUniqueCodeInvalid(nn::hid::PalmaConnectionHandle)
  1050. public long SetPalmaUniqueCodeInvalid(ServiceCtx context)
  1051. {
  1052. int palmaConnectionHandle = context.RequestData.ReadInt32();
  1053. Logger.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
  1054. return 0;
  1055. }
  1056. // SetNpadCommunicationMode(long CommunicationMode, nn::applet::AppletResourceUserId)
  1057. public long SetNpadCommunicationMode(ServiceCtx context)
  1058. {
  1059. _npadCommunicationMode = context.RequestData.ReadInt64();
  1060. long appletResourceUserId = context.RequestData.ReadInt64();
  1061. Logger.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _npadCommunicationMode });
  1062. return 0;
  1063. }
  1064. // GetNpadCommunicationMode() -> long CommunicationMode
  1065. public long GetNpadCommunicationMode(ServiceCtx context)
  1066. {
  1067. context.ResponseData.Write(_npadCommunicationMode);
  1068. Logger.PrintStub(LogClass.ServiceHid, new { _npadCommunicationMode });
  1069. return 0;
  1070. }
  1071. }
  1072. }