summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/logging/filter.cpp2
-rw-r--r--src/common/logging/types.h2
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/hle/service/nifm/nifm.cpp42
-rw-r--r--src/core/hle/service/ptm/psm.cpp122
-rw-r--r--src/core/hle/service/ptm/psm.h31
-rw-r--r--src/core/hle/service/ptm/ptm.cpp18
-rw-r--r--src/core/hle/service/ptm/ptm.h18
-rw-r--r--src/core/hle/service/ptm/ts.cpp41
-rw-r--r--src/core/hle/service/ptm/ts.h25
-rw-r--r--src/core/hle/service/service.cpp4
11 files changed, 224 insertions, 85 deletions
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index 4acbff649..6de9bacbf 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -128,7 +128,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
128 SUB(Service, PM) \ 128 SUB(Service, PM) \
129 SUB(Service, PREPO) \ 129 SUB(Service, PREPO) \
130 SUB(Service, PSC) \ 130 SUB(Service, PSC) \
131 SUB(Service, PSM) \ 131 SUB(Service, PTM) \
132 SUB(Service, SET) \ 132 SUB(Service, SET) \
133 SUB(Service, SM) \ 133 SUB(Service, SM) \
134 SUB(Service, SPL) \ 134 SUB(Service, SPL) \
diff --git a/src/common/logging/types.h b/src/common/logging/types.h
index cabb4db8e..595c15ada 100644
--- a/src/common/logging/types.h
+++ b/src/common/logging/types.h
@@ -95,7 +95,7 @@ enum class Class : u8 {
95 Service_PM, ///< The PM service 95 Service_PM, ///< The PM service
96 Service_PREPO, ///< The PREPO (Play report) service 96 Service_PREPO, ///< The PREPO (Play report) service
97 Service_PSC, ///< The PSC service 97 Service_PSC, ///< The PSC service
98 Service_PSM, ///< The PSM service 98 Service_PTM, ///< The PTM service
99 Service_SET, ///< The SET (Settings) service 99 Service_SET, ///< The SET (Settings) service
100 Service_SM, ///< The SM (Service manager) service 100 Service_SM, ///< The SM (Service manager) service
101 Service_SPL, ///< The SPL service 101 Service_SPL, ///< The SPL service
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index d9357138f..11d554bad 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -605,6 +605,10 @@ add_library(core STATIC
605 hle/service/psc/psc.h 605 hle/service/psc/psc.h
606 hle/service/ptm/psm.cpp 606 hle/service/ptm/psm.cpp
607 hle/service/ptm/psm.h 607 hle/service/ptm/psm.h
608 hle/service/ptm/ptm.cpp
609 hle/service/ptm/ptm.h
610 hle/service/ptm/ts.cpp
611 hle/service/ptm/ts.h
608 hle/service/kernel_helpers.cpp 612 hle/service/kernel_helpers.cpp
609 hle/service/kernel_helpers.h 613 hle/service/kernel_helpers.h
610 hle/service/service.cpp 614 hle/service/service.cpp
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp
index 0310ce883..7055ea93e 100644
--- a/src/core/hle/service/nifm/nifm.cpp
+++ b/src/core/hle/service/nifm/nifm.cpp
@@ -30,6 +30,19 @@ enum class RequestState : u32 {
30 Connected = 3, 30 Connected = 3,
31}; 31};
32 32
33enum class InternetConnectionType : u8 {
34 WiFi = 1,
35 Ethernet = 2,
36};
37
38enum class InternetConnectionStatus : u8 {
39 ConnectingUnknown1,
40 ConnectingUnknown2,
41 ConnectingUnknown3,
42 ConnectingUnknown4,
43 Connected,
44};
45
33struct IpAddressSetting { 46struct IpAddressSetting {
34 bool is_automatic{}; 47 bool is_automatic{};
35 Network::IPv4Address current_address{}; 48 Network::IPv4Address current_address{};
@@ -271,6 +284,7 @@ private:
271 rb.Push(ResultSuccess); 284 rb.Push(ResultSuccess);
272 rb.Push<u64>(client_id); // Client ID needs to be non zero otherwise it's considered invalid 285 rb.Push<u64>(client_id); // Client ID needs to be non zero otherwise it's considered invalid
273 } 286 }
287
274 void CreateScanRequest(Kernel::HLERequestContext& ctx) { 288 void CreateScanRequest(Kernel::HLERequestContext& ctx) {
275 LOG_DEBUG(Service_NIFM, "called"); 289 LOG_DEBUG(Service_NIFM, "called");
276 290
@@ -279,6 +293,7 @@ private:
279 rb.Push(ResultSuccess); 293 rb.Push(ResultSuccess);
280 rb.PushIpcInterface<IScanRequest>(system); 294 rb.PushIpcInterface<IScanRequest>(system);
281 } 295 }
296
282 void CreateRequest(Kernel::HLERequestContext& ctx) { 297 void CreateRequest(Kernel::HLERequestContext& ctx) {
283 LOG_DEBUG(Service_NIFM, "called"); 298 LOG_DEBUG(Service_NIFM, "called");
284 299
@@ -287,6 +302,7 @@ private:
287 rb.Push(ResultSuccess); 302 rb.Push(ResultSuccess);
288 rb.PushIpcInterface<IRequest>(system); 303 rb.PushIpcInterface<IRequest>(system);
289 } 304 }
305
290 void GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) { 306 void GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) {
291 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 307 LOG_WARNING(Service_NIFM, "(STUBBED) called");
292 308
@@ -335,12 +351,14 @@ private:
335 IPC::ResponseBuilder rb{ctx, 2}; 351 IPC::ResponseBuilder rb{ctx, 2};
336 rb.Push(ResultSuccess); 352 rb.Push(ResultSuccess);
337 } 353 }
354
338 void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) { 355 void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) {
339 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 356 LOG_WARNING(Service_NIFM, "(STUBBED) called");
340 357
341 IPC::ResponseBuilder rb{ctx, 2}; 358 IPC::ResponseBuilder rb{ctx, 2};
342 rb.Push(ResultSuccess); 359 rb.Push(ResultSuccess);
343 } 360 }
361
344 void GetCurrentIpAddress(Kernel::HLERequestContext& ctx) { 362 void GetCurrentIpAddress(Kernel::HLERequestContext& ctx) {
345 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 363 LOG_WARNING(Service_NIFM, "(STUBBED) called");
346 364
@@ -354,6 +372,7 @@ private:
354 rb.Push(ResultSuccess); 372 rb.Push(ResultSuccess);
355 rb.PushRaw(*ipv4); 373 rb.PushRaw(*ipv4);
356 } 374 }
375
357 void CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx) { 376 void CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx) {
358 LOG_DEBUG(Service_NIFM, "called"); 377 LOG_DEBUG(Service_NIFM, "called");
359 378
@@ -369,6 +388,7 @@ private:
369 rb.PushIpcInterface<INetworkProfile>(system); 388 rb.PushIpcInterface<INetworkProfile>(system);
370 rb.PushRaw<u128>(uuid); 389 rb.PushRaw<u128>(uuid);
371 } 390 }
391
372 void GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) { 392 void GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) {
373 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 393 LOG_WARNING(Service_NIFM, "(STUBBED) called");
374 394
@@ -405,6 +425,7 @@ private:
405 rb.Push(ResultSuccess); 425 rb.Push(ResultSuccess);
406 rb.PushRaw<IpConfigInfo>(ip_config_info); 426 rb.PushRaw<IpConfigInfo>(ip_config_info);
407 } 427 }
428
408 void IsWirelessCommunicationEnabled(Kernel::HLERequestContext& ctx) { 429 void IsWirelessCommunicationEnabled(Kernel::HLERequestContext& ctx) {
409 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 430 LOG_WARNING(Service_NIFM, "(STUBBED) called");
410 431
@@ -412,6 +433,24 @@ private:
412 rb.Push(ResultSuccess); 433 rb.Push(ResultSuccess);
413 rb.Push<u8>(0); 434 rb.Push<u8>(0);
414 } 435 }
436
437 void GetInternetConnectionStatus(Kernel::HLERequestContext& ctx) {
438 LOG_WARNING(Service_NIFM, "(STUBBED) called");
439
440 struct Output {
441 InternetConnectionType type{InternetConnectionType::WiFi};
442 u8 wifi_strength{3};
443 InternetConnectionStatus state{InternetConnectionStatus::Connected};
444 };
445 static_assert(sizeof(Output) == 0x3, "Output has incorrect size.");
446
447 constexpr Output out{};
448
449 IPC::ResponseBuilder rb{ctx, 3};
450 rb.Push(ResultSuccess);
451 rb.PushRaw(out);
452 }
453
415 void IsEthernetCommunicationEnabled(Kernel::HLERequestContext& ctx) { 454 void IsEthernetCommunicationEnabled(Kernel::HLERequestContext& ctx) {
416 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 455 LOG_WARNING(Service_NIFM, "(STUBBED) called");
417 456
@@ -423,6 +462,7 @@ private:
423 rb.Push<u8>(0); 462 rb.Push<u8>(0);
424 } 463 }
425 } 464 }
465
426 void IsAnyInternetRequestAccepted(Kernel::HLERequestContext& ctx) { 466 void IsAnyInternetRequestAccepted(Kernel::HLERequestContext& ctx) {
427 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 467 LOG_WARNING(Service_NIFM, "(STUBBED) called");
428 468
@@ -456,7 +496,7 @@ IGeneralService::IGeneralService(Core::System& system_)
456 {15, &IGeneralService::GetCurrentIpConfigInfo, "GetCurrentIpConfigInfo"}, 496 {15, &IGeneralService::GetCurrentIpConfigInfo, "GetCurrentIpConfigInfo"},
457 {16, nullptr, "SetWirelessCommunicationEnabled"}, 497 {16, nullptr, "SetWirelessCommunicationEnabled"},
458 {17, &IGeneralService::IsWirelessCommunicationEnabled, "IsWirelessCommunicationEnabled"}, 498 {17, &IGeneralService::IsWirelessCommunicationEnabled, "IsWirelessCommunicationEnabled"},
459 {18, nullptr, "GetInternetConnectionStatus"}, 499 {18, &IGeneralService::GetInternetConnectionStatus, "GetInternetConnectionStatus"},
460 {19, nullptr, "SetEthernetCommunicationEnabled"}, 500 {19, nullptr, "SetEthernetCommunicationEnabled"},
461 {20, &IGeneralService::IsEthernetCommunicationEnabled, "IsEthernetCommunicationEnabled"}, 501 {20, &IGeneralService::IsEthernetCommunicationEnabled, "IsEthernetCommunicationEnabled"},
462 {21, &IGeneralService::IsAnyInternetRequestAccepted, "IsAnyInternetRequestAccepted"}, 502 {21, &IGeneralService::IsAnyInternetRequestAccepted, "IsAnyInternetRequestAccepted"},
diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cpp
index 9e0eb6ac0..2c31e9485 100644
--- a/src/core/hle/service/ptm/psm.cpp
+++ b/src/core/hle/service/ptm/psm.cpp
@@ -9,10 +9,8 @@
9#include "core/hle/kernel/k_event.h" 9#include "core/hle/kernel/k_event.h"
10#include "core/hle/service/kernel_helpers.h" 10#include "core/hle/service/kernel_helpers.h"
11#include "core/hle/service/ptm/psm.h" 11#include "core/hle/service/ptm/psm.h"
12#include "core/hle/service/service.h"
13#include "core/hle/service/sm/sm.h"
14 12
15namespace Service::PSM { 13namespace Service::PTM {
16 14
17class IPsmSession final : public ServiceFramework<IPsmSession> { 15class IPsmSession final : public ServiceFramework<IPsmSession> {
18public: 16public:
@@ -57,7 +55,7 @@ public:
57 55
58private: 56private:
59 void BindStateChangeEvent(Kernel::HLERequestContext& ctx) { 57 void BindStateChangeEvent(Kernel::HLERequestContext& ctx) {
60 LOG_DEBUG(Service_PSM, "called"); 58 LOG_DEBUG(Service_PTM, "called");
61 59
62 should_signal = true; 60 should_signal = true;
63 61
@@ -67,7 +65,7 @@ private:
67 } 65 }
68 66
69 void UnbindStateChangeEvent(Kernel::HLERequestContext& ctx) { 67 void UnbindStateChangeEvent(Kernel::HLERequestContext& ctx) {
70 LOG_DEBUG(Service_PSM, "called"); 68 LOG_DEBUG(Service_PTM, "called");
71 69
72 should_signal = false; 70 should_signal = false;
73 71
@@ -78,7 +76,7 @@ private:
78 void SetChargerTypeChangeEventEnabled(Kernel::HLERequestContext& ctx) { 76 void SetChargerTypeChangeEventEnabled(Kernel::HLERequestContext& ctx) {
79 IPC::RequestParser rp{ctx}; 77 IPC::RequestParser rp{ctx};
80 const auto state = rp.Pop<bool>(); 78 const auto state = rp.Pop<bool>();
81 LOG_DEBUG(Service_PSM, "called, state={}", state); 79 LOG_DEBUG(Service_PTM, "called, state={}", state);
82 80
83 should_signal_charger_type = state; 81 should_signal_charger_type = state;
84 82
@@ -89,7 +87,7 @@ private:
89 void SetPowerSupplyChangeEventEnabled(Kernel::HLERequestContext& ctx) { 87 void SetPowerSupplyChangeEventEnabled(Kernel::HLERequestContext& ctx) {
90 IPC::RequestParser rp{ctx}; 88 IPC::RequestParser rp{ctx};
91 const auto state = rp.Pop<bool>(); 89 const auto state = rp.Pop<bool>();
92 LOG_DEBUG(Service_PSM, "called, state={}", state); 90 LOG_DEBUG(Service_PTM, "called, state={}", state);
93 91
94 should_signal_power_supply = state; 92 should_signal_power_supply = state;
95 93
@@ -100,7 +98,7 @@ private:
100 void SetBatteryVoltageStateChangeEventEnabled(Kernel::HLERequestContext& ctx) { 98 void SetBatteryVoltageStateChangeEventEnabled(Kernel::HLERequestContext& ctx) {
101 IPC::RequestParser rp{ctx}; 99 IPC::RequestParser rp{ctx};
102 const auto state = rp.Pop<bool>(); 100 const auto state = rp.Pop<bool>();
103 LOG_DEBUG(Service_PSM, "called, state={}", state); 101 LOG_DEBUG(Service_PTM, "called, state={}", state);
104 102
105 should_signal_battery_voltage = state; 103 should_signal_battery_voltage = state;
106 104
@@ -117,76 +115,58 @@ private:
117 Kernel::KEvent* state_change_event; 115 Kernel::KEvent* state_change_event;
118}; 116};
119 117
120class PSM final : public ServiceFramework<PSM> { 118PSM::PSM(Core::System& system_) : ServiceFramework{system_, "psm"} {
121public: 119 // clang-format off
122 explicit PSM(Core::System& system_) : ServiceFramework{system_, "psm"} { 120 static const FunctionInfo functions[] = {
123 // clang-format off 121 {0, &PSM::GetBatteryChargePercentage, "GetBatteryChargePercentage"},
124 static const FunctionInfo functions[] = { 122 {1, &PSM::GetChargerType, "GetChargerType"},
125 {0, &PSM::GetBatteryChargePercentage, "GetBatteryChargePercentage"}, 123 {2, nullptr, "EnableBatteryCharging"},
126 {1, &PSM::GetChargerType, "GetChargerType"}, 124 {3, nullptr, "DisableBatteryCharging"},
127 {2, nullptr, "EnableBatteryCharging"}, 125 {4, nullptr, "IsBatteryChargingEnabled"},
128 {3, nullptr, "DisableBatteryCharging"}, 126 {5, nullptr, "AcquireControllerPowerSupply"},
129 {4, nullptr, "IsBatteryChargingEnabled"}, 127 {6, nullptr, "ReleaseControllerPowerSupply"},
130 {5, nullptr, "AcquireControllerPowerSupply"}, 128 {7, &PSM::OpenSession, "OpenSession"},
131 {6, nullptr, "ReleaseControllerPowerSupply"}, 129 {8, nullptr, "EnableEnoughPowerChargeEmulation"},
132 {7, &PSM::OpenSession, "OpenSession"}, 130 {9, nullptr, "DisableEnoughPowerChargeEmulation"},
133 {8, nullptr, "EnableEnoughPowerChargeEmulation"}, 131 {10, nullptr, "EnableFastBatteryCharging"},
134 {9, nullptr, "DisableEnoughPowerChargeEmulation"}, 132 {11, nullptr, "DisableFastBatteryCharging"},
135 {10, nullptr, "EnableFastBatteryCharging"}, 133 {12, nullptr, "GetBatteryVoltageState"},
136 {11, nullptr, "DisableFastBatteryCharging"}, 134 {13, nullptr, "GetRawBatteryChargePercentage"},
137 {12, nullptr, "GetBatteryVoltageState"}, 135 {14, nullptr, "IsEnoughPowerSupplied"},
138 {13, nullptr, "GetRawBatteryChargePercentage"}, 136 {15, nullptr, "GetBatteryAgePercentage"},
139 {14, nullptr, "IsEnoughPowerSupplied"}, 137 {16, nullptr, "GetBatteryChargeInfoEvent"},
140 {15, nullptr, "GetBatteryAgePercentage"}, 138 {17, nullptr, "GetBatteryChargeInfoFields"},
141 {16, nullptr, "GetBatteryChargeInfoEvent"}, 139 {18, nullptr, "GetBatteryChargeCalibratedEvent"},
142 {17, nullptr, "GetBatteryChargeInfoFields"}, 140 };
143 {18, nullptr, "GetBatteryChargeCalibratedEvent"}, 141 // clang-format on
144 };
145 // clang-format on
146
147 RegisterHandlers(functions);
148 }
149
150 ~PSM() override = default;
151
152private:
153 void GetBatteryChargePercentage(Kernel::HLERequestContext& ctx) {
154 LOG_DEBUG(Service_PSM, "called");
155 142
156 IPC::ResponseBuilder rb{ctx, 3}; 143 RegisterHandlers(functions);
157 rb.Push(ResultSuccess); 144}
158 rb.Push<u32>(battery_charge_percentage);
159 }
160 145
161 void GetChargerType(Kernel::HLERequestContext& ctx) { 146PSM::~PSM() = default;
162 LOG_DEBUG(Service_PSM, "called");
163 147
164 IPC::ResponseBuilder rb{ctx, 3}; 148void PSM::GetBatteryChargePercentage(Kernel::HLERequestContext& ctx) {
165 rb.Push(ResultSuccess); 149 LOG_DEBUG(Service_PTM, "called");
166 rb.PushEnum(charger_type);
167 }
168 150
169 void OpenSession(Kernel::HLERequestContext& ctx) { 151 IPC::ResponseBuilder rb{ctx, 3};
170 LOG_DEBUG(Service_PSM, "called"); 152 rb.Push(ResultSuccess);
153 rb.Push<u32>(battery_charge_percentage);
154}
171 155
172 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 156void PSM::GetChargerType(Kernel::HLERequestContext& ctx) {
173 rb.Push(ResultSuccess); 157 LOG_DEBUG(Service_PTM, "called");
174 rb.PushIpcInterface<IPsmSession>(system);
175 }
176 158
177 enum class ChargerType : u32 { 159 IPC::ResponseBuilder rb{ctx, 3};
178 Unplugged = 0, 160 rb.Push(ResultSuccess);
179 RegularCharger = 1, 161 rb.PushEnum(charger_type);
180 LowPowerCharger = 2, 162}
181 Unknown = 3,
182 };
183 163
184 u32 battery_charge_percentage{100}; // 100% 164void PSM::OpenSession(Kernel::HLERequestContext& ctx) {
185 ChargerType charger_type{ChargerType::RegularCharger}; 165 LOG_DEBUG(Service_PTM, "called");
186};
187 166
188void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { 167 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
189 std::make_shared<PSM>(system)->InstallAsService(sm); 168 rb.Push(ResultSuccess);
169 rb.PushIpcInterface<IPsmSession>(system);
190} 170}
191 171
192} // namespace Service::PSM 172} // namespace Service::PTM
diff --git a/src/core/hle/service/ptm/psm.h b/src/core/hle/service/ptm/psm.h
index 94a1044db..f674ba8bc 100644
--- a/src/core/hle/service/ptm/psm.h
+++ b/src/core/hle/service/ptm/psm.h
@@ -3,16 +3,29 @@
3 3
4#pragma once 4#pragma once
5 5
6namespace Core { 6#include "core/hle/service/service.h"
7class System;
8}
9 7
10namespace Service::SM { 8namespace Service::PTM {
11class ServiceManager;
12}
13 9
14namespace Service::PSM { 10class PSM final : public ServiceFramework<PSM> {
11public:
12 explicit PSM(Core::System& system_);
13 ~PSM() override;
15 14
16void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); 15private:
16 enum class ChargerType : u32 {
17 Unplugged = 0,
18 RegularCharger = 1,
19 LowPowerCharger = 2,
20 Unknown = 3,
21 };
17 22
18} // namespace Service::PSM 23 void GetBatteryChargePercentage(Kernel::HLERequestContext& ctx);
24 void GetChargerType(Kernel::HLERequestContext& ctx);
25 void OpenSession(Kernel::HLERequestContext& ctx);
26
27 u32 battery_charge_percentage{100};
28 ChargerType charger_type{ChargerType::RegularCharger};
29};
30
31} // namespace Service::PTM
diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp
new file mode 100644
index 000000000..4bea995c6
--- /dev/null
+++ b/src/core/hle/service/ptm/ptm.cpp
@@ -0,0 +1,18 @@
1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#include <memory>
5
6#include "core/core.h"
7#include "core/hle/service/ptm/psm.h"
8#include "core/hle/service/ptm/ptm.h"
9#include "core/hle/service/ptm/ts.h"
10
11namespace Service::PTM {
12
13void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
14 std::make_shared<PSM>(system)->InstallAsService(sm);
15 std::make_shared<TS>(system)->InstallAsService(sm);
16}
17
18} // namespace Service::PTM
diff --git a/src/core/hle/service/ptm/ptm.h b/src/core/hle/service/ptm/ptm.h
new file mode 100644
index 000000000..06224a24e
--- /dev/null
+++ b/src/core/hle/service/ptm/ptm.h
@@ -0,0 +1,18 @@
1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6namespace Core {
7class System;
8}
9
10namespace Service::SM {
11class ServiceManager;
12}
13
14namespace Service::PTM {
15
16void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
17
18} // namespace Service::PTM
diff --git a/src/core/hle/service/ptm/ts.cpp b/src/core/hle/service/ptm/ts.cpp
new file mode 100644
index 000000000..65c3f135f
--- /dev/null
+++ b/src/core/hle/service/ptm/ts.cpp
@@ -0,0 +1,41 @@
1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#include <memory>
5
6#include "core/core.h"
7#include "core/hle/ipc_helpers.h"
8#include "core/hle/service/ptm/ts.h"
9
10namespace Service::PTM {
11
12TS::TS(Core::System& system_) : ServiceFramework{system_, "ts"} {
13 // clang-format off
14 static const FunctionInfo functions[] = {
15 {0, nullptr, "GetTemperatureRange"},
16 {1, &TS::GetTemperature, "GetTemperature"},
17 {2, nullptr, "SetMeasurementMode"},
18 {3, nullptr, "GetTemperatureMilliC"},
19 {4, nullptr, "OpenSession"},
20 };
21 // clang-format on
22
23 RegisterHandlers(functions);
24}
25
26TS::~TS() = default;
27
28void TS::GetTemperature(Kernel::HLERequestContext& ctx) {
29 IPC::RequestParser rp{ctx};
30 const auto location{rp.PopEnum<Location>()};
31
32 LOG_WARNING(Service_HID, "(STUBBED) called. location={}", location);
33
34 const s32 temperature = location == Location::Internal ? 35 : 20;
35
36 IPC::ResponseBuilder rb{ctx, 3};
37 rb.Push(ResultSuccess);
38 rb.Push(temperature);
39}
40
41} // namespace Service::PTM
diff --git a/src/core/hle/service/ptm/ts.h b/src/core/hle/service/ptm/ts.h
new file mode 100644
index 000000000..39a734ef7
--- /dev/null
+++ b/src/core/hle/service/ptm/ts.h
@@ -0,0 +1,25 @@
1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include "common/common_types.h"
7#include "core/hle/service/service.h"
8
9namespace Service::PTM {
10
11class TS final : public ServiceFramework<TS> {
12public:
13 explicit TS(Core::System& system_);
14 ~TS() override;
15
16private:
17 enum class Location : u8 {
18 Internal,
19 External,
20 };
21
22 void GetTemperature(Kernel::HLERequestContext& ctx);
23};
24
25} // namespace Service::PTM
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 318009e4f..c64291e7f 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -58,7 +58,7 @@
58#include "core/hle/service/pm/pm.h" 58#include "core/hle/service/pm/pm.h"
59#include "core/hle/service/prepo/prepo.h" 59#include "core/hle/service/prepo/prepo.h"
60#include "core/hle/service/psc/psc.h" 60#include "core/hle/service/psc/psc.h"
61#include "core/hle/service/ptm/psm.h" 61#include "core/hle/service/ptm/ptm.h"
62#include "core/hle/service/service.h" 62#include "core/hle/service/service.h"
63#include "core/hle/service/set/settings.h" 63#include "core/hle/service/set/settings.h"
64#include "core/hle/service/sm/sm.h" 64#include "core/hle/service/sm/sm.h"
@@ -287,7 +287,7 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system
287 PlayReport::InstallInterfaces(*sm, system); 287 PlayReport::InstallInterfaces(*sm, system);
288 PM::InstallInterfaces(system); 288 PM::InstallInterfaces(system);
289 PSC::InstallInterfaces(*sm, system); 289 PSC::InstallInterfaces(*sm, system);
290 PSM::InstallInterfaces(*sm, system); 290 PTM::InstallInterfaces(*sm, system);
291 Set::InstallInterfaces(*sm, system); 291 Set::InstallInterfaces(*sm, system);
292 Sockets::InstallInterfaces(*sm, system); 292 Sockets::InstallInterfaces(*sm, system);
293 SPL::InstallInterfaces(*sm, system); 293 SPL::InstallInterfaces(*sm, system);