IHidSystemServer.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Services.Hid.HidServer;
  3. using Ryujinx.HLE.HOS.Services.Hid.Types;
  4. namespace Ryujinx.HLE.HOS.Services.Hid
  5. {
  6. [Service("hid:sys")]
  7. class IHidSystemServer : IpcService
  8. {
  9. public IHidSystemServer(ServiceCtx context) { }
  10. [CommandHipc(303)]
  11. // ApplyNpadSystemCommonPolicy(u64)
  12. public ResultCode ApplyNpadSystemCommonPolicy(ServiceCtx context)
  13. {
  14. ulong commonPolicy = context.RequestData.ReadUInt64();
  15. Logger.Stub?.PrintStub(LogClass.ServiceHid, new { commonPolicy });
  16. return ResultCode.Success;
  17. }
  18. [CommandHipc(306)]
  19. // GetLastActiveNpad(u32) -> u8, u8
  20. public ResultCode GetLastActiveNpad(ServiceCtx context)
  21. {
  22. // TODO: RequestData seems to have garbage data, reading an extra uint seems to fix the issue.
  23. context.RequestData.ReadUInt32();
  24. ResultCode resultCode = GetAppletFooterUiTypeImpl(context, out AppletFooterUiType appletFooterUiType);
  25. context.ResponseData.Write((byte)appletFooterUiType);
  26. context.ResponseData.Write((byte)0);
  27. return resultCode;
  28. }
  29. [CommandHipc(307)]
  30. // GetNpadSystemExtStyle() -> u64
  31. public ResultCode GetNpadSystemExtStyle(ServiceCtx context)
  32. {
  33. foreach (PlayerIndex playerIndex in context.Device.Hid.Npads.GetSupportedPlayers())
  34. {
  35. if (HidUtils.GetNpadIdTypeFromIndex(playerIndex) > NpadIdType.Handheld)
  36. {
  37. return ResultCode.InvalidNpadIdType;
  38. }
  39. }
  40. context.ResponseData.Write((ulong)context.Device.Hid.Npads.SupportedStyleSets);
  41. return ResultCode.Success;
  42. }
  43. [CommandHipc(314)] // 9.0.0+
  44. // GetAppletFooterUiType(u32) -> u8
  45. public ResultCode GetAppletFooterUiType(ServiceCtx context)
  46. {
  47. ResultCode resultCode = GetAppletFooterUiTypeImpl(context, out AppletFooterUiType appletFooterUiType);
  48. context.ResponseData.Write((byte)appletFooterUiType);
  49. return resultCode;
  50. }
  51. private ResultCode GetAppletFooterUiTypeImpl(ServiceCtx context, out AppletFooterUiType appletFooterUiType)
  52. {
  53. NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();
  54. PlayerIndex playerIndex = HidUtils.GetIndexFromNpadIdType(npadIdType);
  55. appletFooterUiType = context.Device.Hid.SharedMemory.Npads[(int)playerIndex].InternalState.AppletFooterUiType;
  56. return ResultCode.Success;
  57. }
  58. }
  59. }