2018-10-21 06:01:22 +00:00
|
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Psm
|
|
|
|
|
{
|
|
|
|
|
class IPsmServer : IpcService
|
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
enum ChargerType : int
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
|
|
|
|
None,
|
|
|
|
|
ChargerOrDock,
|
|
|
|
|
UsbC
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
|
|
|
|
public IPsmServer()
|
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
|
|
|
|
{ 0, GetBatteryChargePercentage },
|
|
|
|
|
{ 1, GetChargerType },
|
|
|
|
|
{ 7, OpenSession }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetBatteryChargePercentage() -> u32
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public static long GetBatteryChargePercentage(ServiceCtx Context)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
int ChargePercentage = 100;
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
Context.ResponseData.Write(ChargePercentage);
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargePercentage: {ChargePercentage}");
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetChargerType() -> u32
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public static long GetChargerType(ServiceCtx Context)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
Context.ResponseData.Write((int)ChargerType.ChargerOrDock);
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargerType: {ChargerType.ChargerOrDock}");
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OpenSession() -> IPsmSession
|
2018-12-05 00:52:39 +00:00
|
|
|
|
public long OpenSession(ServiceCtx Context)
|
2018-10-21 06:01:22 +00:00
|
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
|
MakeObject(Context, new IPsmSession(Context.Device.System));
|
2018-10-21 06:01:22 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|