2018-10-21 08:01:22 +02: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 01:52:39 +01:00
|
|
|
|
enum ChargerType : int
|
2018-10-21 08:01:22 +02:00
|
|
|
|
{
|
|
|
|
|
None,
|
|
|
|
|
ChargerOrDock,
|
|
|
|
|
UsbC
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
2018-10-21 08:01:22 +02:00
|
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
2018-10-21 08:01:22 +02:00
|
|
|
|
|
|
|
|
|
public IPsmServer()
|
|
|
|
|
{
|
2018-12-05 01:52:39 +01:00
|
|
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
2018-10-21 08:01:22 +02:00
|
|
|
|
{
|
|
|
|
|
{ 0, GetBatteryChargePercentage },
|
|
|
|
|
{ 1, GetChargerType },
|
|
|
|
|
{ 7, OpenSession }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetBatteryChargePercentage() -> u32
|
2018-12-05 01:52:39 +01:00
|
|
|
|
public static long GetBatteryChargePercentage(ServiceCtx Context)
|
2018-10-21 08:01:22 +02:00
|
|
|
|
{
|
2018-12-05 01:52:39 +01:00
|
|
|
|
int ChargePercentage = 100;
|
2018-10-21 08:01:22 +02:00
|
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
|
Context.ResponseData.Write(ChargePercentage);
|
2018-10-21 08:01:22 +02:00
|
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargePercentage: {ChargePercentage}");
|
2018-10-21 08:01:22 +02:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetChargerType() -> u32
|
2018-12-05 01:52:39 +01:00
|
|
|
|
public static long GetChargerType(ServiceCtx Context)
|
2018-10-21 08:01:22 +02:00
|
|
|
|
{
|
2018-12-05 01:52:39 +01:00
|
|
|
|
Context.ResponseData.Write((int)ChargerType.ChargerOrDock);
|
2018-10-21 08:01:22 +02:00
|
|
|
|
|
|
|
|
|
Logger.PrintStub(LogClass.ServicePsm, $"Stubbed. ChargerType: {ChargerType.ChargerOrDock}");
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OpenSession() -> IPsmSession
|
2018-12-05 01:52:39 +01:00
|
|
|
|
public long OpenSession(ServiceCtx Context)
|
2018-10-21 08:01:22 +02:00
|
|
|
|
{
|
2018-12-05 01:52:39 +01:00
|
|
|
|
MakeObject(Context, new IPsmSession(Context.Device.System));
|
2018-10-21 08:01:22 +02:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|