summaryrefslogtreecommitdiff
path: root/src/core/hle/service/hid
diff options
context:
space:
mode:
authorGravatar Narr the Reg2023-11-20 16:53:33 -0600
committerGravatar GitHub2023-11-20 16:53:33 -0600
commit8da5bd27e9d4fe5e850700039d79f77e52ba6aea (patch)
treef7092ca45b92aa83ef636cc13f970cd3561ba93e /src/core/hle/service/hid
parentMerge pull request #12093 from t895/zip-intent (diff)
parentImplemented qlaunch version of the controller applet (diff)
downloadyuzu-8da5bd27e9d4fe5e850700039d79f77e52ba6aea.tar.gz
yuzu-8da5bd27e9d4fe5e850700039d79f77e52ba6aea.tar.xz
yuzu-8da5bd27e9d4fe5e850700039d79f77e52ba6aea.zip
Merge pull request #12011 from Macj0rdan/controller-applet
Implemented qlaunch version of the controller applet
Diffstat (limited to 'src/core/hle/service/hid')
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp16
-rw-r--r--src/core/hle/service/hid/controllers/npad.h72
-rw-r--r--src/core/hle/service/hid/hid_server.cpp4
-rw-r--r--src/core/hle/service/hid/hid_system_server.cpp293
-rw-r--r--src/core/hle/service/hid/hid_system_server.h23
5 files changed, 352 insertions, 56 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index d46bf917e..127af2b82 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -344,6 +344,7 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) {
344 controller.device->SetPollingMode(Core::HID::EmulatedDeviceIndex::AllDevices, 344 controller.device->SetPollingMode(Core::HID::EmulatedDeviceIndex::AllDevices,
345 Common::Input::PollingMode::Active); 345 Common::Input::PollingMode::Active);
346 } 346 }
347
347 SignalStyleSetChangedEvent(npad_id); 348 SignalStyleSetChangedEvent(npad_id);
348 WriteEmptyEntry(controller.shared_memory); 349 WriteEmptyEntry(controller.shared_memory);
349 hid_core.SetLastActiveController(npad_id); 350 hid_core.SetLastActiveController(npad_id);
@@ -1726,4 +1727,19 @@ const Controller_NPad::SixaxisParameters& Controller_NPad::GetSixaxisState(
1726 } 1727 }
1727} 1728}
1728 1729
1730Controller_NPad::AppletDetailedUiType Controller_NPad::GetAppletDetailedUiType(
1731 Core::HID::NpadIdType npad_id) {
1732
1733 auto controller = GetControllerFromNpadIdType(npad_id);
1734 auto shared_memory = controller.shared_memory;
1735 Service::HID::Controller_NPad::AppletFooterUiType applet_footer_type =
1736 shared_memory->applet_footer_type;
1737
1738 Controller_NPad::AppletDetailedUiType detailed_ui_type{
1739 .ui_variant = 0,
1740 .footer = applet_footer_type,
1741 };
1742 return detailed_ui_type;
1743}
1744
1729} // namespace Service::HID 1745} // namespace Service::HID
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index e23b4986c..cd93abdd1 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -78,6 +78,46 @@ public:
78 MaxActivationMode = 3, 78 MaxActivationMode = 3,
79 }; 79 };
80 80
81 // This is nn::hid::system::AppletFooterUiAttributesSet
82 struct AppletFooterUiAttributes {
83 INSERT_PADDING_BYTES(0x4);
84 };
85
86 // This is nn::hid::system::AppletFooterUiType
87 enum class AppletFooterUiType : u8 {
88 None = 0,
89 HandheldNone = 1,
90 HandheldJoyConLeftOnly = 2,
91 HandheldJoyConRightOnly = 3,
92 HandheldJoyConLeftJoyConRight = 4,
93 JoyDual = 5,
94 JoyDualLeftOnly = 6,
95 JoyDualRightOnly = 7,
96 JoyLeftHorizontal = 8,
97 JoyLeftVertical = 9,
98 JoyRightHorizontal = 10,
99 JoyRightVertical = 11,
100 SwitchProController = 12,
101 CompatibleProController = 13,
102 CompatibleJoyCon = 14,
103 LarkHvc1 = 15,
104 LarkHvc2 = 16,
105 LarkNesLeft = 17,
106 LarkNesRight = 18,
107 Lucia = 19,
108 Verification = 20,
109 Lagon = 21,
110 };
111
112 using AppletFooterUiVariant = u8;
113
114 // This is "nn::hid::system::AppletDetailedUiType".
115 struct AppletDetailedUiType {
116 AppletFooterUiVariant ui_variant;
117 INSERT_PADDING_BYTES(0x2);
118 AppletFooterUiType footer;
119 };
120 static_assert(sizeof(AppletDetailedUiType) == 0x4, "AppletDetailedUiType is an invalid size");
81 // This is nn::hid::NpadCommunicationMode 121 // This is nn::hid::NpadCommunicationMode
82 enum class NpadCommunicationMode : u64 { 122 enum class NpadCommunicationMode : u64 {
83 Mode_5ms = 0, 123 Mode_5ms = 0,
@@ -203,6 +243,7 @@ public:
203 static Result IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle); 243 static Result IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle);
204 static Result VerifyValidSixAxisSensorHandle( 244 static Result VerifyValidSixAxisSensorHandle(
205 const Core::HID::SixAxisSensorHandle& device_handle); 245 const Core::HID::SixAxisSensorHandle& device_handle);
246 AppletDetailedUiType GetAppletDetailedUiType(Core::HID::NpadIdType npad_id);
206 247
207private: 248private:
208 static constexpr std::size_t NPAD_COUNT = 10; 249 static constexpr std::size_t NPAD_COUNT = 10;
@@ -360,37 +401,6 @@ private:
360 static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18, 401 static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18,
361 "NfcXcdDeviceHandleStateImpl is an invalid size"); 402 "NfcXcdDeviceHandleStateImpl is an invalid size");
362 403
363 // This is nn::hid::system::AppletFooterUiAttributesSet
364 struct AppletFooterUiAttributes {
365 INSERT_PADDING_BYTES(0x4);
366 };
367
368 // This is nn::hid::system::AppletFooterUiType
369 enum class AppletFooterUiType : u8 {
370 None = 0,
371 HandheldNone = 1,
372 HandheldJoyConLeftOnly = 2,
373 HandheldJoyConRightOnly = 3,
374 HandheldJoyConLeftJoyConRight = 4,
375 JoyDual = 5,
376 JoyDualLeftOnly = 6,
377 JoyDualRightOnly = 7,
378 JoyLeftHorizontal = 8,
379 JoyLeftVertical = 9,
380 JoyRightHorizontal = 10,
381 JoyRightVertical = 11,
382 SwitchProController = 12,
383 CompatibleProController = 13,
384 CompatibleJoyCon = 14,
385 LarkHvc1 = 15,
386 LarkHvc2 = 16,
387 LarkNesLeft = 17,
388 LarkNesRight = 18,
389 Lucia = 19,
390 Verification = 20,
391 Lagon = 21,
392 };
393
394 // This is nn::hid::NpadLarkType 404 // This is nn::hid::NpadLarkType
395 enum class NpadLarkType : u32 { 405 enum class NpadLarkType : u32 {
396 Invalid, 406 Invalid,
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp
index 9094fdcc7..9caed6541 100644
--- a/src/core/hle/service/hid/hid_server.cpp
+++ b/src/core/hle/service/hid/hid_server.cpp
@@ -1222,8 +1222,8 @@ void IHidServer::SetNpadJoyAssignmentModeDual(HLERequestContext& ctx) {
1222 controller.SetNpadMode(new_npad_id, parameters.npad_id, {}, 1222 controller.SetNpadMode(new_npad_id, parameters.npad_id, {},
1223 Controller_NPad::NpadJoyAssignmentMode::Dual); 1223 Controller_NPad::NpadJoyAssignmentMode::Dual);
1224 1224
1225 LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, 1225 LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id,
1226 parameters.applet_resource_user_id); 1226 parameters.applet_resource_user_id); // Spams a lot when controller applet is open
1227 1227
1228 IPC::ResponseBuilder rb{ctx, 2}; 1228 IPC::ResponseBuilder rb{ctx, 2};
1229 rb.Push(ResultSuccess); 1229 rb.Push(ResultSuccess);
diff --git a/src/core/hle/service/hid/hid_system_server.cpp b/src/core/hle/service/hid/hid_system_server.cpp
index 83cfadada..6f1902ee5 100644
--- a/src/core/hle/service/hid/hid_system_server.cpp
+++ b/src/core/hle/service/hid/hid_system_server.cpp
@@ -36,24 +36,24 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
36 {233, nullptr, "GetXcdHandleForNpadWithIrSensor"}, 36 {233, nullptr, "GetXcdHandleForNpadWithIrSensor"},
37 {301, nullptr, "ActivateNpadSystem"}, 37 {301, nullptr, "ActivateNpadSystem"},
38 {303, &IHidSystemServer::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"}, 38 {303, &IHidSystemServer::ApplyNpadSystemCommonPolicy, "ApplyNpadSystemCommonPolicy"},
39 {304, nullptr, "EnableAssigningSingleOnSlSrPress"}, 39 {304, &IHidSystemServer::EnableAssigningSingleOnSlSrPress, "EnableAssigningSingleOnSlSrPress"},
40 {305, nullptr, "DisableAssigningSingleOnSlSrPress"}, 40 {305, &IHidSystemServer::DisableAssigningSingleOnSlSrPress, "DisableAssigningSingleOnSlSrPress"},
41 {306, &IHidSystemServer::GetLastActiveNpad, "GetLastActiveNpad"}, 41 {306, &IHidSystemServer::GetLastActiveNpad, "GetLastActiveNpad"},
42 {307, nullptr, "GetNpadSystemExtStyle"}, 42 {307, nullptr, "GetNpadSystemExtStyle"},
43 {308, nullptr, "ApplyNpadSystemCommonPolicyFull"}, 43 {308, &IHidSystemServer::ApplyNpadSystemCommonPolicyFull, "ApplyNpadSystemCommonPolicyFull"},
44 {309, nullptr, "GetNpadFullKeyGripColor"}, 44 {309, &IHidSystemServer::GetNpadFullKeyGripColor, "GetNpadFullKeyGripColor"},
45 {310, nullptr, "GetMaskedSupportedNpadStyleSet"}, 45 {310, &IHidSystemServer::GetMaskedSupportedNpadStyleSet, "GetMaskedSupportedNpadStyleSet"},
46 {311, nullptr, "SetNpadPlayerLedBlinkingDevice"}, 46 {311, nullptr, "SetNpadPlayerLedBlinkingDevice"},
47 {312, nullptr, "SetSupportedNpadStyleSetAll"}, 47 {312, &IHidSystemServer::SetSupportedNpadStyleSetAll, "SetSupportedNpadStyleSetAll"},
48 {313, nullptr, "GetNpadCaptureButtonAssignment"}, 48 {313, nullptr, "GetNpadCaptureButtonAssignment"},
49 {314, nullptr, "GetAppletFooterUiType"}, 49 {314, nullptr, "GetAppletFooterUiType"},
50 {315, nullptr, "GetAppletDetailedUiType"}, 50 {315, &IHidSystemServer::GetAppletDetailedUiType, "GetAppletDetailedUiType"},
51 {316, nullptr, "GetNpadInterfaceType"}, 51 {316, &IHidSystemServer::GetNpadInterfaceType, "GetNpadInterfaceType"},
52 {317, nullptr, "GetNpadLeftRightInterfaceType"}, 52 {317, &IHidSystemServer::GetNpadLeftRightInterfaceType, "GetNpadLeftRightInterfaceType"},
53 {318, nullptr, "HasBattery"}, 53 {318, &IHidSystemServer::HasBattery, "HasBattery"},
54 {319, nullptr, "HasLeftRightBattery"}, 54 {319, &IHidSystemServer::HasLeftRightBattery, "HasLeftRightBattery"},
55 {321, &IHidSystemServer::GetUniquePadsFromNpad, "GetUniquePadsFromNpad"}, 55 {321, &IHidSystemServer::GetUniquePadsFromNpad, "GetUniquePadsFromNpad"},
56 {322, nullptr, "GetIrSensorState"}, 56 {322, &IHidSystemServer::GetIrSensorState, "GetIrSensorState"},
57 {323, nullptr, "GetXcdHandleForNpadWithIrSensor"}, 57 {323, nullptr, "GetXcdHandleForNpadWithIrSensor"},
58 {324, nullptr, "GetUniquePadButtonSet"}, 58 {324, nullptr, "GetUniquePadButtonSet"},
59 {325, nullptr, "GetUniquePadColor"}, 59 {325, nullptr, "GetUniquePadColor"},
@@ -85,15 +85,15 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
85 {541, nullptr, "GetPlayReportControllerUsages"}, 85 {541, nullptr, "GetPlayReportControllerUsages"},
86 {542, nullptr, "AcquirePlayReportRegisteredDeviceUpdateEvent"}, 86 {542, nullptr, "AcquirePlayReportRegisteredDeviceUpdateEvent"},
87 {543, nullptr, "GetRegisteredDevicesOld"}, 87 {543, nullptr, "GetRegisteredDevicesOld"},
88 {544, nullptr, "AcquireConnectionTriggerTimeoutEvent"}, 88 {544, &IHidSystemServer::AcquireConnectionTriggerTimeoutEvent, "AcquireConnectionTriggerTimeoutEvent"},
89 {545, nullptr, "SendConnectionTrigger"}, 89 {545, nullptr, "SendConnectionTrigger"},
90 {546, nullptr, "AcquireDeviceRegisteredEventForControllerSupport"}, 90 {546, &IHidSystemServer::AcquireDeviceRegisteredEventForControllerSupport, "AcquireDeviceRegisteredEventForControllerSupport"},
91 {547, nullptr, "GetAllowedBluetoothLinksCount"}, 91 {547, nullptr, "GetAllowedBluetoothLinksCount"},
92 {548, nullptr, "GetRegisteredDevices"}, 92 {548, &IHidSystemServer::GetRegisteredDevices, "GetRegisteredDevices"},
93 {549, nullptr, "GetConnectableRegisteredDevices"}, 93 {549, nullptr, "GetConnectableRegisteredDevices"},
94 {700, nullptr, "ActivateUniquePad"}, 94 {700, nullptr, "ActivateUniquePad"},
95 {702, nullptr, "AcquireUniquePadConnectionEventHandle"}, 95 {702, &IHidSystemServer::AcquireUniquePadConnectionEventHandle, "AcquireUniquePadConnectionEventHandle"},
96 {703, nullptr, "GetUniquePadIds"}, 96 {703, &IHidSystemServer::GetUniquePadIds, "GetUniquePadIds"},
97 {751, &IHidSystemServer::AcquireJoyDetachOnBluetoothOffEventHandle, "AcquireJoyDetachOnBluetoothOffEventHandle"}, 97 {751, &IHidSystemServer::AcquireJoyDetachOnBluetoothOffEventHandle, "AcquireJoyDetachOnBluetoothOffEventHandle"},
98 {800, nullptr, "ListSixAxisSensorHandles"}, 98 {800, nullptr, "ListSixAxisSensorHandles"},
99 {801, nullptr, "IsSixAxisSensorUserCalibrationSupported"}, 99 {801, nullptr, "IsSixAxisSensorUserCalibrationSupported"},
@@ -123,10 +123,10 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
123 {850, &IHidSystemServer::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"}, 123 {850, &IHidSystemServer::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"},
124 {851, nullptr, "EnableUsbFullKeyController"}, 124 {851, nullptr, "EnableUsbFullKeyController"},
125 {852, nullptr, "IsUsbConnected"}, 125 {852, nullptr, "IsUsbConnected"},
126 {870, nullptr, "IsHandheldButtonPressedOnConsoleMode"}, 126 {870, &IHidSystemServer::IsHandheldButtonPressedOnConsoleMode, "IsHandheldButtonPressedOnConsoleMode"},
127 {900, nullptr, "ActivateInputDetector"}, 127 {900, nullptr, "ActivateInputDetector"},
128 {901, nullptr, "NotifyInputDetector"}, 128 {901, nullptr, "NotifyInputDetector"},
129 {1000, nullptr, "InitializeFirmwareUpdate"}, 129 {1000, &IHidSystemServer::InitializeFirmwareUpdate, "InitializeFirmwareUpdate"},
130 {1001, nullptr, "GetFirmwareVersion"}, 130 {1001, nullptr, "GetFirmwareVersion"},
131 {1002, nullptr, "GetAvailableFirmwareVersion"}, 131 {1002, nullptr, "GetAvailableFirmwareVersion"},
132 {1003, nullptr, "IsFirmwareUpdateAvailable"}, 132 {1003, nullptr, "IsFirmwareUpdateAvailable"},
@@ -149,6 +149,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
149 {1132, nullptr, "CheckUsbFirmwareUpdateRequired"}, 149 {1132, nullptr, "CheckUsbFirmwareUpdateRequired"},
150 {1133, nullptr, "StartUsbFirmwareUpdate"}, 150 {1133, nullptr, "StartUsbFirmwareUpdate"},
151 {1134, nullptr, "GetUsbFirmwareUpdateState"}, 151 {1134, nullptr, "GetUsbFirmwareUpdateState"},
152 {1135, &IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory, "InitializeUsbFirmwareUpdateWithoutMemory"},
152 {1150, nullptr, "SetTouchScreenMagnification"}, 153 {1150, nullptr, "SetTouchScreenMagnification"},
153 {1151, nullptr, "GetTouchScreenFirmwareVersion"}, 154 {1151, nullptr, "GetTouchScreenFirmwareVersion"},
154 {1152, nullptr, "SetTouchScreenDefaultConfiguration"}, 155 {1152, nullptr, "SetTouchScreenDefaultConfiguration"},
@@ -220,11 +221,20 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
220 221
221 RegisterHandlers(functions); 222 RegisterHandlers(functions);
222 223
223 joy_detach_event = service_context.CreateEvent("HidSys::JoyDetachEvent"); 224 joy_detach_event = service_context.CreateEvent("IHidSystemServer::JoyDetachEvent");
225 acquire_device_registered_event =
226 service_context.CreateEvent("IHidSystemServer::AcquireDeviceRegisteredEvent");
227 acquire_connection_trigger_timeout_event =
228 service_context.CreateEvent("IHidSystemServer::AcquireConnectionTriggerTimeoutEvent");
229 unique_pad_connection_event =
230 service_context.CreateEvent("IHidSystemServer::AcquireUniquePadConnectionEventHandle");
224} 231}
225 232
226IHidSystemServer::~IHidSystemServer() { 233IHidSystemServer::~IHidSystemServer() {
227 service_context.CloseEvent(joy_detach_event); 234 service_context.CloseEvent(joy_detach_event);
235 service_context.CloseEvent(acquire_device_registered_event);
236 service_context.CloseEvent(acquire_connection_trigger_timeout_event);
237 service_context.CloseEvent(unique_pad_connection_event);
228}; 238};
229 239
230void IHidSystemServer::ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) { 240void IHidSystemServer::ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) {
@@ -238,29 +248,241 @@ void IHidSystemServer::ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) {
238 rb.Push(ResultSuccess); 248 rb.Push(ResultSuccess);
239} 249}
240 250
251void IHidSystemServer::EnableAssigningSingleOnSlSrPress(HLERequestContext& ctx) {
252 LOG_WARNING(Service_HID, "(STUBBED) called");
253
254 IPC::ResponseBuilder rb{ctx, 2};
255 rb.Push(ResultSuccess);
256}
257
258void IHidSystemServer::DisableAssigningSingleOnSlSrPress(HLERequestContext& ctx) {
259 LOG_WARNING(Service_HID, "(STUBBED) called");
260
261 IPC::ResponseBuilder rb{ctx, 2};
262 rb.Push(ResultSuccess);
263}
264
241void IHidSystemServer::GetLastActiveNpad(HLERequestContext& ctx) { 265void IHidSystemServer::GetLastActiveNpad(HLERequestContext& ctx) {
242 LOG_DEBUG(Service_HID, "(STUBBED) called"); 266 LOG_DEBUG(Service_HID, "(STUBBED) called"); // Spams a lot when controller applet is running
243 267
244 IPC::ResponseBuilder rb{ctx, 3}; 268 IPC::ResponseBuilder rb{ctx, 3};
245 rb.Push(ResultSuccess); 269 rb.Push(ResultSuccess);
246 rb.PushEnum(system.HIDCore().GetLastActiveController()); 270 rb.PushEnum(system.HIDCore().GetLastActiveController());
247} 271}
248 272
273void IHidSystemServer::ApplyNpadSystemCommonPolicyFull(HLERequestContext& ctx) {
274 LOG_WARNING(Service_HID, "called");
275
276 GetResourceManager()
277 ->GetController<Controller_NPad>(HidController::NPad)
278 .ApplyNpadSystemCommonPolicy();
279
280 IPC::ResponseBuilder rb{ctx, 2};
281 rb.Push(ResultSuccess);
282}
283
284void IHidSystemServer::GetNpadFullKeyGripColor(HLERequestContext& ctx) {
285 IPC::RequestParser rp{ctx};
286 const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
287
288 LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
289 npad_id_type); // Spams a lot when controller applet is running
290
291 Core::HID::NpadColor left_color{};
292 Core::HID::NpadColor right_color{};
293 // TODO: Get colors from Npad
294
295 IPC::ResponseBuilder rb{ctx, 4};
296 rb.Push(ResultSuccess);
297 rb.PushRaw(left_color);
298 rb.PushRaw(right_color);
299}
300
301void IHidSystemServer::GetMaskedSupportedNpadStyleSet(HLERequestContext& ctx) {
302 IPC::RequestParser rp{ctx};
303
304 LOG_INFO(Service_HID, "(STUBBED) called");
305
306 Core::HID::NpadStyleSet supported_styleset =
307 GetResourceManager()
308 ->GetController<Controller_NPad>(HidController::NPad)
309 .GetSupportedStyleSet()
310 .raw;
311
312 IPC::ResponseBuilder rb{ctx, 3};
313 rb.Push(ResultSuccess);
314 rb.PushEnum(supported_styleset);
315}
316
317void IHidSystemServer::SetSupportedNpadStyleSetAll(HLERequestContext& ctx) {
318 IPC::RequestParser rp{ctx};
319
320 LOG_INFO(Service_HID, "(STUBBED) called");
321
322 Core::HID::NpadStyleSet supported_styleset =
323 GetResourceManager()
324 ->GetController<Controller_NPad>(HidController::NPad)
325 .GetSupportedStyleSet()
326 .raw;
327
328 IPC::ResponseBuilder rb{ctx, 3};
329 rb.Push(ResultSuccess);
330 rb.PushEnum(supported_styleset);
331}
332
333void IHidSystemServer::GetAppletDetailedUiType(HLERequestContext& ctx) {
334 IPC::RequestParser rp{ctx};
335 const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
336
337 LOG_DEBUG(Service_HID, "called, npad_id_type={}",
338 npad_id_type); // Spams a lot when controller applet is running
339
340 const Service::HID::Controller_NPad::AppletDetailedUiType detailed_ui_type =
341 GetResourceManager()
342 ->GetController<Controller_NPad>(HidController::NPad)
343 .GetAppletDetailedUiType(npad_id_type);
344
345 IPC::ResponseBuilder rb{ctx, 3};
346 rb.Push(ResultSuccess);
347 rb.PushRaw(detailed_ui_type);
348}
349
350void IHidSystemServer::GetNpadInterfaceType(HLERequestContext& ctx) {
351 IPC::RequestParser rp{ctx};
352 const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
353
354 LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
355 npad_id_type); // Spams a lot when controller applet is running
356
357 IPC::ResponseBuilder rb{ctx, 3};
358 rb.Push(ResultSuccess);
359 rb.PushEnum(Core::HID::NpadInterfaceType::Bluetooth);
360}
361
362void IHidSystemServer::GetNpadLeftRightInterfaceType(HLERequestContext& ctx) {
363 IPC::RequestParser rp{ctx};
364 const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
365
366 LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
367 npad_id_type); // Spams a lot when controller applet is running
368
369 IPC::ResponseBuilder rb{ctx, 4};
370 rb.Push(ResultSuccess);
371 rb.PushEnum(Core::HID::NpadInterfaceType::Bluetooth);
372 rb.PushEnum(Core::HID::NpadInterfaceType::Bluetooth);
373}
374
375void IHidSystemServer::HasBattery(HLERequestContext& ctx) {
376 IPC::RequestParser rp{ctx};
377 const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
378
379 LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
380 npad_id_type); // Spams a lot when controller applet is running
381
382 IPC::ResponseBuilder rb{ctx, 3};
383 rb.Push(ResultSuccess);
384 rb.Push(false);
385}
386
387void IHidSystemServer::HasLeftRightBattery(HLERequestContext& ctx) {
388 IPC::RequestParser rp{ctx};
389 const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
390
391 LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
392 npad_id_type); // Spams a lot when controller applet is running
393
394 struct LeftRightBattery {
395 bool left;
396 bool right;
397 };
398
399 LeftRightBattery left_right_battery{
400 .left = false,
401 .right = false,
402 };
403
404 IPC::ResponseBuilder rb{ctx, 3};
405 rb.Push(ResultSuccess);
406 rb.PushRaw(left_right_battery);
407}
408
249void IHidSystemServer::GetUniquePadsFromNpad(HLERequestContext& ctx) { 409void IHidSystemServer::GetUniquePadsFromNpad(HLERequestContext& ctx) {
250 IPC::RequestParser rp{ctx}; 410 IPC::RequestParser rp{ctx};
251 const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()}; 411 const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()};
252 412
253 LOG_WARNING(Service_HID, "(STUBBED) called, npad_id_type={}", npad_id_type); 413 LOG_DEBUG(Service_HID, "(STUBBED) called, npad_id_type={}",
414 npad_id_type); // Spams a lot when controller applet is running
254 415
255 const std::vector<Core::HID::UniquePadId> unique_pads{}; 416 const std::vector<Core::HID::UniquePadId> unique_pads{};
256 417
257 ctx.WriteBuffer(unique_pads); 418 if (!unique_pads.empty()) {
419 ctx.WriteBuffer(unique_pads);
420 }
258 421
259 IPC::ResponseBuilder rb{ctx, 3}; 422 IPC::ResponseBuilder rb{ctx, 3};
260 rb.Push(ResultSuccess); 423 rb.Push(ResultSuccess);
261 rb.Push(static_cast<u32>(unique_pads.size())); 424 rb.Push(static_cast<u32>(unique_pads.size()));
262} 425}
263 426
427void IHidSystemServer::GetIrSensorState(HLERequestContext& ctx) {
428 IPC::RequestParser rp{ctx};
429
430 LOG_WARNING(Service_HID, "(STUBBED) called");
431
432 IPC::ResponseBuilder rb{ctx, 2};
433 rb.Push(ResultSuccess);
434}
435
436void IHidSystemServer::AcquireConnectionTriggerTimeoutEvent(HLERequestContext& ctx) {
437 LOG_INFO(Service_AM, "(STUBBED) called");
438
439 IPC::ResponseBuilder rb{ctx, 2, 1};
440 rb.Push(ResultSuccess);
441 rb.PushCopyObjects(acquire_device_registered_event->GetReadableEvent());
442}
443
444void IHidSystemServer::AcquireDeviceRegisteredEventForControllerSupport(HLERequestContext& ctx) {
445 LOG_INFO(Service_HID, "(STUBBED) called");
446
447 IPC::ResponseBuilder rb{ctx, 2, 1};
448 rb.Push(ResultSuccess);
449 rb.PushCopyObjects(acquire_device_registered_event->GetReadableEvent());
450}
451
452void IHidSystemServer::GetRegisteredDevices(HLERequestContext& ctx) {
453 LOG_WARNING(Service_HID, "(STUBBED) called");
454
455 struct RegisterData {
456 std::array<u8, 0x68> data;
457 };
458 static_assert(sizeof(RegisterData) == 0x68, "RegisterData is an invalid size");
459 std::vector<RegisterData> registered_devices{};
460
461 if (!registered_devices.empty()) {
462 ctx.WriteBuffer(registered_devices);
463 }
464
465 IPC::ResponseBuilder rb{ctx, 4};
466 rb.Push(ResultSuccess);
467 rb.Push<u64>(registered_devices.size());
468}
469
470void IHidSystemServer::AcquireUniquePadConnectionEventHandle(HLERequestContext& ctx) {
471 LOG_WARNING(Service_HID, "(STUBBED) called");
472
473 IPC::ResponseBuilder rb{ctx, 2, 1};
474 rb.PushCopyObjects(unique_pad_connection_event->GetReadableEvent());
475 rb.Push(ResultSuccess);
476}
477
478void IHidSystemServer::GetUniquePadIds(HLERequestContext& ctx) {
479 LOG_WARNING(Service_HID, "(STUBBED) called");
480
481 IPC::ResponseBuilder rb{ctx, 4};
482 rb.Push(ResultSuccess);
483 rb.Push<u64>(0);
484}
485
264void IHidSystemServer::AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx) { 486void IHidSystemServer::AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx) {
265 LOG_INFO(Service_AM, "called"); 487 LOG_INFO(Service_AM, "called");
266 488
@@ -279,6 +501,31 @@ void IHidSystemServer::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) {
279 rb.Push(is_enabled); 501 rb.Push(is_enabled);
280} 502}
281 503
504void IHidSystemServer::IsHandheldButtonPressedOnConsoleMode(HLERequestContext& ctx) {
505 const bool button_pressed = false;
506
507 LOG_DEBUG(Service_HID, "(STUBBED) called, is_enabled={}",
508 button_pressed); // Spams a lot when controller applet is open
509
510 IPC::ResponseBuilder rb{ctx, 3};
511 rb.Push(ResultSuccess);
512 rb.Push(button_pressed);
513}
514
515void IHidSystemServer::InitializeFirmwareUpdate(HLERequestContext& ctx) {
516 LOG_WARNING(Service_HID, "(STUBBED) called");
517
518 IPC::ResponseBuilder rb{ctx, 2};
519 rb.Push(ResultSuccess);
520}
521
522void IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx) {
523 LOG_WARNING(Service_HID, "(STUBBED) called");
524
525 IPC::ResponseBuilder rb{ctx, 2};
526 rb.Push(ResultSuccess);
527}
528
282void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) { 529void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) {
283 LOG_WARNING(Service_HID, "(STUBBED) called"); 530 LOG_WARNING(Service_HID, "(STUBBED) called");
284 531
diff --git a/src/core/hle/service/hid/hid_system_server.h b/src/core/hle/service/hid/hid_system_server.h
index d4b3910fa..822d5e5b9 100644
--- a/src/core/hle/service/hid/hid_system_server.h
+++ b/src/core/hle/service/hid/hid_system_server.h
@@ -24,15 +24,38 @@ public:
24 24
25private: 25private:
26 void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx); 26 void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx);
27 void EnableAssigningSingleOnSlSrPress(HLERequestContext& ctx);
28 void DisableAssigningSingleOnSlSrPress(HLERequestContext& ctx);
27 void GetLastActiveNpad(HLERequestContext& ctx); 29 void GetLastActiveNpad(HLERequestContext& ctx);
30 void ApplyNpadSystemCommonPolicyFull(HLERequestContext& ctx);
31 void GetNpadFullKeyGripColor(HLERequestContext& ctx);
32 void GetMaskedSupportedNpadStyleSet(HLERequestContext& ctx);
33 void SetSupportedNpadStyleSetAll(HLERequestContext& ctx);
34 void GetAppletDetailedUiType(HLERequestContext& ctx);
35 void GetNpadInterfaceType(HLERequestContext& ctx);
36 void GetNpadLeftRightInterfaceType(HLERequestContext& ctx);
37 void HasBattery(HLERequestContext& ctx);
38 void HasLeftRightBattery(HLERequestContext& ctx);
28 void GetUniquePadsFromNpad(HLERequestContext& ctx); 39 void GetUniquePadsFromNpad(HLERequestContext& ctx);
40 void GetIrSensorState(HLERequestContext& ctx);
41 void AcquireConnectionTriggerTimeoutEvent(HLERequestContext& ctx);
42 void AcquireDeviceRegisteredEventForControllerSupport(HLERequestContext& ctx);
43 void GetRegisteredDevices(HLERequestContext& ctx);
44 void AcquireUniquePadConnectionEventHandle(HLERequestContext& ctx);
45 void GetUniquePadIds(HLERequestContext& ctx);
29 void AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx); 46 void AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx);
30 void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx); 47 void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx);
48 void IsHandheldButtonPressedOnConsoleMode(HLERequestContext& ctx);
49 void InitializeFirmwareUpdate(HLERequestContext& ctx);
50 void InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx);
31 void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx); 51 void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
32 52
33 std::shared_ptr<ResourceManager> GetResourceManager(); 53 std::shared_ptr<ResourceManager> GetResourceManager();
34 54
55 Kernel::KEvent* acquire_connection_trigger_timeout_event;
56 Kernel::KEvent* acquire_device_registered_event;
35 Kernel::KEvent* joy_detach_event; 57 Kernel::KEvent* joy_detach_event;
58 Kernel::KEvent* unique_pad_connection_event;
36 KernelHelpers::ServiceContext service_context; 59 KernelHelpers::ServiceContext service_context;
37 std::shared_ptr<ResourceManager> resource_manager; 60 std::shared_ptr<ResourceManager> resource_manager;
38}; 61};