IPsmServer.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Ipc;
  3. using System.Collections.Generic;
  4. namespace Ryujinx.HLE.HOS.Services.Psm
  5. {
  6. class IPsmServer : IpcService
  7. {
  8. enum ChargerType
  9. {
  10. None,
  11. ChargerOrDock,
  12. UsbC
  13. }
  14. private Dictionary<int, ServiceProcessRequest> _commands;
  15. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  16. public IPsmServer()
  17. {
  18. _commands = new Dictionary<int, ServiceProcessRequest>
  19. {
  20. { 0, GetBatteryChargePercentage },
  21. { 1, GetChargerType },
  22. { 7, OpenSession }
  23. };
  24. }
  25. // GetBatteryChargePercentage() -> u32
  26. public static long GetBatteryChargePercentage(ServiceCtx context)
  27. {
  28. int chargePercentage = 100;
  29. context.ResponseData.Write(chargePercentage);
  30. Logger.PrintStub(LogClass.ServicePsm, new { chargePercentage });
  31. return 0;
  32. }
  33. // GetChargerType() -> u32
  34. public static long GetChargerType(ServiceCtx context)
  35. {
  36. ChargerType chargerType = ChargerType.ChargerOrDock;
  37. context.ResponseData.Write((int)chargerType);
  38. Logger.PrintStub(LogClass.ServicePsm, new { chargerType });
  39. return 0;
  40. }
  41. // OpenSession() -> IPsmSession
  42. public long OpenSession(ServiceCtx context)
  43. {
  44. MakeObject(context, new IPsmSession(context.Device.System));
  45. return 0;
  46. }
  47. }
  48. }