IPsmServer.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 : int
  9. {
  10. None,
  11. ChargerOrDock,
  12. UsbC
  13. }
  14. private Dictionary<int, ServiceProcessRequest> m_Commands;
  15. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  16. public IPsmServer()
  17. {
  18. m_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, $"Stubbed. ChargePercentage: {ChargePercentage}");
  31. return 0;
  32. }
  33. // GetChargerType() -> u32
  34. public static long GetChargerType(ServiceCtx Context)
  35. {
  36. Context.ResponseData.Write((int)ChargerType.ChargerOrDock);
  37. Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargerType: {ChargerType.ChargerOrDock}");
  38. return 0;
  39. }
  40. // OpenSession() -> IPsmSession
  41. public long OpenSession(ServiceCtx Context)
  42. {
  43. MakeObject(Context, new IPsmSession(Context.Device.System));
  44. return 0;
  45. }
  46. }
  47. }