aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/Ptm/Ipc/MeasurementServer.cs
blob: ce7c0474a7d38f1838d039172283240a369da90b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using Ryujinx.Common.Logging;
using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Sf;
using Ryujinx.Horizon.Sdk.Ts;
using Ryujinx.Horizon.Ts.Ipc;

namespace Ryujinx.Horizon.Ptm.Ipc
{
    partial class MeasurementServer : IMeasurementServer
    {
        // NOTE: Values are randomly choosen.
        public const int DefaultTemperature = 42;
        public const int MinimumTemperature = 0;
        public const int MaximumTemperature = 100;

        [CmifCommand(0)] // 1.0.0-16.1.0
        public Result GetTemperatureRange(out int minimumTemperature, out int maximumTemperature, Location location)
        {
            Logger.Stub?.PrintStub(LogClass.ServicePtm, new { location });

            minimumTemperature = MinimumTemperature;
            maximumTemperature = MaximumTemperature;

            return Result.Success;
        }

        [CmifCommand(1)] // 1.0.0-16.1.0
        public Result GetTemperature(out int temperature, Location location)
        {
            Logger.Stub?.PrintStub(LogClass.ServicePtm, new { location });

            temperature = DefaultTemperature;

            return Result.Success;
        }

        [CmifCommand(2)] // 1.0.0-13.2.1
        public Result SetMeasurementMode(Location location, byte measurementMode)
        {
            Logger.Stub?.PrintStub(LogClass.ServicePtm, new { location, measurementMode });

            return Result.Success;
        }

        [CmifCommand(3)] // 1.0.0-13.2.1
        public Result GetTemperatureMilliC(out int temperatureMilliC, Location location)
        {
            Logger.Stub?.PrintStub(LogClass.ServicePtm, new { location });

            temperatureMilliC = DefaultTemperature * 1000;

            return Result.Success;
        }

        [CmifCommand(4)] // 8.0.0+
        public Result OpenSession(out ISession session, DeviceCode deviceCode)
        {
            session = new Session(deviceCode);

            return Result.Success;
        }
    }
}