diff --git a/Ryujinx.Common/Logging/LogClass.cs b/Ryujinx.Common/Logging/LogClass.cs index 97ffb31477..8739fbc677 100644 --- a/Ryujinx.Common/Logging/LogClass.cs +++ b/Ryujinx.Common/Logging/LogClass.cs @@ -33,6 +33,7 @@ namespace Ryujinx.Common.Logging ServicePctl, ServicePl, ServicePrepo, + ServicePsm, ServiceSet, ServiceSfdnsres, ServiceSm, diff --git a/Ryujinx.HLE/HOS/Services/Psm/IPsmServer.cs b/Ryujinx.HLE/HOS/Services/Psm/IPsmServer.cs new file mode 100644 index 0000000000..99df636c88 --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Psm/IPsmServer.cs @@ -0,0 +1,51 @@ +using Ryujinx.Common.Logging; +using Ryujinx.HLE.HOS.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.HLE.HOS.Services.Psm +{ + class IPsmServer : IpcService + { + enum ChargerType : int + { + None, + ChargerOrDock, + UsbC + } + + private Dictionary m_Commands; + + public override IReadOnlyDictionary Commands => m_Commands; + + public IPsmServer() + { + m_Commands = new Dictionary() + { + { 0, GetBatteryChargePercentage }, + { 1, GetChargerType } + }; + } + + // GetBatteryChargePercentage() -> u32 + public static long GetBatteryChargePercentage(ServiceCtx Context) + { + int ChargePercentage = 100; + + Context.ResponseData.Write(ChargePercentage); + + Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargePercentage: {ChargePercentage}"); + + return 0; + } + + // GetChargerType() -> u32 + public static long GetChargerType(ServiceCtx Context) + { + Context.ResponseData.Write((int)ChargerType.ChargerOrDock); + + Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargerType: {ChargerType.ChargerOrDock}"); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/ServiceFactory.cs b/Ryujinx.HLE/HOS/Services/ServiceFactory.cs index 29f1c0e775..30676fe071 100644 --- a/Ryujinx.HLE/HOS/Services/ServiceFactory.cs +++ b/Ryujinx.HLE/HOS/Services/ServiceFactory.cs @@ -16,6 +16,7 @@ using Ryujinx.HLE.HOS.Services.Nv; using Ryujinx.HLE.HOS.Services.Pctl; using Ryujinx.HLE.HOS.Services.Pl; using Ryujinx.HLE.HOS.Services.Prepo; +using Ryujinx.HLE.HOS.Services.Psm; using Ryujinx.HLE.HOS.Services.Set; using Ryujinx.HLE.HOS.Services.Sfdnsres; using Ryujinx.HLE.HOS.Services.Sm; @@ -146,6 +147,9 @@ namespace Ryujinx.HLE.HOS.Services case "pl:u": return new ISharedFontManager(); + case "psm": + return new IPsmServer(); + case "prepo:a": return new IPrepoService();