| 
									
										
										
										
											2022-04-23 04:59:50 -04:00
										 |  |  | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
 | 
					
						
							|  |  |  | // SPDX-License-Identifier: GPL-2.0-or-later
 | 
					
						
							| 
									
										
										
										
											2015-01-18 15:07:48 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-06 00:23:21 +10:00
										 |  |  | #include <array>
 | 
					
						
							|  |  |  | #include "common/common_types.h"
 | 
					
						
							| 
									
										
										
										
											2016-09-18 09:38:01 +09:00
										 |  |  | #include "common/logging/log.h"
 | 
					
						
							| 
									
										
										
										
											2021-04-14 16:07:40 -07:00
										 |  |  | #include "common/settings.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-28 12:30:33 -04:00
										 |  |  | #include "core/core.h"
 | 
					
						
							| 
									
										
										
										
											2018-01-15 02:21:02 -07:00
										 |  |  | #include "core/core_timing.h"
 | 
					
						
							| 
									
										
										
										
											2021-11-04 19:05:58 -06:00
										 |  |  | #include "core/hid/hid_core.h"
 | 
					
						
							| 
									
										
										
										
											2021-01-29 22:48:06 -08:00
										 |  |  | #include "core/hle/kernel/k_readable_event.h"
 | 
					
						
							| 
									
										
										
										
											2021-02-05 23:14:31 -08:00
										 |  |  | #include "core/hle/kernel/k_shared_memory.h"
 | 
					
						
							| 
									
										
										
										
											2021-04-17 00:52:53 -07:00
										 |  |  | #include "core/hle/kernel/k_transfer_memory.h"
 | 
					
						
							| 
									
										
										
										
											2020-04-08 21:08:44 -04:00
										 |  |  | #include "core/hle/kernel/kernel.h"
 | 
					
						
							| 
									
										
										
										
											2019-07-01 15:12:57 +10:00
										 |  |  | #include "core/hle/service/hid/errors.h"
 | 
					
						
							| 
									
										
										
										
											2016-09-20 23:52:38 -07:00
										 |  |  | #include "core/hle/service/hid/hid.h"
 | 
					
						
							| 
									
										
										
										
											2021-05-02 18:41:03 -05:00
										 |  |  | #include "core/hle/service/hid/hidbus.h"
 | 
					
						
							| 
									
										
										
										
											2018-07-26 08:39:25 -04:00
										 |  |  | #include "core/hle/service/hid/irs.h"
 | 
					
						
							| 
									
										
										
										
											2018-07-26 08:50:32 -04:00
										 |  |  | #include "core/hle/service/hid/xcd.h"
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | #include "core/hle/service/ipc_helpers.h"
 | 
					
						
							| 
									
										
										
										
											2023-02-18 16:26:48 -05:00
										 |  |  | #include "core/hle/service/server_manager.h"
 | 
					
						
							| 
									
										
										
										
											2021-04-17 00:52:53 -07:00
										 |  |  | #include "core/memory.h"
 | 
					
						
							| 
									
										
										
										
											2015-03-09 00:14:59 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-22 13:15:59 -05:00
										 |  |  | #include "core/hle/service/hid/controllers/console_sixaxis.h"
 | 
					
						
							| 
									
										
										
										
											2018-10-06 00:23:21 +10:00
										 |  |  | #include "core/hle/service/hid/controllers/controller_base.h"
 | 
					
						
							|  |  |  | #include "core/hle/service/hid/controllers/debug_pad.h"
 | 
					
						
							|  |  |  | #include "core/hle/service/hid/controllers/gesture.h"
 | 
					
						
							|  |  |  | #include "core/hle/service/hid/controllers/keyboard.h"
 | 
					
						
							|  |  |  | #include "core/hle/service/hid/controllers/mouse.h"
 | 
					
						
							|  |  |  | #include "core/hle/service/hid/controllers/npad.h"
 | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  | #include "core/hle/service/hid/controllers/palma.h"
 | 
					
						
							| 
									
										
										
										
											2018-10-06 00:23:21 +10:00
										 |  |  | #include "core/hle/service/hid/controllers/stubbed.h"
 | 
					
						
							|  |  |  | #include "core/hle/service/hid/controllers/touchscreen.h"
 | 
					
						
							|  |  |  | #include "core/hle/service/hid/controllers/xpad.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-19 21:41:44 -04:00
										 |  |  | namespace Service::HID { | 
					
						
							| 
									
										
										
										
											2015-01-18 15:07:48 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-15 02:21:02 -07:00
										 |  |  | // Updating period for each HID device.
 | 
					
						
							| 
									
										
										
										
											2021-10-21 13:56:52 -05:00
										 |  |  | // Period time is obtained by measuring the number of samples in a second on HW using a homebrew
 | 
					
						
							| 
									
										
										
										
											2022-11-05 11:40:19 -06:00
										 |  |  | // Correct npad_update_ns is 4ms this is overclocked to lower input lag
 | 
					
						
							|  |  |  | constexpr auto npad_update_ns = std::chrono::nanoseconds{1 * 1000 * 1000};    // (1ms, 1000Hz)
 | 
					
						
							|  |  |  | constexpr auto default_update_ns = std::chrono::nanoseconds{4 * 1000 * 1000}; // (4ms, 1000Hz)
 | 
					
						
							| 
									
										
										
										
											2021-11-14 21:28:38 -06:00
										 |  |  | constexpr auto mouse_keyboard_update_ns = std::chrono::nanoseconds{8 * 1000 * 1000}; // (8ms, 125Hz)
 | 
					
						
							| 
									
										
										
										
											2022-05-05 18:58:00 -05:00
										 |  |  | constexpr auto motion_update_ns = std::chrono::nanoseconds{5 * 1000 * 1000};         // (5ms, 200Hz)
 | 
					
						
							| 
									
										
										
										
											2018-03-04 10:34:25 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 14:41:24 -07:00
										 |  |  | IAppletResource::IAppletResource(Core::System& system_, | 
					
						
							|  |  |  |                                  KernelHelpers::ServiceContext& service_context_) | 
					
						
							|  |  |  |     : ServiceFramework{system_, "IAppletResource"}, service_context{service_context_} { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     static const FunctionInfo functions[] = { | 
					
						
							|  |  |  |         {0, &IAppletResource::GetSharedMemoryHandle, "GetSharedMemoryHandle"}, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     RegisterHandlers(functions); | 
					
						
							| 
									
										
										
										
											2022-04-19 15:30:32 -05:00
										 |  |  |     u8* shared_memory = system.Kernel().GetHidSharedMem().GetPointer(); | 
					
						
							|  |  |  |     MakeController<Controller_DebugPad>(HidController::DebugPad, shared_memory); | 
					
						
							|  |  |  |     MakeController<Controller_Touchscreen>(HidController::Touchscreen, shared_memory); | 
					
						
							|  |  |  |     MakeController<Controller_Mouse>(HidController::Mouse, shared_memory); | 
					
						
							|  |  |  |     MakeController<Controller_Keyboard>(HidController::Keyboard, shared_memory); | 
					
						
							|  |  |  |     MakeController<Controller_XPad>(HidController::XPad, shared_memory); | 
					
						
							|  |  |  |     MakeController<Controller_Stubbed>(HidController::HomeButton, shared_memory); | 
					
						
							|  |  |  |     MakeController<Controller_Stubbed>(HidController::SleepButton, shared_memory); | 
					
						
							|  |  |  |     MakeController<Controller_Stubbed>(HidController::CaptureButton, shared_memory); | 
					
						
							|  |  |  |     MakeController<Controller_Stubbed>(HidController::InputDetector, shared_memory); | 
					
						
							|  |  |  |     MakeController<Controller_Stubbed>(HidController::UniquePad, shared_memory); | 
					
						
							|  |  |  |     MakeControllerWithServiceContext<Controller_NPad>(HidController::NPad, shared_memory); | 
					
						
							|  |  |  |     MakeController<Controller_Gesture>(HidController::Gesture, shared_memory); | 
					
						
							|  |  |  |     MakeController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor, shared_memory); | 
					
						
							| 
									
										
										
										
											2023-02-24 12:52:32 -06:00
										 |  |  |     MakeController<Controller_Stubbed>(HidController::DebugMouse, shared_memory); | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     MakeControllerWithServiceContext<Controller_Palma>(HidController::Palma, shared_memory); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-05 22:34:56 -05:00
										 |  |  |     // Homebrew doesn't try to activate some controllers, so we activate them by default
 | 
					
						
							|  |  |  |     GetController<Controller_NPad>(HidController::NPad).ActivateController(); | 
					
						
							|  |  |  |     GetController<Controller_Touchscreen>(HidController::Touchscreen).ActivateController(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-10 11:37:19 -06:00
										 |  |  |     GetController<Controller_Stubbed>(HidController::HomeButton).SetCommonHeaderOffset(0x4C00); | 
					
						
							|  |  |  |     GetController<Controller_Stubbed>(HidController::SleepButton).SetCommonHeaderOffset(0x4E00); | 
					
						
							|  |  |  |     GetController<Controller_Stubbed>(HidController::CaptureButton).SetCommonHeaderOffset(0x5000); | 
					
						
							|  |  |  |     GetController<Controller_Stubbed>(HidController::InputDetector).SetCommonHeaderOffset(0x5200); | 
					
						
							|  |  |  |     GetController<Controller_Stubbed>(HidController::UniquePad).SetCommonHeaderOffset(0x5A00); | 
					
						
							| 
									
										
										
										
											2023-02-24 12:52:32 -06:00
										 |  |  |     GetController<Controller_Stubbed>(HidController::DebugMouse).SetCommonHeaderOffset(0x3DC00); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Register update callbacks
 | 
					
						
							| 
									
										
										
										
											2022-11-05 11:40:19 -06:00
										 |  |  |     npad_update_event = Core::Timing::CreateEvent( | 
					
						
							| 
									
										
										
										
											2020-07-27 19:00:41 -04:00
										 |  |  |         "HID::UpdatePadCallback", | 
					
						
							| 
									
										
										
										
											2022-11-05 11:40:19 -06:00
										 |  |  |         [this](std::uintptr_t user_data, s64 time, | 
					
						
							|  |  |  |                std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> { | 
					
						
							|  |  |  |             const auto guard = LockService(); | 
					
						
							|  |  |  |             UpdateNpad(user_data, ns_late); | 
					
						
							|  |  |  |             return std::nullopt; | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     default_update_event = Core::Timing::CreateEvent( | 
					
						
							|  |  |  |         "HID::UpdateDefaultCallback", | 
					
						
							| 
									
										
										
										
											2022-07-10 06:59:40 +01:00
										 |  |  |         [this](std::uintptr_t user_data, s64 time, | 
					
						
							|  |  |  |                std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> { | 
					
						
							| 
									
										
										
										
											2020-12-28 18:23:42 -08:00
										 |  |  |             const auto guard = LockService(); | 
					
						
							| 
									
										
										
										
											2020-07-27 19:00:41 -04:00
										 |  |  |             UpdateControllers(user_data, ns_late); | 
					
						
							| 
									
										
										
										
											2022-07-10 06:59:40 +01:00
										 |  |  |             return std::nullopt; | 
					
						
							| 
									
										
										
										
											2019-02-14 12:42:58 -05:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2021-11-14 21:28:38 -06:00
										 |  |  |     mouse_keyboard_update_event = Core::Timing::CreateEvent( | 
					
						
							|  |  |  |         "HID::UpdateMouseKeyboardCallback", | 
					
						
							| 
									
										
										
										
											2022-07-10 06:59:40 +01:00
										 |  |  |         [this](std::uintptr_t user_data, s64 time, | 
					
						
							|  |  |  |                std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> { | 
					
						
							| 
									
										
										
										
											2021-11-13 23:25:45 -06:00
										 |  |  |             const auto guard = LockService(); | 
					
						
							| 
									
										
										
										
											2021-11-14 21:28:38 -06:00
										 |  |  |             UpdateMouseKeyboard(user_data, ns_late); | 
					
						
							| 
									
										
										
										
											2022-07-10 06:59:40 +01:00
										 |  |  |             return std::nullopt; | 
					
						
							| 
									
										
										
										
											2021-11-13 23:25:45 -06:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-09-23 17:51:09 -05:00
										 |  |  |     motion_update_event = Core::Timing::CreateEvent( | 
					
						
							| 
									
										
										
										
											2021-11-13 23:25:45 -06:00
										 |  |  |         "HID::UpdateMotionCallback", | 
					
						
							| 
									
										
										
										
											2022-07-10 06:59:40 +01:00
										 |  |  |         [this](std::uintptr_t user_data, s64 time, | 
					
						
							|  |  |  |                std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> { | 
					
						
							| 
									
										
										
										
											2020-12-28 18:23:42 -08:00
										 |  |  |             const auto guard = LockService(); | 
					
						
							| 
									
										
										
										
											2020-09-23 17:51:09 -05:00
										 |  |  |             UpdateMotion(user_data, ns_late); | 
					
						
							| 
									
										
										
										
											2022-07-10 06:59:40 +01:00
										 |  |  |             return std::nullopt; | 
					
						
							| 
									
										
										
										
											2020-09-23 17:51:09 -05:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-05 11:40:19 -06:00
										 |  |  |     system.CoreTiming().ScheduleLoopingEvent(npad_update_ns, npad_update_ns, npad_update_event); | 
					
						
							|  |  |  |     system.CoreTiming().ScheduleLoopingEvent(default_update_ns, default_update_ns, | 
					
						
							|  |  |  |                                              default_update_event); | 
					
						
							| 
									
										
										
										
											2022-07-10 08:29:37 +01:00
										 |  |  |     system.CoreTiming().ScheduleLoopingEvent(mouse_keyboard_update_ns, mouse_keyboard_update_ns, | 
					
						
							| 
									
										
										
										
											2022-07-10 06:59:40 +01:00
										 |  |  |                                              mouse_keyboard_update_event); | 
					
						
							| 
									
										
										
										
											2022-07-10 08:29:37 +01:00
										 |  |  |     system.CoreTiming().ScheduleLoopingEvent(motion_update_ns, motion_update_ns, | 
					
						
							| 
									
										
										
										
											2022-07-10 06:59:40 +01:00
										 |  |  |                                              motion_update_event); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |     system.HIDCore().ReloadInputDevices(); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void IAppletResource::ActivateController(HidController controller) { | 
					
						
							| 
									
										
										
										
											2019-09-22 16:41:34 +10:00
										 |  |  |     controllers[static_cast<size_t>(controller)]->ActivateController(); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void IAppletResource::DeactivateController(HidController controller) { | 
					
						
							|  |  |  |     controllers[static_cast<size_t>(controller)]->DeactivateController(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-29 01:17:30 -04:00
										 |  |  | IAppletResource::~IAppletResource() { | 
					
						
							| 
									
										
										
										
											2022-11-05 11:40:19 -06:00
										 |  |  |     system.CoreTiming().UnscheduleEvent(npad_update_event, 0); | 
					
						
							|  |  |  |     system.CoreTiming().UnscheduleEvent(default_update_event, 0); | 
					
						
							| 
									
										
										
										
											2021-11-14 21:28:38 -06:00
										 |  |  |     system.CoreTiming().UnscheduleEvent(mouse_keyboard_update_event, 0); | 
					
						
							| 
									
										
										
										
											2021-02-02 09:59:59 -06:00
										 |  |  |     system.CoreTiming().UnscheduleEvent(motion_update_event, 0); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void IAppletResource::GetSharedMemoryHandle(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     LOG_DEBUG(Service_HID, "called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2, 1}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2021-04-03 23:22:07 -07:00
										 |  |  |     rb.PushCopyObjects(&system.Kernel().GetHidSharedMem()); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-27 19:00:41 -04:00
										 |  |  | void IAppletResource::UpdateControllers(std::uintptr_t user_data, | 
					
						
							|  |  |  |                                         std::chrono::nanoseconds ns_late) { | 
					
						
							| 
									
										
										
										
											2019-09-21 18:43:43 +10:00
										 |  |  |     auto& core_timing = system.CoreTiming(); | 
					
						
							| 
									
										
										
										
											2019-02-14 12:42:58 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     for (const auto& controller : controllers) { | 
					
						
							| 
									
										
										
										
											2021-11-13 23:25:45 -06:00
										 |  |  |         // Keyboard has it's own update event
 | 
					
						
							|  |  |  |         if (controller == controllers[static_cast<size_t>(HidController::Keyboard)]) { | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-11-14 21:28:38 -06:00
										 |  |  |         // Mouse has it's own update event
 | 
					
						
							|  |  |  |         if (controller == controllers[static_cast<size_t>(HidController::Mouse)]) { | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-11-05 11:40:19 -06:00
										 |  |  |         // Npad has it's own update event
 | 
					
						
							|  |  |  |         if (controller == controllers[static_cast<size_t>(HidController::NPad)]) { | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-04-19 15:30:32 -05:00
										 |  |  |         controller->OnUpdate(core_timing); | 
					
						
							| 
									
										
										
										
											2018-01-15 02:21:02 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-01-14 21:24:50 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-05 11:40:19 -06:00
										 |  |  | void IAppletResource::UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) { | 
					
						
							|  |  |  |     auto& core_timing = system.CoreTiming(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     controllers[static_cast<size_t>(HidController::NPad)]->OnUpdate(core_timing); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 21:28:38 -06:00
										 |  |  | void IAppletResource::UpdateMouseKeyboard(std::uintptr_t user_data, | 
					
						
							|  |  |  |                                           std::chrono::nanoseconds ns_late) { | 
					
						
							| 
									
										
										
										
											2021-11-13 23:25:45 -06:00
										 |  |  |     auto& core_timing = system.CoreTiming(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-19 15:30:32 -05:00
										 |  |  |     controllers[static_cast<size_t>(HidController::Mouse)]->OnUpdate(core_timing); | 
					
						
							|  |  |  |     controllers[static_cast<size_t>(HidController::Keyboard)]->OnUpdate(core_timing); | 
					
						
							| 
									
										
										
										
											2021-11-13 23:25:45 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-23 17:51:09 -05:00
										 |  |  | void IAppletResource::UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) { | 
					
						
							|  |  |  |     auto& core_timing = system.CoreTiming(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-19 15:30:32 -05:00
										 |  |  |     controllers[static_cast<size_t>(HidController::NPad)]->OnMotionUpdate(core_timing); | 
					
						
							| 
									
										
										
										
											2020-09-23 17:51:09 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-04 17:06:14 -05:00
										 |  |  | class IActiveVibrationDeviceList final : public ServiceFramework<IActiveVibrationDeviceList> { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-11-26 15:19:08 -05:00
										 |  |  |     explicit IActiveVibrationDeviceList(Core::System& system_, | 
					
						
							|  |  |  |                                         std::shared_ptr<IAppletResource> applet_resource_) | 
					
						
							|  |  |  |         : ServiceFramework{system_, "IActiveVibrationDeviceList"}, | 
					
						
							|  |  |  |           applet_resource(applet_resource_) { | 
					
						
							| 
									
										
										
										
											2020-10-06 04:50:15 -04:00
										 |  |  |         // clang-format off
 | 
					
						
							| 
									
										
										
										
											2018-02-04 17:06:14 -05:00
										 |  |  |         static const FunctionInfo functions[] = { | 
					
						
							| 
									
										
										
										
											2020-10-06 04:50:15 -04:00
										 |  |  |             {0, &IActiveVibrationDeviceList::InitializeVibrationDevice, "InitializeVibrationDevice"}, | 
					
						
							| 
									
										
										
										
											2018-02-04 17:06:14 -05:00
										 |  |  |         }; | 
					
						
							| 
									
										
										
										
											2020-10-06 04:50:15 -04:00
										 |  |  |         // clang-format on
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-04 17:06:14 -05:00
										 |  |  |         RegisterHandlers(functions); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  |     void InitializeVibrationDevice(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-10-06 04:50:15 -04:00
										 |  |  |         IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         const auto vibration_device_handle{rp.PopRaw<Core::HID::VibrationDeviceHandle>()}; | 
					
						
							| 
									
										
										
										
											2020-10-06 04:50:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-25 13:33:01 -05:00
										 |  |  |         if (applet_resource != nullptr) { | 
					
						
							|  |  |  |             applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |                 .InitializeVibrationDevice(vibration_device_handle); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-10-22 06:55:23 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         LOG_DEBUG(Service_HID, "called, npad_type={}, npad_id={}, device_index={}", | 
					
						
							|  |  |  |                   vibration_device_handle.npad_type, vibration_device_handle.npad_id, | 
					
						
							|  |  |  |                   vibration_device_handle.device_index); | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-04 17:06:14 -05:00
										 |  |  |         IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |         rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-02-04 17:06:14 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-10-22 06:55:23 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     std::shared_ptr<IAppletResource> applet_resource; | 
					
						
							| 
									
										
										
										
											2018-02-04 17:06:14 -05:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | std::shared_ptr<IAppletResource> Hid::GetAppletResource() { | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |     if (applet_resource == nullptr) { | 
					
						
							| 
									
										
										
										
											2021-06-28 14:41:24 -07:00
										 |  |  |         applet_resource = std::make_shared<IAppletResource>(system, service_context); | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     return applet_resource; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 14:41:24 -07:00
										 |  |  | Hid::Hid(Core::System& system_) | 
					
						
							|  |  |  |     : ServiceFramework{system_, "hid"}, service_context{system_, service_name} { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     // clang-format off
 | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |     static const FunctionInfo functions[] = { | 
					
						
							|  |  |  |         {0, &Hid::CreateAppletResource, "CreateAppletResource"}, | 
					
						
							|  |  |  |         {1, &Hid::ActivateDebugPad, "ActivateDebugPad"}, | 
					
						
							|  |  |  |         {11, &Hid::ActivateTouchScreen, "ActivateTouchScreen"}, | 
					
						
							|  |  |  |         {21, &Hid::ActivateMouse, "ActivateMouse"}, | 
					
						
							| 
									
										
										
										
											2023-02-24 12:52:32 -06:00
										 |  |  |         {26, nullptr, "ActivateDebugMouse"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {31, &Hid::ActivateKeyboard, "ActivateKeyboard"}, | 
					
						
							| 
									
										
										
										
											2020-05-12 01:01:50 +10:00
										 |  |  |         {32, &Hid::SendKeyboardLockKeyEvent, "SendKeyboardLockKeyEvent"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {40, nullptr, "AcquireXpadIdEventHandle"}, | 
					
						
							|  |  |  |         {41, nullptr, "ReleaseXpadIdEventHandle"}, | 
					
						
							|  |  |  |         {51, &Hid::ActivateXpad, "ActivateXpad"}, | 
					
						
							| 
									
										
										
										
											2020-06-01 19:38:44 +02:00
										 |  |  |         {55, &Hid::GetXpadIDs, "GetXpadIds"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {56, nullptr, "ActivateJoyXpad"}, | 
					
						
							|  |  |  |         {58, nullptr, "GetJoyXpadLifoHandle"}, | 
					
						
							|  |  |  |         {59, nullptr, "GetJoyXpadIds"}, | 
					
						
							| 
									
										
										
										
											2020-09-04 21:48:03 -05:00
										 |  |  |         {60, &Hid::ActivateSixAxisSensor, "ActivateSixAxisSensor"}, | 
					
						
							|  |  |  |         {61, &Hid::DeactivateSixAxisSensor, "DeactivateSixAxisSensor"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {62, nullptr, "GetSixAxisSensorLifoHandle"}, | 
					
						
							|  |  |  |         {63, nullptr, "ActivateJoySixAxisSensor"}, | 
					
						
							|  |  |  |         {64, nullptr, "DeactivateJoySixAxisSensor"}, | 
					
						
							|  |  |  |         {65, nullptr, "GetJoySixAxisSensorLifoHandle"}, | 
					
						
							|  |  |  |         {66, &Hid::StartSixAxisSensor, "StartSixAxisSensor"}, | 
					
						
							|  |  |  |         {67, &Hid::StopSixAxisSensor, "StopSixAxisSensor"}, | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |         {68, &Hid::IsSixAxisSensorFusionEnabled, "IsSixAxisSensorFusionEnabled"}, | 
					
						
							| 
									
										
										
										
											2020-09-29 19:37:22 -05:00
										 |  |  |         {69, &Hid::EnableSixAxisSensorFusion, "EnableSixAxisSensorFusion"}, | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  |         {70, &Hid::SetSixAxisSensorFusionParameters, "SetSixAxisSensorFusionParameters"}, | 
					
						
							|  |  |  |         {71, &Hid::GetSixAxisSensorFusionParameters, "GetSixAxisSensorFusionParameters"}, | 
					
						
							|  |  |  |         {72, &Hid::ResetSixAxisSensorFusionParameters, "ResetSixAxisSensorFusionParameters"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {73, nullptr, "SetAccelerometerParameters"}, | 
					
						
							|  |  |  |         {74, nullptr, "GetAccelerometerParameters"}, | 
					
						
							|  |  |  |         {75, nullptr, "ResetAccelerometerParameters"}, | 
					
						
							|  |  |  |         {76, nullptr, "SetAccelerometerPlayMode"}, | 
					
						
							|  |  |  |         {77, nullptr, "GetAccelerometerPlayMode"}, | 
					
						
							|  |  |  |         {78, nullptr, "ResetAccelerometerPlayMode"}, | 
					
						
							|  |  |  |         {79, &Hid::SetGyroscopeZeroDriftMode, "SetGyroscopeZeroDriftMode"}, | 
					
						
							| 
									
										
										
										
											2020-06-21 15:48:02 -04:00
										 |  |  |         {80, &Hid::GetGyroscopeZeroDriftMode, "GetGyroscopeZeroDriftMode"}, | 
					
						
							|  |  |  |         {81, &Hid::ResetGyroscopeZeroDriftMode, "ResetGyroscopeZeroDriftMode"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {82, &Hid::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"}, | 
					
						
							| 
									
										
										
										
											2021-06-11 14:35:35 -05:00
										 |  |  |         {83, &Hid::IsFirmwareUpdateAvailableForSixAxisSensor, "IsFirmwareUpdateAvailableForSixAxisSensor"}, | 
					
						
							| 
									
										
										
										
											2022-05-21 17:03:08 -05:00
										 |  |  |         {84, &Hid::EnableSixAxisSensorUnalteredPassthrough, "EnableSixAxisSensorUnalteredPassthrough"}, | 
					
						
							|  |  |  |         {85, &Hid::IsSixAxisSensorUnalteredPassthroughEnabled, "IsSixAxisSensorUnalteredPassthroughEnabled"}, | 
					
						
							| 
									
										
										
										
											2021-09-26 19:45:47 -05:00
										 |  |  |         {86, nullptr, "StoreSixAxisSensorCalibrationParameter"}, | 
					
						
							| 
									
										
										
										
											2022-05-21 17:10:20 -05:00
										 |  |  |         {87, &Hid::LoadSixAxisSensorCalibrationParameter, "LoadSixAxisSensorCalibrationParameter"}, | 
					
						
							|  |  |  |         {88, &Hid::GetSixAxisSensorIcInformation, "GetSixAxisSensorIcInformation"}, | 
					
						
							| 
									
										
										
										
											2022-05-21 17:21:45 -05:00
										 |  |  |         {89, &Hid::ResetIsSixAxisSensorDeviceNewlyAssigned, "ResetIsSixAxisSensorDeviceNewlyAssigned"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {91, &Hid::ActivateGesture, "ActivateGesture"}, | 
					
						
							|  |  |  |         {100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"}, | 
					
						
							|  |  |  |         {101, &Hid::GetSupportedNpadStyleSet, "GetSupportedNpadStyleSet"}, | 
					
						
							|  |  |  |         {102, &Hid::SetSupportedNpadIdType, "SetSupportedNpadIdType"}, | 
					
						
							|  |  |  |         {103, &Hid::ActivateNpad, "ActivateNpad"}, | 
					
						
							| 
									
										
										
										
											2019-09-21 18:17:46 -04:00
										 |  |  |         {104, &Hid::DeactivateNpad, "DeactivateNpad"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {106, &Hid::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"}, | 
					
						
							|  |  |  |         {107, &Hid::DisconnectNpad, "DisconnectNpad"}, | 
					
						
							|  |  |  |         {108, &Hid::GetPlayerLedPattern, "GetPlayerLedPattern"}, | 
					
						
							|  |  |  |         {109, &Hid::ActivateNpadWithRevision, "ActivateNpadWithRevision"}, | 
					
						
							|  |  |  |         {120, &Hid::SetNpadJoyHoldType, "SetNpadJoyHoldType"}, | 
					
						
							|  |  |  |         {121, &Hid::GetNpadJoyHoldType, "GetNpadJoyHoldType"}, | 
					
						
							|  |  |  |         {122, &Hid::SetNpadJoyAssignmentModeSingleByDefault, "SetNpadJoyAssignmentModeSingleByDefault"}, | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |         {123, &Hid::SetNpadJoyAssignmentModeSingle, "SetNpadJoyAssignmentModeSingle"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {124, &Hid::SetNpadJoyAssignmentModeDual, "SetNpadJoyAssignmentModeDual"}, | 
					
						
							|  |  |  |         {125, &Hid::MergeSingleJoyAsDualJoy, "MergeSingleJoyAsDualJoy"}, | 
					
						
							| 
									
										
										
										
											2019-07-01 15:12:57 +10:00
										 |  |  |         {126, &Hid::StartLrAssignmentMode, "StartLrAssignmentMode"}, | 
					
						
							|  |  |  |         {127, &Hid::StopLrAssignmentMode, "StopLrAssignmentMode"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {128, &Hid::SetNpadHandheldActivationMode, "SetNpadHandheldActivationMode"}, | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |         {129, &Hid::GetNpadHandheldActivationMode, "GetNpadHandheldActivationMode"}, | 
					
						
							| 
									
										
										
										
											2019-07-01 15:12:57 +10:00
										 |  |  |         {130, &Hid::SwapNpadAssignment, "SwapNpadAssignment"}, | 
					
						
							| 
									
										
										
										
											2020-09-30 06:34:08 -04:00
										 |  |  |         {131, &Hid::IsUnintendedHomeButtonInputProtectionEnabled, "IsUnintendedHomeButtonInputProtectionEnabled"}, | 
					
						
							|  |  |  |         {132, &Hid::EnableUnintendedHomeButtonInputProtection, "EnableUnintendedHomeButtonInputProtection"}, | 
					
						
							| 
									
										
										
										
											2023-03-26 23:56:00 -06:00
										 |  |  |         {133, &Hid::SetNpadJoyAssignmentModeSingleWithDestination, "SetNpadJoyAssignmentModeSingleWithDestination"}, | 
					
						
							| 
									
										
										
										
											2021-04-08 03:41:06 -04:00
										 |  |  |         {134, &Hid::SetNpadAnalogStickUseCenterClamp, "SetNpadAnalogStickUseCenterClamp"}, | 
					
						
							| 
									
										
										
										
											2021-12-05 22:41:21 -06:00
										 |  |  |         {135, &Hid::SetNpadCaptureButtonAssignment, "SetNpadCaptureButtonAssignment"}, | 
					
						
							|  |  |  |         {136, &Hid::ClearNpadCaptureButtonAssignment, "ClearNpadCaptureButtonAssignment"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {200, &Hid::GetVibrationDeviceInfo, "GetVibrationDeviceInfo"}, | 
					
						
							|  |  |  |         {201, &Hid::SendVibrationValue, "SendVibrationValue"}, | 
					
						
							|  |  |  |         {202, &Hid::GetActualVibrationValue, "GetActualVibrationValue"}, | 
					
						
							|  |  |  |         {203, &Hid::CreateActiveVibrationDeviceList, "CreateActiveVibrationDeviceList"}, | 
					
						
							| 
									
										
										
										
											2019-09-04 02:42:22 -04:00
										 |  |  |         {204, &Hid::PermitVibration, "PermitVibration"}, | 
					
						
							|  |  |  |         {205, &Hid::IsVibrationPermitted, "IsVibrationPermitted"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {206, &Hid::SendVibrationValues, "SendVibrationValues"}, | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |         {207, &Hid::SendVibrationGcErmCommand, "SendVibrationGcErmCommand"}, | 
					
						
							|  |  |  |         {208, &Hid::GetActualVibrationGcErmCommand, "GetActualVibrationGcErmCommand"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {209, &Hid::BeginPermitVibrationSession, "BeginPermitVibrationSession"}, | 
					
						
							|  |  |  |         {210, &Hid::EndPermitVibrationSession, "EndPermitVibrationSession"}, | 
					
						
							| 
									
										
										
										
											2020-10-11 08:35:40 -04:00
										 |  |  |         {211, &Hid::IsVibrationDeviceMounted, "IsVibrationDeviceMounted"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |         {212, nullptr, "SendVibrationValueInBool"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {300, &Hid::ActivateConsoleSixAxisSensor, "ActivateConsoleSixAxisSensor"}, | 
					
						
							|  |  |  |         {301, &Hid::StartConsoleSixAxisSensor, "StartConsoleSixAxisSensor"}, | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  |         {302, &Hid::StopConsoleSixAxisSensor, "StopConsoleSixAxisSensor"}, | 
					
						
							|  |  |  |         {303, &Hid::ActivateSevenSixAxisSensor, "ActivateSevenSixAxisSensor"}, | 
					
						
							|  |  |  |         {304, &Hid::StartSevenSixAxisSensor, "StartSevenSixAxisSensor"}, | 
					
						
							| 
									
										
										
										
											2020-04-25 15:30:52 -07:00
										 |  |  |         {305, &Hid::StopSevenSixAxisSensor, "StopSevenSixAxisSensor"}, | 
					
						
							| 
									
										
										
										
											2020-03-27 10:48:01 -04:00
										 |  |  |         {306, &Hid::InitializeSevenSixAxisSensor, "InitializeSevenSixAxisSensor"}, | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  |         {307, &Hid::FinalizeSevenSixAxisSensor, "FinalizeSevenSixAxisSensor"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {308, nullptr, "SetSevenSixAxisSensorFusionStrength"}, | 
					
						
							|  |  |  |         {309, nullptr, "GetSevenSixAxisSensorFusionStrength"}, | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  |         {310, &Hid::ResetSevenSixAxisSensorTimestamp, "ResetSevenSixAxisSensorTimestamp"}, | 
					
						
							| 
									
										
										
										
											2022-02-12 15:32:11 -05:00
										 |  |  |         {400, &Hid::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {401, nullptr, "EnableUsbFullKeyController"}, | 
					
						
							|  |  |  |         {402, nullptr, "IsUsbFullKeyControllerConnected"}, | 
					
						
							|  |  |  |         {403, nullptr, "HasBattery"}, | 
					
						
							|  |  |  |         {404, nullptr, "HasLeftRightBattery"}, | 
					
						
							|  |  |  |         {405, nullptr, "GetNpadInterfaceType"}, | 
					
						
							|  |  |  |         {406, nullptr, "GetNpadLeftRightInterfaceType"}, | 
					
						
							| 
									
										
										
										
											2020-10-27 21:19:44 -04:00
										 |  |  |         {407, nullptr, "GetNpadOfHighestBatteryLevel"}, | 
					
						
							| 
									
										
										
										
											2019-11-12 08:54:58 -05:00
										 |  |  |         {408, nullptr, "GetNpadOfHighestBatteryLevelForJoyRight"}, | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |         {500, &Hid::GetPalmaConnectionHandle, "GetPalmaConnectionHandle"}, | 
					
						
							|  |  |  |         {501, &Hid::InitializePalma, "InitializePalma"}, | 
					
						
							|  |  |  |         {502, &Hid::AcquirePalmaOperationCompleteEvent, "AcquirePalmaOperationCompleteEvent"}, | 
					
						
							|  |  |  |         {503, &Hid::GetPalmaOperationInfo, "GetPalmaOperationInfo"}, | 
					
						
							|  |  |  |         {504, &Hid::PlayPalmaActivity, "PlayPalmaActivity"}, | 
					
						
							|  |  |  |         {505, &Hid::SetPalmaFrModeType, "SetPalmaFrModeType"}, | 
					
						
							|  |  |  |         {506, &Hid::ReadPalmaStep, "ReadPalmaStep"}, | 
					
						
							|  |  |  |         {507, &Hid::EnablePalmaStep, "EnablePalmaStep"}, | 
					
						
							|  |  |  |         {508, &Hid::ResetPalmaStep, "ResetPalmaStep"}, | 
					
						
							|  |  |  |         {509, &Hid::ReadPalmaApplicationSection, "ReadPalmaApplicationSection"}, | 
					
						
							|  |  |  |         {510, &Hid::WritePalmaApplicationSection, "WritePalmaApplicationSection"}, | 
					
						
							|  |  |  |         {511, &Hid::ReadPalmaUniqueCode, "ReadPalmaUniqueCode"}, | 
					
						
							|  |  |  |         {512, &Hid::SetPalmaUniqueCodeInvalid, "SetPalmaUniqueCodeInvalid"}, | 
					
						
							|  |  |  |         {513, &Hid::WritePalmaActivityEntry, "WritePalmaActivityEntry"}, | 
					
						
							|  |  |  |         {514, &Hid::WritePalmaRgbLedPatternEntry, "WritePalmaRgbLedPatternEntry"}, | 
					
						
							|  |  |  |         {515, &Hid::WritePalmaWaveEntry, "WritePalmaWaveEntry"}, | 
					
						
							|  |  |  |         {516, &Hid::SetPalmaDataBaseIdentificationVersion, "SetPalmaDataBaseIdentificationVersion"}, | 
					
						
							|  |  |  |         {517, &Hid::GetPalmaDataBaseIdentificationVersion, "GetPalmaDataBaseIdentificationVersion"}, | 
					
						
							|  |  |  |         {518, &Hid::SuspendPalmaFeature, "SuspendPalmaFeature"}, | 
					
						
							|  |  |  |         {519, &Hid::GetPalmaOperationResult, "GetPalmaOperationResult"}, | 
					
						
							|  |  |  |         {520, &Hid::ReadPalmaPlayLog, "ReadPalmaPlayLog"}, | 
					
						
							|  |  |  |         {521, &Hid::ResetPalmaPlayLog, "ResetPalmaPlayLog"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {522, &Hid::SetIsPalmaAllConnectable, "SetIsPalmaAllConnectable"}, | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |         {523, &Hid::SetIsPalmaPairedConnectable, "SetIsPalmaPairedConnectable"}, | 
					
						
							|  |  |  |         {524, &Hid::PairPalma, "PairPalma"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |         {525, &Hid::SetPalmaBoostMode, "SetPalmaBoostMode"}, | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |         {526, &Hid::CancelWritePalmaWaveEntry, "CancelWritePalmaWaveEntry"}, | 
					
						
							|  |  |  |         {527, &Hid::EnablePalmaBoostMode, "EnablePalmaBoostMode"}, | 
					
						
							|  |  |  |         {528, &Hid::GetPalmaBluetoothAddress, "GetPalmaBluetoothAddress"}, | 
					
						
							|  |  |  |         {529, &Hid::SetDisallowedPalmaConnection, "SetDisallowedPalmaConnection"}, | 
					
						
							| 
									
										
										
										
											2020-11-26 21:15:48 -06:00
										 |  |  |         {1000, &Hid::SetNpadCommunicationMode, "SetNpadCommunicationMode"}, | 
					
						
							|  |  |  |         {1001, &Hid::GetNpadCommunicationMode, "GetNpadCommunicationMode"}, | 
					
						
							| 
									
										
										
										
											2021-09-10 10:09:22 -05:00
										 |  |  |         {1002, &Hid::SetTouchScreenConfiguration, "SetTouchScreenConfiguration"}, | 
					
						
							| 
									
										
										
										
											2022-04-26 22:22:27 -05:00
										 |  |  |         {1003, &Hid::IsFirmwareUpdateNeededForNotification, "IsFirmwareUpdateNeededForNotification"}, | 
					
						
							| 
									
										
										
										
											2020-04-20 15:18:23 -04:00
										 |  |  |         {2000, nullptr, "ActivateDigitizer"}, | 
					
						
							| 
									
										
										
										
											2018-12-28 18:20:29 -05:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     // clang-format on
 | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     RegisterHandlers(functions); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | Hid::~Hid() = default; | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::CreateAppletResource(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-02-04 22:24:20 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     if (applet_resource == nullptr) { | 
					
						
							| 
									
										
										
										
											2021-06-28 14:41:24 -07:00
										 |  |  |         applet_resource = std::make_shared<IAppletResource>(system, service_context); | 
					
						
							| 
									
										
										
										
											2018-02-05 21:53:11 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     rb.PushIpcInterface<IAppletResource>(applet_resource); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ActivateDebugPad(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     applet_resource->ActivateController(HidController::DebugPad); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-02-15 17:22:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ActivateTouchScreen(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-06-01 19:38:44 +02:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     applet_resource->ActivateController(HidController::Touchscreen); | 
					
						
							| 
									
										
										
										
											2020-06-01 19:38:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-09-04 21:48:03 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-09-04 21:48:03 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ActivateMouse(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-09-04 21:48:03 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     applet_resource->ActivateController(HidController::Mouse); | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ActivateKeyboard(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2018-10-06 00:23:21 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     applet_resource->ActivateController(HidController::Keyboard); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SendKeyboardLockKeyEvent(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     const auto flags{rp.Pop<u32>()}; | 
					
						
							| 
									
										
										
										
											2018-02-15 17:22:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called. flags={}", flags); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ActivateXpad(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         u32 basic_xpad_id; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2018-02-04 22:24:20 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     applet_resource->ActivateController(HidController::XPad); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, basic_xpad_id={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.basic_xpad_id, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetXpadIDs(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "(STUBBED) called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     rb.Push(0); | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ActivateSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         u32 basic_xpad_id; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2018-02-15 17:22:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     // This function does nothing on 10.0.0+
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, basic_xpad_id={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 parameters.basic_xpad_id, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::DeactivateSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         u32 basic_xpad_id; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2018-07-30 20:06:21 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     // This function does nothing on 10.0.0+
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, basic_xpad_id={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 parameters.basic_xpad_id, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::StartSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2018-10-06 00:23:21 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.SetSixAxisEnabled(parameters.sixaxis_handle, true); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |               parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-02-04 22:24:20 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::StopSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.SetSixAxisEnabled(parameters.sixaxis_handle, false); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |               parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::IsSixAxisSensorFusionEnabled(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool is_enabled{}; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = | 
					
						
							|  |  |  |         controller.IsSixAxisSensorFusionEnabled(parameters.sixaxis_handle, is_enabled); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |               parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  |     rb.Push(is_enabled); | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::EnableSixAxisSensorFusion(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-09-29 19:37:22 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         bool enable_sixaxis_sensor_fusion; | 
					
						
							|  |  |  |         INSERT_PADDING_BYTES_NOINIT(3); | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-01-28 09:41:43 -05:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-09-29 19:37:22 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.SetSixAxisFusionEnabled(parameters.sixaxis_handle, | 
					
						
							|  |  |  |                                                            parameters.enable_sixaxis_sensor_fusion); | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, enable_sixaxis_sensor_fusion={}, npad_type={}, npad_id={}, " | 
					
						
							|  |  |  |               "device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.enable_sixaxis_sensor_fusion, parameters.sixaxis_handle.npad_type, | 
					
						
							|  |  |  |               parameters.sixaxis_handle.npad_id, parameters.sixaxis_handle.device_index, | 
					
						
							|  |  |  |               parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-09-29 19:37:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							| 
									
										
										
										
											2020-09-29 19:37:22 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetSixAxisSensorFusionParameters(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							|  |  |  |         Core::HID::SixAxisSensorFusionParameters sixaxis_fusion; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-01-28 09:41:43 -05:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = | 
					
						
							|  |  |  |         controller.SetSixAxisFusionParameters(parameters.sixaxis_handle, parameters.sixaxis_fusion); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, parameter1={}, " | 
					
						
							|  |  |  |               "parameter2={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |               parameters.sixaxis_handle.device_index, parameters.sixaxis_fusion.parameter1, | 
					
						
							|  |  |  |               parameters.sixaxis_fusion.parameter2, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetSixAxisSensorFusionParameters(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-01-28 09:41:43 -05:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     Core::HID::SixAxisSensorFusionParameters fusion_parameters{}; | 
					
						
							|  |  |  |     const auto& controller = | 
					
						
							|  |  |  |         GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = | 
					
						
							|  |  |  |         controller.GetSixAxisFusionParameters(parameters.sixaxis_handle, fusion_parameters); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |               parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 4}; | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							|  |  |  |     rb.PushRaw(fusion_parameters); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ResetSixAxisSensorFusionParameters(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-01-28 09:41:43 -05:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-11 22:10:38 -05:00
										 |  |  |     // Since these parameters are unknown just use what HW outputs
 | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     const Core::HID::SixAxisSensorFusionParameters fusion_parameters{ | 
					
						
							|  |  |  |         .parameter1 = 0.03f, | 
					
						
							|  |  |  |         .parameter2 = 0.4f, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result1 = | 
					
						
							|  |  |  |         controller.SetSixAxisFusionParameters(parameters.sixaxis_handle, fusion_parameters); | 
					
						
							|  |  |  |     const auto result2 = controller.SetSixAxisFusionEnabled(parameters.sixaxis_handle, true); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |               parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     if (result1.IsError()) { | 
					
						
							|  |  |  |         rb.Push(result1); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     rb.Push(result2); | 
					
						
							| 
									
										
										
										
											2021-01-24 10:27:04 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetGyroscopeZeroDriftMode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     const auto sixaxis_handle{rp.PopRaw<Core::HID::SixAxisSensorHandle>()}; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:05:20 -06:00
										 |  |  |     const auto drift_mode{rp.PopEnum<Core::HID::GyroscopeZeroDriftMode>()}; | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.SetGyroscopeZeroDriftMode(sixaxis_handle, drift_mode); | 
					
						
							| 
									
										
										
										
											2020-06-21 15:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, drift_mode={}, " | 
					
						
							|  |  |  |               "applet_resource_user_id={}", | 
					
						
							|  |  |  |               sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index, | 
					
						
							| 
									
										
										
										
											2020-06-21 15:48:02 -04:00
										 |  |  |               drift_mode, applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							| 
									
										
										
										
											2020-06-21 15:48:02 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetGyroscopeZeroDriftMode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-06-21 15:48:02 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-06-21 15:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-09 19:05:20 -06:00
										 |  |  |     auto drift_mode{Core::HID::GyroscopeZeroDriftMode::Standard}; | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.GetGyroscopeZeroDriftMode(parameters.sixaxis_handle, drift_mode); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |               parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-06-21 15:48:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							|  |  |  |     rb.PushEnum(drift_mode); | 
					
						
							| 
									
										
										
										
											2020-06-21 15:48:02 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ResetGyroscopeZeroDriftMode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-06-21 15:48:02 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2020-06-21 15:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-09 19:05:20 -06:00
										 |  |  |     const auto drift_mode{Core::HID::GyroscopeZeroDriftMode::Standard}; | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.SetGyroscopeZeroDriftMode(parameters.sixaxis_handle, drift_mode); | 
					
						
							| 
									
										
										
										
											2020-06-21 15:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |               parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-10-06 00:23:21 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-31 16:05:45 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::IsSixAxisSensorAtRest(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     bool is_at_rest{}; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     controller.IsSixAxisSensorAtRest(parameters.sixaxis_handle, is_at_rest); | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |               parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     rb.Push(is_at_rest); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::IsFirmwareUpdateAvailableForSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-06-11 14:35:35 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							| 
									
										
										
										
											2021-06-11 14:35:35 -05:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2021-06-11 14:35:35 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     bool is_firmware_available{}; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     controller.IsFirmwareUpdateAvailableForSixAxisSensor(parameters.sixaxis_handle, | 
					
						
							|  |  |  |                                                          is_firmware_available); | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-11 14:35:35 -05:00
										 |  |  |     LOG_WARNING( | 
					
						
							|  |  |  |         Service_HID, | 
					
						
							|  |  |  |         "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |         parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |         parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2022-04-13 12:52:29 -05:00
										 |  |  |     rb.Push(is_firmware_available); | 
					
						
							| 
									
										
										
										
											2021-06-11 14:35:35 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::EnableSixAxisSensorUnalteredPassthrough(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-05-21 17:03:08 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         bool enabled; | 
					
						
							|  |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.EnableSixAxisSensorUnalteredPassthrough( | 
					
						
							|  |  |  |         parameters.sixaxis_handle, parameters.enabled); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:47:47 +01:00
										 |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "(STUBBED) called, enabled={}, npad_type={}, npad_id={}, device_index={}, " | 
					
						
							|  |  |  |               "applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.enabled, parameters.sixaxis_handle.npad_type, | 
					
						
							|  |  |  |               parameters.sixaxis_handle.npad_id, parameters.sixaxis_handle.device_index, | 
					
						
							|  |  |  |               parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2022-05-21 17:03:08 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::IsSixAxisSensorUnalteredPassthroughEnabled(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-05-21 17:03:08 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool is_unaltered_sisxaxis_enabled{}; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.IsSixAxisSensorUnalteredPassthroughEnabled( | 
					
						
							|  |  |  |         parameters.sixaxis_handle, is_unaltered_sisxaxis_enabled); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:47:47 +01:00
										 |  |  |     LOG_DEBUG( | 
					
						
							| 
									
										
										
										
											2022-05-21 17:03:08 -05:00
										 |  |  |         Service_HID, | 
					
						
							|  |  |  |         "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |         parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |         parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  |     rb.Push(is_unaltered_sisxaxis_enabled); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::LoadSixAxisSensorCalibrationParameter(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-05-21 17:10:20 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Core::HID::SixAxisSensorCalibrationParameter calibration{}; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = | 
					
						
							|  |  |  |         controller.LoadSixAxisSensorCalibrationParameter(parameters.sixaxis_handle, calibration); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING( | 
					
						
							|  |  |  |         Service_HID, | 
					
						
							|  |  |  |         "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |         parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |         parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (result.IsSuccess()) { | 
					
						
							|  |  |  |         ctx.WriteBuffer(calibration); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetSixAxisSensorIcInformation(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-05-21 17:10:20 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Core::HID::SixAxisSensorIcInformation ic_information{}; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = | 
					
						
							|  |  |  |         controller.GetSixAxisSensorIcInformation(parameters.sixaxis_handle, ic_information); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING( | 
					
						
							|  |  |  |         Service_HID, | 
					
						
							|  |  |  |         "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |         parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |         parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (result.IsSuccess()) { | 
					
						
							|  |  |  |         ctx.WriteBuffer(ic_information); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ResetIsSixAxisSensorDeviceNewlyAssigned(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-05-21 17:21:45 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         Core::HID::SixAxisSensorHandle sixaxis_handle; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = | 
					
						
							|  |  |  |         controller.ResetIsSixAxisSensorDeviceNewlyAssigned(parameters.sixaxis_handle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING( | 
					
						
							|  |  |  |         Service_HID, | 
					
						
							|  |  |  |         "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |         parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 
					
						
							|  |  |  |         parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ActivateGesture(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         u32 unknown; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->ActivateController(HidController::Gesture); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, unknown={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 parameters.unknown, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetSupportedNpadStyleSet(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     struct Parameters { | 
					
						
							|  |  |  |         Core::HID::NpadStyleSet supported_styleset; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2018-02-04 22:24:20 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         .SetSupportedStyleSet({parameters.supported_styleset}); | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, supported_styleset={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.supported_styleset, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-02-04 22:24:20 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetSupportedNpadStyleSet(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     rb.PushEnum(applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |                     .GetSupportedStyleSet() | 
					
						
							|  |  |  |                     .raw); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetSupportedNpadIdType(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-07 21:10:15 -06:00
										 |  |  |     const auto result = applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |                             .SetSupportedNpadIdTypes(ctx.ReadBuffer()); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2023-02-07 21:10:15 -06:00
										 |  |  |     rb.Push(result); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-02-07 15:11:17 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ActivateNpad(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     applet_resource->ActivateController(HidController::NPad); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::DeactivateNpad(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2019-09-21 18:17:46 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     applet_resource->DeactivateController(HidController::NPad); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-21 18:17:46 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2019-09-21 18:17:46 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::NpadIdType npad_id; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |         u64 unknown; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2018-08-12 05:56:25 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}, unknown={}", | 
					
						
							|  |  |  |               parameters.npad_id, parameters.applet_resource_user_id, parameters.unknown); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-30 17:09:28 -06:00
										 |  |  |     // Games expect this event to be signaled after calling this function
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |         .SignalStyleSetChangedEvent(parameters.npad_id); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2, 1}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     rb.PushCopyObjects(applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |                            .GetStyleSetChangedEvent(parameters.npad_id)); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::DisconnectNpad(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::NpadIdType npad_id; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2018-04-13 17:05:03 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     controller.DisconnectNpad(parameters.npad_id); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, | 
					
						
							|  |  |  |               parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetPlayerLedPattern(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()}; | 
					
						
							| 
									
										
										
										
											2018-10-06 00:23:21 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     Core::HID::LedPattern pattern{0, 0, 0, 0}; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.GetLedPattern(npad_id, pattern); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id); | 
					
						
							| 
									
										
										
										
											2018-02-05 21:53:11 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 4}; | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							|  |  |  |     rb.Push(pattern.raw); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ActivateNpadWithRevision(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     // Should have no effect with how our npad sets up the data
 | 
					
						
							|  |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         s32 revision; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->ActivateController(HidController::NPad); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, revision={}, applet_resource_user_id={}", parameters.revision, | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |               parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetNpadJoyHoldType(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |     const auto hold_type{rp.PopEnum<Controller_NPad::NpadJoyHoldType>()}; | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad).SetHoldType(hold_type); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, hold_type={}", | 
					
						
							|  |  |  |               applet_resource_user_id, hold_type); | 
					
						
							| 
									
										
										
										
											2018-02-07 15:11:17 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetNpadJoyHoldType(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2018-02-15 17:22:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 4}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     rb.PushEnum(applet_resource->GetController<Controller_NPad>(HidController::NPad).GetHoldType()); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetNpadJoyAssignmentModeSingleByDefault(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::NpadIdType npad_id; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-26 23:56:00 -06:00
										 |  |  |     Core::HID::NpadIdType new_npad_id{}; | 
					
						
							| 
									
										
										
										
											2022-05-21 16:29:41 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							| 
									
										
										
										
											2023-03-26 23:56:00 -06:00
										 |  |  |     controller.SetNpadMode(new_npad_id, parameters.npad_id, | 
					
						
							|  |  |  |                            Controller_NPad::NpadJoyDeviceType::Left, | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |                            Controller_NPad::NpadJoyAssignmentMode::Single); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-05 16:17:52 -06:00
										 |  |  |     LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, | 
					
						
							|  |  |  |              parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-10-11 00:58:47 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetNpadJoyAssignmentModeSingle(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::NpadIdType npad_id; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2021-12-05 16:17:52 -06:00
										 |  |  |         Controller_NPad::NpadJoyDeviceType npad_joy_device_type; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-26 23:56:00 -06:00
										 |  |  |     Core::HID::NpadIdType new_npad_id{}; | 
					
						
							| 
									
										
										
										
											2022-05-21 16:29:41 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							| 
									
										
										
										
											2023-03-26 23:56:00 -06:00
										 |  |  |     controller.SetNpadMode(new_npad_id, parameters.npad_id, parameters.npad_joy_device_type, | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |                            Controller_NPad::NpadJoyAssignmentMode::Single); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-05 16:17:52 -06:00
										 |  |  |     LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", | 
					
						
							|  |  |  |              parameters.npad_id, parameters.applet_resource_user_id, | 
					
						
							|  |  |  |              parameters.npad_joy_device_type); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetNpadJoyAssignmentModeDual(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::NpadIdType npad_id; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-26 23:56:00 -06:00
										 |  |  |     Core::HID::NpadIdType new_npad_id{}; | 
					
						
							| 
									
										
										
										
											2022-05-21 16:29:41 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							| 
									
										
										
										
											2023-03-26 23:56:00 -06:00
										 |  |  |     controller.SetNpadMode(new_npad_id, parameters.npad_id, {}, | 
					
						
							|  |  |  |                            Controller_NPad::NpadJoyAssignmentMode::Dual); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-05 16:17:52 -06:00
										 |  |  |     LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, | 
					
						
							|  |  |  |              parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::MergeSingleJoyAsDualJoy(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     const auto npad_id_1{rp.PopEnum<Core::HID::NpadIdType>()}; | 
					
						
							|  |  |  |     const auto npad_id_2{rp.PopEnum<Core::HID::NpadIdType>()}; | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 16:40:11 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.MergeSingleJoyAsDualJoy(npad_id_1, npad_id_2); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-27 13:27:03 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, npad_id_1={}, npad_id_2={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               npad_id_1, npad_id_2, applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-05-21 16:40:11 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::StartLrAssignmentMode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad).StartLRAssignmentMode(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::StopLrAssignmentMode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad).StopLRAssignmentMode(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetNpadHandheldActivationMode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     const auto activation_mode{rp.PopEnum<Controller_NPad::NpadHandheldActivationMode>()}; | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |         .SetNpadHandheldActivationMode(activation_mode); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, activation_mode={}", | 
					
						
							|  |  |  |               applet_resource_user_id, activation_mode); | 
					
						
							| 
									
										
										
										
											2020-09-18 10:10:30 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetNpadHandheldActivationMode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-18 10:10:30 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-18 10:10:30 -04:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 4}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     rb.PushEnum(applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |                     .GetNpadHandheldActivationMode()); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SwapNpadAssignment(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     const auto npad_id_1{rp.PopEnum<Core::HID::NpadIdType>()}; | 
					
						
							|  |  |  |     const auto npad_id_2{rp.PopEnum<Core::HID::NpadIdType>()}; | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.SwapNpadAssignment(npad_id_1, npad_id_2); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, npad_id_1={}, npad_id_2={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               npad_id_1, npad_id_2, applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							| 
									
										
										
										
											2019-09-14 17:09:14 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::IsUnintendedHomeButtonInputProtectionEnabled(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-09-30 06:34:08 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::NpadIdType npad_id; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-09-30 06:34:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     bool is_enabled = false; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = | 
					
						
							|  |  |  |         controller.IsUnintendedHomeButtonInputProtectionEnabled(parameters.npad_id, is_enabled); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, npad_id={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 parameters.npad_id, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-09-30 06:34:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							|  |  |  |     rb.Push(is_enabled); | 
					
						
							| 
									
										
										
										
											2020-09-30 06:34:08 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::EnableUnintendedHomeButtonInputProtection(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-09-30 06:34:08 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         bool unintended_home_button_input_protection; | 
					
						
							|  |  |  |         INSERT_PADDING_BYTES_NOINIT(3); | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::NpadIdType npad_id; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2020-09-30 06:34:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto result = controller.SetUnintendedHomeButtonInputProtectionEnabled( | 
					
						
							|  |  |  |         parameters.unintended_home_button_input_protection, parameters.npad_id); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-30 06:34:08 -04:00
										 |  |  |     LOG_WARNING(Service_HID, | 
					
						
							|  |  |  |                 "(STUBBED) called, unintended_home_button_input_protection={}, npad_id={}," | 
					
						
							|  |  |  |                 "applet_resource_user_id={}", | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |                 parameters.unintended_home_button_input_protection, parameters.npad_id, | 
					
						
							|  |  |  |                 parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-09-30 06:34:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     rb.Push(result); | 
					
						
							| 
									
										
										
										
											2020-09-30 06:34:08 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-26 23:56:00 -06:00
										 |  |  | void Hid::SetNpadJoyAssignmentModeSingleWithDestination(HLERequestContext& ctx) { | 
					
						
							|  |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         Core::HID::NpadIdType npad_id; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |         Controller_NPad::NpadJoyDeviceType npad_joy_device_type; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Core::HID::NpadIdType new_npad_id{}; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							|  |  |  |     const auto is_reassigned = | 
					
						
							|  |  |  |         controller.SetNpadMode(new_npad_id, parameters.npad_id, parameters.npad_joy_device_type, | 
					
						
							|  |  |  |                                Controller_NPad::NpadJoyAssignmentMode::Single); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", | 
					
						
							|  |  |  |              parameters.npad_id, parameters.applet_resource_user_id, | 
					
						
							|  |  |  |              parameters.npad_joy_device_type); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 4}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  |     rb.Push(is_reassigned); | 
					
						
							|  |  |  |     rb.PushEnum(new_npad_id); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-04-08 03:41:06 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         bool analog_stick_use_center_clamp; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         INSERT_PADDING_BYTES_NOINIT(7); | 
					
						
							| 
									
										
										
										
											2021-04-08 03:41:06 -04:00
										 |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-16 23:02:02 -06:00
										 |  |  |     GetAppletResource() | 
					
						
							|  |  |  |         ->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							| 
									
										
										
										
											2021-04-08 03:41:06 -04:00
										 |  |  |         .SetAnalogStickUseCenterClamp(parameters.analog_stick_use_center_clamp); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, | 
					
						
							|  |  |  |                 "(STUBBED) called, analog_stick_use_center_clamp={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 parameters.analog_stick_use_center_clamp, parameters.applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2021-04-08 03:41:06 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetNpadCaptureButtonAssignment(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-12-05 22:41:21 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         Core::HID::NpadStyleSet npad_styleset; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |         Core::HID::NpadButton button; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, | 
					
						
							|  |  |  |                 "(STUBBED) called, npad_styleset={}, applet_resource_user_id={}, button={}", | 
					
						
							|  |  |  |                 parameters.npad_styleset, parameters.applet_resource_user_id, parameters.button); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ClearNpadCaptureButtonAssignment(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-12-05 22:41:21 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetVibrationDeviceInfo(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     const auto vibration_device_handle{rp.PopRaw<Core::HID::VibrationDeviceHandle>()}; | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     const auto& controller = | 
					
						
							|  |  |  |         GetAppletResource()->GetController<Controller_NPad>(HidController::NPad); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |     Core::HID::VibrationDeviceInfo vibration_device_info; | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     bool check_device_index = false; | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |     switch (vibration_device_handle.npad_type) { | 
					
						
							| 
									
										
										
										
											2021-11-04 12:08:54 -06:00
										 |  |  |     case Core::HID::NpadStyleIndex::ProController: | 
					
						
							|  |  |  |     case Core::HID::NpadStyleIndex::Handheld: | 
					
						
							|  |  |  |     case Core::HID::NpadStyleIndex::JoyconDual: | 
					
						
							|  |  |  |     case Core::HID::NpadStyleIndex::JoyconLeft: | 
					
						
							|  |  |  |     case Core::HID::NpadStyleIndex::JoyconRight: | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |         vibration_device_info.type = Core::HID::VibrationDeviceType::LinearResonantActuator; | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |         check_device_index = true; | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2021-11-04 12:08:54 -06:00
										 |  |  |     case Core::HID::NpadStyleIndex::GameCube: | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |         vibration_device_info.type = Core::HID::VibrationDeviceType::GcErm; | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     case Core::HID::NpadStyleIndex::N64: | 
					
						
							|  |  |  |         vibration_device_info.type = Core::HID::VibrationDeviceType::N64; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     default: | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |         vibration_device_info.type = Core::HID::VibrationDeviceType::Unknown; | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-10-11 00:58:47 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     vibration_device_info.position = Core::HID::VibrationDevicePosition::None; | 
					
						
							|  |  |  |     if (check_device_index) { | 
					
						
							|  |  |  |         switch (vibration_device_handle.device_index) { | 
					
						
							|  |  |  |         case Core::HID::DeviceIndex::Left: | 
					
						
							|  |  |  |             vibration_device_info.position = Core::HID::VibrationDevicePosition::Left; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Core::HID::DeviceIndex::Right: | 
					
						
							|  |  |  |             vibration_device_info.position = Core::HID::VibrationDevicePosition::Right; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Core::HID::DeviceIndex::None: | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             ASSERT_MSG(false, "DeviceIndex should never be None!"); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called, vibration_device_type={}, vibration_device_position={}", | 
					
						
							|  |  |  |               vibration_device_info.type, vibration_device_info.position); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-23 00:35:17 -05:00
										 |  |  |     const auto result = controller.IsDeviceHandleValid(vibration_device_handle); | 
					
						
							|  |  |  |     if (result.IsError()) { | 
					
						
							|  |  |  |         IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |         rb.Push(result); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 4}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     rb.PushRaw(vibration_device_info); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SendVibrationValue(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 14:22:47 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::VibrationDeviceHandle vibration_device_handle; | 
					
						
							|  |  |  |         Core::HID::VibrationValue vibration_value; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 14:22:47 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x20, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-07 14:22:47 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2018-10-06 00:23:21 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							| 
									
										
										
										
											2020-10-25 07:30:23 -04:00
										 |  |  |         .VibrateController(parameters.vibration_device_handle, parameters.vibration_value); | 
					
						
							| 
									
										
										
										
											2018-02-15 17:22:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 14:22:47 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.vibration_device_handle.npad_type, | 
					
						
							|  |  |  |               parameters.vibration_device_handle.npad_id, | 
					
						
							|  |  |  |               parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-10-06 00:23:21 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-10-06 00:23:21 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetActualVibrationValue(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 14:22:47 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::VibrationDeviceHandle vibration_device_handle; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 14:22:47 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 14:22:47 -04:00
										 |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.vibration_device_handle.npad_type, | 
					
						
							|  |  |  |               parameters.vibration_device_handle.npad_id, | 
					
						
							|  |  |  |               parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 6}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-10-07 14:22:47 -04:00
										 |  |  |     rb.PushRaw(applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |                    .GetLastVibration(parameters.vibration_device_handle)); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-02-15 17:22:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::CreateActiveVibrationDeviceList(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     LOG_DEBUG(Service_HID, "called"); | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-11-26 15:19:08 -05:00
										 |  |  |     rb.PushIpcInterface<IActiveVibrationDeviceList>(system, applet_resource); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-02-13 19:05:06 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::PermitVibration(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2019-09-04 02:42:22 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto can_vibrate{rp.Pop<bool>()}; | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     // nnSDK saves this value as a float. Since it can only be 1.0f or 0.0f we simplify this value
 | 
					
						
							|  |  |  |     // by converting it to a bool
 | 
					
						
							| 
									
										
										
										
											2020-09-28 10:00:15 -04:00
										 |  |  |     Settings::values.vibration_enabled.SetValue(can_vibrate); | 
					
						
							| 
									
										
										
										
											2019-09-04 02:42:22 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, "called, can_vibrate={}", can_vibrate); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2019-09-04 02:42:22 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::IsVibrationPermitted(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2019-09-04 02:42:22 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, "called"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     // nnSDK checks if a float is greater than zero. We return the bool we stored earlier
 | 
					
						
							|  |  |  |     const auto is_enabled = Settings::values.vibration_enabled.GetValue(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-04 02:42:22 -04:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2022-05-21 15:38:17 -05:00
										 |  |  |     rb.Push(is_enabled); | 
					
						
							| 
									
										
										
										
											2019-09-04 02:42:22 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SendVibrationValues(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-14 09:22:00 -06:00
										 |  |  |     const auto handle_data = ctx.ReadBuffer(0); | 
					
						
							|  |  |  |     const auto handle_count = ctx.GetReadBufferNumElements<Core::HID::VibrationDeviceHandle>(0); | 
					
						
							|  |  |  |     const auto vibration_data = ctx.ReadBuffer(1); | 
					
						
							|  |  |  |     const auto vibration_count = ctx.GetReadBufferNumElements<Core::HID::VibrationValue>(1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto vibration_device_handles = | 
					
						
							|  |  |  |         std::span(reinterpret_cast<const Core::HID::VibrationDeviceHandle*>(handle_data.data()), | 
					
						
							|  |  |  |                   handle_count); | 
					
						
							|  |  |  |     auto vibration_values = std::span( | 
					
						
							|  |  |  |         reinterpret_cast<const Core::HID::VibrationValue*>(vibration_data.data()), vibration_count); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							| 
									
										
										
										
											2020-10-11 11:25:17 -04:00
										 |  |  |         .VibrateControllers(vibration_device_handles, vibration_values); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SendVibrationGcErmCommand(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::VibrationDeviceHandle vibration_device_handle; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |         Core::HID::VibrationGcErmCommand gc_erm_command; | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Note: This uses yuzu-specific behavior such that the StopHard command produces | 
					
						
							|  |  |  |      * vibrations where freq_low == 0.0f and freq_high == 0.0f, as defined below, | 
					
						
							|  |  |  |      * in order to differentiate between Stop and StopHard commands. | 
					
						
							|  |  |  |      * This is done to reuse the controller vibration functions made for regular controllers. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     const auto vibration_value = [parameters] { | 
					
						
							|  |  |  |         switch (parameters.gc_erm_command) { | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |         case Core::HID::VibrationGcErmCommand::Stop: | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |             return Core::HID::VibrationValue{ | 
					
						
							|  |  |  |                 .low_amplitude = 0.0f, | 
					
						
							|  |  |  |                 .low_frequency = 160.0f, | 
					
						
							|  |  |  |                 .high_amplitude = 0.0f, | 
					
						
							|  |  |  |                 .high_frequency = 320.0f, | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |             }; | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |         case Core::HID::VibrationGcErmCommand::Start: | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |             return Core::HID::VibrationValue{ | 
					
						
							|  |  |  |                 .low_amplitude = 1.0f, | 
					
						
							|  |  |  |                 .low_frequency = 160.0f, | 
					
						
							|  |  |  |                 .high_amplitude = 1.0f, | 
					
						
							|  |  |  |                 .high_frequency = 320.0f, | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |             }; | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |         case Core::HID::VibrationGcErmCommand::StopHard: | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |             return Core::HID::VibrationValue{ | 
					
						
							|  |  |  |                 .low_amplitude = 0.0f, | 
					
						
							|  |  |  |                 .low_frequency = 0.0f, | 
					
						
							|  |  |  |                 .high_amplitude = 0.0f, | 
					
						
							|  |  |  |                 .high_frequency = 0.0f, | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |             }; | 
					
						
							|  |  |  |         default: | 
					
						
							| 
									
										
										
										
											2021-12-15 20:00:24 -06:00
										 |  |  |             return Core::HID::DEFAULT_VIBRATION_VALUE; | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |         } | 
					
						
							|  |  |  |     }(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |         .VibrateController(parameters.vibration_device_handle, vibration_value); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}, " | 
					
						
							|  |  |  |               "gc_erm_command={}", | 
					
						
							|  |  |  |               parameters.vibration_device_handle.npad_type, | 
					
						
							|  |  |  |               parameters.vibration_device_handle.npad_id, | 
					
						
							|  |  |  |               parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id, | 
					
						
							|  |  |  |               parameters.gc_erm_command); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetActualVibrationGcErmCommand(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::VibrationDeviceHandle vibration_device_handle; | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto last_vibration = applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |                                     .GetLastVibration(parameters.vibration_device_handle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto gc_erm_command = [last_vibration] { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         if (last_vibration.low_amplitude != 0.0f || last_vibration.high_amplitude != 0.0f) { | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |             return Core::HID::VibrationGcErmCommand::Start; | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         /**
 | 
					
						
							|  |  |  |          * Note: This uses yuzu-specific behavior such that the StopHard command produces | 
					
						
							|  |  |  |          * vibrations where freq_low == 0.0f and freq_high == 0.0f, as defined in the HID function | 
					
						
							|  |  |  |          * SendVibrationGcErmCommand, in order to differentiate between Stop and StopHard commands. | 
					
						
							|  |  |  |          * This is done to reuse the controller vibration functions made for regular controllers. | 
					
						
							|  |  |  |          */ | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         if (last_vibration.low_frequency == 0.0f && last_vibration.high_frequency == 0.0f) { | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |             return Core::HID::VibrationGcErmCommand::StopHard; | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-20 20:29:00 -05:00
										 |  |  |         return Core::HID::VibrationGcErmCommand::Stop; | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |     }(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.vibration_device_handle.npad_type, | 
					
						
							|  |  |  |               parameters.vibration_device_handle.npad_id, | 
					
						
							|  |  |  |               parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 4}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2021-02-16 04:46:56 -05:00
										 |  |  |     rb.PushEnum(gc_erm_command); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::BeginPermitVibrationSession(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 12:09:44 -05:00
										 |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |         .SetPermitVibrationSession(true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::EndPermitVibrationSession(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-11-10 12:09:44 -05:00
										 |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |         .SetPermitVibrationSession(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_DEBUG(Service_HID, "called"); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-10-06 07:00:18 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::IsVibrationDeviceMounted(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-10-11 08:35:40 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::VibrationDeviceHandle vibration_device_handle; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-11 08:35:40 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2020-10-11 08:35:40 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-22 06:55:23 -04:00
										 |  |  |     LOG_DEBUG(Service_HID, | 
					
						
							|  |  |  |               "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |               parameters.vibration_device_handle.npad_type, | 
					
						
							|  |  |  |               parameters.vibration_device_handle.npad_id, | 
					
						
							|  |  |  |               parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-10-11 08:35:40 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-10-22 06:55:23 -04:00
										 |  |  |     rb.Push(applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |                 .IsVibrationDeviceMounted(parameters.vibration_device_handle)); | 
					
						
							| 
									
										
										
										
											2020-10-11 08:35:40 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ActivateConsoleSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-22 13:15:59 -05:00
										 |  |  |     applet_resource->ActivateController(HidController::ConsoleSixAxisSensor); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-09-19 00:52:20 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::StartConsoleSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     LOG_WARNING(Service_HID, | 
					
						
							|  |  |  |                 "(STUBBED) called, unknown_1={}, unknown_2={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 parameters.console_sixaxis_handle.unknown_1, | 
					
						
							|  |  |  |                 parameters.console_sixaxis_handle.unknown_2, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-09-19 00:56:02 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::StopConsoleSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     struct Parameters { | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |         Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle; | 
					
						
							| 
									
										
										
										
											2021-01-15 05:33:33 -03:00
										 |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-07 00:37:13 -04:00
										 |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     LOG_WARNING(Service_HID, | 
					
						
							|  |  |  |                 "(STUBBED) called, unknown_1={}, unknown_2={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 parameters.console_sixaxis_handle.unknown_1, | 
					
						
							|  |  |  |                 parameters.console_sixaxis_handle.unknown_2, parameters.applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-17 01:40:18 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ActivateSevenSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-22 13:15:59 -05:00
										 |  |  |     applet_resource->ActivateController(HidController::ConsoleSixAxisSensor); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-17 01:40:18 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::StartSevenSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							| 
									
										
										
										
											2018-12-21 13:37:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2018-11-26 17:06:13 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2018-12-24 16:19:16 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-01-18 15:07:48 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::StopSevenSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-04-25 15:30:52 -07:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-04-25 15:30:52 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::InitializeSevenSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-04-22 05:47:41 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  |     const auto t_mem_1_size{rp.Pop<u64>()}; | 
					
						
							|  |  |  |     const auto t_mem_2_size{rp.Pop<u64>()}; | 
					
						
							|  |  |  |     const auto t_mem_1_handle{ctx.GetCopyHandle(0)}; | 
					
						
							|  |  |  |     const auto t_mem_2_handle{ctx.GetCopyHandle(1)}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_MSG(t_mem_1_size == 0x1000, "t_mem_1_size is not 0x1000 bytes"); | 
					
						
							|  |  |  |     ASSERT_MSG(t_mem_2_size == 0x7F000, "t_mem_2_size is not 0x7F000 bytes"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 11:21:43 -05:00
										 |  |  |     auto t_mem_1 = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( | 
					
						
							| 
									
										
										
										
											2021-04-17 00:52:53 -07:00
										 |  |  |         t_mem_1_handle); | 
					
						
							| 
									
										
										
										
											2021-04-22 05:47:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-17 00:52:53 -07:00
										 |  |  |     if (t_mem_1.IsNull()) { | 
					
						
							| 
									
										
										
										
											2021-04-22 05:47:41 -04:00
										 |  |  |         LOG_ERROR(Service_HID, "t_mem_1 is a nullptr for handle=0x{:08X}", t_mem_1_handle); | 
					
						
							|  |  |  |         IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:06:31 -04:00
										 |  |  |         rb.Push(ResultUnknown); | 
					
						
							| 
									
										
										
										
											2021-04-22 05:47:41 -04:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 11:21:43 -05:00
										 |  |  |     auto t_mem_2 = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( | 
					
						
							| 
									
										
										
										
											2021-04-17 00:52:53 -07:00
										 |  |  |         t_mem_2_handle); | 
					
						
							| 
									
										
										
										
											2021-04-22 05:47:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-17 00:52:53 -07:00
										 |  |  |     if (t_mem_2.IsNull()) { | 
					
						
							| 
									
										
										
										
											2021-04-22 05:47:41 -04:00
										 |  |  |         LOG_ERROR(Service_HID, "t_mem_2 is a nullptr for handle=0x{:08X}", t_mem_2_handle); | 
					
						
							|  |  |  |         IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:06:31 -04:00
										 |  |  |         rb.Push(ResultUnknown); | 
					
						
							| 
									
										
										
										
											2021-04-22 05:47:41 -04:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_MSG(t_mem_1->GetSize() == 0x1000, "t_mem_1 has incorrect size"); | 
					
						
							|  |  |  |     ASSERT_MSG(t_mem_2->GetSize() == 0x7F000, "t_mem_2 has incorrect size"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-22 13:15:59 -05:00
										 |  |  |     // Activate console six axis controller
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) | 
					
						
							|  |  |  |         .ActivateController(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) | 
					
						
							| 
									
										
										
										
											2023-02-24 12:29:55 -05:00
										 |  |  |         .SetTransferMemoryAddress(t_mem_1->GetSourceAddress()); | 
					
						
							| 
									
										
										
										
											2021-04-22 13:15:59 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-22 05:47:41 -04:00
										 |  |  |     LOG_WARNING(Service_HID, | 
					
						
							| 
									
										
										
										
											2021-04-22 13:15:59 -05:00
										 |  |  |                 "called, t_mem_1_handle=0x{:08X}, t_mem_2_handle=0x{:08X}, " | 
					
						
							| 
									
										
										
										
											2021-04-22 05:47:41 -04:00
										 |  |  |                 "applet_resource_user_id={}", | 
					
						
							|  |  |  |                 t_mem_1_handle, t_mem_2_handle, applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-03-27 10:48:01 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-03-27 10:48:01 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::FinalizeSevenSixAxisSensor(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-05-12 01:01:50 +10:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-22 13:15:59 -05:00
										 |  |  |     applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) | 
					
						
							|  |  |  |         .ResetTimestamp(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-02-12 15:32:11 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  |     rb.Push(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetPalmaConnectionHandle(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         Core::HID::NpadIdType npad_id; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, npad_id={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 parameters.npad_id, parameters.applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Controller_Palma::PalmaConnectionHandle handle; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | 
					
						
							|  |  |  |     const auto result = controller.GetPalmaConnectionHandle(parameters.npad_id, handle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 4}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  |     rb.PushRaw(handle); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::InitializePalma(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | 
					
						
							|  |  |  |     const auto result = controller.InitializePalma(connection_handle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::AcquirePalmaOperationCompleteEvent(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2, 1}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  |     rb.PushCopyObjects(controller.AcquirePalmaOperationCompleteEvent(connection_handle)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetPalmaOperationInfo(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Controller_Palma::PalmaOperationType operation_type; | 
					
						
							|  |  |  |     Controller_Palma::PalmaOperationData data; | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | 
					
						
							|  |  |  |     const auto result = controller.GetPalmaOperationInfo(connection_handle, operation_type, data); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (result.IsError()) { | 
					
						
							|  |  |  |         IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |         rb.Push(result); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ctx.WriteBuffer(data); | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 4}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  |     rb.Push(static_cast<u64>(operation_type)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::PlayPalmaActivity(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  |     const auto palma_activity{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, palma_activity={}", | 
					
						
							|  |  |  |                 connection_handle.npad_id, palma_activity); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | 
					
						
							|  |  |  |     const auto result = controller.PlayPalmaActivity(connection_handle, palma_activity); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetPalmaFrModeType(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  |     const auto fr_mode{rp.PopEnum<Controller_Palma::PalmaFrModeType>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, fr_mode={}", | 
					
						
							|  |  |  |                 connection_handle.npad_id, fr_mode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | 
					
						
							|  |  |  |     const auto result = controller.SetPalmaFrModeType(connection_handle, fr_mode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ReadPalmaStep(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | 
					
						
							|  |  |  |     const auto result = controller.ReadPalmaStep(connection_handle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::EnablePalmaStep(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         bool is_enabled; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         Controller_Palma::PalmaConnectionHandle connection_handle; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, is_enabled={}", | 
					
						
							|  |  |  |                 parameters.connection_handle.npad_id, parameters.is_enabled); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | 
					
						
							|  |  |  |     const auto result = | 
					
						
							|  |  |  |         controller.EnablePalmaStep(parameters.connection_handle, parameters.is_enabled); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ResetPalmaStep(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | 
					
						
							|  |  |  |     const auto result = controller.ResetPalmaStep(connection_handle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ReadPalmaApplicationSection(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::WritePalmaApplicationSection(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ReadPalmaUniqueCode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_Palma>(HidController::Palma) | 
					
						
							|  |  |  |         .ReadPalmaUniqueCode(connection_handle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetPalmaUniqueCodeInvalid(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_Palma>(HidController::Palma) | 
					
						
							|  |  |  |         .SetPalmaUniqueCodeInvalid(connection_handle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::WritePalmaActivityEntry(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     LOG_CRITICAL(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::WritePalmaRgbLedPatternEntry(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  |     const auto unknown{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-03 00:08:45 -05:00
										 |  |  |     [[maybe_unused]] const auto buffer = ctx.ReadBuffer(); | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, unknown={}", | 
					
						
							|  |  |  |                 connection_handle.npad_id, unknown); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_Palma>(HidController::Palma) | 
					
						
							|  |  |  |         .WritePalmaRgbLedPatternEntry(connection_handle, unknown); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::WritePalmaWaveEntry(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  |     const auto wave_set{rp.PopEnum<Controller_Palma::PalmaWaveSet>()}; | 
					
						
							|  |  |  |     const auto unknown{rp.Pop<u64>()}; | 
					
						
							|  |  |  |     const auto t_mem_size{rp.Pop<u64>()}; | 
					
						
							|  |  |  |     const auto t_mem_handle{ctx.GetCopyHandle(0)}; | 
					
						
							|  |  |  |     const auto size{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_MSG(t_mem_size == 0x3000, "t_mem_size is not 0x3000 bytes"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 11:21:43 -05:00
										 |  |  |     auto t_mem = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( | 
					
						
							|  |  |  |         t_mem_handle); | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (t_mem.IsNull()) { | 
					
						
							|  |  |  |         LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle); | 
					
						
							|  |  |  |         IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |         rb.Push(ResultUnknown); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_MSG(t_mem->GetSize() == 0x3000, "t_mem has incorrect size"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, | 
					
						
							| 
									
										
										
										
											2022-10-16 00:46:22 -04:00
										 |  |  |                 "(STUBBED) called, connection_handle={}, wave_set={}, unknown={}, " | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |                 "t_mem_handle=0x{:08X}, t_mem_size={}, size={}", | 
					
						
							|  |  |  |                 connection_handle.npad_id, wave_set, unknown, t_mem_handle, t_mem_size, size); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_Palma>(HidController::Palma) | 
					
						
							| 
									
										
										
										
											2023-02-24 12:29:55 -05:00
										 |  |  |         .WritePalmaWaveEntry(connection_handle, wave_set, t_mem->GetSourceAddress(), t_mem_size); | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         s32 database_id_version; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         Controller_Palma::PalmaConnectionHandle connection_handle; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, database_id_version={}", | 
					
						
							|  |  |  |                 parameters.connection_handle.npad_id, parameters.database_id_version); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_Palma>(HidController::Palma) | 
					
						
							|  |  |  |         .SetPalmaDataBaseIdentificationVersion(parameters.connection_handle, | 
					
						
							|  |  |  |                                                parameters.database_id_version); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_Palma>(HidController::Palma) | 
					
						
							|  |  |  |         .GetPalmaDataBaseIdentificationVersion(connection_handle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SuspendPalmaFeature(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetPalmaOperationResult(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto result = applet_resource->GetController<Controller_Palma>(HidController::Palma) | 
					
						
							|  |  |  |                             .GetPalmaOperationResult(connection_handle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ReadPalmaPlayLog(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::ResetPalmaPlayLog(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetIsPalmaAllConnectable(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     struct Parameters { | 
					
						
							|  |  |  |         bool is_palma_all_connectable; | 
					
						
							|  |  |  |         INSERT_PADDING_BYTES_NOINIT(7); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |                 "(STUBBED) called, is_palma_all_connectable={},applet_resource_user_id={}", | 
					
						
							|  |  |  |                 parameters.is_palma_all_connectable, parameters.applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_Palma>(HidController::Palma) | 
					
						
							|  |  |  |         .SetIsPalmaAllConnectable(parameters.is_palma_all_connectable); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetIsPalmaPairedConnectable(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::PairPalma(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_Palma>(HidController::Palma) | 
					
						
							|  |  |  |         .PairPalma(connection_handle); | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetPalmaBoostMode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-06-22 05:37:46 -04:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto palma_boost_mode{rp.Pop<bool>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, palma_boost_mode={}", palma_boost_mode); | 
					
						
							| 
									
										
										
										
											2020-05-12 01:01:50 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     applet_resource->GetController<Controller_Palma>(HidController::Palma) | 
					
						
							|  |  |  |         .SetPalmaBoostMode(palma_boost_mode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::CancelWritePalmaWaveEntry(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::EnablePalmaBoostMode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetPalmaBluetoothAddress(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetDisallowedPalmaConnection(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-01-18 20:08:56 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-12 01:01:50 +10:00
										 |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-05-12 01:01:50 +10:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetNpadCommunicationMode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-11-26 21:15:48 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  |     const auto communication_mode{rp.PopEnum<Controller_NPad::NpadCommunicationMode>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |         .SetNpadCommunicationMode(communication_mode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}, communication_mode={}", | 
					
						
							|  |  |  |                 applet_resource_user_id, communication_mode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-11-26 21:15:48 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::GetNpadCommunicationMode(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2020-11-26 21:15:48 -06:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							| 
									
										
										
										
											2020-11-26 21:15:48 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 4}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |     rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2020-11-26 21:15:48 -06:00
										 |  |  |     rb.PushEnum(applet_resource->GetController<Controller_NPad>(HidController::NPad) | 
					
						
							|  |  |  |                     .GetNpadCommunicationMode()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::SetTouchScreenConfiguration(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-09-10 10:09:22 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							| 
									
										
										
										
											2023-08-11 00:44:42 -06:00
										 |  |  |     const auto touchscreen_mode{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()}; | 
					
						
							| 
									
										
										
										
											2021-09-10 10:09:22 -05:00
										 |  |  |     const auto applet_resource_user_id{rp.Pop<u64>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, touchscreen_mode={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 touchscreen_mode.mode, applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  | void Hid::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2022-04-26 22:22:27 -05:00
										 |  |  |     IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |     struct Parameters { | 
					
						
							|  |  |  |         s32 unknown; | 
					
						
							|  |  |  |         INSERT_PADDING_WORDS_NOINIT(1); | 
					
						
							|  |  |  |         u64 applet_resource_user_id; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const auto parameters{rp.PopRaw<Parameters>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LOG_WARNING(Service_HID, "(STUBBED) called, unknown={}, applet_resource_user_id={}", | 
					
						
							|  |  |  |                 parameters.unknown, parameters.applet_resource_user_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							|  |  |  |     rb.Push(ResultSuccess); | 
					
						
							|  |  |  |     rb.Push(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  | class HidDbg final : public ServiceFramework<HidDbg> { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-11-26 15:19:08 -05:00
										 |  |  |     explicit HidDbg(Core::System& system_) : ServiceFramework{system_, "hid:dbg"} { | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |         // clang-format off
 | 
					
						
							|  |  |  |         static const FunctionInfo functions[] = { | 
					
						
							|  |  |  |             {0, nullptr, "DeactivateDebugPad"}, | 
					
						
							|  |  |  |             {1, nullptr, "SetDebugPadAutoPilotState"}, | 
					
						
							|  |  |  |             {2, nullptr, "UnsetDebugPadAutoPilotState"}, | 
					
						
							|  |  |  |             {10, nullptr, "DeactivateTouchScreen"}, | 
					
						
							|  |  |  |             {11, nullptr, "SetTouchScreenAutoPilotState"}, | 
					
						
							|  |  |  |             {12, nullptr, "UnsetTouchScreenAutoPilotState"}, | 
					
						
							| 
									
										
										
										
											2020-04-20 15:18:23 -04:00
										 |  |  |             {13, nullptr, "GetTouchScreenConfiguration"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |             {14, nullptr, "ProcessTouchScreenAutoTune"}, | 
					
						
							| 
									
										
										
										
											2021-09-26 19:45:47 -05:00
										 |  |  |             {15, nullptr, "ForceStopTouchScreenManagement"}, | 
					
						
							|  |  |  |             {16, nullptr, "ForceRestartTouchScreenManagement"}, | 
					
						
							|  |  |  |             {17, nullptr, "IsTouchScreenManaged"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {20, nullptr, "DeactivateMouse"}, | 
					
						
							|  |  |  |             {21, nullptr, "SetMouseAutoPilotState"}, | 
					
						
							|  |  |  |             {22, nullptr, "UnsetMouseAutoPilotState"}, | 
					
						
							| 
									
										
										
										
											2023-02-24 12:52:32 -06:00
										 |  |  |             {25, nullptr, "SetDebugMouseAutoPilotState"}, | 
					
						
							|  |  |  |             {26, nullptr, "UnsetDebugMouseAutoPilotState"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {30, nullptr, "DeactivateKeyboard"}, | 
					
						
							|  |  |  |             {31, nullptr, "SetKeyboardAutoPilotState"}, | 
					
						
							|  |  |  |             {32, nullptr, "UnsetKeyboardAutoPilotState"}, | 
					
						
							|  |  |  |             {50, nullptr, "DeactivateXpad"}, | 
					
						
							|  |  |  |             {51, nullptr, "SetXpadAutoPilotState"}, | 
					
						
							|  |  |  |             {52, nullptr, "UnsetXpadAutoPilotState"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |             {53, nullptr, "DeactivateJoyXpad"}, | 
					
						
							| 
									
										
										
										
											2020-04-20 15:18:23 -04:00
										 |  |  |             {60, nullptr, "ClearNpadSystemCommonPolicy"}, | 
					
						
							|  |  |  |             {61, nullptr, "DeactivateNpad"}, | 
					
						
							|  |  |  |             {62, nullptr, "ForceDisconnectNpad"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {91, nullptr, "DeactivateGesture"}, | 
					
						
							|  |  |  |             {110, nullptr, "DeactivateHomeButton"}, | 
					
						
							|  |  |  |             {111, nullptr, "SetHomeButtonAutoPilotState"}, | 
					
						
							|  |  |  |             {112, nullptr, "UnsetHomeButtonAutoPilotState"}, | 
					
						
							|  |  |  |             {120, nullptr, "DeactivateSleepButton"}, | 
					
						
							|  |  |  |             {121, nullptr, "SetSleepButtonAutoPilotState"}, | 
					
						
							|  |  |  |             {122, nullptr, "UnsetSleepButtonAutoPilotState"}, | 
					
						
							|  |  |  |             {123, nullptr, "DeactivateInputDetector"}, | 
					
						
							|  |  |  |             {130, nullptr, "DeactivateCaptureButton"}, | 
					
						
							|  |  |  |             {131, nullptr, "SetCaptureButtonAutoPilotState"}, | 
					
						
							|  |  |  |             {132, nullptr, "UnsetCaptureButtonAutoPilotState"}, | 
					
						
							|  |  |  |             {133, nullptr, "SetShiftAccelerometerCalibrationValue"}, | 
					
						
							|  |  |  |             {134, nullptr, "GetShiftAccelerometerCalibrationValue"}, | 
					
						
							|  |  |  |             {135, nullptr, "SetShiftGyroscopeCalibrationValue"}, | 
					
						
							|  |  |  |             {136, nullptr, "GetShiftGyroscopeCalibrationValue"}, | 
					
						
							|  |  |  |             {140, nullptr, "DeactivateConsoleSixAxisSensor"}, | 
					
						
							|  |  |  |             {141, nullptr, "GetConsoleSixAxisSensorSamplingFrequency"}, | 
					
						
							|  |  |  |             {142, nullptr, "DeactivateSevenSixAxisSensor"}, | 
					
						
							| 
									
										
										
										
											2018-10-19 03:57:14 -04:00
										 |  |  |             {143, nullptr, "GetConsoleSixAxisSensorCountStates"}, | 
					
						
							| 
									
										
										
										
											2020-04-20 15:18:23 -04:00
										 |  |  |             {144, nullptr, "GetAccelerometerFsr"}, | 
					
						
							|  |  |  |             {145, nullptr, "SetAccelerometerFsr"}, | 
					
						
							|  |  |  |             {146, nullptr, "GetAccelerometerOdr"}, | 
					
						
							|  |  |  |             {147, nullptr, "SetAccelerometerOdr"}, | 
					
						
							|  |  |  |             {148, nullptr, "GetGyroscopeFsr"}, | 
					
						
							|  |  |  |             {149, nullptr, "SetGyroscopeFsr"}, | 
					
						
							|  |  |  |             {150, nullptr, "GetGyroscopeOdr"}, | 
					
						
							|  |  |  |             {151, nullptr, "SetGyroscopeOdr"}, | 
					
						
							|  |  |  |             {152, nullptr, "GetWhoAmI"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {201, nullptr, "ActivateFirmwareUpdate"}, | 
					
						
							|  |  |  |             {202, nullptr, "DeactivateFirmwareUpdate"}, | 
					
						
							|  |  |  |             {203, nullptr, "StartFirmwareUpdate"}, | 
					
						
							|  |  |  |             {204, nullptr, "GetFirmwareUpdateStage"}, | 
					
						
							|  |  |  |             {205, nullptr, "GetFirmwareVersion"}, | 
					
						
							|  |  |  |             {206, nullptr, "GetDestinationFirmwareVersion"}, | 
					
						
							|  |  |  |             {207, nullptr, "DiscardFirmwareInfoCacheForRevert"}, | 
					
						
							|  |  |  |             {208, nullptr, "StartFirmwareUpdateForRevert"}, | 
					
						
							|  |  |  |             {209, nullptr, "GetAvailableFirmwareVersionForRevert"}, | 
					
						
							|  |  |  |             {210, nullptr, "IsFirmwareUpdatingDevice"}, | 
					
						
							| 
									
										
										
										
											2018-10-19 03:57:14 -04:00
										 |  |  |             {211, nullptr, "StartFirmwareUpdateIndividual"}, | 
					
						
							|  |  |  |             {215, nullptr, "SetUsbFirmwareForceUpdateEnabled"}, | 
					
						
							|  |  |  |             {216, nullptr, "SetAllKuinaDevicesToFirmwareUpdateMode"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {221, nullptr, "UpdateControllerColor"}, | 
					
						
							|  |  |  |             {222, nullptr, "ConnectUsbPadsAsync"}, | 
					
						
							|  |  |  |             {223, nullptr, "DisconnectUsbPadsAsync"}, | 
					
						
							|  |  |  |             {224, nullptr, "UpdateDesignInfo"}, | 
					
						
							|  |  |  |             {225, nullptr, "GetUniquePadDriverState"}, | 
					
						
							|  |  |  |             {226, nullptr, "GetSixAxisSensorDriverStates"}, | 
					
						
							| 
									
										
										
										
											2018-10-19 03:57:14 -04:00
										 |  |  |             {227, nullptr, "GetRxPacketHistory"}, | 
					
						
							|  |  |  |             {228, nullptr, "AcquireOperationEventHandle"}, | 
					
						
							|  |  |  |             {229, nullptr, "ReadSerialFlash"}, | 
					
						
							|  |  |  |             {230, nullptr, "WriteSerialFlash"}, | 
					
						
							|  |  |  |             {231, nullptr, "GetOperationResult"}, | 
					
						
							|  |  |  |             {232, nullptr, "EnableShipmentMode"}, | 
					
						
							|  |  |  |             {233, nullptr, "ClearPairingInfo"}, | 
					
						
							|  |  |  |             {234, nullptr, "GetUniquePadDeviceTypeSetInternal"}, | 
					
						
							| 
									
										
										
										
											2019-04-10 14:48:37 -04:00
										 |  |  |             {235, nullptr, "EnableAnalogStickPower"}, | 
					
						
							| 
									
										
										
										
											2020-04-20 15:18:23 -04:00
										 |  |  |             {236, nullptr, "RequestKuinaUartClockCal"}, | 
					
						
							|  |  |  |             {237, nullptr, "GetKuinaUartClockCal"}, | 
					
						
							|  |  |  |             {238, nullptr, "SetKuinaUartClockTrim"}, | 
					
						
							|  |  |  |             {239, nullptr, "KuinaLoopbackTest"}, | 
					
						
							|  |  |  |             {240, nullptr, "RequestBatteryVoltage"}, | 
					
						
							|  |  |  |             {241, nullptr, "GetBatteryVoltage"}, | 
					
						
							|  |  |  |             {242, nullptr, "GetUniquePadPowerInfo"}, | 
					
						
							|  |  |  |             {243, nullptr, "RebootUniquePad"}, | 
					
						
							|  |  |  |             {244, nullptr, "RequestKuinaFirmwareVersion"}, | 
					
						
							|  |  |  |             {245, nullptr, "GetKuinaFirmwareVersion"}, | 
					
						
							|  |  |  |             {246, nullptr, "GetVidPid"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |             {247, nullptr, "GetAnalogStickCalibrationValue"}, | 
					
						
							|  |  |  |             {248, nullptr, "GetUniquePadIdsFull"}, | 
					
						
							|  |  |  |             {249, nullptr, "ConnectUniquePad"}, | 
					
						
							|  |  |  |             {250, nullptr, "IsVirtual"}, | 
					
						
							|  |  |  |             {251, nullptr, "GetAnalogStickModuleParam"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {301, nullptr, "GetAbstractedPadHandles"}, | 
					
						
							|  |  |  |             {302, nullptr, "GetAbstractedPadState"}, | 
					
						
							|  |  |  |             {303, nullptr, "GetAbstractedPadsState"}, | 
					
						
							|  |  |  |             {321, nullptr, "SetAutoPilotVirtualPadState"}, | 
					
						
							|  |  |  |             {322, nullptr, "UnsetAutoPilotVirtualPadState"}, | 
					
						
							|  |  |  |             {323, nullptr, "UnsetAllAutoPilotVirtualPadState"}, | 
					
						
							| 
									
										
										
										
											2019-04-10 14:48:37 -04:00
										 |  |  |             {324, nullptr, "AttachHdlsWorkBuffer"}, | 
					
						
							|  |  |  |             {325, nullptr, "ReleaseHdlsWorkBuffer"}, | 
					
						
							|  |  |  |             {326, nullptr, "DumpHdlsNpadAssignmentState"}, | 
					
						
							|  |  |  |             {327, nullptr, "DumpHdlsStates"}, | 
					
						
							|  |  |  |             {328, nullptr, "ApplyHdlsNpadAssignmentState"}, | 
					
						
							|  |  |  |             {329, nullptr, "ApplyHdlsStateList"}, | 
					
						
							|  |  |  |             {330, nullptr, "AttachHdlsVirtualDevice"}, | 
					
						
							|  |  |  |             {331, nullptr, "DetachHdlsVirtualDevice"}, | 
					
						
							|  |  |  |             {332, nullptr, "SetHdlsState"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {350, nullptr, "AddRegisteredDevice"}, | 
					
						
							| 
									
										
										
										
											2018-10-19 03:57:14 -04:00
										 |  |  |             {400, nullptr, "DisableExternalMcuOnNxDevice"}, | 
					
						
							|  |  |  |             {401, nullptr, "DisableRailDeviceFiltering"}, | 
					
						
							| 
									
										
										
										
											2020-04-20 15:18:23 -04:00
										 |  |  |             {402, nullptr, "EnableWiredPairing"}, | 
					
						
							|  |  |  |             {403, nullptr, "EnableShipmentModeAutoClear"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |             {404, nullptr, "SetRailEnabled"}, | 
					
						
							| 
									
										
										
										
											2020-04-20 15:18:23 -04:00
										 |  |  |             {500, nullptr, "SetFactoryInt"}, | 
					
						
							|  |  |  |             {501, nullptr, "IsFactoryBootEnabled"}, | 
					
						
							|  |  |  |             {550, nullptr, "SetAnalogStickModelDataTemporarily"}, | 
					
						
							|  |  |  |             {551, nullptr, "GetAnalogStickModelData"}, | 
					
						
							|  |  |  |             {552, nullptr, "ResetAnalogStickModelData"}, | 
					
						
							|  |  |  |             {600, nullptr, "ConvertPadState"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |             {650, nullptr, "AddButtonPlayData"}, | 
					
						
							|  |  |  |             {651, nullptr, "StartButtonPlayData"}, | 
					
						
							|  |  |  |             {652, nullptr, "StopButtonPlayData"}, | 
					
						
							| 
									
										
										
										
											2020-04-20 15:18:23 -04:00
										 |  |  |             {2000, nullptr, "DeactivateDigitizer"}, | 
					
						
							|  |  |  |             {2001, nullptr, "SetDigitizerAutoPilotState"}, | 
					
						
							|  |  |  |             {2002, nullptr, "UnsetDigitizerAutoPilotState"}, | 
					
						
							| 
									
										
										
										
											2023-02-24 12:52:32 -06:00
										 |  |  |             {2002, nullptr, "ReloadFirmwareDebugSettings"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |         }; | 
					
						
							|  |  |  |         // clang-format on
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         RegisterHandlers(functions); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class HidSys final : public ServiceFramework<HidSys> { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2023-08-11 00:44:42 -06:00
										 |  |  |     explicit HidSys(Core::System& system_) | 
					
						
							|  |  |  |         : ServiceFramework{system_, "hid:sys"}, service_context{system_, "hid:sys"} { | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |         // clang-format off
 | 
					
						
							|  |  |  |         static const FunctionInfo functions[] = { | 
					
						
							|  |  |  |             {31, nullptr, "SendKeyboardLockKeyEvent"}, | 
					
						
							|  |  |  |             {101, nullptr, "AcquireHomeButtonEventHandle"}, | 
					
						
							|  |  |  |             {111, nullptr, "ActivateHomeButton"}, | 
					
						
							|  |  |  |             {121, nullptr, "AcquireSleepButtonEventHandle"}, | 
					
						
							|  |  |  |             {131, nullptr, "ActivateSleepButton"}, | 
					
						
							|  |  |  |             {141, nullptr, "AcquireCaptureButtonEventHandle"}, | 
					
						
							|  |  |  |             {151, nullptr, "ActivateCaptureButton"}, | 
					
						
							| 
									
										
										
										
											2019-04-10 14:48:37 -04:00
										 |  |  |             {161, nullptr, "GetPlatformConfig"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {210, nullptr, "AcquireNfcDeviceUpdateEventHandle"}, | 
					
						
							|  |  |  |             {211, nullptr, "GetNpadsWithNfc"}, | 
					
						
							|  |  |  |             {212, nullptr, "AcquireNfcActivateEventHandle"}, | 
					
						
							|  |  |  |             {213, nullptr, "ActivateNfc"}, | 
					
						
							|  |  |  |             {214, nullptr, "GetXcdHandleForNpadWithNfc"}, | 
					
						
							|  |  |  |             {215, nullptr, "IsNfcActivated"}, | 
					
						
							|  |  |  |             {230, nullptr, "AcquireIrSensorEventHandle"}, | 
					
						
							|  |  |  |             {231, nullptr, "ActivateIrSensor"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |             {232, nullptr, "GetIrSensorState"}, | 
					
						
							|  |  |  |             {233, nullptr, "GetXcdHandleForNpadWithIrSensor"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {301, nullptr, "ActivateNpadSystem"}, | 
					
						
							| 
									
										
										
										
											2021-05-24 15:07:47 +10:00
										 |  |  |             {303, &HidSys::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {304, nullptr, "EnableAssigningSingleOnSlSrPress"}, | 
					
						
							|  |  |  |             {305, nullptr, "DisableAssigningSingleOnSlSrPress"}, | 
					
						
							| 
									
										
										
										
											2023-08-11 00:44:42 -06:00
										 |  |  |             {306, &HidSys::GetLastActiveNpad, "GetLastActiveNpad"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {307, nullptr, "GetNpadSystemExtStyle"}, | 
					
						
							|  |  |  |             {308, nullptr, "ApplyNpadSystemCommonPolicyFull"}, | 
					
						
							|  |  |  |             {309, nullptr, "GetNpadFullKeyGripColor"}, | 
					
						
							| 
									
										
										
										
											2018-10-19 03:57:14 -04:00
										 |  |  |             {310, nullptr, "GetMaskedSupportedNpadStyleSet"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {311, nullptr, "SetNpadPlayerLedBlinkingDevice"}, | 
					
						
							| 
									
										
										
										
											2018-10-19 03:57:14 -04:00
										 |  |  |             {312, nullptr, "SetSupportedNpadStyleSetAll"}, | 
					
						
							| 
									
										
										
										
											2019-11-12 08:54:58 -05:00
										 |  |  |             {313, nullptr, "GetNpadCaptureButtonAssignment"}, | 
					
						
							|  |  |  |             {314, nullptr, "GetAppletFooterUiType"}, | 
					
						
							|  |  |  |             {315, nullptr, "GetAppletDetailedUiType"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |             {316, nullptr, "GetNpadInterfaceType"}, | 
					
						
							|  |  |  |             {317, nullptr, "GetNpadLeftRightInterfaceType"}, | 
					
						
							|  |  |  |             {318, nullptr, "HasBattery"}, | 
					
						
							|  |  |  |             {319, nullptr, "HasLeftRightBattery"}, | 
					
						
							| 
									
										
										
										
											2021-11-25 20:12:47 -06:00
										 |  |  |             {321, &HidSys::GetUniquePadsFromNpad, "GetUniquePadsFromNpad"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {322, nullptr, "GetIrSensorState"}, | 
					
						
							|  |  |  |             {323, nullptr, "GetXcdHandleForNpadWithIrSensor"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |             {324, nullptr, "GetUniquePadButtonSet"}, | 
					
						
							|  |  |  |             {325, nullptr, "GetUniquePadColor"}, | 
					
						
							|  |  |  |             {326, nullptr, "GetUniquePadAppletDetailedUiType"}, | 
					
						
							| 
									
										
										
										
											2022-08-21 23:31:11 -05:00
										 |  |  |             {327, nullptr, "GetAbstractedPadIdDataFromNpad"}, | 
					
						
							|  |  |  |             {328, nullptr, "AttachAbstractedPadToNpad"}, | 
					
						
							|  |  |  |             {329, nullptr, "DetachAbstractedPadAll"}, | 
					
						
							|  |  |  |             {330, nullptr, "CheckAbstractedPadConnection"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {500, nullptr, "SetAppletResourceUserId"}, | 
					
						
							|  |  |  |             {501, nullptr, "RegisterAppletResourceUserId"}, | 
					
						
							|  |  |  |             {502, nullptr, "UnregisterAppletResourceUserId"}, | 
					
						
							|  |  |  |             {503, nullptr, "EnableAppletToGetInput"}, | 
					
						
							|  |  |  |             {504, nullptr, "SetAruidValidForVibration"}, | 
					
						
							|  |  |  |             {505, nullptr, "EnableAppletToGetSixAxisSensor"}, | 
					
						
							| 
									
										
										
										
											2022-08-21 23:31:11 -05:00
										 |  |  |             {506, nullptr, "EnableAppletToGetPadInput"}, | 
					
						
							|  |  |  |             {507, nullptr, "EnableAppletToGetTouchScreen"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {510, nullptr, "SetVibrationMasterVolume"}, | 
					
						
							|  |  |  |             {511, nullptr, "GetVibrationMasterVolume"}, | 
					
						
							|  |  |  |             {512, nullptr, "BeginPermitVibrationSession"}, | 
					
						
							|  |  |  |             {513, nullptr, "EndPermitVibrationSession"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |             {514, nullptr, "Unknown514"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {520, nullptr, "EnableHandheldHids"}, | 
					
						
							|  |  |  |             {521, nullptr, "DisableHandheldHids"}, | 
					
						
							| 
									
										
										
										
											2019-11-12 08:54:58 -05:00
										 |  |  |             {522, nullptr, "SetJoyConRailEnabled"}, | 
					
						
							|  |  |  |             {523, nullptr, "IsJoyConRailEnabled"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |             {524, nullptr, "IsHandheldHidsEnabled"}, | 
					
						
							|  |  |  |             {525, nullptr, "IsJoyConAttachedOnAllRail"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {540, nullptr, "AcquirePlayReportControllerUsageUpdateEvent"}, | 
					
						
							|  |  |  |             {541, nullptr, "GetPlayReportControllerUsages"}, | 
					
						
							|  |  |  |             {542, nullptr, "AcquirePlayReportRegisteredDeviceUpdateEvent"}, | 
					
						
							|  |  |  |             {543, nullptr, "GetRegisteredDevicesOld"}, | 
					
						
							|  |  |  |             {544, nullptr, "AcquireConnectionTriggerTimeoutEvent"}, | 
					
						
							|  |  |  |             {545, nullptr, "SendConnectionTrigger"}, | 
					
						
							|  |  |  |             {546, nullptr, "AcquireDeviceRegisteredEventForControllerSupport"}, | 
					
						
							|  |  |  |             {547, nullptr, "GetAllowedBluetoothLinksCount"}, | 
					
						
							|  |  |  |             {548, nullptr, "GetRegisteredDevices"}, | 
					
						
							| 
									
										
										
										
											2018-10-19 03:57:14 -04:00
										 |  |  |             {549, nullptr, "GetConnectableRegisteredDevices"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {700, nullptr, "ActivateUniquePad"}, | 
					
						
							|  |  |  |             {702, nullptr, "AcquireUniquePadConnectionEventHandle"}, | 
					
						
							|  |  |  |             {703, nullptr, "GetUniquePadIds"}, | 
					
						
							| 
									
										
										
										
											2023-08-11 00:44:42 -06:00
										 |  |  |             {751, &HidSys::AcquireJoyDetachOnBluetoothOffEventHandle, "AcquireJoyDetachOnBluetoothOffEventHandle"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {800, nullptr, "ListSixAxisSensorHandles"}, | 
					
						
							|  |  |  |             {801, nullptr, "IsSixAxisSensorUserCalibrationSupported"}, | 
					
						
							|  |  |  |             {802, nullptr, "ResetSixAxisSensorCalibrationValues"}, | 
					
						
							|  |  |  |             {803, nullptr, "StartSixAxisSensorUserCalibration"}, | 
					
						
							|  |  |  |             {804, nullptr, "CancelSixAxisSensorUserCalibration"}, | 
					
						
							|  |  |  |             {805, nullptr, "GetUniquePadBluetoothAddress"}, | 
					
						
							|  |  |  |             {806, nullptr, "DisconnectUniquePad"}, | 
					
						
							|  |  |  |             {807, nullptr, "GetUniquePadType"}, | 
					
						
							|  |  |  |             {808, nullptr, "GetUniquePadInterface"}, | 
					
						
							|  |  |  |             {809, nullptr, "GetUniquePadSerialNumber"}, | 
					
						
							|  |  |  |             {810, nullptr, "GetUniquePadControllerNumber"}, | 
					
						
							|  |  |  |             {811, nullptr, "GetSixAxisSensorUserCalibrationStage"}, | 
					
						
							| 
									
										
										
										
											2019-11-12 08:54:58 -05:00
										 |  |  |             {812, nullptr, "GetConsoleUniqueSixAxisSensorHandle"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {821, nullptr, "StartAnalogStickManualCalibration"}, | 
					
						
							|  |  |  |             {822, nullptr, "RetryCurrentAnalogStickManualCalibrationStage"}, | 
					
						
							|  |  |  |             {823, nullptr, "CancelAnalogStickManualCalibration"}, | 
					
						
							|  |  |  |             {824, nullptr, "ResetAnalogStickManualCalibration"}, | 
					
						
							|  |  |  |             {825, nullptr, "GetAnalogStickState"}, | 
					
						
							|  |  |  |             {826, nullptr, "GetAnalogStickManualCalibrationStage"}, | 
					
						
							|  |  |  |             {827, nullptr, "IsAnalogStickButtonPressed"}, | 
					
						
							|  |  |  |             {828, nullptr, "IsAnalogStickInReleasePosition"}, | 
					
						
							|  |  |  |             {829, nullptr, "IsAnalogStickInCircumference"}, | 
					
						
							| 
									
										
										
										
											2019-04-10 14:48:37 -04:00
										 |  |  |             {830, nullptr, "SetNotificationLedPattern"}, | 
					
						
							| 
									
										
										
										
											2019-11-12 08:54:58 -05:00
										 |  |  |             {831, nullptr, "SetNotificationLedPatternWithTimeout"}, | 
					
						
							|  |  |  |             {832, nullptr, "PrepareHidsForNotificationWake"}, | 
					
						
							| 
									
										
										
										
											2023-08-11 00:44:42 -06:00
										 |  |  |             {850, &HidSys::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {851, nullptr, "EnableUsbFullKeyController"}, | 
					
						
							|  |  |  |             {852, nullptr, "IsUsbConnected"}, | 
					
						
							| 
									
										
										
										
											2018-10-19 03:57:14 -04:00
										 |  |  |             {870, nullptr, "IsHandheldButtonPressedOnConsoleMode"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |             {900, nullptr, "ActivateInputDetector"}, | 
					
						
							|  |  |  |             {901, nullptr, "NotifyInputDetector"}, | 
					
						
							|  |  |  |             {1000, nullptr, "InitializeFirmwareUpdate"}, | 
					
						
							|  |  |  |             {1001, nullptr, "GetFirmwareVersion"}, | 
					
						
							|  |  |  |             {1002, nullptr, "GetAvailableFirmwareVersion"}, | 
					
						
							|  |  |  |             {1003, nullptr, "IsFirmwareUpdateAvailable"}, | 
					
						
							|  |  |  |             {1004, nullptr, "CheckFirmwareUpdateRequired"}, | 
					
						
							|  |  |  |             {1005, nullptr, "StartFirmwareUpdate"}, | 
					
						
							|  |  |  |             {1006, nullptr, "AbortFirmwareUpdate"}, | 
					
						
							|  |  |  |             {1007, nullptr, "GetFirmwareUpdateState"}, | 
					
						
							|  |  |  |             {1008, nullptr, "ActivateAudioControl"}, | 
					
						
							|  |  |  |             {1009, nullptr, "AcquireAudioControlEventHandle"}, | 
					
						
							|  |  |  |             {1010, nullptr, "GetAudioControlStates"}, | 
					
						
							|  |  |  |             {1011, nullptr, "DeactivateAudioControl"}, | 
					
						
							|  |  |  |             {1050, nullptr, "IsSixAxisSensorAccurateUserCalibrationSupported"}, | 
					
						
							|  |  |  |             {1051, nullptr, "StartSixAxisSensorAccurateUserCalibration"}, | 
					
						
							|  |  |  |             {1052, nullptr, "CancelSixAxisSensorAccurateUserCalibration"}, | 
					
						
							|  |  |  |             {1053, nullptr, "GetSixAxisSensorAccurateUserCalibrationState"}, | 
					
						
							|  |  |  |             {1100, nullptr, "GetHidbusSystemServiceObject"}, | 
					
						
							| 
									
										
										
										
											2018-10-19 03:57:14 -04:00
										 |  |  |             {1120, nullptr, "SetFirmwareHotfixUpdateSkipEnabled"}, | 
					
						
							|  |  |  |             {1130, nullptr, "InitializeUsbFirmwareUpdate"}, | 
					
						
							|  |  |  |             {1131, nullptr, "FinalizeUsbFirmwareUpdate"}, | 
					
						
							|  |  |  |             {1132, nullptr, "CheckUsbFirmwareUpdateRequired"}, | 
					
						
							|  |  |  |             {1133, nullptr, "StartUsbFirmwareUpdate"}, | 
					
						
							|  |  |  |             {1134, nullptr, "GetUsbFirmwareUpdateState"}, | 
					
						
							| 
									
										
										
										
											2019-11-12 08:54:58 -05:00
										 |  |  |             {1150, nullptr, "SetTouchScreenMagnification"}, | 
					
						
							|  |  |  |             {1151, nullptr, "GetTouchScreenFirmwareVersion"}, | 
					
						
							|  |  |  |             {1152, nullptr, "SetTouchScreenDefaultConfiguration"}, | 
					
						
							| 
									
										
										
										
											2023-08-11 00:44:42 -06:00
										 |  |  |             {1153, &HidSys::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"}, | 
					
						
							| 
									
										
										
										
											2019-11-12 08:54:58 -05:00
										 |  |  |             {1154, nullptr, "IsFirmwareAvailableForNotification"}, | 
					
						
							|  |  |  |             {1155, nullptr, "SetForceHandheldStyleVibration"}, | 
					
						
							|  |  |  |             {1156, nullptr, "SendConnectionTriggerWithoutTimeoutEvent"}, | 
					
						
							| 
									
										
										
										
											2021-04-07 01:10:24 -05:00
										 |  |  |             {1157, nullptr, "CancelConnectionTrigger"}, | 
					
						
							|  |  |  |             {1200, nullptr, "IsButtonConfigSupported"}, | 
					
						
							|  |  |  |             {1201, nullptr, "IsButtonConfigEmbeddedSupported"}, | 
					
						
							|  |  |  |             {1202, nullptr, "DeleteButtonConfig"}, | 
					
						
							|  |  |  |             {1203, nullptr, "DeleteButtonConfigEmbedded"}, | 
					
						
							|  |  |  |             {1204, nullptr, "SetButtonConfigEnabled"}, | 
					
						
							|  |  |  |             {1205, nullptr, "SetButtonConfigEmbeddedEnabled"}, | 
					
						
							|  |  |  |             {1206, nullptr, "IsButtonConfigEnabled"}, | 
					
						
							|  |  |  |             {1207, nullptr, "IsButtonConfigEmbeddedEnabled"}, | 
					
						
							|  |  |  |             {1208, nullptr, "SetButtonConfigEmbedded"}, | 
					
						
							|  |  |  |             {1209, nullptr, "SetButtonConfigFull"}, | 
					
						
							|  |  |  |             {1210, nullptr, "SetButtonConfigLeft"}, | 
					
						
							|  |  |  |             {1211, nullptr, "SetButtonConfigRight"}, | 
					
						
							|  |  |  |             {1212, nullptr, "GetButtonConfigEmbedded"}, | 
					
						
							|  |  |  |             {1213, nullptr, "GetButtonConfigFull"}, | 
					
						
							|  |  |  |             {1214, nullptr, "GetButtonConfigLeft"}, | 
					
						
							|  |  |  |             {1215, nullptr, "GetButtonConfigRight"}, | 
					
						
							|  |  |  |             {1250, nullptr, "IsCustomButtonConfigSupported"}, | 
					
						
							|  |  |  |             {1251, nullptr, "IsDefaultButtonConfigEmbedded"}, | 
					
						
							|  |  |  |             {1252, nullptr, "IsDefaultButtonConfigFull"}, | 
					
						
							|  |  |  |             {1253, nullptr, "IsDefaultButtonConfigLeft"}, | 
					
						
							|  |  |  |             {1254, nullptr, "IsDefaultButtonConfigRight"}, | 
					
						
							|  |  |  |             {1255, nullptr, "IsButtonConfigStorageEmbeddedEmpty"}, | 
					
						
							|  |  |  |             {1256, nullptr, "IsButtonConfigStorageFullEmpty"}, | 
					
						
							|  |  |  |             {1257, nullptr, "IsButtonConfigStorageLeftEmpty"}, | 
					
						
							|  |  |  |             {1258, nullptr, "IsButtonConfigStorageRightEmpty"}, | 
					
						
							|  |  |  |             {1259, nullptr, "GetButtonConfigStorageEmbeddedDeprecated"}, | 
					
						
							|  |  |  |             {1260, nullptr, "GetButtonConfigStorageFullDeprecated"}, | 
					
						
							|  |  |  |             {1261, nullptr, "GetButtonConfigStorageLeftDeprecated"}, | 
					
						
							|  |  |  |             {1262, nullptr, "GetButtonConfigStorageRightDeprecated"}, | 
					
						
							|  |  |  |             {1263, nullptr, "SetButtonConfigStorageEmbeddedDeprecated"}, | 
					
						
							|  |  |  |             {1264, nullptr, "SetButtonConfigStorageFullDeprecated"}, | 
					
						
							|  |  |  |             {1265, nullptr, "SetButtonConfigStorageLeftDeprecated"}, | 
					
						
							|  |  |  |             {1266, nullptr, "SetButtonConfigStorageRightDeprecated"}, | 
					
						
							|  |  |  |             {1267, nullptr, "DeleteButtonConfigStorageEmbedded"}, | 
					
						
							|  |  |  |             {1268, nullptr, "DeleteButtonConfigStorageFull"}, | 
					
						
							|  |  |  |             {1269, nullptr, "DeleteButtonConfigStorageLeft"}, | 
					
						
							|  |  |  |             {1270, nullptr, "DeleteButtonConfigStorageRight"}, | 
					
						
							|  |  |  |             {1271, nullptr, "IsUsingCustomButtonConfig"}, | 
					
						
							|  |  |  |             {1272, nullptr, "IsAnyCustomButtonConfigEnabled"}, | 
					
						
							|  |  |  |             {1273, nullptr, "SetAllCustomButtonConfigEnabled"}, | 
					
						
							|  |  |  |             {1274, nullptr, "SetDefaultButtonConfig"}, | 
					
						
							|  |  |  |             {1275, nullptr, "SetAllDefaultButtonConfig"}, | 
					
						
							|  |  |  |             {1276, nullptr, "SetHidButtonConfigEmbedded"}, | 
					
						
							|  |  |  |             {1277, nullptr, "SetHidButtonConfigFull"}, | 
					
						
							|  |  |  |             {1278, nullptr, "SetHidButtonConfigLeft"}, | 
					
						
							|  |  |  |             {1279, nullptr, "SetHidButtonConfigRight"}, | 
					
						
							|  |  |  |             {1280, nullptr, "GetHidButtonConfigEmbedded"}, | 
					
						
							|  |  |  |             {1281, nullptr, "GetHidButtonConfigFull"}, | 
					
						
							|  |  |  |             {1282, nullptr, "GetHidButtonConfigLeft"}, | 
					
						
							|  |  |  |             {1283, nullptr, "GetHidButtonConfigRight"}, | 
					
						
							|  |  |  |             {1284, nullptr, "GetButtonConfigStorageEmbedded"}, | 
					
						
							|  |  |  |             {1285, nullptr, "GetButtonConfigStorageFull"}, | 
					
						
							|  |  |  |             {1286, nullptr, "GetButtonConfigStorageLeft"}, | 
					
						
							|  |  |  |             {1287, nullptr, "GetButtonConfigStorageRight"}, | 
					
						
							|  |  |  |             {1288, nullptr, "SetButtonConfigStorageEmbedded"}, | 
					
						
							|  |  |  |             {1289, nullptr, "SetButtonConfigStorageFull"}, | 
					
						
							|  |  |  |             {1290, nullptr, "DeleteButtonConfigStorageRight"}, | 
					
						
							|  |  |  |             {1291, nullptr, "DeleteButtonConfigStorageRight"}, | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |         }; | 
					
						
							|  |  |  |         // clang-format on
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         RegisterHandlers(functions); | 
					
						
							| 
									
										
										
										
											2023-08-11 00:44:42 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |         joy_detach_event = service_context.CreateEvent("HidSys::JoyDetachEvent"); | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-05-24 15:07:47 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  |     void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-05-24 15:07:47 +10:00
										 |  |  |         // We already do this for homebrew so we can just stub it out
 | 
					
						
							|  |  |  |         LOG_WARNING(Service_HID, "called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         IPC::ResponseBuilder rb{ctx, 2}; | 
					
						
							| 
									
										
										
										
											2021-05-21 01:05:04 -04:00
										 |  |  |         rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2021-05-24 15:07:47 +10:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-11-25 20:12:47 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-11 00:44:42 -06:00
										 |  |  |     void GetLastActiveNpad(HLERequestContext& ctx) { | 
					
						
							|  |  |  |         LOG_DEBUG(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							|  |  |  |         rb.Push(ResultSuccess); | 
					
						
							|  |  |  |         rb.PushEnum(Core::HID::NpadIdType::Handheld); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-19 14:42:12 -05:00
										 |  |  |     void GetUniquePadsFromNpad(HLERequestContext& ctx) { | 
					
						
							| 
									
										
										
										
											2021-11-25 20:12:47 -06:00
										 |  |  |         IPC::RequestParser rp{ctx}; | 
					
						
							|  |  |  |         const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         LOG_WARNING(Service_HID, "(STUBBED) called, npad_id_type={}", npad_id_type); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-11 00:44:42 -06:00
										 |  |  |         const std::vector<Core::HID::UniquePadId> unique_pads{}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ctx.WriteBuffer(unique_pads); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-25 20:12:47 -06:00
										 |  |  |         IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							|  |  |  |         rb.Push(ResultSuccess); | 
					
						
							| 
									
										
										
										
											2023-08-11 00:44:42 -06:00
										 |  |  |         rb.Push(static_cast<u32>(unique_pads.size())); | 
					
						
							| 
									
										
										
										
											2021-11-25 20:12:47 -06:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-08-11 00:44:42 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     void AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx) { | 
					
						
							|  |  |  |         LOG_INFO(Service_AM, "called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         IPC::ResponseBuilder rb{ctx, 2, 1}; | 
					
						
							|  |  |  |         rb.Push(ResultSuccess); | 
					
						
							|  |  |  |         rb.PushCopyObjects(joy_detach_event->GetReadableEvent()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) { | 
					
						
							|  |  |  |         const bool is_enabled = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         LOG_WARNING(Service_HID, "(STUBBED) called, is_enabled={}", is_enabled); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         IPC::ResponseBuilder rb{ctx, 3}; | 
					
						
							|  |  |  |         rb.Push(ResultSuccess); | 
					
						
							|  |  |  |         rb.Push(is_enabled); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) { | 
					
						
							|  |  |  |         LOG_WARNING(Service_HID, "(STUBBED) called"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         Core::HID::TouchScreenConfigurationForNx touchscreen_config{ | 
					
						
							|  |  |  |             .mode = Core::HID::TouchScreenModeForNx::Finger, | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 && | 
					
						
							|  |  |  |             touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) { | 
					
						
							|  |  |  |             touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         IPC::ResponseBuilder rb{ctx, 6}; | 
					
						
							|  |  |  |         rb.Push(ResultSuccess); | 
					
						
							|  |  |  |         rb.PushRaw(touchscreen_config); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Kernel::KEvent* joy_detach_event; | 
					
						
							|  |  |  |     KernelHelpers::ServiceContext service_context; | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-18 16:26:48 -05:00
										 |  |  | void LoopProcess(Core::System& system) { | 
					
						
							|  |  |  |     auto server_manager = std::make_unique<ServerManager>(system); | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-18 16:26:48 -05:00
										 |  |  |     server_manager->RegisterNamedService("hid", std::make_shared<Hid>(system)); | 
					
						
							|  |  |  |     server_manager->RegisterNamedService("hidbus", std::make_shared<HidBus>(system)); | 
					
						
							|  |  |  |     server_manager->RegisterNamedService("hid:dbg", std::make_shared<HidDbg>(system)); | 
					
						
							|  |  |  |     server_manager->RegisterNamedService("hid:sys", std::make_shared<HidSys>(system)); | 
					
						
							| 
									
										
										
										
											2018-07-26 08:56:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-18 16:26:48 -05:00
										 |  |  |     server_manager->RegisterNamedService("irs", std::make_shared<Service::IRS::IRS>(system)); | 
					
						
							|  |  |  |     server_manager->RegisterNamedService("irs:sys", | 
					
						
							|  |  |  |                                          std::make_shared<Service::IRS::IRS_SYS>(system)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     server_manager->RegisterNamedService("xcd:sys", std::make_shared<XCD_SYS>(system)); | 
					
						
							|  |  |  |     system.RunServer(std::move(server_manager)); | 
					
						
							| 
									
										
										
										
											2018-01-14 21:24:50 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-19 21:41:44 -04:00
										 |  |  | } // namespace Service::HID
 |