summaryrefslogtreecommitdiff
path: root/src/core/hle/service/hid
diff options
context:
space:
mode:
authorGravatar Narr the Reg2024-01-16 12:17:18 -0600
committerGravatar german772024-01-28 18:27:25 -0600
commit575183d6dcd8da9b10ee41e47be4b7d4f8631783 (patch)
treed2898bdefae5be2fb68e7df97465422c0fae3991 /src/core/hle/service/hid
parentMerge pull request #12555 from flodavid/fix-gamemode-setting (diff)
downloadyuzu-575183d6dcd8da9b10ee41e47be4b7d4f8631783.tar.gz
yuzu-575183d6dcd8da9b10ee41e47be4b7d4f8631783.tar.xz
yuzu-575183d6dcd8da9b10ee41e47be4b7d4f8631783.zip
service: hid: Fully implement touch resource
Diffstat (limited to 'src/core/hle/service/hid')
-rw-r--r--src/core/hle/service/hid/hid.cpp5
-rw-r--r--src/core/hle/service/hid/hid_debug_server.cpp196
-rw-r--r--src/core/hle/service/hid/hid_debug_server.h15
-rw-r--r--src/core/hle/service/hid/hid_server.cpp24
-rw-r--r--src/core/hle/service/hid/hid_system_server.cpp64
-rw-r--r--src/core/hle/service/hid/hid_system_server.h3
6 files changed, 277 insertions, 30 deletions
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 5b28be577..b60fb9139 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -18,9 +18,10 @@ namespace Service::HID {
18 18
19void LoopProcess(Core::System& system) { 19void LoopProcess(Core::System& system) {
20 auto server_manager = std::make_unique<ServerManager>(system); 20 auto server_manager = std::make_unique<ServerManager>(system);
21 std::shared_ptr<ResourceManager> resource_manager = std::make_shared<ResourceManager>(system);
22 std::shared_ptr<HidFirmwareSettings> firmware_settings = 21 std::shared_ptr<HidFirmwareSettings> firmware_settings =
23 std::make_shared<HidFirmwareSettings>(system); 22 std::make_shared<HidFirmwareSettings>(system);
23 std::shared_ptr<ResourceManager> resource_manager =
24 std::make_shared<ResourceManager>(system, firmware_settings);
24 25
25 // TODO: Remove this hack when am is emulated properly. 26 // TODO: Remove this hack when am is emulated properly.
26 resource_manager->Initialize(); 27 resource_manager->Initialize();
@@ -31,7 +32,7 @@ void LoopProcess(Core::System& system) {
31 server_manager->RegisterNamedService( 32 server_manager->RegisterNamedService(
32 "hid", std::make_shared<IHidServer>(system, resource_manager, firmware_settings)); 33 "hid", std::make_shared<IHidServer>(system, resource_manager, firmware_settings));
33 server_manager->RegisterNamedService( 34 server_manager->RegisterNamedService(
34 "hid:dbg", std::make_shared<IHidDebugServer>(system, resource_manager)); 35 "hid:dbg", std::make_shared<IHidDebugServer>(system, resource_manager, firmware_settings));
35 server_manager->RegisterNamedService( 36 server_manager->RegisterNamedService(
36 "hid:sys", std::make_shared<IHidSystemServer>(system, resource_manager, firmware_settings)); 37 "hid:sys", std::make_shared<IHidSystemServer>(system, resource_manager, firmware_settings));
37 38
diff --git a/src/core/hle/service/hid/hid_debug_server.cpp b/src/core/hle/service/hid/hid_debug_server.cpp
index f2a767d37..610af34dd 100644
--- a/src/core/hle/service/hid/hid_debug_server.cpp
+++ b/src/core/hle/service/hid/hid_debug_server.cpp
@@ -1,27 +1,37 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later 2// SPDX-License-Identifier: GPL-3.0-or-later
3 3
4#include <algorithm>
5
4#include "core/hle/service/hid/hid_debug_server.h" 6#include "core/hle/service/hid/hid_debug_server.h"
5#include "core/hle/service/ipc_helpers.h" 7#include "core/hle/service/ipc_helpers.h"
8#include "hid_core/hid_types.h"
6#include "hid_core/resource_manager.h" 9#include "hid_core/resource_manager.h"
10#include "hid_core/resources/hid_firmware_settings.h"
11
12#include "hid_core/resources/touch_screen/gesture.h"
13#include "hid_core/resources/touch_screen/touch_screen.h"
14#include "hid_core/resources/touch_screen/touch_types.h"
7 15
8namespace Service::HID { 16namespace Service::HID {
9 17
10IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource) 18IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource,
11 : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource} { 19 std::shared_ptr<HidFirmwareSettings> settings)
20 : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource}, firmware_settings{
21 settings} {
12 // clang-format off 22 // clang-format off
13 static const FunctionInfo functions[] = { 23 static const FunctionInfo functions[] = {
14 {0, nullptr, "DeactivateDebugPad"}, 24 {0, nullptr, "DeactivateDebugPad"},
15 {1, nullptr, "SetDebugPadAutoPilotState"}, 25 {1, nullptr, "SetDebugPadAutoPilotState"},
16 {2, nullptr, "UnsetDebugPadAutoPilotState"}, 26 {2, nullptr, "UnsetDebugPadAutoPilotState"},
17 {10, nullptr, "DeactivateTouchScreen"}, 27 {10, &IHidDebugServer::DeactivateTouchScreen, "DeactivateTouchScreen"},
18 {11, nullptr, "SetTouchScreenAutoPilotState"}, 28 {11, &IHidDebugServer::SetTouchScreenAutoPilotState, "SetTouchScreenAutoPilotState"},
19 {12, nullptr, "UnsetTouchScreenAutoPilotState"}, 29 {12, &IHidDebugServer::UnsetTouchScreenAutoPilotState, "UnsetTouchScreenAutoPilotState"},
20 {13, nullptr, "GetTouchScreenConfiguration"}, 30 {13, &IHidDebugServer::GetTouchScreenConfiguration, "GetTouchScreenConfiguration"},
21 {14, nullptr, "ProcessTouchScreenAutoTune"}, 31 {14, &IHidDebugServer::ProcessTouchScreenAutoTune, "ProcessTouchScreenAutoTune"},
22 {15, nullptr, "ForceStopTouchScreenManagement"}, 32 {15, &IHidDebugServer::ForceStopTouchScreenManagement, "ForceStopTouchScreenManagement"},
23 {16, nullptr, "ForceRestartTouchScreenManagement"}, 33 {16, &IHidDebugServer::ForceRestartTouchScreenManagement, "ForceRestartTouchScreenManagement"},
24 {17, nullptr, "IsTouchScreenManaged"}, 34 {17, &IHidDebugServer::IsTouchScreenManaged, "IsTouchScreenManaged"},
25 {20, nullptr, "DeactivateMouse"}, 35 {20, nullptr, "DeactivateMouse"},
26 {21, nullptr, "SetMouseAutoPilotState"}, 36 {21, nullptr, "SetMouseAutoPilotState"},
27 {22, nullptr, "UnsetMouseAutoPilotState"}, 37 {22, nullptr, "UnsetMouseAutoPilotState"},
@@ -37,7 +47,7 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource
37 {60, nullptr, "ClearNpadSystemCommonPolicy"}, 47 {60, nullptr, "ClearNpadSystemCommonPolicy"},
38 {61, nullptr, "DeactivateNpad"}, 48 {61, nullptr, "DeactivateNpad"},
39 {62, nullptr, "ForceDisconnectNpad"}, 49 {62, nullptr, "ForceDisconnectNpad"},
40 {91, nullptr, "DeactivateGesture"}, 50 {91, &IHidDebugServer::DeactivateGesture, "DeactivateGesture"},
41 {110, nullptr, "DeactivateHomeButton"}, 51 {110, nullptr, "DeactivateHomeButton"},
42 {111, nullptr, "SetHomeButtonAutoPilotState"}, 52 {111, nullptr, "SetHomeButtonAutoPilotState"},
43 {112, nullptr, "UnsetHomeButtonAutoPilotState"}, 53 {112, nullptr, "UnsetHomeButtonAutoPilotState"},
@@ -150,6 +160,170 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource
150} 160}
151 161
152IHidDebugServer::~IHidDebugServer() = default; 162IHidDebugServer::~IHidDebugServer() = default;
163void IHidDebugServer::DeactivateTouchScreen(HLERequestContext& ctx) {
164 LOG_INFO(Service_HID, "called");
165
166 Result result = ResultSuccess;
167
168 if (!firmware_settings->IsDeviceManaged()) {
169 result = GetResourceManager()->GetTouchScreen()->Deactivate();
170 }
171
172 IPC::ResponseBuilder rb{ctx, 2};
173 rb.Push(result);
174}
175
176void IHidDebugServer::SetTouchScreenAutoPilotState(HLERequestContext& ctx) {
177 AutoPilotState auto_pilot{};
178 auto_pilot.count = ctx.GetReadBufferNumElements<TouchState>();
179 const auto buffer = ctx.ReadBuffer();
180
181 auto_pilot.count = std::min(auto_pilot.count, static_cast<u64>(auto_pilot.state.size()));
182 memcpy(auto_pilot.state.data(), buffer.data(), auto_pilot.count * sizeof(TouchState));
183
184 LOG_INFO(Service_HID, "called, auto_pilot_count={}", auto_pilot.count);
185
186 const Result result =
187 GetResourceManager()->GetTouchScreen()->SetTouchScreenAutoPilotState(auto_pilot);
188
189 IPC::ResponseBuilder rb{ctx, 2};
190 rb.Push(result);
191}
192
193void IHidDebugServer::UnsetTouchScreenAutoPilotState(HLERequestContext& ctx) {
194 LOG_INFO(Service_HID, "called");
195
196 const Result result = GetResourceManager()->GetTouchScreen()->UnsetTouchScreenAutoPilotState();
197
198 IPC::ResponseBuilder rb{ctx, 2};
199 rb.Push(result);
200}
201
202void IHidDebugServer::GetTouchScreenConfiguration(HLERequestContext& ctx) {
203 IPC::RequestParser rp{ctx};
204 const auto applet_resource_user_id{rp.Pop<u64>()};
205
206 LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
207
208 Core::HID::TouchScreenConfigurationForNx touchscreen_config{};
209 const Result result = GetResourceManager()->GetTouchScreen()->GetTouchScreenConfiguration(
210 touchscreen_config, applet_resource_user_id);
211
212 if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
213 touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
214 touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
215 }
216
217 IPC::ResponseBuilder rb{ctx, 6};
218 rb.Push(result);
219 rb.PushRaw(touchscreen_config);
220}
221
222void IHidDebugServer::ProcessTouchScreenAutoTune(HLERequestContext& ctx) {
223 LOG_INFO(Service_HID, "called");
224
225 Result result = GetResourceManager()->GetTouchScreen()->ProcessTouchScreenAutoTune();
226
227 IPC::ResponseBuilder rb{ctx, 2};
228 rb.Push(result);
229}
230
231void IHidDebugServer::ForceStopTouchScreenManagement(HLERequestContext& ctx) {
232 LOG_INFO(Service_HID, "called");
233
234 if (!firmware_settings->IsDeviceManaged()) {
235 IPC::ResponseBuilder rb{ctx, 2};
236 rb.Push(ResultSuccess);
237 return;
238 }
239
240 Result result = ResultSuccess;
241 bool is_touch_active{};
242 bool is_gesture_active{};
243 auto touch_screen = GetResourceManager()->GetTouchScreen();
244 auto gesture = GetResourceManager()->GetGesture();
245
246 if (firmware_settings->IsTouchI2cManaged()) {
247 result = touch_screen->IsActive(is_touch_active);
248 if (result.IsSuccess()) {
249 result = gesture->IsActive(is_gesture_active);
250 }
251 if (result.IsSuccess() && is_touch_active) {
252 result = touch_screen->Deactivate();
253 }
254 if (result.IsSuccess() && is_gesture_active) {
255 result = gesture->Deactivate();
256 }
257 }
258
259 IPC::ResponseBuilder rb{ctx, 2};
260 rb.Push(result);
261}
262
263void IHidDebugServer::ForceRestartTouchScreenManagement(HLERequestContext& ctx) {
264 IPC::RequestParser rp{ctx};
265 struct Parameters {
266 u32 basic_gesture_id;
267 INSERT_PADDING_WORDS_NOINIT(1);
268 u64 applet_resource_user_id;
269 };
270 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
271
272 const auto parameters{rp.PopRaw<Parameters>()};
273
274 LOG_INFO(Service_HID, "called, basic_gesture_id={}, applet_resource_user_id={}",
275 parameters.basic_gesture_id, parameters.applet_resource_user_id);
276
277 Result result = ResultSuccess;
278 auto touch_screen = GetResourceManager()->GetTouchScreen();
279 auto gesture = GetResourceManager()->GetGesture();
280
281 if (firmware_settings->IsDeviceManaged() && firmware_settings->IsTouchI2cManaged()) {
282 result = gesture->Activate();
283 if (result.IsSuccess()) {
284 result =
285 gesture->Activate(parameters.applet_resource_user_id, parameters.basic_gesture_id);
286 }
287 if (result.IsSuccess()) {
288 result = touch_screen->Activate();
289 }
290 if (result.IsSuccess()) {
291 result = touch_screen->Activate(parameters.applet_resource_user_id);
292 }
293 }
294
295 IPC::ResponseBuilder rb{ctx, 2};
296 rb.Push(result);
297}
298
299void IHidDebugServer::IsTouchScreenManaged(HLERequestContext& ctx) {
300 LOG_INFO(Service_HID, "called");
301
302 bool is_touch_active{};
303 bool is_gesture_active{};
304
305 Result result = GetResourceManager()->GetTouchScreen()->IsActive(is_touch_active);
306 if (result.IsSuccess()) {
307 result = GetResourceManager()->GetGesture()->IsActive(is_gesture_active);
308 }
309
310 IPC::ResponseBuilder rb{ctx, 3};
311 rb.Push(result);
312 rb.Push(is_touch_active | is_gesture_active);
313}
314
315void IHidDebugServer::DeactivateGesture(HLERequestContext& ctx) {
316 LOG_INFO(Service_HID, "called");
317
318 Result result = ResultSuccess;
319
320 if (!firmware_settings->IsDeviceManaged()) {
321 result = GetResourceManager()->GetGesture()->Deactivate();
322 }
323
324 IPC::ResponseBuilder rb{ctx, 2};
325 rb.Push(result);
326}
153 327
154std::shared_ptr<ResourceManager> IHidDebugServer::GetResourceManager() { 328std::shared_ptr<ResourceManager> IHidDebugServer::GetResourceManager() {
155 resource_manager->Initialize(); 329 resource_manager->Initialize();
diff --git a/src/core/hle/service/hid/hid_debug_server.h b/src/core/hle/service/hid/hid_debug_server.h
index 406db2211..7d5b082b3 100644
--- a/src/core/hle/service/hid/hid_debug_server.h
+++ b/src/core/hle/service/hid/hid_debug_server.h
@@ -11,16 +11,29 @@ class System;
11 11
12namespace Service::HID { 12namespace Service::HID {
13class ResourceManager; 13class ResourceManager;
14class HidFirmwareSettings;
14 15
15class IHidDebugServer final : public ServiceFramework<IHidDebugServer> { 16class IHidDebugServer final : public ServiceFramework<IHidDebugServer> {
16public: 17public:
17 explicit IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource); 18 explicit IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource,
19 std::shared_ptr<HidFirmwareSettings> settings);
18 ~IHidDebugServer() override; 20 ~IHidDebugServer() override;
19 21
20private: 22private:
23 void DeactivateTouchScreen(HLERequestContext& ctx);
24 void SetTouchScreenAutoPilotState(HLERequestContext& ctx);
25 void UnsetTouchScreenAutoPilotState(HLERequestContext& ctx);
26 void GetTouchScreenConfiguration(HLERequestContext& ctx);
27 void ProcessTouchScreenAutoTune(HLERequestContext& ctx);
28 void ForceStopTouchScreenManagement(HLERequestContext& ctx);
29 void ForceRestartTouchScreenManagement(HLERequestContext& ctx);
30 void IsTouchScreenManaged(HLERequestContext& ctx);
31 void DeactivateGesture(HLERequestContext& ctx);
32
21 std::shared_ptr<ResourceManager> GetResourceManager(); 33 std::shared_ptr<ResourceManager> GetResourceManager();
22 34
23 std::shared_ptr<ResourceManager> resource_manager; 35 std::shared_ptr<ResourceManager> resource_manager;
36 std::shared_ptr<HidFirmwareSettings> firmware_settings;
24}; 37};
25 38
26} // namespace Service::HID 39} // namespace Service::HID
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp
index 09c47b5e3..9ffe027ff 100644
--- a/src/core/hle/service/hid/hid_server.cpp
+++ b/src/core/hle/service/hid/hid_server.cpp
@@ -989,8 +989,7 @@ void IHidServer::ActivateGesture(HLERequestContext& ctx) {
989 } 989 }
990 990
991 if (result.IsSuccess()) { 991 if (result.IsSuccess()) {
992 // TODO: Use gesture id here 992 result = gesture->Activate(parameters.applet_resource_user_id, parameters.basic_gesture_id);
993 result = gesture->Activate(parameters.applet_resource_user_id);
994 } 993 }
995 994
996 IPC::ResponseBuilder rb{ctx, 2}; 995 IPC::ResponseBuilder rb{ctx, 2};
@@ -2449,14 +2448,22 @@ void IHidServer::GetNpadCommunicationMode(HLERequestContext& ctx) {
2449 2448
2450void IHidServer::SetTouchScreenConfiguration(HLERequestContext& ctx) { 2449void IHidServer::SetTouchScreenConfiguration(HLERequestContext& ctx) {
2451 IPC::RequestParser rp{ctx}; 2450 IPC::RequestParser rp{ctx};
2452 const auto touchscreen_mode{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()}; 2451 auto touchscreen_config{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()};
2453 const auto applet_resource_user_id{rp.Pop<u64>()}; 2452 const auto applet_resource_user_id{rp.Pop<u64>()};
2454 2453
2455 LOG_WARNING(Service_HID, "(STUBBED) called, touchscreen_mode={}, applet_resource_user_id={}", 2454 LOG_INFO(Service_HID, "called, touchscreen_config={}, applet_resource_user_id={}",
2456 touchscreen_mode.mode, applet_resource_user_id); 2455 touchscreen_config.mode, applet_resource_user_id);
2456
2457 if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
2458 touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
2459 touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
2460 }
2461
2462 const Result result = GetResourceManager()->GetTouchScreen()->SetTouchScreenConfiguration(
2463 touchscreen_config, applet_resource_user_id);
2457 2464
2458 IPC::ResponseBuilder rb{ctx, 2}; 2465 IPC::ResponseBuilder rb{ctx, 2};
2459 rb.Push(ResultSuccess); 2466 rb.Push(result);
2460} 2467}
2461 2468
2462void IHidServer::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) { 2469void IHidServer::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) {
@@ -2484,11 +2491,12 @@ void IHidServer::SetTouchScreenResolution(HLERequestContext& ctx) {
2484 const auto height{rp.Pop<u32>()}; 2491 const auto height{rp.Pop<u32>()};
2485 const auto applet_resource_user_id{rp.Pop<u64>()}; 2492 const auto applet_resource_user_id{rp.Pop<u64>()};
2486 2493
2487 GetResourceManager()->GetTouchScreen()->SetTouchscreenDimensions(width, height);
2488
2489 LOG_INFO(Service_HID, "called, width={}, height={}, applet_resource_user_id={}", width, height, 2494 LOG_INFO(Service_HID, "called, width={}, height={}, applet_resource_user_id={}", width, height,
2490 applet_resource_user_id); 2495 applet_resource_user_id);
2491 2496
2497 GetResourceManager()->GetTouchScreen()->SetTouchScreenResolution(width, height,
2498 applet_resource_user_id);
2499
2492 IPC::ResponseBuilder rb{ctx, 2}; 2500 IPC::ResponseBuilder rb{ctx, 2};
2493 rb.Push(ResultSuccess); 2501 rb.Push(ResultSuccess);
2494} 2502}
diff --git a/src/core/hle/service/hid/hid_system_server.cpp b/src/core/hle/service/hid/hid_system_server.cpp
index d1ec42edc..22471e9e2 100644
--- a/src/core/hle/service/hid/hid_system_server.cpp
+++ b/src/core/hle/service/hid/hid_system_server.cpp
@@ -155,9 +155,9 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
155 {1133, nullptr, "StartUsbFirmwareUpdate"}, 155 {1133, nullptr, "StartUsbFirmwareUpdate"},
156 {1134, nullptr, "GetUsbFirmwareUpdateState"}, 156 {1134, nullptr, "GetUsbFirmwareUpdateState"},
157 {1135, &IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory, "InitializeUsbFirmwareUpdateWithoutMemory"}, 157 {1135, &IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory, "InitializeUsbFirmwareUpdateWithoutMemory"},
158 {1150, nullptr, "SetTouchScreenMagnification"}, 158 {1150, &IHidSystemServer::SetTouchScreenMagnification, "SetTouchScreenMagnification"},
159 {1151, nullptr, "GetTouchScreenFirmwareVersion"}, 159 {1151, &IHidSystemServer::GetTouchScreenFirmwareVersion, "GetTouchScreenFirmwareVersion"},
160 {1152, nullptr, "SetTouchScreenDefaultConfiguration"}, 160 {1152, &IHidSystemServer::SetTouchScreenDefaultConfiguration, "SetTouchScreenDefaultConfiguration"},
161 {1153, &IHidSystemServer::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"}, 161 {1153, &IHidSystemServer::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"},
162 {1154, nullptr, "IsFirmwareAvailableForNotification"}, 162 {1154, nullptr, "IsFirmwareAvailableForNotification"},
163 {1155, &IHidSystemServer::SetForceHandheldStyleVibration, "SetForceHandheldStyleVibration"}, 163 {1155, &IHidSystemServer::SetForceHandheldStyleVibration, "SetForceHandheldStyleVibration"},
@@ -845,12 +845,60 @@ void IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContex
845 rb.Push(ResultSuccess); 845 rb.Push(ResultSuccess);
846} 846}
847 847
848void IHidSystemServer::SetTouchScreenMagnification(HLERequestContext& ctx) {
849 IPC::RequestParser rp{ctx};
850 const auto point1x{rp.Pop<f32>()};
851 const auto point1y{rp.Pop<f32>()};
852 const auto point2x{rp.Pop<f32>()};
853 const auto point2y{rp.Pop<f32>()};
854
855 LOG_INFO(Service_HID, "called, point1=-({},{}), point2=({},{})", point1x, point1y, point2x,
856 point2y);
857
858 const Result result = GetResourceManager()->GetTouchScreen()->SetTouchScreenMagnification(
859 point1x, point1y, point2x, point2y);
860
861 IPC::ResponseBuilder rb{ctx, 2};
862 rb.Push(result);
863}
864
865void IHidSystemServer::GetTouchScreenFirmwareVersion(HLERequestContext& ctx) {
866 LOG_INFO(Service_HID, "called");
867
868 Core::HID::FirmwareVersion firmware{};
869 const auto result = GetResourceManager()->GetTouchScreenFirmwareVersion(firmware);
870
871 IPC::ResponseBuilder rb{ctx, 6};
872 rb.Push(result);
873 rb.PushRaw(firmware);
874}
875
876void IHidSystemServer::SetTouchScreenDefaultConfiguration(HLERequestContext& ctx) {
877 IPC::RequestParser rp{ctx};
878 auto touchscreen_config{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()};
879
880 LOG_INFO(Service_HID, "called, touchscreen_config={}", touchscreen_config.mode);
881
882 if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
883 touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
884 touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
885 }
886
887 const Result result =
888 GetResourceManager()->GetTouchScreen()->SetTouchScreenDefaultConfiguration(
889 touchscreen_config);
890
891 IPC::ResponseBuilder rb{ctx, 2};
892 rb.Push(result);
893}
894
848void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) { 895void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) {
849 LOG_WARNING(Service_HID, "(STUBBED) called"); 896 LOG_INFO(Service_HID, "called");
850 897
851 Core::HID::TouchScreenConfigurationForNx touchscreen_config{ 898 Core::HID::TouchScreenConfigurationForNx touchscreen_config{};
852 .mode = Core::HID::TouchScreenModeForNx::Finger, 899 const Result result =
853 }; 900 GetResourceManager()->GetTouchScreen()->GetTouchScreenDefaultConfiguration(
901 touchscreen_config);
854 902
855 if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 && 903 if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
856 touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) { 904 touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
@@ -858,7 +906,7 @@ void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx
858 } 906 }
859 907
860 IPC::ResponseBuilder rb{ctx, 6}; 908 IPC::ResponseBuilder rb{ctx, 6};
861 rb.Push(ResultSuccess); 909 rb.Push(result);
862 rb.PushRaw(touchscreen_config); 910 rb.PushRaw(touchscreen_config);
863} 911}
864 912
diff --git a/src/core/hle/service/hid/hid_system_server.h b/src/core/hle/service/hid/hid_system_server.h
index 4ab4d3931..738313e08 100644
--- a/src/core/hle/service/hid/hid_system_server.h
+++ b/src/core/hle/service/hid/hid_system_server.h
@@ -71,6 +71,9 @@ private:
71 void FinalizeUsbFirmwareUpdate(HLERequestContext& ctx); 71 void FinalizeUsbFirmwareUpdate(HLERequestContext& ctx);
72 void CheckUsbFirmwareUpdateRequired(HLERequestContext& ctx); 72 void CheckUsbFirmwareUpdateRequired(HLERequestContext& ctx);
73 void InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx); 73 void InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx);
74 void SetTouchScreenMagnification(HLERequestContext& ctx);
75 void GetTouchScreenFirmwareVersion(HLERequestContext& ctx);
76 void SetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
74 void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx); 77 void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
75 void SetForceHandheldStyleVibration(HLERequestContext& ctx); 78 void SetForceHandheldStyleVibration(HLERequestContext& ctx);
76 void IsUsingCustomButtonConfig(HLERequestContext& ctx); 79 void IsUsingCustomButtonConfig(HLERequestContext& ctx);