diff options
author | pineappleEA <pineaea@gmail.com> | 2021-11-10 14:45:07 +0100 |
---|---|---|
committer | pineappleEA <pineaea@gmail.com> | 2021-11-10 14:45:07 +0100 |
commit | 7d72f511d31353f2448956acdd80a47708385d76 (patch) | |
tree | 09537aa9a5695934f787e83a8dc5b9bd7f5ee22b | |
parent | d701e13d493fcb0b0c5233a8a5c08bbae6243fa5 (diff) |
early-access version 2192EA-2192
-rwxr-xr-x | README.md | 2 | ||||
-rwxr-xr-x | src/core/hid/emulated_console.cpp | 2 | ||||
-rwxr-xr-x | src/core/hid/emulated_controller.cpp | 4 | ||||
-rwxr-xr-x | src/core/hid/emulated_controller.h | 4 | ||||
-rwxr-xr-x | src/core/hid/hid_types.h | 67 | ||||
-rwxr-xr-x | src/core/hle/service/am/applets/applet_controller.cpp | 1 | ||||
-rwxr-xr-x | src/core/hle/service/am/applets/applet_controller.h | 6 | ||||
-rwxr-xr-x | src/core/hle/service/am/applets/applet_software_keyboard.cpp | 22 | ||||
-rwxr-xr-x | src/core/hle/service/hid/controllers/npad.cpp | 498 | ||||
-rwxr-xr-x | src/core/hle/service/hid/controllers/npad.h | 161 | ||||
-rwxr-xr-x | src/core/hle/service/hid/hid.cpp | 296 | ||||
-rwxr-xr-x | src/yuzu/configuration/configure_input_player.cpp | 4 | ||||
-rwxr-xr-x | src/yuzu/configuration/configure_input_player_widget.cpp | 24 |
13 files changed, 626 insertions, 465 deletions
@@ -1,7 +1,7 @@ | |||
1 | yuzu emulator early access | 1 | yuzu emulator early access |
2 | ============= | 2 | ============= |
3 | 3 | ||
4 | This is the source code for early-access 2191. | 4 | This is the source code for early-access 2192. |
5 | 5 | ||
6 | ## Legal Notice | 6 | ## Legal Notice |
7 | 7 | ||
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp index 864481f52..374dd5d41 100755 --- a/src/core/hid/emulated_console.cpp +++ b/src/core/hid/emulated_console.cpp | |||
@@ -152,7 +152,7 @@ void EmulatedConsole::SetMotion(Common::Input::CallbackStatus callback) { | |||
152 | motion.rotation = emulated.GetGyroscope(); | 152 | motion.rotation = emulated.GetGyroscope(); |
153 | motion.orientation = emulated.GetOrientation(); | 153 | motion.orientation = emulated.GetOrientation(); |
154 | motion.quaternion = emulated.GetQuaternion(); | 154 | motion.quaternion = emulated.GetQuaternion(); |
155 | motion.is_at_rest = emulated.IsMoving(motion_sensitivity); | 155 | motion.is_at_rest = !emulated.IsMoving(motion_sensitivity); |
156 | 156 | ||
157 | TriggerOnChange(ConsoleTriggerType::Motion); | 157 | TriggerOnChange(ConsoleTriggerType::Motion); |
158 | } | 158 | } |
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index a9038e06f..54c1a2324 100755 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
@@ -347,7 +347,7 @@ void EmulatedController::RestoreConfig() { | |||
347 | } | 347 | } |
348 | 348 | ||
349 | std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices( | 349 | std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices( |
350 | DeviceIndex device_index) const { | 350 | EmulatedDeviceIndex device_index) const { |
351 | std::vector<Common::ParamPackage> devices; | 351 | std::vector<Common::ParamPackage> devices; |
352 | for (const auto& param : button_params) { | 352 | for (const auto& param : button_params) { |
353 | if (!param.Has("engine")) { | 353 | if (!param.Has("engine")) { |
@@ -704,7 +704,7 @@ void EmulatedController::SetMotion(Common::Input::CallbackStatus callback, std:: | |||
704 | motion.gyro = emulated.GetGyroscope(); | 704 | motion.gyro = emulated.GetGyroscope(); |
705 | motion.rotation = emulated.GetRotations(); | 705 | motion.rotation = emulated.GetRotations(); |
706 | motion.orientation = emulated.GetOrientation(); | 706 | motion.orientation = emulated.GetOrientation(); |
707 | motion.is_at_rest = emulated.IsMoving(motion_sensitivity); | 707 | motion.is_at_rest = !emulated.IsMoving(motion_sensitivity); |
708 | 708 | ||
709 | TriggerOnChange(ControllerTriggerType::Motion, true); | 709 | TriggerOnChange(ControllerTriggerType::Motion, true); |
710 | } | 710 | } |
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index fa2e89c0b..2c5d51bc8 100755 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
@@ -81,7 +81,7 @@ struct ControllerMotion { | |||
81 | bool is_at_rest{}; | 81 | bool is_at_rest{}; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | enum DeviceIndex : u8 { | 84 | enum EmulatedDeviceIndex : u8 { |
85 | LeftIndex, | 85 | LeftIndex, |
86 | RightIndex, | 86 | RightIndex, |
87 | DualIndex, | 87 | DualIndex, |
@@ -202,7 +202,7 @@ public: | |||
202 | void RestoreConfig(); | 202 | void RestoreConfig(); |
203 | 203 | ||
204 | /// Returns a vector of mapped devices from the mapped button and stick parameters | 204 | /// Returns a vector of mapped devices from the mapped button and stick parameters |
205 | std::vector<Common::ParamPackage> GetMappedDevices(DeviceIndex device_index) const; | 205 | std::vector<Common::ParamPackage> GetMappedDevices(EmulatedDeviceIndex device_index) const; |
206 | 206 | ||
207 | // Returns the current mapped button device | 207 | // Returns the current mapped button device |
208 | Common::ParamPackage GetButtonParam(std::size_t index) const; | 208 | Common::ParamPackage GetButtonParam(std::size_t index) const; |
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h index 22177b5ed..5e09becf6 100755 --- a/src/core/hid/hid_types.h +++ b/src/core/hid/hid_types.h | |||
@@ -13,7 +13,7 @@ | |||
13 | namespace Core::HID { | 13 | namespace Core::HID { |
14 | 14 | ||
15 | // This is nn::hid::NpadIdType | 15 | // This is nn::hid::NpadIdType |
16 | enum class NpadIdType : u8 { | 16 | enum class NpadIdType : u32 { |
17 | Player1 = 0x0, | 17 | Player1 = 0x0, |
18 | Player2 = 0x1, | 18 | Player2 = 0x1, |
19 | Player3 = 0x2, | 19 | Player3 = 0x2, |
@@ -25,7 +25,7 @@ enum class NpadIdType : u8 { | |||
25 | Other = 0x10, | 25 | Other = 0x10, |
26 | Handheld = 0x20, | 26 | Handheld = 0x20, |
27 | 27 | ||
28 | Invalid = 0xFF, | 28 | Invalid = 0xFFFFFFFF, |
29 | }; | 29 | }; |
30 | 30 | ||
31 | /// Converts a NpadIdType to an array index. | 31 | /// Converts a NpadIdType to an array index. |
@@ -104,10 +104,30 @@ enum class NpadStyleIndex : u8 { | |||
104 | MaxNpadType = 34, | 104 | MaxNpadType = 34, |
105 | }; | 105 | }; |
106 | 106 | ||
107 | // This is nn::hid::NpadStyleSet | ||
108 | enum class NpadStyleSet : u32 { | ||
109 | None = 0, | ||
110 | Fullkey = 1U << 0, | ||
111 | Handheld = 1U << 1, | ||
112 | Joycon_dual = 1U << 2, | ||
113 | Joycon_left = 1U << 3, | ||
114 | Joycon_right = 1U << 4, | ||
115 | Gamecube = 1U << 5, | ||
116 | Palma = 1U << 6, | ||
117 | Lark = 1U << 7, | ||
118 | Handheld_lark = 1U << 8, | ||
119 | Lucia = 1U << 9, | ||
120 | Lagoon = 1U << 10, | ||
121 | Lager = 1U << 11, | ||
122 | System_ext = 1U << 29, | ||
123 | System = 1U << 30, | ||
124 | }; | ||
125 | static_assert(sizeof(NpadStyleSet) == 4, "NpadStyleSet is an invalid size"); | ||
126 | |||
107 | // This is nn::hid::NpadStyleTag | 127 | // This is nn::hid::NpadStyleTag |
108 | struct NpadStyleTag { | 128 | struct NpadStyleTag { |
109 | union { | 129 | union { |
110 | u32 raw{}; | 130 | NpadStyleSet raw{}; |
111 | 131 | ||
112 | BitField<0, 1, u32> fullkey; | 132 | BitField<0, 1, u32> fullkey; |
113 | BitField<1, 1, u32> handheld; | 133 | BitField<1, 1, u32> handheld; |
@@ -322,6 +342,47 @@ struct DebugPadButton { | |||
322 | }; | 342 | }; |
323 | static_assert(sizeof(DebugPadButton) == 0x4, "DebugPadButton is an invalid size"); | 343 | static_assert(sizeof(DebugPadButton) == 0x4, "DebugPadButton is an invalid size"); |
324 | 344 | ||
345 | enum class DeviceIndex : u8 { | ||
346 | Left = 0, | ||
347 | Right = 1, | ||
348 | None = 2, | ||
349 | MaxDeviceIndex = 3, | ||
350 | }; | ||
351 | |||
352 | // This is nn::hid::ConsoleSixAxisSensorHandle | ||
353 | struct ConsoleSixAxisSensorHandle { | ||
354 | u8 unknown_1; | ||
355 | u8 unknown_2; | ||
356 | INSERT_PADDING_BYTES_NOINIT(2); | ||
357 | }; | ||
358 | static_assert(sizeof(ConsoleSixAxisSensorHandle) == 4, | ||
359 | "ConsoleSixAxisSensorHandle is an invalid size"); | ||
360 | |||
361 | // This is nn::hid::SixAxisSensorHandle | ||
362 | struct SixAxisSensorHandle { | ||
363 | NpadStyleIndex npad_type; | ||
364 | u8 npad_id; | ||
365 | DeviceIndex device_index; | ||
366 | INSERT_PADDING_BYTES_NOINIT(1); | ||
367 | }; | ||
368 | static_assert(sizeof(SixAxisSensorHandle) == 4, "SixAxisSensorHandle is an invalid size"); | ||
369 | |||
370 | struct SixAxisSensorFusionParameters { | ||
371 | f32 parameter1; | ||
372 | f32 parameter2; | ||
373 | }; | ||
374 | static_assert(sizeof(SixAxisSensorFusionParameters) == 8, | ||
375 | "SixAxisSensorFusionParameters is an invalid size"); | ||
376 | |||
377 | // This is nn::hid::VibrationDeviceHandle | ||
378 | struct VibrationDeviceHandle { | ||
379 | NpadStyleIndex npad_type; | ||
380 | u8 npad_id; | ||
381 | DeviceIndex device_index; | ||
382 | INSERT_PADDING_BYTES_NOINIT(1); | ||
383 | }; | ||
384 | static_assert(sizeof(VibrationDeviceHandle) == 4, "SixAxisSensorHandle is an invalid size"); | ||
385 | |||
325 | // This is nn::hid::VibrationDeviceType | 386 | // This is nn::hid::VibrationDeviceType |
326 | enum class VibrationDeviceType : u32 { | 387 | enum class VibrationDeviceType : u32 { |
327 | Unknown = 0, | 388 | Unknown = 0, |
diff --git a/src/core/hle/service/am/applets/applet_controller.cpp b/src/core/hle/service/am/applets/applet_controller.cpp index 374e0c7f4..d073f2210 100755 --- a/src/core/hle/service/am/applets/applet_controller.cpp +++ b/src/core/hle/service/am/applets/applet_controller.cpp | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "core/frontend/applets/controller.h" | 12 | #include "core/frontend/applets/controller.h" |
13 | #include "core/hid/emulated_controller.h" | 13 | #include "core/hid/emulated_controller.h" |
14 | #include "core/hid/hid_core.h" | 14 | #include "core/hid/hid_core.h" |
15 | #include "core/hid/hid_types.h" | ||
15 | #include "core/hle/result.h" | 16 | #include "core/hle/result.h" |
16 | #include "core/hle/service/am/am.h" | 17 | #include "core/hle/service/am/am.h" |
17 | #include "core/hle/service/am/applets/applet_controller.h" | 18 | #include "core/hle/service/am/applets/applet_controller.h" |
diff --git a/src/core/hle/service/am/applets/applet_controller.h b/src/core/hle/service/am/applets/applet_controller.h index 0a34c4fc0..1a832505e 100755 --- a/src/core/hle/service/am/applets/applet_controller.h +++ b/src/core/hle/service/am/applets/applet_controller.h | |||
@@ -16,6 +16,10 @@ namespace Core { | |||
16 | class System; | 16 | class System; |
17 | } | 17 | } |
18 | 18 | ||
19 | namespace Core::HID { | ||
20 | enum class NpadStyleSet : u32; | ||
21 | } | ||
22 | |||
19 | namespace Service::AM::Applets { | 23 | namespace Service::AM::Applets { |
20 | 24 | ||
21 | using IdentificationColor = std::array<u8, 4>; | 25 | using IdentificationColor = std::array<u8, 4>; |
@@ -52,7 +56,7 @@ struct ControllerSupportArgPrivate { | |||
52 | bool flag_1{}; | 56 | bool flag_1{}; |
53 | ControllerSupportMode mode{}; | 57 | ControllerSupportMode mode{}; |
54 | ControllerSupportCaller caller{}; | 58 | ControllerSupportCaller caller{}; |
55 | u32 style_set{}; | 59 | Core::HID::NpadStyleSet style_set{}; |
56 | u32 joy_hold_type{}; | 60 | u32 joy_hold_type{}; |
57 | }; | 61 | }; |
58 | static_assert(sizeof(ControllerSupportArgPrivate) == 0x14, | 62 | static_assert(sizeof(ControllerSupportArgPrivate) == 0x14, |
diff --git a/src/core/hle/service/am/applets/applet_software_keyboard.cpp b/src/core/hle/service/am/applets/applet_software_keyboard.cpp index 1f21cee91..f38f53f69 100755 --- a/src/core/hle/service/am/applets/applet_software_keyboard.cpp +++ b/src/core/hle/service/am/applets/applet_software_keyboard.cpp | |||
@@ -278,13 +278,21 @@ void SoftwareKeyboard::ProcessTextCheck() { | |||
278 | 278 | ||
279 | std::memcpy(&swkbd_text_check, text_check_data.data(), sizeof(SwkbdTextCheck)); | 279 | std::memcpy(&swkbd_text_check, text_check_data.data(), sizeof(SwkbdTextCheck)); |
280 | 280 | ||
281 | std::u16string text_check_message = | 281 | std::u16string text_check_message = [this, &swkbd_text_check]() -> std::u16string { |
282 | swkbd_text_check.text_check_result == SwkbdTextCheckResult::Failure || | 282 | if (swkbd_text_check.text_check_result == SwkbdTextCheckResult::Failure || |
283 | swkbd_text_check.text_check_result == SwkbdTextCheckResult::Confirm | 283 | swkbd_text_check.text_check_result == SwkbdTextCheckResult::Confirm) { |
284 | ? Common::UTF16StringFromFixedZeroTerminatedBuffer( | 284 | return swkbd_config_common.use_utf8 |
285 | swkbd_text_check.text_check_message.data(), | 285 | ? Common::UTF8ToUTF16(Common::StringFromFixedZeroTerminatedBuffer( |
286 | swkbd_text_check.text_check_message.size()) | 286 | reinterpret_cast<const char*>( |
287 | : u""; | 287 | swkbd_text_check.text_check_message.data()), |
288 | swkbd_text_check.text_check_message.size() * sizeof(char16_t))) | ||
289 | : Common::UTF16StringFromFixedZeroTerminatedBuffer( | ||
290 | swkbd_text_check.text_check_message.data(), | ||
291 | swkbd_text_check.text_check_message.size()); | ||
292 | } else { | ||
293 | return u""; | ||
294 | } | ||
295 | }(); | ||
288 | 296 | ||
289 | LOG_INFO(Service_AM, "\nTextCheckResult: {}\nTextCheckMessage: {}", | 297 | LOG_INFO(Service_AM, "\nTextCheckResult: {}\nTextCheckMessage: {}", |
290 | GetTextCheckResultName(swkbd_text_check.text_check_result), | 298 | GetTextCheckResultName(swkbd_text_check.text_check_result), |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index b97e575f3..a1a328162 100755 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
@@ -21,68 +21,25 @@ | |||
21 | 21 | ||
22 | namespace Service::HID { | 22 | namespace Service::HID { |
23 | constexpr std::size_t NPAD_OFFSET = 0x9A00; | 23 | constexpr std::size_t NPAD_OFFSET = 0x9A00; |
24 | constexpr u32 MAX_NPAD_ID = 7; | 24 | constexpr std::array<Core::HID::NpadIdType, 10> npad_id_list{ |
25 | constexpr std::size_t HANDHELD_INDEX = 8; | 25 | Core::HID::NpadIdType::Player1, Core::HID::NpadIdType::Player2, Core::HID::NpadIdType::Player3, |
26 | constexpr std::array<u32, 10> npad_id_list{ | 26 | Core::HID::NpadIdType::Player4, Core::HID::NpadIdType::Player5, Core::HID::NpadIdType::Player6, |
27 | 0, 1, 2, 3, 4, 5, 6, 7, NPAD_HANDHELD, NPAD_UNKNOWN, | 27 | Core::HID::NpadIdType::Player7, Core::HID::NpadIdType::Player8, Core::HID::NpadIdType::Other, |
28 | Core::HID::NpadIdType::Handheld, | ||
28 | }; | 29 | }; |
29 | 30 | ||
30 | std::size_t Controller_NPad::NPadIdToIndex(u32 npad_id) { | 31 | bool Controller_NPad::IsNpadIdValid(Core::HID::NpadIdType npad_id) { |
31 | switch (npad_id) { | 32 | switch (npad_id) { |
32 | case 0: | 33 | case Core::HID::NpadIdType::Player1: |
33 | case 1: | 34 | case Core::HID::NpadIdType::Player2: |
34 | case 2: | 35 | case Core::HID::NpadIdType::Player3: |
35 | case 3: | 36 | case Core::HID::NpadIdType::Player4: |
36 | case 4: | 37 | case Core::HID::NpadIdType::Player5: |
37 | case 5: | 38 | case Core::HID::NpadIdType::Player6: |
38 | case 6: | 39 | case Core::HID::NpadIdType::Player7: |
39 | case 7: | 40 | case Core::HID::NpadIdType::Player8: |
40 | return npad_id; | 41 | case Core::HID::NpadIdType::Other: |
41 | case HANDHELD_INDEX: | 42 | case Core::HID::NpadIdType::Handheld: |
42 | case NPAD_HANDHELD: | ||
43 | return HANDHELD_INDEX; | ||
44 | case 9: | ||
45 | case NPAD_UNKNOWN: | ||
46 | return 9; | ||
47 | default: | ||
48 | UNIMPLEMENTED_MSG("Unknown npad id {}", npad_id); | ||
49 | return 0; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | u32 Controller_NPad::IndexToNPad(std::size_t index) { | ||
54 | switch (index) { | ||
55 | case 0: | ||
56 | case 1: | ||
57 | case 2: | ||
58 | case 3: | ||
59 | case 4: | ||
60 | case 5: | ||
61 | case 6: | ||
62 | case 7: | ||
63 | return static_cast<u32>(index); | ||
64 | case HANDHELD_INDEX: | ||
65 | return NPAD_HANDHELD; | ||
66 | case 9: | ||
67 | return NPAD_UNKNOWN; | ||
68 | default: | ||
69 | UNIMPLEMENTED_MSG("Unknown npad index {}", index); | ||
70 | return 0; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | bool Controller_NPad::IsNpadIdValid(u32 npad_id) { | ||
75 | switch (npad_id) { | ||
76 | case 0: | ||
77 | case 1: | ||
78 | case 2: | ||
79 | case 3: | ||
80 | case 4: | ||
81 | case 5: | ||
82 | case 6: | ||
83 | case 7: | ||
84 | case NPAD_UNKNOWN: | ||
85 | case NPAD_HANDHELD: | ||
86 | return true; | 43 | return true; |
87 | default: | 44 | default: |
88 | LOG_ERROR(Service_HID, "Invalid npad id {}", npad_id); | 45 | LOG_ERROR(Service_HID, "Invalid npad id {}", npad_id); |
@@ -90,10 +47,16 @@ bool Controller_NPad::IsNpadIdValid(u32 npad_id) { | |||
90 | } | 47 | } |
91 | } | 48 | } |
92 | 49 | ||
93 | bool Controller_NPad::IsDeviceHandleValid(const DeviceHandle& device_handle) { | 50 | bool Controller_NPad::IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle) { |
94 | return IsNpadIdValid(device_handle.npad_id) && | 51 | return IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id)) && |
52 | device_handle.npad_type < Core::HID::NpadStyleIndex::MaxNpadType && | ||
53 | device_handle.device_index < Core::HID::DeviceIndex::MaxDeviceIndex; | ||
54 | } | ||
55 | |||
56 | bool Controller_NPad::IsDeviceHandleValid(const Core::HID::SixAxisSensorHandle& device_handle) { | ||
57 | return IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id)) && | ||
95 | device_handle.npad_type < Core::HID::NpadStyleIndex::MaxNpadType && | 58 | device_handle.npad_type < Core::HID::NpadStyleIndex::MaxNpadType && |
96 | device_handle.device_index < DeviceIndex::MaxDeviceIndex; | 59 | device_handle.device_index < Core::HID::DeviceIndex::MaxDeviceIndex; |
97 | } | 60 | } |
98 | 61 | ||
99 | Controller_NPad::Controller_NPad(Core::HID::HIDCore& hid_core_, | 62 | Controller_NPad::Controller_NPad(Core::HID::HIDCore& hid_core_, |
@@ -102,9 +65,9 @@ Controller_NPad::Controller_NPad(Core::HID::HIDCore& hid_core_, | |||
102 | for (std::size_t i = 0; i < controller_data.size(); ++i) { | 65 | for (std::size_t i = 0; i < controller_data.size(); ++i) { |
103 | auto& controller = controller_data[i]; | 66 | auto& controller = controller_data[i]; |
104 | controller.device = hid_core.GetEmulatedControllerByIndex(i); | 67 | controller.device = hid_core.GetEmulatedControllerByIndex(i); |
105 | controller.vibration[Core::HID::DeviceIndex::LeftIndex].latest_vibration_value = | 68 | controller.vibration[Core::HID::EmulatedDeviceIndex::LeftIndex].latest_vibration_value = |
106 | DEFAULT_VIBRATION_VALUE; | 69 | DEFAULT_VIBRATION_VALUE; |
107 | controller.vibration[Core::HID::DeviceIndex::RightIndex].latest_vibration_value = | 70 | controller.vibration[Core::HID::EmulatedDeviceIndex::RightIndex].latest_vibration_value = |
108 | DEFAULT_VIBRATION_VALUE; | 71 | DEFAULT_VIBRATION_VALUE; |
109 | Core::HID::ControllerUpdateCallback engine_callback{ | 72 | Core::HID::ControllerUpdateCallback engine_callback{ |
110 | .on_change = [this, | 73 | .on_change = [this, |
@@ -130,17 +93,21 @@ void Controller_NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, | |||
130 | ControllerUpdate(Core::HID::ControllerTriggerType::Battery, controller_idx); | 93 | ControllerUpdate(Core::HID::ControllerTriggerType::Battery, controller_idx); |
131 | return; | 94 | return; |
132 | } | 95 | } |
96 | if (controller_idx >= controller_data.size()) { | ||
97 | return; | ||
98 | } | ||
133 | 99 | ||
134 | auto& controller = controller_data[controller_idx]; | 100 | auto& controller = controller_data[controller_idx]; |
135 | const auto is_connected = controller.device->IsConnected(); | 101 | const auto is_connected = controller.device->IsConnected(); |
136 | const auto npad_type = controller.device->GetNpadStyleIndex(); | 102 | const auto npad_type = controller.device->GetNpadStyleIndex(); |
103 | const auto npad_id = controller.device->GetNpadIdType(); | ||
137 | switch (type) { | 104 | switch (type) { |
138 | case Core::HID::ControllerTriggerType::Connected: | 105 | case Core::HID::ControllerTriggerType::Connected: |
139 | case Core::HID::ControllerTriggerType::Disconnected: | 106 | case Core::HID::ControllerTriggerType::Disconnected: |
140 | if (is_connected == controller.is_connected) { | 107 | if (is_connected == controller.is_connected) { |
141 | return; | 108 | return; |
142 | } | 109 | } |
143 | UpdateControllerAt(npad_type, controller_idx, is_connected); | 110 | UpdateControllerAt(npad_type, npad_id, is_connected); |
144 | break; | 111 | break; |
145 | case Core::HID::ControllerTriggerType::Battery: { | 112 | case Core::HID::ControllerTriggerType::Battery: { |
146 | if (!controller.is_connected) { | 113 | if (!controller.is_connected) { |
@@ -158,15 +125,16 @@ void Controller_NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, | |||
158 | } | 125 | } |
159 | } | 126 | } |
160 | 127 | ||
161 | void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | 128 | void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) { |
162 | auto& controller = controller_data[controller_idx]; | 129 | LOG_DEBUG(Service_HID, "Npad connected {}", npad_id); |
130 | auto& controller = GetControllerFromNpadIdType(npad_id); | ||
163 | const auto controller_type = controller.device->GetNpadStyleIndex(); | 131 | const auto controller_type = controller.device->GetNpadStyleIndex(); |
164 | auto& shared_memory = controller.shared_memory_entry; | 132 | auto& shared_memory = controller.shared_memory_entry; |
165 | if (controller_type == Core::HID::NpadStyleIndex::None) { | 133 | if (controller_type == Core::HID::NpadStyleIndex::None) { |
166 | controller.styleset_changed_event->GetWritableEvent().Signal(); | 134 | controller.styleset_changed_event->GetWritableEvent().Signal(); |
167 | return; | 135 | return; |
168 | } | 136 | } |
169 | shared_memory.style_set.raw = 0; // Zero out | 137 | shared_memory.style_tag.raw = Core::HID::NpadStyleSet::None; |
170 | shared_memory.device_type.raw = 0; | 138 | shared_memory.device_type.raw = 0; |
171 | shared_memory.system_properties.raw = 0; | 139 | shared_memory.system_properties.raw = 0; |
172 | switch (controller_type) { | 140 | switch (controller_type) { |
@@ -174,7 +142,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
174 | UNREACHABLE(); | 142 | UNREACHABLE(); |
175 | break; | 143 | break; |
176 | case Core::HID::NpadStyleIndex::ProController: | 144 | case Core::HID::NpadStyleIndex::ProController: |
177 | shared_memory.style_set.fullkey.Assign(1); | 145 | shared_memory.style_tag.fullkey.Assign(1); |
178 | shared_memory.device_type.fullkey.Assign(1); | 146 | shared_memory.device_type.fullkey.Assign(1); |
179 | shared_memory.system_properties.is_vertical.Assign(1); | 147 | shared_memory.system_properties.is_vertical.Assign(1); |
180 | shared_memory.system_properties.use_plus.Assign(1); | 148 | shared_memory.system_properties.use_plus.Assign(1); |
@@ -183,7 +151,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
183 | shared_memory.applet_footer.type = AppletFooterUiType::SwitchProController; | 151 | shared_memory.applet_footer.type = AppletFooterUiType::SwitchProController; |
184 | break; | 152 | break; |
185 | case Core::HID::NpadStyleIndex::Handheld: | 153 | case Core::HID::NpadStyleIndex::Handheld: |
186 | shared_memory.style_set.handheld.Assign(1); | 154 | shared_memory.style_tag.handheld.Assign(1); |
187 | shared_memory.device_type.handheld_left.Assign(1); | 155 | shared_memory.device_type.handheld_left.Assign(1); |
188 | shared_memory.device_type.handheld_right.Assign(1); | 156 | shared_memory.device_type.handheld_right.Assign(1); |
189 | shared_memory.system_properties.is_vertical.Assign(1); | 157 | shared_memory.system_properties.is_vertical.Assign(1); |
@@ -193,7 +161,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
193 | shared_memory.applet_footer.type = AppletFooterUiType::HandheldJoyConLeftJoyConRight; | 161 | shared_memory.applet_footer.type = AppletFooterUiType::HandheldJoyConLeftJoyConRight; |
194 | break; | 162 | break; |
195 | case Core::HID::NpadStyleIndex::JoyconDual: | 163 | case Core::HID::NpadStyleIndex::JoyconDual: |
196 | shared_memory.style_set.joycon_dual.Assign(1); | 164 | shared_memory.style_tag.joycon_dual.Assign(1); |
197 | shared_memory.device_type.joycon_left.Assign(1); | 165 | shared_memory.device_type.joycon_left.Assign(1); |
198 | shared_memory.device_type.joycon_right.Assign(1); | 166 | shared_memory.device_type.joycon_right.Assign(1); |
199 | shared_memory.system_properties.is_vertical.Assign(1); | 167 | shared_memory.system_properties.is_vertical.Assign(1); |
@@ -203,7 +171,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
203 | shared_memory.applet_footer.type = AppletFooterUiType::JoyDual; | 171 | shared_memory.applet_footer.type = AppletFooterUiType::JoyDual; |
204 | break; | 172 | break; |
205 | case Core::HID::NpadStyleIndex::JoyconLeft: | 173 | case Core::HID::NpadStyleIndex::JoyconLeft: |
206 | shared_memory.style_set.joycon_left.Assign(1); | 174 | shared_memory.style_tag.joycon_left.Assign(1); |
207 | shared_memory.device_type.joycon_left.Assign(1); | 175 | shared_memory.device_type.joycon_left.Assign(1); |
208 | shared_memory.system_properties.is_horizontal.Assign(1); | 176 | shared_memory.system_properties.is_horizontal.Assign(1); |
209 | shared_memory.system_properties.use_minus.Assign(1); | 177 | shared_memory.system_properties.use_minus.Assign(1); |
@@ -211,7 +179,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
211 | shared_memory.applet_footer.type = AppletFooterUiType::JoyLeftHorizontal; | 179 | shared_memory.applet_footer.type = AppletFooterUiType::JoyLeftHorizontal; |
212 | break; | 180 | break; |
213 | case Core::HID::NpadStyleIndex::JoyconRight: | 181 | case Core::HID::NpadStyleIndex::JoyconRight: |
214 | shared_memory.style_set.joycon_right.Assign(1); | 182 | shared_memory.style_tag.joycon_right.Assign(1); |
215 | shared_memory.device_type.joycon_right.Assign(1); | 183 | shared_memory.device_type.joycon_right.Assign(1); |
216 | shared_memory.system_properties.is_horizontal.Assign(1); | 184 | shared_memory.system_properties.is_horizontal.Assign(1); |
217 | shared_memory.system_properties.use_plus.Assign(1); | 185 | shared_memory.system_properties.use_plus.Assign(1); |
@@ -219,32 +187,32 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
219 | shared_memory.applet_footer.type = AppletFooterUiType::JoyRightHorizontal; | 187 | shared_memory.applet_footer.type = AppletFooterUiType::JoyRightHorizontal; |
220 | break; | 188 | break; |
221 | case Core::HID::NpadStyleIndex::GameCube: | 189 | case Core::HID::NpadStyleIndex::GameCube: |
222 | shared_memory.style_set.gamecube.Assign(1); | 190 | shared_memory.style_tag.gamecube.Assign(1); |
223 | shared_memory.device_type.fullkey.Assign(1); | 191 | shared_memory.device_type.fullkey.Assign(1); |
224 | shared_memory.system_properties.is_vertical.Assign(1); | 192 | shared_memory.system_properties.is_vertical.Assign(1); |
225 | shared_memory.system_properties.use_plus.Assign(1); | 193 | shared_memory.system_properties.use_plus.Assign(1); |
226 | break; | 194 | break; |
227 | case Core::HID::NpadStyleIndex::Pokeball: | 195 | case Core::HID::NpadStyleIndex::Pokeball: |
228 | shared_memory.style_set.palma.Assign(1); | 196 | shared_memory.style_tag.palma.Assign(1); |
229 | shared_memory.device_type.palma.Assign(1); | 197 | shared_memory.device_type.palma.Assign(1); |
230 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; | 198 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; |
231 | break; | 199 | break; |
232 | case Core::HID::NpadStyleIndex::NES: | 200 | case Core::HID::NpadStyleIndex::NES: |
233 | shared_memory.style_set.lark.Assign(1); | 201 | shared_memory.style_tag.lark.Assign(1); |
234 | shared_memory.device_type.fullkey.Assign(1); | 202 | shared_memory.device_type.fullkey.Assign(1); |
235 | break; | 203 | break; |
236 | case Core::HID::NpadStyleIndex::SNES: | 204 | case Core::HID::NpadStyleIndex::SNES: |
237 | shared_memory.style_set.lucia.Assign(1); | 205 | shared_memory.style_tag.lucia.Assign(1); |
238 | shared_memory.device_type.fullkey.Assign(1); | 206 | shared_memory.device_type.fullkey.Assign(1); |
239 | shared_memory.applet_footer.type = AppletFooterUiType::Lucia; | 207 | shared_memory.applet_footer.type = AppletFooterUiType::Lucia; |
240 | break; | 208 | break; |
241 | case Core::HID::NpadStyleIndex::N64: | 209 | case Core::HID::NpadStyleIndex::N64: |
242 | shared_memory.style_set.lagoon.Assign(1); | 210 | shared_memory.style_tag.lagoon.Assign(1); |
243 | shared_memory.device_type.fullkey.Assign(1); | 211 | shared_memory.device_type.fullkey.Assign(1); |
244 | shared_memory.applet_footer.type = AppletFooterUiType::Lagon; | 212 | shared_memory.applet_footer.type = AppletFooterUiType::Lagon; |
245 | break; | 213 | break; |
246 | case Core::HID::NpadStyleIndex::SegaGenesis: | 214 | case Core::HID::NpadStyleIndex::SegaGenesis: |
247 | shared_memory.style_set.lager.Assign(1); | 215 | shared_memory.style_tag.lager.Assign(1); |
248 | shared_memory.device_type.fullkey.Assign(1); | 216 | shared_memory.device_type.fullkey.Assign(1); |
249 | break; | 217 | break; |
250 | default: | 218 | default: |
@@ -268,7 +236,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
268 | 236 | ||
269 | controller.is_connected = true; | 237 | controller.is_connected = true; |
270 | controller.device->Connect(); | 238 | controller.device->Connect(); |
271 | SignalStyleSetChangedEvent(IndexToNPad(controller_idx)); | 239 | SignalStyleSetChangedEvent(npad_id); |
272 | WriteEmptyEntry(controller.shared_memory_entry); | 240 | WriteEmptyEntry(controller.shared_memory_entry); |
273 | } | 241 | } |
274 | 242 | ||
@@ -283,7 +251,7 @@ void Controller_NPad::OnInit() { | |||
283 | service_context.CreateEvent(fmt::format("npad:NpadStyleSetChanged_{}", i)); | 251 | service_context.CreateEvent(fmt::format("npad:NpadStyleSetChanged_{}", i)); |
284 | } | 252 | } |
285 | 253 | ||
286 | if (hid_core.GetSupportedStyleTag().raw == 0) { | 254 | if (hid_core.GetSupportedStyleTag().raw == Core::HID::NpadStyleSet::None) { |
287 | // We want to support all controllers | 255 | // We want to support all controllers |
288 | Core::HID::NpadStyleTag style{}; | 256 | Core::HID::NpadStyleTag style{}; |
289 | style.handheld.Assign(1); | 257 | style.handheld.Assign(1); |
@@ -298,7 +266,7 @@ void Controller_NPad::OnInit() { | |||
298 | 266 | ||
299 | supported_npad_id_types.resize(npad_id_list.size()); | 267 | supported_npad_id_types.resize(npad_id_list.size()); |
300 | std::memcpy(supported_npad_id_types.data(), npad_id_list.data(), | 268 | std::memcpy(supported_npad_id_types.data(), npad_id_list.data(), |
301 | npad_id_list.size() * sizeof(u32)); | 269 | npad_id_list.size() * sizeof(Core::HID::NpadIdType)); |
302 | 270 | ||
303 | // Prefill controller buffers | 271 | // Prefill controller buffers |
304 | for (auto& controller : controller_data) { | 272 | for (auto& controller : controller_data) { |
@@ -322,8 +290,7 @@ void Controller_NPad::OnInit() { | |||
322 | for (auto& controller : controller_data) { | 290 | for (auto& controller : controller_data) { |
323 | const auto& device = controller.device; | 291 | const auto& device = controller.device; |
324 | if (device->IsConnected()) { | 292 | if (device->IsConnected()) { |
325 | const std::size_t index = Core::HID::NpadIdTypeToIndex(device->GetNpadIdType()); | 293 | AddNewControllerAt(device->GetNpadStyleIndex(), device->GetNpadIdType()); |
326 | AddNewControllerAt(device->GetNpadStyleIndex(), index); | ||
327 | } | 294 | } |
328 | } | 295 | } |
329 | } | 296 | } |
@@ -354,15 +321,14 @@ void Controller_NPad::OnRelease() { | |||
354 | auto& controller = controller_data[i]; | 321 | auto& controller = controller_data[i]; |
355 | service_context.CloseEvent(controller.styleset_changed_event); | 322 | service_context.CloseEvent(controller.styleset_changed_event); |
356 | for (std::size_t device_idx = 0; device_idx < controller.vibration.size(); ++device_idx) { | 323 | for (std::size_t device_idx = 0; device_idx < controller.vibration.size(); ++device_idx) { |
357 | VibrateControllerAtIndex(i, device_idx, {}); | 324 | VibrateControllerAtIndex(controller.device->GetNpadIdType(), device_idx, {}); |
358 | } | 325 | } |
359 | } | 326 | } |
360 | } | 327 | } |
361 | 328 | ||
362 | void Controller_NPad::RequestPadStateUpdate(u32 npad_id) { | 329 | void Controller_NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) { |
363 | std::lock_guard lock{mutex}; | 330 | std::lock_guard lock{mutex}; |
364 | const auto controller_idx = NPadIdToIndex(npad_id); | 331 | auto& controller = GetControllerFromNpadIdType(npad_id); |
365 | auto& controller = controller_data[controller_idx]; | ||
366 | const auto controller_type = controller.device->GetNpadStyleIndex(); | 332 | const auto controller_type = controller.device->GetNpadStyleIndex(); |
367 | if (!controller.device->IsConnected()) { | 333 | if (!controller.device->IsConnected()) { |
368 | return; | 334 | return; |
@@ -431,9 +397,8 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* | |||
431 | &controller.shared_memory_entry, sizeof(NpadInternalState)); | 397 | &controller.shared_memory_entry, sizeof(NpadInternalState)); |
432 | continue; | 398 | continue; |
433 | } | 399 | } |
434 | const u32 npad_index = static_cast<u32>(i); | ||
435 | 400 | ||
436 | RequestPadStateUpdate(npad_index); | 401 | RequestPadStateUpdate(controller.device->GetNpadIdType()); |
437 | auto& pad_state = controller.npad_pad_state; | 402 | auto& pad_state = controller.npad_pad_state; |
438 | auto& libnx_state = controller.npad_libnx_state; | 403 | auto& libnx_state = controller.npad_libnx_state; |
439 | auto& trigger_state = controller.npad_trigger_state; | 404 | auto& trigger_state = controller.npad_trigger_state; |
@@ -571,10 +536,11 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
571 | auto& sixaxis_left_lifo_state = controller.sixaxis_left_lifo_state; | 536 | auto& sixaxis_left_lifo_state = controller.sixaxis_left_lifo_state; |
572 | auto& sixaxis_right_lifo_state = controller.sixaxis_right_lifo_state; | 537 | auto& sixaxis_right_lifo_state = controller.sixaxis_right_lifo_state; |
573 | 538 | ||
574 | if (sixaxis_sensors_enabled && Settings::values.motion_enabled.GetValue()) { | 539 | if (controller.sixaxis_sensor_enabled && Settings::values.motion_enabled.GetValue()) { |
575 | sixaxis_at_rest = true; | 540 | controller.sixaxis_at_rest = true; |
576 | for (std::size_t e = 0; e < motion_state.size(); ++e) { | 541 | for (std::size_t e = 0; e < motion_state.size(); ++e) { |
577 | sixaxis_at_rest = sixaxis_at_rest && motion_state[e].is_at_rest; | 542 | controller.sixaxis_at_rest = |
543 | controller.sixaxis_at_rest && motion_state[e].is_at_rest; | ||
578 | } | 544 | } |
579 | } | 545 | } |
580 | 546 | ||
@@ -584,7 +550,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
584 | break; | 550 | break; |
585 | case Core::HID::NpadStyleIndex::ProController: | 551 | case Core::HID::NpadStyleIndex::ProController: |
586 | sixaxis_fullkey_state.attribute.raw = 0; | 552 | sixaxis_fullkey_state.attribute.raw = 0; |
587 | if (sixaxis_sensors_enabled) { | 553 | if (controller.sixaxis_sensor_enabled) { |
588 | sixaxis_fullkey_state.attribute.is_connected.Assign(1); | 554 | sixaxis_fullkey_state.attribute.is_connected.Assign(1); |
589 | sixaxis_fullkey_state.accel = motion_state[0].accel; | 555 | sixaxis_fullkey_state.accel = motion_state[0].accel; |
590 | sixaxis_fullkey_state.gyro = motion_state[0].gyro; | 556 | sixaxis_fullkey_state.gyro = motion_state[0].gyro; |
@@ -594,7 +560,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
594 | break; | 560 | break; |
595 | case Core::HID::NpadStyleIndex::Handheld: | 561 | case Core::HID::NpadStyleIndex::Handheld: |
596 | sixaxis_handheld_state.attribute.raw = 0; | 562 | sixaxis_handheld_state.attribute.raw = 0; |
597 | if (sixaxis_sensors_enabled) { | 563 | if (controller.sixaxis_sensor_enabled) { |
598 | sixaxis_handheld_state.attribute.is_connected.Assign(1); | 564 | sixaxis_handheld_state.attribute.is_connected.Assign(1); |
599 | sixaxis_handheld_state.accel = motion_state[0].accel; | 565 | sixaxis_handheld_state.accel = motion_state[0].accel; |
600 | sixaxis_handheld_state.gyro = motion_state[0].gyro; | 566 | sixaxis_handheld_state.gyro = motion_state[0].gyro; |
@@ -605,7 +571,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
605 | case Core::HID::NpadStyleIndex::JoyconDual: | 571 | case Core::HID::NpadStyleIndex::JoyconDual: |
606 | sixaxis_dual_left_state.attribute.raw = 0; | 572 | sixaxis_dual_left_state.attribute.raw = 0; |
607 | sixaxis_dual_right_state.attribute.raw = 0; | 573 | sixaxis_dual_right_state.attribute.raw = 0; |
608 | if (sixaxis_sensors_enabled) { | 574 | if (controller.sixaxis_sensor_enabled) { |
609 | // Set motion for the left joycon | 575 | // Set motion for the left joycon |
610 | sixaxis_dual_left_state.attribute.is_connected.Assign(1); | 576 | sixaxis_dual_left_state.attribute.is_connected.Assign(1); |
611 | sixaxis_dual_left_state.accel = motion_state[0].accel; | 577 | sixaxis_dual_left_state.accel = motion_state[0].accel; |
@@ -613,7 +579,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
613 | sixaxis_dual_left_state.rotation = motion_state[0].rotation; | 579 | sixaxis_dual_left_state.rotation = motion_state[0].rotation; |
614 | sixaxis_dual_left_state.orientation = motion_state[0].orientation; | 580 | sixaxis_dual_left_state.orientation = motion_state[0].orientation; |
615 | } | 581 | } |
616 | if (sixaxis_sensors_enabled) { | 582 | if (controller.sixaxis_sensor_enabled) { |
617 | // Set motion for the right joycon | 583 | // Set motion for the right joycon |
618 | sixaxis_dual_right_state.attribute.is_connected.Assign(1); | 584 | sixaxis_dual_right_state.attribute.is_connected.Assign(1); |
619 | sixaxis_dual_right_state.accel = motion_state[1].accel; | 585 | sixaxis_dual_right_state.accel = motion_state[1].accel; |
@@ -624,7 +590,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
624 | break; | 590 | break; |
625 | case Core::HID::NpadStyleIndex::JoyconLeft: | 591 | case Core::HID::NpadStyleIndex::JoyconLeft: |
626 | sixaxis_left_lifo_state.attribute.raw = 0; | 592 | sixaxis_left_lifo_state.attribute.raw = 0; |
627 | if (sixaxis_sensors_enabled) { | 593 | if (controller.sixaxis_sensor_enabled) { |
628 | sixaxis_left_lifo_state.attribute.is_connected.Assign(1); | 594 | sixaxis_left_lifo_state.attribute.is_connected.Assign(1); |
629 | sixaxis_left_lifo_state.accel = motion_state[0].accel; | 595 | sixaxis_left_lifo_state.accel = motion_state[0].accel; |
630 | sixaxis_left_lifo_state.gyro = motion_state[0].gyro; | 596 | sixaxis_left_lifo_state.gyro = motion_state[0].gyro; |
@@ -634,7 +600,7 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
634 | break; | 600 | break; |
635 | case Core::HID::NpadStyleIndex::JoyconRight: | 601 | case Core::HID::NpadStyleIndex::JoyconRight: |
636 | sixaxis_right_lifo_state.attribute.raw = 0; | 602 | sixaxis_right_lifo_state.attribute.raw = 0; |
637 | if (sixaxis_sensors_enabled) { | 603 | if (controller.sixaxis_sensor_enabled) { |
638 | sixaxis_right_lifo_state.attribute.is_connected.Assign(1); | 604 | sixaxis_right_lifo_state.attribute.is_connected.Assign(1); |
639 | sixaxis_right_lifo_state.accel = motion_state[1].accel; | 605 | sixaxis_right_lifo_state.accel = motion_state[1].accel; |
640 | sixaxis_right_lifo_state.gyro = motion_state[1].gyro; | 606 | sixaxis_right_lifo_state.gyro = motion_state[1].gyro; |
@@ -724,26 +690,30 @@ Controller_NPad::NpadCommunicationMode Controller_NPad::GetNpadCommunicationMode | |||
724 | return communication_mode; | 690 | return communication_mode; |
725 | } | 691 | } |
726 | 692 | ||
727 | void Controller_NPad::SetNpadMode(u32 npad_id, NpadJoyAssignmentMode assignment_mode) { | 693 | void Controller_NPad::SetNpadMode(Core::HID::NpadIdType npad_id, |
728 | const std::size_t npad_index = NPadIdToIndex(npad_id); | 694 | NpadJoyAssignmentMode assignment_mode) { |
729 | ASSERT(npad_index < controller_data.size()); | 695 | if (!IsNpadIdValid(npad_id)) { |
730 | auto& controller = controller_data[npad_index]; | 696 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); |
697 | return; | ||
698 | } | ||
699 | |||
700 | auto& controller = GetControllerFromNpadIdType(npad_id); | ||
731 | if (controller.shared_memory_entry.assignment_mode != assignment_mode) { | 701 | if (controller.shared_memory_entry.assignment_mode != assignment_mode) { |
732 | controller.shared_memory_entry.assignment_mode = assignment_mode; | 702 | controller.shared_memory_entry.assignment_mode = assignment_mode; |
733 | } | 703 | } |
734 | } | 704 | } |
735 | 705 | ||
736 | bool Controller_NPad::VibrateControllerAtIndex(std::size_t npad_index, std::size_t device_index, | 706 | bool Controller_NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, |
737 | const VibrationValue& vibration_value) { | 707 | std::size_t device_index, |
738 | auto& controller = controller_data[npad_index]; | 708 | const Core::HID::VibrationValue& vibration_value) { |
739 | 709 | auto& controller = GetControllerFromNpadIdType(npad_id); | |
740 | if (!controller.device->IsConnected()) { | 710 | if (!controller.device->IsConnected()) { |
741 | return false; | 711 | return false; |
742 | } | 712 | } |
743 | 713 | ||
744 | if (!controller.device->IsVibrationEnabled()) { | 714 | if (!controller.device->IsVibrationEnabled()) { |
745 | if (controller.vibration[device_index].latest_vibration_value.amp_low != 0.0f || | 715 | if (controller.vibration[device_index].latest_vibration_value.low_amplitude != 0.0f || |
746 | controller.vibration[device_index].latest_vibration_value.amp_high != 0.0f) { | 716 | controller.vibration[device_index].latest_vibration_value.high_amplitude != 0.0f) { |
747 | // Send an empty vibration to stop any vibrations. | 717 | // Send an empty vibration to stop any vibrations. |
748 | Core::HID::VibrationValue vibration{0.0f, 160.0f, 0.0f, 320.0f}; | 718 | Core::HID::VibrationValue vibration{0.0f, 160.0f, 0.0f, 320.0f}; |
749 | controller.device->SetVibration(device_index, vibration); | 719 | controller.device->SetVibration(device_index, vibration); |
@@ -762,7 +732,7 @@ bool Controller_NPad::VibrateControllerAtIndex(std::size_t npad_index, std::size | |||
762 | const auto now = steady_clock::now(); | 732 | const auto now = steady_clock::now(); |
763 | 733 | ||
764 | // Filter out non-zero vibrations that are within 10ms of each other. | 734 | // Filter out non-zero vibrations that are within 10ms of each other. |
765 | if ((vibration_value.amp_low != 0.0f || vibration_value.amp_high != 0.0f) && | 735 | if ((vibration_value.low_amplitude != 0.0f || vibration_value.high_amplitude != 0.0f) && |
766 | duration_cast<milliseconds>( | 736 | duration_cast<milliseconds>( |
767 | now - controller.vibration[device_index].last_vibration_timepoint) < | 737 | now - controller.vibration[device_index].last_vibration_timepoint) < |
768 | milliseconds(10)) { | 738 | milliseconds(10)) { |
@@ -772,13 +742,15 @@ bool Controller_NPad::VibrateControllerAtIndex(std::size_t npad_index, std::size | |||
772 | controller.vibration[device_index].last_vibration_timepoint = now; | 742 | controller.vibration[device_index].last_vibration_timepoint = now; |
773 | } | 743 | } |
774 | 744 | ||
775 | Core::HID::VibrationValue vibration{vibration_value.amp_low, vibration_value.freq_low, | 745 | Core::HID::VibrationValue vibration{ |
776 | vibration_value.amp_high, vibration_value.freq_high}; | 746 | vibration_value.low_amplitude, vibration_value.low_frequency, |
747 | vibration_value.high_amplitude, vibration_value.high_frequency}; | ||
777 | return controller.device->SetVibration(device_index, vibration); | 748 | return controller.device->SetVibration(device_index, vibration); |
778 | } | 749 | } |
779 | 750 | ||
780 | void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_handle, | 751 | void Controller_NPad::VibrateController( |
781 | const VibrationValue& vibration_value) { | 752 | const Core::HID::VibrationDeviceHandle& vibration_device_handle, |
753 | const Core::HID::VibrationValue& vibration_value) { | ||
782 | if (!IsDeviceHandleValid(vibration_device_handle)) { | 754 | if (!IsDeviceHandleValid(vibration_device_handle)) { |
783 | return; | 755 | return; |
784 | } | 756 | } |
@@ -787,15 +759,14 @@ void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_han | |||
787 | return; | 759 | return; |
788 | } | 760 | } |
789 | 761 | ||
790 | const auto npad_index = NPadIdToIndex(vibration_device_handle.npad_id); | 762 | auto& controller = GetControllerFromHandle(vibration_device_handle); |
791 | auto& controller = controller_data[npad_index]; | ||
792 | const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index); | 763 | const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index); |
793 | 764 | ||
794 | if (!controller.vibration[device_index].device_mounted || !controller.device->IsConnected()) { | 765 | if (!controller.vibration[device_index].device_mounted || !controller.device->IsConnected()) { |
795 | return; | 766 | return; |
796 | } | 767 | } |
797 | 768 | ||
798 | if (vibration_device_handle.device_index == DeviceIndex::None) { | 769 | if (vibration_device_handle.device_index == Core::HID::DeviceIndex::None) { |
799 | UNREACHABLE_MSG("DeviceIndex should never be None!"); | 770 | UNREACHABLE_MSG("DeviceIndex should never be None!"); |
800 | return; | 771 | return; |
801 | } | 772 | } |
@@ -803,28 +774,30 @@ void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_han | |||
803 | // Some games try to send mismatched parameters in the device handle, block these. | 774 | // Some games try to send mismatched parameters in the device handle, block these. |
804 | if ((controller.device->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconLeft && | 775 | if ((controller.device->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconLeft && |
805 | (vibration_device_handle.npad_type == Core::HID::NpadStyleIndex::JoyconRight || | 776 | (vibration_device_handle.npad_type == Core::HID::NpadStyleIndex::JoyconRight || |
806 | vibration_device_handle.device_index == DeviceIndex::Right)) || | 777 | vibration_device_handle.device_index == Core::HID::DeviceIndex::Right)) || |
807 | (controller.device->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight && | 778 | (controller.device->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight && |
808 | (vibration_device_handle.npad_type == Core::HID::NpadStyleIndex::JoyconLeft || | 779 | (vibration_device_handle.npad_type == Core::HID::NpadStyleIndex::JoyconLeft || |
809 | vibration_device_handle.device_index == DeviceIndex::Left))) { | 780 | vibration_device_handle.device_index == Core::HID::DeviceIndex::Left))) { |
810 | return; | 781 | return; |
811 | } | 782 | } |
812 | 783 | ||
813 | // Filter out vibrations with equivalent values to reduce unnecessary state changes. | 784 | // Filter out vibrations with equivalent values to reduce unnecessary state changes. |
814 | if (vibration_value.amp_low == | 785 | if (vibration_value.low_amplitude == |
815 | controller.vibration[device_index].latest_vibration_value.amp_low && | 786 | controller.vibration[device_index].latest_vibration_value.low_amplitude && |
816 | vibration_value.amp_high == | 787 | vibration_value.high_amplitude == |
817 | controller.vibration[device_index].latest_vibration_value.amp_high) { | 788 | controller.vibration[device_index].latest_vibration_value.high_amplitude) { |
818 | return; | 789 | return; |
819 | } | 790 | } |
820 | 791 | ||
821 | if (VibrateControllerAtIndex(npad_index, device_index, vibration_value)) { | 792 | if (VibrateControllerAtIndex(controller.device->GetNpadIdType(), device_index, |
793 | vibration_value)) { | ||
822 | controller.vibration[device_index].latest_vibration_value = vibration_value; | 794 | controller.vibration[device_index].latest_vibration_value = vibration_value; |
823 | } | 795 | } |
824 | } | 796 | } |
825 | 797 | ||
826 | void Controller_NPad::VibrateControllers(const std::vector<DeviceHandle>& vibration_device_handles, | 798 | void Controller_NPad::VibrateControllers( |
827 | const std::vector<VibrationValue>& vibration_values) { | 799 | const std::vector<Core::HID::VibrationDeviceHandle>& vibration_device_handles, |
800 | const std::vector<Core::HID::VibrationValue>& vibration_values) { | ||
828 | if (!Settings::values.vibration_enabled.GetValue() && !permit_vibration_session_enabled) { | 801 | if (!Settings::values.vibration_enabled.GetValue() && !permit_vibration_session_enabled) { |
829 | return; | 802 | return; |
830 | } | 803 | } |
@@ -839,31 +812,31 @@ void Controller_NPad::VibrateControllers(const std::vector<DeviceHandle>& vibrat | |||
839 | } | 812 | } |
840 | } | 813 | } |
841 | 814 | ||
842 | Controller_NPad::VibrationValue Controller_NPad::GetLastVibration( | 815 | Core::HID::VibrationValue Controller_NPad::GetLastVibration( |
843 | const DeviceHandle& vibration_device_handle) const { | 816 | const Core::HID::VibrationDeviceHandle& vibration_device_handle) const { |
844 | if (!IsDeviceHandleValid(vibration_device_handle)) { | 817 | if (!IsDeviceHandleValid(vibration_device_handle)) { |
845 | return {}; | 818 | return {}; |
846 | } | 819 | } |
847 | 820 | ||
848 | const auto npad_index = NPadIdToIndex(vibration_device_handle.npad_id); | 821 | const auto& controller = GetControllerFromHandle(vibration_device_handle); |
849 | const auto& controller = controller_data[npad_index]; | ||
850 | const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index); | 822 | const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index); |
851 | return controller.vibration[device_index].latest_vibration_value; | 823 | return controller.vibration[device_index].latest_vibration_value; |
852 | } | 824 | } |
853 | 825 | ||
854 | void Controller_NPad::InitializeVibrationDevice(const DeviceHandle& vibration_device_handle) { | 826 | void Controller_NPad::InitializeVibrationDevice( |
827 | const Core::HID::VibrationDeviceHandle& vibration_device_handle) { | ||
855 | if (!IsDeviceHandleValid(vibration_device_handle)) { | 828 | if (!IsDeviceHandleValid(vibration_device_handle)) { |
856 | return; | 829 | return; |
857 | } | 830 | } |
858 | 831 | ||
859 | const auto npad_index = NPadIdToIndex(vibration_device_handle.npad_id); | 832 | const auto npad_index = static_cast<Core::HID::NpadIdType>(vibration_device_handle.npad_id); |
860 | const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index); | 833 | const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index); |
861 | InitializeVibrationDeviceAtIndex(npad_index, device_index); | 834 | InitializeVibrationDeviceAtIndex(npad_index, device_index); |
862 | } | 835 | } |
863 | 836 | ||
864 | void Controller_NPad::InitializeVibrationDeviceAtIndex(std::size_t npad_index, | 837 | void Controller_NPad::InitializeVibrationDeviceAtIndex(Core::HID::NpadIdType npad_id, |
865 | std::size_t device_index) { | 838 | std::size_t device_index) { |
866 | auto& controller = controller_data[npad_index]; | 839 | auto& controller = GetControllerFromNpadIdType(npad_id); |
867 | if (!Settings::values.vibration_enabled.GetValue()) { | 840 | if (!Settings::values.vibration_enabled.GetValue()) { |
868 | controller.vibration[device_index].device_mounted = false; | 841 | controller.vibration[device_index].device_mounted = false; |
869 | return; | 842 | return; |
@@ -877,58 +850,67 @@ void Controller_NPad::SetPermitVibrationSession(bool permit_vibration_session) { | |||
877 | permit_vibration_session_enabled = permit_vibration_session; | 850 | permit_vibration_session_enabled = permit_vibration_session; |
878 | } | 851 | } |
879 | 852 | ||
880 | bool Controller_NPad::IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const { | 853 | bool Controller_NPad::IsVibrationDeviceMounted( |
854 | const Core::HID::VibrationDeviceHandle& vibration_device_handle) const { | ||
881 | if (!IsDeviceHandleValid(vibration_device_handle)) { | 855 | if (!IsDeviceHandleValid(vibration_device_handle)) { |
882 | return false; | 856 | return false; |
883 | } | 857 | } |
884 | 858 | ||
885 | const auto npad_index = NPadIdToIndex(vibration_device_handle.npad_id); | 859 | const auto& controller = GetControllerFromHandle(vibration_device_handle); |
886 | const auto& controller = controller_data[npad_index]; | ||
887 | const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index); | 860 | const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index); |
888 | return controller.vibration[device_index].device_mounted; | 861 | return controller.vibration[device_index].device_mounted; |
889 | } | 862 | } |
890 | 863 | ||
891 | Kernel::KReadableEvent& Controller_NPad::GetStyleSetChangedEvent(u32 npad_id) { | 864 | Kernel::KReadableEvent& Controller_NPad::GetStyleSetChangedEvent(Core::HID::NpadIdType npad_id) { |
892 | const auto& controller = controller_data[NPadIdToIndex(npad_id)]; | 865 | if (!IsNpadIdValid(npad_id)) { |
866 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); | ||
867 | // Fallback to player 1 | ||
868 | const auto& controller = GetControllerFromNpadIdType(Core::HID::NpadIdType::Player1); | ||
869 | return controller.styleset_changed_event->GetReadableEvent(); | ||
870 | } | ||
871 | |||
872 | const auto& controller = GetControllerFromNpadIdType(npad_id); | ||
893 | return controller.styleset_changed_event->GetReadableEvent(); | 873 | return controller.styleset_changed_event->GetReadableEvent(); |
894 | } | 874 | } |
895 | 875 | ||
896 | void Controller_NPad::SignalStyleSetChangedEvent(u32 npad_id) const { | 876 | void Controller_NPad::SignalStyleSetChangedEvent(Core::HID::NpadIdType npad_id) const { |
897 | const auto& controller = controller_data[NPadIdToIndex(npad_id)]; | 877 | const auto& controller = GetControllerFromNpadIdType(npad_id); |
898 | controller.styleset_changed_event->GetWritableEvent().Signal(); | 878 | controller.styleset_changed_event->GetWritableEvent().Signal(); |
899 | } | 879 | } |
900 | 880 | ||
901 | void Controller_NPad::AddNewControllerAt(Core::HID::NpadStyleIndex controller, | 881 | void Controller_NPad::AddNewControllerAt(Core::HID::NpadStyleIndex controller, |
902 | std::size_t npad_index) { | 882 | Core::HID::NpadIdType npad_id) { |
903 | UpdateControllerAt(controller, npad_index, true); | 883 | UpdateControllerAt(controller, npad_id, true); |
904 | } | 884 | } |
905 | 885 | ||
906 | void Controller_NPad::UpdateControllerAt(Core::HID::NpadStyleIndex type, std::size_t npad_index, | 886 | void Controller_NPad::UpdateControllerAt(Core::HID::NpadStyleIndex type, |
907 | bool connected) { | 887 | Core::HID::NpadIdType npad_id, bool connected) { |
908 | auto& controller = controller_data[npad_index]; | 888 | auto& controller = GetControllerFromNpadIdType(npad_id); |
909 | if (!connected) { | 889 | if (!connected) { |
910 | DisconnectNpadAtIndex(npad_index); | 890 | DisconnectNpad(npad_id); |
911 | return; | 891 | return; |
912 | } | 892 | } |
913 | 893 | ||
914 | controller.device->SetNpadStyleIndex(type); | 894 | controller.device->SetNpadStyleIndex(type); |
915 | InitNewlyAddedController(npad_index); | 895 | InitNewlyAddedController(npad_id); |
916 | } | 896 | } |
917 | 897 | ||
918 | void Controller_NPad::DisconnectNpad(u32 npad_id) { | 898 | void Controller_NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) { |
919 | DisconnectNpadAtIndex(NPadIdToIndex(npad_id)); | 899 | if (!IsNpadIdValid(npad_id)) { |
920 | } | 900 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); |
901 | return; | ||
902 | } | ||
921 | 903 | ||
922 | void Controller_NPad::DisconnectNpadAtIndex(std::size_t npad_index) { | 904 | LOG_DEBUG(Service_HID, "Npad disconnected {}", npad_id); |
923 | auto& controller = controller_data[npad_index]; | 905 | auto& controller = GetControllerFromNpadIdType(npad_id); |
924 | for (std::size_t device_idx = 0; device_idx < controller.vibration.size(); ++device_idx) { | 906 | for (std::size_t device_idx = 0; device_idx < controller.vibration.size(); ++device_idx) { |
925 | // Send an empty vibration to stop any vibrations. | 907 | // Send an empty vibration to stop any vibrations. |
926 | VibrateControllerAtIndex(npad_index, device_idx, {}); | 908 | VibrateControllerAtIndex(npad_id, device_idx, {}); |
927 | controller.vibration[device_idx].device_mounted = false; | 909 | controller.vibration[device_idx].device_mounted = false; |
928 | } | 910 | } |
929 | 911 | ||
930 | auto& shared_memory_entry = controller.shared_memory_entry; | 912 | auto& shared_memory_entry = controller.shared_memory_entry; |
931 | shared_memory_entry.style_set.raw = 0; // Zero out | 913 | shared_memory_entry.style_tag.raw = Core::HID::NpadStyleSet::None; // Zero out |
932 | shared_memory_entry.device_type.raw = 0; | 914 | shared_memory_entry.device_type.raw = 0; |
933 | shared_memory_entry.system_properties.raw = 0; | 915 | shared_memory_entry.system_properties.raw = 0; |
934 | shared_memory_entry.button_properties.raw = 0; | 916 | shared_memory_entry.button_properties.raw = 0; |
@@ -949,48 +931,102 @@ void Controller_NPad::DisconnectNpadAtIndex(std::size_t npad_index) { | |||
949 | 931 | ||
950 | controller.is_connected = false; | 932 | controller.is_connected = false; |
951 | controller.device->Disconnect(); | 933 | controller.device->Disconnect(); |
952 | SignalStyleSetChangedEvent(IndexToNPad(npad_index)); | 934 | SignalStyleSetChangedEvent(npad_id); |
953 | WriteEmptyEntry(controller.shared_memory_entry); | 935 | WriteEmptyEntry(controller.shared_memory_entry); |
954 | } | 936 | } |
955 | 937 | ||
956 | void Controller_NPad::SetGyroscopeZeroDriftMode(GyroscopeZeroDriftMode drift_mode) { | 938 | void Controller_NPad::SetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle, |
957 | gyroscope_zero_drift_mode = drift_mode; | 939 | GyroscopeZeroDriftMode drift_mode) { |
940 | if (!IsDeviceHandleValid(sixaxis_handle)) { | ||
941 | LOG_ERROR(Service_HID, "Invalid handle"); | ||
942 | return; | ||
943 | } | ||
944 | auto& controller = GetControllerFromHandle(sixaxis_handle); | ||
945 | controller.gyroscope_zero_drift_mode = drift_mode; | ||
958 | } | 946 | } |
959 | 947 | ||
960 | Controller_NPad::GyroscopeZeroDriftMode Controller_NPad::GetGyroscopeZeroDriftMode() const { | 948 | Controller_NPad::GyroscopeZeroDriftMode Controller_NPad::GetGyroscopeZeroDriftMode( |
961 | return gyroscope_zero_drift_mode; | 949 | Core::HID::SixAxisSensorHandle sixaxis_handle) const { |
950 | if (!IsDeviceHandleValid(sixaxis_handle)) { | ||
951 | LOG_ERROR(Service_HID, "Invalid handle"); | ||
952 | // Return the default value | ||
953 | return GyroscopeZeroDriftMode::Standard; | ||
954 | } | ||
955 | const auto& controller = GetControllerFromHandle(sixaxis_handle); | ||
956 | return controller.gyroscope_zero_drift_mode; | ||
962 | } | 957 | } |
963 | 958 | ||
964 | bool Controller_NPad::IsSixAxisSensorAtRest() const { | 959 | bool Controller_NPad::IsSixAxisSensorAtRest(Core::HID::SixAxisSensorHandle sixaxis_handle) const { |
965 | return sixaxis_at_rest; | 960 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
961 | LOG_ERROR(Service_HID, "Invalid handle"); | ||
962 | // Return the default value | ||
963 | return true; | ||
964 | } | ||
965 | const auto& controller = GetControllerFromHandle(sixaxis_handle); | ||
966 | return controller.sixaxis_at_rest; | ||
967 | } | ||
968 | |||
969 | void Controller_NPad::SetSixAxisEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle, | ||
970 | bool sixaxis_status) { | ||
971 | if (!IsDeviceHandleValid(sixaxis_handle)) { | ||
972 | LOG_ERROR(Service_HID, "Invalid handle"); | ||
973 | return; | ||
974 | } | ||
975 | auto& controller = GetControllerFromHandle(sixaxis_handle); | ||
976 | controller.sixaxis_sensor_enabled = sixaxis_status; | ||
966 | } | 977 | } |
967 | 978 | ||
968 | void Controller_NPad::SetSixAxisEnabled(bool six_axis_status) { | 979 | void Controller_NPad::SetSixAxisFusionEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle, |
969 | sixaxis_sensors_enabled = six_axis_status; | 980 | bool sixaxis_fusion_status) { |
981 | if (!IsDeviceHandleValid(sixaxis_handle)) { | ||
982 | LOG_ERROR(Service_HID, "Invalid handle"); | ||
983 | return; | ||
984 | } | ||
985 | auto& controller = GetControllerFromHandle(sixaxis_handle); | ||
986 | controller.sixaxis_fusion_enabled = sixaxis_fusion_status; | ||
970 | } | 987 | } |
971 | 988 | ||
972 | void Controller_NPad::SetSixAxisFusionParameters(f32 parameter1, f32 parameter2) { | 989 | void Controller_NPad::SetSixAxisFusionParameters( |
973 | sixaxis_fusion_parameter1 = parameter1; | 990 | Core::HID::SixAxisSensorHandle sixaxis_handle, |
974 | sixaxis_fusion_parameter2 = parameter2; | 991 | Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters) { |
992 | if (!IsDeviceHandleValid(sixaxis_handle)) { | ||
993 | LOG_ERROR(Service_HID, "Invalid handle"); | ||
994 | return; | ||
995 | } | ||
996 | auto& controller = GetControllerFromHandle(sixaxis_handle); | ||
997 | controller.sixaxis_fusion = sixaxis_fusion_parameters; | ||
975 | } | 998 | } |
976 | 999 | ||
977 | std::pair<f32, f32> Controller_NPad::GetSixAxisFusionParameters() { | 1000 | Core::HID::SixAxisSensorFusionParameters Controller_NPad::GetSixAxisFusionParameters( |
978 | return { | 1001 | Core::HID::SixAxisSensorHandle sixaxis_handle) { |
979 | sixaxis_fusion_parameter1, | 1002 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
980 | sixaxis_fusion_parameter2, | 1003 | LOG_ERROR(Service_HID, "Invalid handle"); |
981 | }; | 1004 | // Since these parameters are unknow just return zeros |
1005 | return {}; | ||
1006 | } | ||
1007 | auto& controller = GetControllerFromHandle(sixaxis_handle); | ||
1008 | return controller.sixaxis_fusion; | ||
982 | } | 1009 | } |
983 | 1010 | ||
984 | void Controller_NPad::ResetSixAxisFusionParameters() { | 1011 | void Controller_NPad::ResetSixAxisFusionParameters(Core::HID::SixAxisSensorHandle sixaxis_handle) { |
985 | sixaxis_fusion_parameter1 = 0.0f; | 1012 | if (!IsDeviceHandleValid(sixaxis_handle)) { |
986 | sixaxis_fusion_parameter2 = 0.0f; | 1013 | LOG_ERROR(Service_HID, "Invalid handle"); |
1014 | return; | ||
1015 | } | ||
1016 | auto& controller = GetControllerFromHandle(sixaxis_handle); | ||
1017 | // Since these parameters are unknow just fill with zeros | ||
1018 | controller.sixaxis_fusion = {}; | ||
987 | } | 1019 | } |
988 | 1020 | ||
989 | void Controller_NPad::MergeSingleJoyAsDualJoy(u32 npad_id_1, u32 npad_id_2) { | 1021 | void Controller_NPad::MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1, |
990 | const auto npad_index_1 = NPadIdToIndex(npad_id_1); | 1022 | Core::HID::NpadIdType npad_id_2) { |
991 | const auto npad_index_2 = NPadIdToIndex(npad_id_2); | 1023 | if (!IsNpadIdValid(npad_id_1) || IsNpadIdValid(npad_id_2)) { |
992 | const auto& controller_1 = controller_data[npad_index_1].device; | 1024 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1, |
993 | const auto& controller_2 = controller_data[npad_index_2].device; | 1025 | npad_id_2); |
1026 | return; | ||
1027 | } | ||
1028 | auto& controller_1 = GetControllerFromNpadIdType(npad_id_1).device; | ||
1029 | auto& controller_2 = GetControllerFromNpadIdType(npad_id_2).device; | ||
994 | 1030 | ||
995 | // If the controllers at both npad indices form a pair of left and right joycons, merge them. | 1031 | // If the controllers at both npad indices form a pair of left and right joycons, merge them. |
996 | // Otherwise, do nothing. | 1032 | // Otherwise, do nothing. |
@@ -1000,7 +1036,7 @@ void Controller_NPad::MergeSingleJoyAsDualJoy(u32 npad_id_1, u32 npad_id_2) { | |||
1000 | controller_1->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight)) { | 1036 | controller_1->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight)) { |
1001 | // Disconnect the joycon at the second id and connect the dual joycon at the first index. | 1037 | // Disconnect the joycon at the second id and connect the dual joycon at the first index. |
1002 | DisconnectNpad(npad_id_2); | 1038 | DisconnectNpad(npad_id_2); |
1003 | AddNewControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_index_1); | 1039 | AddNewControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id_1); |
1004 | } | 1040 | } |
1005 | } | 1041 | } |
1006 | 1042 | ||
@@ -1014,15 +1050,20 @@ void Controller_NPad::StopLRAssignmentMode() { | |||
1014 | is_in_lr_assignment_mode = false; | 1050 | is_in_lr_assignment_mode = false; |
1015 | } | 1051 | } |
1016 | 1052 | ||
1017 | bool Controller_NPad::SwapNpadAssignment(u32 npad_id_1, u32 npad_id_2) { | 1053 | bool Controller_NPad::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, |
1018 | if (npad_id_1 == NPAD_HANDHELD || npad_id_2 == NPAD_HANDHELD || npad_id_1 == NPAD_UNKNOWN || | 1054 | Core::HID::NpadIdType npad_id_2) { |
1019 | npad_id_2 == NPAD_UNKNOWN) { | 1055 | if (!IsNpadIdValid(npad_id_1) || IsNpadIdValid(npad_id_2)) { |
1056 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1, | ||
1057 | npad_id_2); | ||
1058 | return false; | ||
1059 | } | ||
1060 | if (npad_id_1 == Core::HID::NpadIdType::Handheld || | ||
1061 | npad_id_2 == Core::HID::NpadIdType::Handheld || npad_id_1 == Core::HID::NpadIdType::Other || | ||
1062 | npad_id_2 == Core::HID::NpadIdType::Other) { | ||
1020 | return true; | 1063 | return true; |
1021 | } | 1064 | } |
1022 | const auto npad_index_1 = NPadIdToIndex(npad_id_1); | 1065 | const auto& controller_1 = GetControllerFromNpadIdType(npad_id_1).device; |
1023 | const auto npad_index_2 = NPadIdToIndex(npad_id_2); | 1066 | const auto& controller_2 = GetControllerFromNpadIdType(npad_id_2).device; |
1024 | const auto& controller_1 = controller_data[npad_index_1].device; | ||
1025 | const auto& controller_2 = controller_data[npad_index_2].device; | ||
1026 | const auto type_index_1 = controller_1->GetNpadStyleIndex(); | 1067 | const auto type_index_1 = controller_1->GetNpadStyleIndex(); |
1027 | const auto type_index_2 = controller_2->GetNpadStyleIndex(); | 1068 | const auto type_index_2 = controller_2->GetNpadStyleIndex(); |
1028 | 1069 | ||
@@ -1030,28 +1071,39 @@ bool Controller_NPad::SwapNpadAssignment(u32 npad_id_1, u32 npad_id_2) { | |||
1030 | return false; | 1071 | return false; |
1031 | } | 1072 | } |
1032 | 1073 | ||
1033 | AddNewControllerAt(type_index_2, npad_index_1); | 1074 | AddNewControllerAt(type_index_2, npad_id_1); |
1034 | AddNewControllerAt(type_index_1, npad_index_2); | 1075 | AddNewControllerAt(type_index_1, npad_id_2); |
1035 | 1076 | ||
1036 | return true; | 1077 | return true; |
1037 | } | 1078 | } |
1038 | 1079 | ||
1039 | Core::HID::LedPattern Controller_NPad::GetLedPattern(u32 npad_id) { | 1080 | Core::HID::LedPattern Controller_NPad::GetLedPattern(Core::HID::NpadIdType npad_id) { |
1040 | if (npad_id == npad_id_list.back() || npad_id == npad_id_list[npad_id_list.size() - 2]) { | 1081 | if (!IsNpadIdValid(npad_id)) { |
1041 | // These are controllers without led patterns | 1082 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); |
1042 | return Core::HID::LedPattern{0, 0, 0, 0}; | 1083 | return Core::HID::LedPattern{0, 0, 0, 0}; |
1043 | } | 1084 | } |
1044 | return controller_data[npad_id].device->GetLedPattern(); | 1085 | const auto& controller = GetControllerFromNpadIdType(npad_id).device; |
1086 | return controller->GetLedPattern(); | ||
1045 | } | 1087 | } |
1046 | 1088 | ||
1047 | bool Controller_NPad::IsUnintendedHomeButtonInputProtectionEnabled(u32 npad_id) const { | 1089 | bool Controller_NPad::IsUnintendedHomeButtonInputProtectionEnabled( |
1048 | auto& controller = controller_data[NPadIdToIndex(npad_id)]; | 1090 | Core::HID::NpadIdType npad_id) const { |
1091 | if (!IsNpadIdValid(npad_id)) { | ||
1092 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); | ||
1093 | // Return the default value | ||
1094 | return false; | ||
1095 | } | ||
1096 | const auto& controller = GetControllerFromNpadIdType(npad_id); | ||
1049 | return controller.unintended_home_button_input_protection; | 1097 | return controller.unintended_home_button_input_protection; |
1050 | } | 1098 | } |
1051 | 1099 | ||
1052 | void Controller_NPad::SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled, | 1100 | void Controller_NPad::SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled, |
1053 | u32 npad_id) { | 1101 | Core::HID::NpadIdType npad_id) { |
1054 | auto& controller = controller_data[NPadIdToIndex(npad_id)]; | 1102 | if (!IsNpadIdValid(npad_id)) { |
1103 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); | ||
1104 | return; | ||
1105 | } | ||
1106 | auto& controller = GetControllerFromNpadIdType(npad_id); | ||
1055 | controller.unintended_home_button_input_protection = is_protection_enabled; | 1107 | controller.unintended_home_button_input_protection = is_protection_enabled; |
1056 | } | 1108 | } |
1057 | 1109 | ||
@@ -1099,7 +1151,7 @@ bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller | |||
1099 | if (controller == Core::HID::NpadStyleIndex::Handheld) { | 1151 | if (controller == Core::HID::NpadStyleIndex::Handheld) { |
1100 | const bool support_handheld = | 1152 | const bool support_handheld = |
1101 | std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(), | 1153 | std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(), |
1102 | NPAD_HANDHELD) != supported_npad_id_types.end(); | 1154 | Core::HID::NpadIdType::Handheld) != supported_npad_id_types.end(); |
1103 | // Handheld is not even a supported type, lets stop here | 1155 | // Handheld is not even a supported type, lets stop here |
1104 | if (!support_handheld) { | 1156 | if (!support_handheld) { |
1105 | return false; | 1157 | return false; |
@@ -1113,7 +1165,9 @@ bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller | |||
1113 | } | 1165 | } |
1114 | 1166 | ||
1115 | if (std::any_of(supported_npad_id_types.begin(), supported_npad_id_types.end(), | 1167 | if (std::any_of(supported_npad_id_types.begin(), supported_npad_id_types.end(), |
1116 | [](u32 npad_id) { return npad_id <= MAX_NPAD_ID; })) { | 1168 | [](Core::HID::NpadIdType npad_id) { |
1169 | return npad_id <= Core::HID::NpadIdType::Player8; | ||
1170 | })) { | ||
1117 | Core::HID::NpadStyleTag style = GetSupportedStyleSet(); | 1171 | Core::HID::NpadStyleTag style = GetSupportedStyleSet(); |
1118 | switch (controller) { | 1172 | switch (controller) { |
1119 | case Core::HID::NpadStyleIndex::ProController: | 1173 | case Core::HID::NpadStyleIndex::ProController: |
@@ -1144,4 +1198,48 @@ bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller | |||
1144 | return false; | 1198 | return false; |
1145 | } | 1199 | } |
1146 | 1200 | ||
1201 | Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromHandle( | ||
1202 | const Core::HID::SixAxisSensorHandle& device_handle) { | ||
1203 | const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id); | ||
1204 | return GetControllerFromNpadIdType(npad_id); | ||
1205 | } | ||
1206 | |||
1207 | const Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromHandle( | ||
1208 | const Core::HID::SixAxisSensorHandle& device_handle) const { | ||
1209 | const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id); | ||
1210 | return GetControllerFromNpadIdType(npad_id); | ||
1211 | } | ||
1212 | |||
1213 | Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromHandle( | ||
1214 | const Core::HID::VibrationDeviceHandle& device_handle) { | ||
1215 | const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id); | ||
1216 | return GetControllerFromNpadIdType(npad_id); | ||
1217 | } | ||
1218 | |||
1219 | const Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromHandle( | ||
1220 | const Core::HID::VibrationDeviceHandle& device_handle) const { | ||
1221 | const auto npad_id = static_cast<Core::HID::NpadIdType>(device_handle.npad_id); | ||
1222 | return GetControllerFromNpadIdType(npad_id); | ||
1223 | } | ||
1224 | |||
1225 | Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromNpadIdType( | ||
1226 | Core::HID::NpadIdType npad_id) { | ||
1227 | if (!IsNpadIdValid(npad_id)) { | ||
1228 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); | ||
1229 | npad_id = Core::HID::NpadIdType::Player1; | ||
1230 | } | ||
1231 | const auto npad_index = Core::HID::NpadIdTypeToIndex(npad_id); | ||
1232 | return controller_data[npad_index]; | ||
1233 | } | ||
1234 | |||
1235 | const Controller_NPad::NpadControllerData& Controller_NPad::GetControllerFromNpadIdType( | ||
1236 | Core::HID::NpadIdType npad_id) const { | ||
1237 | if (!IsNpadIdValid(npad_id)) { | ||
1238 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); | ||
1239 | npad_id = Core::HID::NpadIdType::Player1; | ||
1240 | } | ||
1241 | const auto npad_index = Core::HID::NpadIdTypeToIndex(npad_id); | ||
1242 | return controller_data[npad_index]; | ||
1243 | } | ||
1244 | |||
1147 | } // namespace Service::HID | 1245 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index a996755ed..3798c037f 100755 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
@@ -31,9 +31,6 @@ class ServiceContext; | |||
31 | 31 | ||
32 | namespace Service::HID { | 32 | namespace Service::HID { |
33 | 33 | ||
34 | constexpr u32 NPAD_HANDHELD = 32; | ||
35 | constexpr u32 NPAD_UNKNOWN = 16; // TODO(ogniK): What is this? | ||
36 | |||
37 | class Controller_NPad final : public ControllerBase { | 34 | class Controller_NPad final : public ControllerBase { |
38 | public: | 35 | public: |
39 | explicit Controller_NPad(Core::HID::HIDCore& hid_core_, | 36 | explicit Controller_NPad(Core::HID::HIDCore& hid_core_, |
@@ -53,13 +50,6 @@ public: | |||
53 | void OnMotionUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, | 50 | void OnMotionUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, |
54 | std::size_t size) override; | 51 | std::size_t size) override; |
55 | 52 | ||
56 | enum class DeviceIndex : u8 { | ||
57 | Left = 0, | ||
58 | Right = 1, | ||
59 | None = 2, | ||
60 | MaxDeviceIndex = 3, | ||
61 | }; | ||
62 | |||
63 | // This is nn::hid::GyroscopeZeroDriftMode | 53 | // This is nn::hid::GyroscopeZeroDriftMode |
64 | enum class GyroscopeZeroDriftMode : u32 { | 54 | enum class GyroscopeZeroDriftMode : u32 { |
65 | Loose = 0, | 55 | Loose = 0, |
@@ -79,6 +69,12 @@ public: | |||
79 | Single = 1, | 69 | Single = 1, |
80 | }; | 70 | }; |
81 | 71 | ||
72 | // This is nn::hid::NpadJoyDeviceType | ||
73 | enum class NpadJoyDeviceType : s64 { | ||
74 | Left = 0, | ||
75 | Right = 1, | ||
76 | }; | ||
77 | |||
82 | // This is nn::hid::NpadHandheldActivationMode | 78 | // This is nn::hid::NpadHandheldActivationMode |
83 | enum class NpadHandheldActivationMode : u64 { | 79 | enum class NpadHandheldActivationMode : u64 { |
84 | Dual = 0, | 80 | Dual = 0, |
@@ -94,28 +90,11 @@ public: | |||
94 | Default = 3, | 90 | Default = 3, |
95 | }; | 91 | }; |
96 | 92 | ||
97 | struct DeviceHandle { | 93 | static constexpr Core::HID::VibrationValue DEFAULT_VIBRATION_VALUE{ |
98 | Core::HID::NpadStyleIndex npad_type; | 94 | .low_amplitude = 0.0f, |
99 | u8 npad_id; | 95 | .low_frequency = 160.0f, |
100 | DeviceIndex device_index; | 96 | .high_amplitude = 0.0f, |
101 | INSERT_PADDING_BYTES_NOINIT(1); | 97 | .high_frequency = 320.0f, |
102 | }; | ||
103 | static_assert(sizeof(DeviceHandle) == 4, "DeviceHandle is an invalid size"); | ||
104 | |||
105 | // This is nn::hid::VibrationValue | ||
106 | struct VibrationValue { | ||
107 | f32 amp_low; | ||
108 | f32 freq_low; | ||
109 | f32 amp_high; | ||
110 | f32 freq_high; | ||
111 | }; | ||
112 | static_assert(sizeof(VibrationValue) == 0x10, "Vibration is an invalid size"); | ||
113 | |||
114 | static constexpr VibrationValue DEFAULT_VIBRATION_VALUE{ | ||
115 | .amp_low = 0.0f, | ||
116 | .freq_low = 160.0f, | ||
117 | .amp_high = 0.0f, | ||
118 | .freq_high = 320.0f, | ||
119 | }; | 98 | }; |
120 | 99 | ||
121 | void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set); | 100 | void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set); |
@@ -134,68 +113,77 @@ public: | |||
134 | void SetNpadCommunicationMode(NpadCommunicationMode communication_mode_); | 113 | void SetNpadCommunicationMode(NpadCommunicationMode communication_mode_); |
135 | NpadCommunicationMode GetNpadCommunicationMode() const; | 114 | NpadCommunicationMode GetNpadCommunicationMode() const; |
136 | 115 | ||
137 | void SetNpadMode(u32 npad_id, NpadJoyAssignmentMode assignment_mode); | 116 | void SetNpadMode(Core::HID::NpadIdType npad_id, NpadJoyAssignmentMode assignment_mode); |
138 | 117 | ||
139 | bool VibrateControllerAtIndex(std::size_t npad_index, std::size_t device_index, | 118 | bool VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index, |
140 | const VibrationValue& vibration_value); | 119 | const Core::HID::VibrationValue& vibration_value); |
141 | 120 | ||
142 | void VibrateController(const DeviceHandle& vibration_device_handle, | 121 | void VibrateController(const Core::HID::VibrationDeviceHandle& vibration_device_handle, |
143 | const VibrationValue& vibration_value); | 122 | const Core::HID::VibrationValue& vibration_value); |
144 | 123 | ||
145 | void VibrateControllers(const std::vector<DeviceHandle>& vibration_device_handles, | 124 | void VibrateControllers( |
146 | const std::vector<VibrationValue>& vibration_values); | 125 | const std::vector<Core::HID::VibrationDeviceHandle>& vibration_device_handles, |
126 | const std::vector<Core::HID::VibrationValue>& vibration_values); | ||
147 | 127 | ||
148 | VibrationValue GetLastVibration(const DeviceHandle& vibration_device_handle) const; | 128 | Core::HID::VibrationValue GetLastVibration( |
129 | const Core::HID::VibrationDeviceHandle& vibration_device_handle) const; | ||
149 | 130 | ||
150 | void InitializeVibrationDevice(const DeviceHandle& vibration_device_handle); | 131 | void InitializeVibrationDevice(const Core::HID::VibrationDeviceHandle& vibration_device_handle); |
151 | 132 | ||
152 | void InitializeVibrationDeviceAtIndex(std::size_t npad_index, std::size_t device_index); | 133 | void InitializeVibrationDeviceAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index); |
153 | 134 | ||
154 | void SetPermitVibrationSession(bool permit_vibration_session); | 135 | void SetPermitVibrationSession(bool permit_vibration_session); |
155 | 136 | ||
156 | bool IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const; | 137 | bool IsVibrationDeviceMounted( |
138 | const Core::HID::VibrationDeviceHandle& vibration_device_handle) const; | ||
157 | 139 | ||
158 | Kernel::KReadableEvent& GetStyleSetChangedEvent(u32 npad_id); | 140 | Kernel::KReadableEvent& GetStyleSetChangedEvent(Core::HID::NpadIdType npad_id); |
159 | void SignalStyleSetChangedEvent(u32 npad_id) const; | 141 | void SignalStyleSetChangedEvent(Core::HID::NpadIdType npad_id) const; |
160 | 142 | ||
161 | // Adds a new controller at an index. | 143 | // Adds a new controller at an index. |
162 | void AddNewControllerAt(Core::HID::NpadStyleIndex controller, std::size_t npad_index); | 144 | void AddNewControllerAt(Core::HID::NpadStyleIndex controller, Core::HID::NpadIdType npad_id); |
163 | // Adds a new controller at an index with connection status. | 145 | // Adds a new controller at an index with connection status. |
164 | void UpdateControllerAt(Core::HID::NpadStyleIndex controller, std::size_t npad_index, | 146 | void UpdateControllerAt(Core::HID::NpadStyleIndex controller, Core::HID::NpadIdType npad_id, |
165 | bool connected); | 147 | bool connected); |
166 | 148 | ||
167 | void DisconnectNpad(u32 npad_id); | 149 | void DisconnectNpad(Core::HID::NpadIdType npad_id); |
168 | void DisconnectNpadAtIndex(std::size_t index); | 150 | |
169 | 151 | void SetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle, | |
170 | void SetGyroscopeZeroDriftMode(GyroscopeZeroDriftMode drift_mode); | 152 | GyroscopeZeroDriftMode drift_mode); |
171 | GyroscopeZeroDriftMode GetGyroscopeZeroDriftMode() const; | 153 | GyroscopeZeroDriftMode GetGyroscopeZeroDriftMode( |
172 | bool IsSixAxisSensorAtRest() const; | 154 | Core::HID::SixAxisSensorHandle sixaxis_handle) const; |
173 | void SetSixAxisEnabled(bool six_axis_status); | 155 | bool IsSixAxisSensorAtRest(Core::HID::SixAxisSensorHandle sixaxis_handle) const; |
174 | void SetSixAxisFusionParameters(f32 parameter1, f32 parameter2); | 156 | void SetSixAxisEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle, bool sixaxis_status); |
175 | std::pair<f32, f32> GetSixAxisFusionParameters(); | 157 | void SetSixAxisFusionEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle, |
176 | void ResetSixAxisFusionParameters(); | 158 | bool sixaxis_fusion_status); |
177 | Core::HID::LedPattern GetLedPattern(u32 npad_id); | 159 | void SetSixAxisFusionParameters( |
178 | bool IsUnintendedHomeButtonInputProtectionEnabled(u32 npad_id) const; | 160 | Core::HID::SixAxisSensorHandle sixaxis_handle, |
179 | void SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled, u32 npad_id); | 161 | Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters); |
162 | Core::HID::SixAxisSensorFusionParameters GetSixAxisFusionParameters( | ||
163 | Core::HID::SixAxisSensorHandle sixaxis_handle); | ||
164 | void ResetSixAxisFusionParameters(Core::HID::SixAxisSensorHandle sixaxis_handle); | ||
165 | Core::HID::LedPattern GetLedPattern(Core::HID::NpadIdType npad_id); | ||
166 | bool IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id) const; | ||
167 | void SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled, | ||
168 | Core::HID::NpadIdType npad_id); | ||
180 | void SetAnalogStickUseCenterClamp(bool use_center_clamp); | 169 | void SetAnalogStickUseCenterClamp(bool use_center_clamp); |
181 | void ClearAllConnectedControllers(); | 170 | void ClearAllConnectedControllers(); |
182 | void DisconnectAllConnectedControllers(); | 171 | void DisconnectAllConnectedControllers(); |
183 | void ConnectAllDisconnectedControllers(); | 172 | void ConnectAllDisconnectedControllers(); |
184 | void ClearAllControllers(); | 173 | void ClearAllControllers(); |
185 | 174 | ||
186 | void MergeSingleJoyAsDualJoy(u32 npad_id_1, u32 npad_id_2); | 175 | void MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1, Core::HID::NpadIdType npad_id_2); |
187 | void StartLRAssignmentMode(); | 176 | void StartLRAssignmentMode(); |
188 | void StopLRAssignmentMode(); | 177 | void StopLRAssignmentMode(); |
189 | bool SwapNpadAssignment(u32 npad_id_1, u32 npad_id_2); | 178 | bool SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, Core::HID::NpadIdType npad_id_2); |
190 | 179 | ||
191 | // Logical OR for all buttons presses on all controllers | 180 | // Logical OR for all buttons presses on all controllers |
192 | // Specifically for cheat engine and other features. | 181 | // Specifically for cheat engine and other features. |
193 | u32 GetAndResetPressState(); | 182 | u32 GetAndResetPressState(); |
194 | 183 | ||
195 | static std::size_t NPadIdToIndex(u32 npad_id); | 184 | static bool IsNpadIdValid(Core::HID::NpadIdType npad_id); |
196 | static u32 IndexToNPad(std::size_t index); | 185 | static bool IsDeviceHandleValid(const Core::HID::SixAxisSensorHandle& device_handle); |
197 | static bool IsNpadIdValid(u32 npad_id); | 186 | static bool IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle); |
198 | static bool IsDeviceHandleValid(const DeviceHandle& device_handle); | ||
199 | 187 | ||
200 | private: | 188 | private: |
201 | // This is nn::hid::detail::ColorAttribute | 189 | // This is nn::hid::detail::ColorAttribute |
@@ -441,7 +429,7 @@ private: | |||
441 | 429 | ||
442 | // This is nn::hid::detail::NpadInternalState | 430 | // This is nn::hid::detail::NpadInternalState |
443 | struct NpadInternalState { | 431 | struct NpadInternalState { |
444 | Core::HID::NpadStyleTag style_set; | 432 | Core::HID::NpadStyleTag style_tag; |
445 | NpadJoyAssignmentMode assignment_mode; | 433 | NpadJoyAssignmentMode assignment_mode; |
446 | NpadFullKeyColorState fullkey_color; | 434 | NpadFullKeyColorState fullkey_color; |
447 | NpadJoyColorState joycon_color; | 435 | NpadJoyColorState joycon_color; |
@@ -476,19 +464,19 @@ private: | |||
476 | NpadLuciaType lucia_type; | 464 | NpadLuciaType lucia_type; |
477 | NpadLagonType lagon_type; | 465 | NpadLagonType lagon_type; |
478 | NpadLagerType lager_type; | 466 | NpadLagerType lager_type; |
479 | INSERT_PADDING_BYTES( | 467 | // FW 13.x Investigate there is some sort of bitflag related to joycons |
480 | 0x4); // FW 13.x Investigate there is some sort of bitflag related to joycons | 468 | INSERT_PADDING_BYTES(0x4); |
481 | INSERT_PADDING_BYTES(0xc08); // Unknown | 469 | INSERT_PADDING_BYTES(0xc08); // Unknown |
482 | }; | 470 | }; |
483 | static_assert(sizeof(NpadInternalState) == 0x5000, "NpadInternalState is an invalid size"); | 471 | static_assert(sizeof(NpadInternalState) == 0x5000, "NpadInternalState is an invalid size"); |
484 | 472 | ||
485 | struct VibrationData { | 473 | struct VibrationData { |
486 | bool device_mounted{}; | 474 | bool device_mounted{}; |
487 | VibrationValue latest_vibration_value{}; | 475 | Core::HID::VibrationValue latest_vibration_value{}; |
488 | std::chrono::steady_clock::time_point last_vibration_timepoint{}; | 476 | std::chrono::steady_clock::time_point last_vibration_timepoint{}; |
489 | }; | 477 | }; |
490 | 478 | ||
491 | struct ControllerData { | 479 | struct NpadControllerData { |
492 | Core::HID::EmulatedController* device; | 480 | Core::HID::EmulatedController* device; |
493 | Kernel::KEvent* styleset_changed_event{}; | 481 | Kernel::KEvent* styleset_changed_event{}; |
494 | NpadInternalState shared_memory_entry{}; | 482 | NpadInternalState shared_memory_entry{}; |
@@ -498,6 +486,13 @@ private: | |||
498 | bool is_connected{}; | 486 | bool is_connected{}; |
499 | Core::HID::NpadStyleIndex npad_type{Core::HID::NpadStyleIndex::None}; | 487 | Core::HID::NpadStyleIndex npad_type{Core::HID::NpadStyleIndex::None}; |
500 | 488 | ||
489 | // Motion parameters | ||
490 | bool sixaxis_at_rest{true}; | ||
491 | bool sixaxis_sensor_enabled{true}; | ||
492 | bool sixaxis_fusion_enabled{false}; | ||
493 | Core::HID::SixAxisSensorFusionParameters sixaxis_fusion{}; | ||
494 | GyroscopeZeroDriftMode gyroscope_zero_drift_mode{GyroscopeZeroDriftMode::Standard}; | ||
495 | |||
501 | // Current pad state | 496 | // Current pad state |
502 | NPadGenericState npad_pad_state{}; | 497 | NPadGenericState npad_pad_state{}; |
503 | NPadGenericState npad_libnx_state{}; | 498 | NPadGenericState npad_libnx_state{}; |
@@ -512,27 +507,33 @@ private: | |||
512 | }; | 507 | }; |
513 | 508 | ||
514 | void ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t controller_idx); | 509 | void ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t controller_idx); |
515 | void InitNewlyAddedController(std::size_t controller_idx); | 510 | void InitNewlyAddedController(Core::HID::NpadIdType npad_id); |
516 | bool IsControllerSupported(Core::HID::NpadStyleIndex controller) const; | 511 | bool IsControllerSupported(Core::HID::NpadStyleIndex controller) const; |
517 | void RequestPadStateUpdate(u32 npad_id); | 512 | void RequestPadStateUpdate(Core::HID::NpadIdType npad_id); |
518 | void WriteEmptyEntry(NpadInternalState& npad); | 513 | void WriteEmptyEntry(NpadInternalState& npad); |
519 | 514 | ||
515 | NpadControllerData& GetControllerFromHandle( | ||
516 | const Core::HID::SixAxisSensorHandle& device_handle); | ||
517 | const NpadControllerData& GetControllerFromHandle( | ||
518 | const Core::HID::SixAxisSensorHandle& device_handle) const; | ||
519 | NpadControllerData& GetControllerFromHandle( | ||
520 | const Core::HID::VibrationDeviceHandle& device_handle); | ||
521 | const NpadControllerData& GetControllerFromHandle( | ||
522 | const Core::HID::VibrationDeviceHandle& device_handle) const; | ||
523 | NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id); | ||
524 | const NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) const; | ||
525 | |||
520 | std::atomic<u32> press_state{}; | 526 | std::atomic<u32> press_state{}; |
521 | 527 | ||
522 | std::array<ControllerData, 10> controller_data{}; | 528 | std::array<NpadControllerData, 10> controller_data{}; |
523 | KernelHelpers::ServiceContext& service_context; | 529 | KernelHelpers::ServiceContext& service_context; |
524 | std::mutex mutex; | 530 | std::mutex mutex; |
525 | std::vector<u32> supported_npad_id_types{}; | 531 | std::vector<Core::HID::NpadIdType> supported_npad_id_types{}; |
526 | NpadJoyHoldType hold_type{NpadJoyHoldType::Vertical}; | 532 | NpadJoyHoldType hold_type{NpadJoyHoldType::Vertical}; |
527 | NpadHandheldActivationMode handheld_activation_mode{NpadHandheldActivationMode::Dual}; | 533 | NpadHandheldActivationMode handheld_activation_mode{NpadHandheldActivationMode::Dual}; |
528 | NpadCommunicationMode communication_mode{NpadCommunicationMode::Default}; | 534 | NpadCommunicationMode communication_mode{NpadCommunicationMode::Default}; |
529 | bool permit_vibration_session_enabled{false}; | 535 | bool permit_vibration_session_enabled{false}; |
530 | bool analog_stick_use_center_clamp{}; | 536 | bool analog_stick_use_center_clamp{}; |
531 | GyroscopeZeroDriftMode gyroscope_zero_drift_mode{GyroscopeZeroDriftMode::Standard}; | ||
532 | bool sixaxis_sensors_enabled{true}; | ||
533 | f32 sixaxis_fusion_parameter1{}; | ||
534 | f32 sixaxis_fusion_parameter2{}; | ||
535 | bool sixaxis_at_rest{true}; | ||
536 | bool is_in_lr_assignment_mode{false}; | 537 | bool is_in_lr_assignment_mode{false}; |
537 | }; | 538 | }; |
538 | } // namespace Service::HID | 539 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 96e8fb7e1..e257b1c8a 100755 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
@@ -161,7 +161,7 @@ public: | |||
161 | private: | 161 | private: |
162 | void InitializeVibrationDevice(Kernel::HLERequestContext& ctx) { | 162 | void InitializeVibrationDevice(Kernel::HLERequestContext& ctx) { |
163 | IPC::RequestParser rp{ctx}; | 163 | IPC::RequestParser rp{ctx}; |
164 | const auto vibration_device_handle{rp.PopRaw<Controller_NPad::DeviceHandle>()}; | 164 | const auto vibration_device_handle{rp.PopRaw<Core::HID::VibrationDeviceHandle>()}; |
165 | 165 | ||
166 | if (applet_resource != nullptr) { | 166 | if (applet_resource != nullptr) { |
167 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 167 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
@@ -405,7 +405,6 @@ void Hid::SendKeyboardLockKeyEvent(Kernel::HLERequestContext& ctx) { | |||
405 | const auto flags{rp.Pop<u32>()}; | 405 | const auto flags{rp.Pop<u32>()}; |
406 | 406 | ||
407 | LOG_WARNING(Service_HID, "(STUBBED) called. flags={}", flags); | 407 | LOG_WARNING(Service_HID, "(STUBBED) called. flags={}", flags); |
408 | |||
409 | IPC::ResponseBuilder rb{ctx, 2}; | 408 | IPC::ResponseBuilder rb{ctx, 2}; |
410 | rb.Push(ResultSuccess); | 409 | rb.Push(ResultSuccess); |
411 | } | 410 | } |
@@ -443,19 +442,17 @@ void Hid::GetXpadIDs(Kernel::HLERequestContext& ctx) { | |||
443 | void Hid::ActivateSixAxisSensor(Kernel::HLERequestContext& ctx) { | 442 | void Hid::ActivateSixAxisSensor(Kernel::HLERequestContext& ctx) { |
444 | IPC::RequestParser rp{ctx}; | 443 | IPC::RequestParser rp{ctx}; |
445 | struct Parameters { | 444 | struct Parameters { |
446 | Controller_NPad::DeviceHandle sixaxis_handle; | 445 | u32 basic_xpad_id; |
447 | INSERT_PADDING_WORDS_NOINIT(1); | 446 | INSERT_PADDING_WORDS_NOINIT(1); |
448 | u64 applet_resource_user_id; | 447 | u64 applet_resource_user_id; |
449 | }; | 448 | }; |
450 | 449 | ||
451 | const auto parameters{rp.PopRaw<Parameters>()}; | 450 | const auto parameters{rp.PopRaw<Parameters>()}; |
452 | 451 | ||
453 | applet_resource->GetController<Controller_NPad>(HidController::NPad).SetSixAxisEnabled(true); | 452 | // This function does nothing on 10.0.0+ |
454 | 453 | ||
455 | LOG_DEBUG(Service_HID, | 454 | LOG_WARNING(Service_HID, "(STUBBED) called, basic_xpad_id={}, applet_resource_user_id={}", |
456 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 455 | parameters.basic_xpad_id, parameters.applet_resource_user_id); |
457 | parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | ||
458 | parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | ||
459 | 456 | ||
460 | IPC::ResponseBuilder rb{ctx, 2}; | 457 | IPC::ResponseBuilder rb{ctx, 2}; |
461 | rb.Push(ResultSuccess); | 458 | rb.Push(ResultSuccess); |
@@ -464,19 +461,17 @@ void Hid::ActivateSixAxisSensor(Kernel::HLERequestContext& ctx) { | |||
464 | void Hid::DeactivateSixAxisSensor(Kernel::HLERequestContext& ctx) { | 461 | void Hid::DeactivateSixAxisSensor(Kernel::HLERequestContext& ctx) { |
465 | IPC::RequestParser rp{ctx}; | 462 | IPC::RequestParser rp{ctx}; |
466 | struct Parameters { | 463 | struct Parameters { |
467 | Controller_NPad::DeviceHandle sixaxis_handle; | 464 | u32 basic_xpad_id; |
468 | INSERT_PADDING_WORDS_NOINIT(1); | 465 | INSERT_PADDING_WORDS_NOINIT(1); |
469 | u64 applet_resource_user_id; | 466 | u64 applet_resource_user_id; |
470 | }; | 467 | }; |
471 | 468 | ||
472 | const auto parameters{rp.PopRaw<Parameters>()}; | 469 | const auto parameters{rp.PopRaw<Parameters>()}; |
473 | 470 | ||
474 | applet_resource->GetController<Controller_NPad>(HidController::NPad).SetSixAxisEnabled(false); | 471 | // This function does nothing on 10.0.0+ |
475 | 472 | ||
476 | LOG_DEBUG(Service_HID, | 473 | LOG_WARNING(Service_HID, "(STUBBED) called, basic_xpad_id={}, applet_resource_user_id={}", |
477 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 474 | parameters.basic_xpad_id, parameters.applet_resource_user_id); |
478 | parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | ||
479 | parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | ||
480 | 475 | ||
481 | IPC::ResponseBuilder rb{ctx, 2}; | 476 | IPC::ResponseBuilder rb{ctx, 2}; |
482 | rb.Push(ResultSuccess); | 477 | rb.Push(ResultSuccess); |
@@ -485,14 +480,15 @@ void Hid::DeactivateSixAxisSensor(Kernel::HLERequestContext& ctx) { | |||
485 | void Hid::StartSixAxisSensor(Kernel::HLERequestContext& ctx) { | 480 | void Hid::StartSixAxisSensor(Kernel::HLERequestContext& ctx) { |
486 | IPC::RequestParser rp{ctx}; | 481 | IPC::RequestParser rp{ctx}; |
487 | struct Parameters { | 482 | struct Parameters { |
488 | Controller_NPad::DeviceHandle sixaxis_handle; | 483 | Core::HID::SixAxisSensorHandle sixaxis_handle; |
489 | INSERT_PADDING_WORDS_NOINIT(1); | 484 | INSERT_PADDING_WORDS_NOINIT(1); |
490 | u64 applet_resource_user_id; | 485 | u64 applet_resource_user_id; |
491 | }; | 486 | }; |
492 | 487 | ||
493 | const auto parameters{rp.PopRaw<Parameters>()}; | 488 | const auto parameters{rp.PopRaw<Parameters>()}; |
494 | 489 | ||
495 | applet_resource->GetController<Controller_NPad>(HidController::NPad).SetSixAxisEnabled(true); | 490 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
491 | .SetSixAxisEnabled(parameters.sixaxis_handle, true); | ||
496 | 492 | ||
497 | LOG_DEBUG(Service_HID, | 493 | LOG_DEBUG(Service_HID, |
498 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 494 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", |
@@ -506,14 +502,15 @@ void Hid::StartSixAxisSensor(Kernel::HLERequestContext& ctx) { | |||
506 | void Hid::StopSixAxisSensor(Kernel::HLERequestContext& ctx) { | 502 | void Hid::StopSixAxisSensor(Kernel::HLERequestContext& ctx) { |
507 | IPC::RequestParser rp{ctx}; | 503 | IPC::RequestParser rp{ctx}; |
508 | struct Parameters { | 504 | struct Parameters { |
509 | Controller_NPad::DeviceHandle sixaxis_handle; | 505 | Core::HID::SixAxisSensorHandle sixaxis_handle; |
510 | INSERT_PADDING_WORDS_NOINIT(1); | 506 | INSERT_PADDING_WORDS_NOINIT(1); |
511 | u64 applet_resource_user_id; | 507 | u64 applet_resource_user_id; |
512 | }; | 508 | }; |
513 | 509 | ||
514 | const auto parameters{rp.PopRaw<Parameters>()}; | 510 | const auto parameters{rp.PopRaw<Parameters>()}; |
515 | 511 | ||
516 | applet_resource->GetController<Controller_NPad>(HidController::NPad).SetSixAxisEnabled(false); | 512 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
513 | .SetSixAxisEnabled(parameters.sixaxis_handle, false); | ||
517 | 514 | ||
518 | LOG_DEBUG(Service_HID, | 515 | LOG_DEBUG(Service_HID, |
519 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 516 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", |
@@ -529,19 +526,23 @@ void Hid::EnableSixAxisSensorFusion(Kernel::HLERequestContext& ctx) { | |||
529 | struct Parameters { | 526 | struct Parameters { |
530 | bool enable_sixaxis_sensor_fusion; | 527 | bool enable_sixaxis_sensor_fusion; |
531 | INSERT_PADDING_BYTES_NOINIT(3); | 528 | INSERT_PADDING_BYTES_NOINIT(3); |
532 | Controller_NPad::DeviceHandle sixaxis_handle; | 529 | Core::HID::SixAxisSensorHandle sixaxis_handle; |
533 | u64 applet_resource_user_id; | 530 | u64 applet_resource_user_id; |
534 | }; | 531 | }; |
535 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | 532 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); |
536 | 533 | ||
537 | const auto parameters{rp.PopRaw<Parameters>()}; | 534 | const auto parameters{rp.PopRaw<Parameters>()}; |
538 | 535 | ||
539 | LOG_WARNING(Service_HID, | 536 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
540 | "(STUBBED) called, enable_sixaxis_sensor_fusion={}, npad_type={}, npad_id={}, " | 537 | .SetSixAxisFusionEnabled(parameters.sixaxis_handle, |
541 | "device_index={}, applet_resource_user_id={}", | 538 | parameters.enable_sixaxis_sensor_fusion); |
542 | parameters.enable_sixaxis_sensor_fusion, parameters.sixaxis_handle.npad_type, | 539 | |
543 | parameters.sixaxis_handle.npad_id, parameters.sixaxis_handle.device_index, | 540 | LOG_DEBUG(Service_HID, |
544 | parameters.applet_resource_user_id); | 541 | "called, enable_sixaxis_sensor_fusion={}, npad_type={}, npad_id={}, " |
542 | "device_index={}, applet_resource_user_id={}", | ||
543 | parameters.enable_sixaxis_sensor_fusion, parameters.sixaxis_handle.npad_type, | ||
544 | parameters.sixaxis_handle.npad_id, parameters.sixaxis_handle.device_index, | ||
545 | parameters.applet_resource_user_id); | ||
545 | 546 | ||
546 | IPC::ResponseBuilder rb{ctx, 2}; | 547 | IPC::ResponseBuilder rb{ctx, 2}; |
547 | rb.Push(ResultSuccess); | 548 | rb.Push(ResultSuccess); |
@@ -549,25 +550,18 @@ void Hid::EnableSixAxisSensorFusion(Kernel::HLERequestContext& ctx) { | |||
549 | 550 | ||
550 | void Hid::SetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { | 551 | void Hid::SetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { |
551 | IPC::RequestParser rp{ctx}; | 552 | IPC::RequestParser rp{ctx}; |
552 | struct Parameters { | 553 | const auto sixaxis_handle{rp.PopRaw<Core::HID::SixAxisSensorHandle>()}; |
553 | Controller_NPad::DeviceHandle sixaxis_handle; | 554 | const auto sixaxis_fusion{rp.PopRaw<Core::HID::SixAxisSensorFusionParameters>()}; |
554 | f32 parameter1; | 555 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
555 | f32 parameter2; | ||
556 | u64 applet_resource_user_id; | ||
557 | }; | ||
558 | static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | ||
559 | |||
560 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
561 | 556 | ||
562 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 557 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
563 | .SetSixAxisFusionParameters(parameters.parameter1, parameters.parameter2); | 558 | .SetSixAxisFusionParameters(sixaxis_handle, sixaxis_fusion); |
564 | 559 | ||
565 | LOG_WARNING(Service_HID, | 560 | LOG_DEBUG(Service_HID, |
566 | "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, parameter1={}, " | 561 | "called, npad_type={}, npad_id={}, device_index={}, parameter1={}, " |
567 | "parameter2={}, applet_resource_user_id={}", | 562 | "parameter2={}, applet_resource_user_id={}", |
568 | parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 563 | sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index, |
569 | parameters.sixaxis_handle.device_index, parameters.parameter1, | 564 | sixaxis_fusion.parameter1, sixaxis_fusion.parameter2, applet_resource_user_id); |
570 | parameters.parameter2, parameters.applet_resource_user_id); | ||
571 | 565 | ||
572 | IPC::ResponseBuilder rb{ctx, 2}; | 566 | IPC::ResponseBuilder rb{ctx, 2}; |
573 | rb.Push(ResultSuccess); | 567 | rb.Push(ResultSuccess); |
@@ -575,50 +569,35 @@ void Hid::SetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { | |||
575 | 569 | ||
576 | void Hid::GetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { | 570 | void Hid::GetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { |
577 | IPC::RequestParser rp{ctx}; | 571 | IPC::RequestParser rp{ctx}; |
578 | struct Parameters { | 572 | const auto sixaxis_handle{rp.PopRaw<Core::HID::SixAxisSensorHandle>()}; |
579 | Controller_NPad::DeviceHandle sixaxis_handle; | 573 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
580 | u64 applet_resource_user_id; | ||
581 | }; | ||
582 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
583 | |||
584 | f32 parameter1 = 0; | ||
585 | f32 parameter2 = 0; | ||
586 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
587 | 574 | ||
588 | std::tie(parameter1, parameter2) = | 575 | const auto sixaxis_fusion_parameters = |
589 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 576 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
590 | .GetSixAxisFusionParameters(); | 577 | .GetSixAxisFusionParameters(sixaxis_handle); |
591 | 578 | ||
592 | LOG_WARNING( | 579 | LOG_DEBUG(Service_HID, |
593 | Service_HID, | 580 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", |
594 | "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 581 | sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index, |
595 | parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 582 | applet_resource_user_id); |
596 | parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | ||
597 | 583 | ||
598 | IPC::ResponseBuilder rb{ctx, 4}; | 584 | IPC::ResponseBuilder rb{ctx, 4}; |
599 | rb.Push(ResultSuccess); | 585 | rb.Push(ResultSuccess); |
600 | rb.Push(parameter1); | 586 | rb.PushRaw(sixaxis_fusion_parameters); |
601 | rb.Push(parameter2); | ||
602 | } | 587 | } |
603 | 588 | ||
604 | void Hid::ResetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { | 589 | void Hid::ResetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { |
605 | IPC::RequestParser rp{ctx}; | 590 | IPC::RequestParser rp{ctx}; |
606 | struct Parameters { | 591 | const auto sixaxis_handle{rp.PopRaw<Core::HID::SixAxisSensorHandle>()}; |
607 | Controller_NPad::DeviceHandle sixaxis_handle; | 592 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
608 | u64 applet_resource_user_id; | ||
609 | }; | ||
610 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
611 | |||
612 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
613 | 593 | ||
614 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 594 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
615 | .ResetSixAxisFusionParameters(); | 595 | .ResetSixAxisFusionParameters(sixaxis_handle); |
616 | 596 | ||
617 | LOG_WARNING( | 597 | LOG_DEBUG(Service_HID, |
618 | Service_HID, | 598 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", |
619 | "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 599 | sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index, |
620 | parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 600 | applet_resource_user_id); |
621 | parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | ||
622 | 601 | ||
623 | IPC::ResponseBuilder rb{ctx, 2}; | 602 | IPC::ResponseBuilder rb{ctx, 2}; |
624 | rb.Push(ResultSuccess); | 603 | rb.Push(ResultSuccess); |
@@ -626,12 +605,12 @@ void Hid::ResetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { | |||
626 | 605 | ||
627 | void Hid::SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { | 606 | void Hid::SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { |
628 | IPC::RequestParser rp{ctx}; | 607 | IPC::RequestParser rp{ctx}; |
629 | const auto sixaxis_handle{rp.PopRaw<Controller_NPad::DeviceHandle>()}; | 608 | const auto sixaxis_handle{rp.PopRaw<Core::HID::SixAxisSensorHandle>()}; |
630 | const auto drift_mode{rp.PopEnum<Controller_NPad::GyroscopeZeroDriftMode>()}; | 609 | const auto drift_mode{rp.PopEnum<Controller_NPad::GyroscopeZeroDriftMode>()}; |
631 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 610 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
632 | 611 | ||
633 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 612 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
634 | .SetGyroscopeZeroDriftMode(drift_mode); | 613 | .SetGyroscopeZeroDriftMode(sixaxis_handle, drift_mode); |
635 | 614 | ||
636 | LOG_DEBUG(Service_HID, | 615 | LOG_DEBUG(Service_HID, |
637 | "called, npad_type={}, npad_id={}, device_index={}, drift_mode={}, " | 616 | "called, npad_type={}, npad_id={}, device_index={}, drift_mode={}, " |
@@ -646,7 +625,7 @@ void Hid::SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { | |||
646 | void Hid::GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { | 625 | void Hid::GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { |
647 | IPC::RequestParser rp{ctx}; | 626 | IPC::RequestParser rp{ctx}; |
648 | struct Parameters { | 627 | struct Parameters { |
649 | Controller_NPad::DeviceHandle sixaxis_handle; | 628 | Core::HID::SixAxisSensorHandle sixaxis_handle; |
650 | INSERT_PADDING_WORDS_NOINIT(1); | 629 | INSERT_PADDING_WORDS_NOINIT(1); |
651 | u64 applet_resource_user_id; | 630 | u64 applet_resource_user_id; |
652 | }; | 631 | }; |
@@ -661,21 +640,22 @@ void Hid::GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { | |||
661 | IPC::ResponseBuilder rb{ctx, 3}; | 640 | IPC::ResponseBuilder rb{ctx, 3}; |
662 | rb.Push(ResultSuccess); | 641 | rb.Push(ResultSuccess); |
663 | rb.PushEnum(applet_resource->GetController<Controller_NPad>(HidController::NPad) | 642 | rb.PushEnum(applet_resource->GetController<Controller_NPad>(HidController::NPad) |
664 | .GetGyroscopeZeroDriftMode()); | 643 | .GetGyroscopeZeroDriftMode(parameters.sixaxis_handle)); |
665 | } | 644 | } |
666 | 645 | ||
667 | void Hid::ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { | 646 | void Hid::ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { |
668 | IPC::RequestParser rp{ctx}; | 647 | IPC::RequestParser rp{ctx}; |
669 | struct Parameters { | 648 | struct Parameters { |
670 | Controller_NPad::DeviceHandle sixaxis_handle; | 649 | Core::HID::SixAxisSensorHandle sixaxis_handle; |
671 | INSERT_PADDING_WORDS_NOINIT(1); | 650 | INSERT_PADDING_WORDS_NOINIT(1); |
672 | u64 applet_resource_user_id; | 651 | u64 applet_resource_user_id; |
673 | }; | 652 | }; |
674 | 653 | ||
675 | const auto parameters{rp.PopRaw<Parameters>()}; | 654 | const auto parameters{rp.PopRaw<Parameters>()}; |
655 | const auto drift_mode{Controller_NPad::GyroscopeZeroDriftMode::Standard}; | ||
676 | 656 | ||
677 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 657 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
678 | .SetGyroscopeZeroDriftMode(Controller_NPad::GyroscopeZeroDriftMode::Standard); | 658 | .SetGyroscopeZeroDriftMode(parameters.sixaxis_handle, drift_mode); |
679 | 659 | ||
680 | LOG_DEBUG(Service_HID, | 660 | LOG_DEBUG(Service_HID, |
681 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 661 | "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", |
@@ -689,7 +669,7 @@ void Hid::ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { | |||
689 | void Hid::IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx) { | 669 | void Hid::IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx) { |
690 | IPC::RequestParser rp{ctx}; | 670 | IPC::RequestParser rp{ctx}; |
691 | struct Parameters { | 671 | struct Parameters { |
692 | Controller_NPad::DeviceHandle sixaxis_handle; | 672 | Core::HID::SixAxisSensorHandle sixaxis_handle; |
693 | INSERT_PADDING_WORDS_NOINIT(1); | 673 | INSERT_PADDING_WORDS_NOINIT(1); |
694 | u64 applet_resource_user_id; | 674 | u64 applet_resource_user_id; |
695 | }; | 675 | }; |
@@ -704,13 +684,13 @@ void Hid::IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx) { | |||
704 | IPC::ResponseBuilder rb{ctx, 3}; | 684 | IPC::ResponseBuilder rb{ctx, 3}; |
705 | rb.Push(ResultSuccess); | 685 | rb.Push(ResultSuccess); |
706 | rb.Push(applet_resource->GetController<Controller_NPad>(HidController::NPad) | 686 | rb.Push(applet_resource->GetController<Controller_NPad>(HidController::NPad) |
707 | .IsSixAxisSensorAtRest()); | 687 | .IsSixAxisSensorAtRest(parameters.sixaxis_handle)); |
708 | } | 688 | } |
709 | 689 | ||
710 | void Hid::IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& ctx) { | 690 | void Hid::IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& ctx) { |
711 | IPC::RequestParser rp{ctx}; | 691 | IPC::RequestParser rp{ctx}; |
712 | struct Parameters { | 692 | struct Parameters { |
713 | Controller_NPad::DeviceHandle sixaxis_handle; | 693 | Core::HID::SixAxisSensorHandle sixaxis_handle; |
714 | INSERT_PADDING_WORDS_NOINIT(1); | 694 | INSERT_PADDING_WORDS_NOINIT(1); |
715 | u64 applet_resource_user_id; | 695 | u64 applet_resource_user_id; |
716 | }; | 696 | }; |
@@ -740,8 +720,8 @@ void Hid::ActivateGesture(Kernel::HLERequestContext& ctx) { | |||
740 | 720 | ||
741 | applet_resource->ActivateController(HidController::Gesture); | 721 | applet_resource->ActivateController(HidController::Gesture); |
742 | 722 | ||
743 | LOG_DEBUG(Service_HID, "called, unknown={}, applet_resource_user_id={}", parameters.unknown, | 723 | LOG_WARNING(Service_HID, "(STUBBED) called, unknown={}, applet_resource_user_id={}", |
744 | parameters.applet_resource_user_id); | 724 | parameters.unknown, parameters.applet_resource_user_id); |
745 | 725 | ||
746 | IPC::ResponseBuilder rb{ctx, 2}; | 726 | IPC::ResponseBuilder rb{ctx, 2}; |
747 | rb.Push(ResultSuccess); | 727 | rb.Push(ResultSuccess); |
@@ -749,12 +729,19 @@ void Hid::ActivateGesture(Kernel::HLERequestContext& ctx) { | |||
749 | 729 | ||
750 | void Hid::SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) { | 730 | void Hid::SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) { |
751 | IPC::RequestParser rp{ctx}; | 731 | IPC::RequestParser rp{ctx}; |
752 | const auto supported_styleset{rp.Pop<u32>()}; | 732 | struct Parameters { |
733 | Core::HID::NpadStyleSet supported_styleset; | ||
734 | INSERT_PADDING_WORDS_NOINIT(1); | ||
735 | u64 applet_resource_user_id; | ||
736 | }; | ||
737 | |||
738 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
753 | 739 | ||
754 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 740 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
755 | .SetSupportedStyleSet({supported_styleset}); | 741 | .SetSupportedStyleSet({parameters.supported_styleset}); |
756 | 742 | ||
757 | LOG_DEBUG(Service_HID, "called, supported_styleset={}", supported_styleset); | 743 | LOG_DEBUG(Service_HID, "called, supported_styleset={}, applet_resource_user_id={}", |
744 | parameters.supported_styleset, parameters.applet_resource_user_id); | ||
758 | 745 | ||
759 | IPC::ResponseBuilder rb{ctx, 2}; | 746 | IPC::ResponseBuilder rb{ctx, 2}; |
760 | rb.Push(ResultSuccess); | 747 | rb.Push(ResultSuccess); |
@@ -768,9 +755,9 @@ void Hid::GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) { | |||
768 | 755 | ||
769 | IPC::ResponseBuilder rb{ctx, 3}; | 756 | IPC::ResponseBuilder rb{ctx, 3}; |
770 | rb.Push(ResultSuccess); | 757 | rb.Push(ResultSuccess); |
771 | rb.Push(applet_resource->GetController<Controller_NPad>(HidController::NPad) | 758 | rb.PushEnum(applet_resource->GetController<Controller_NPad>(HidController::NPad) |
772 | .GetSupportedStyleSet() | 759 | .GetSupportedStyleSet() |
773 | .raw); | 760 | .raw); |
774 | } | 761 | } |
775 | 762 | ||
776 | void Hid::SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) { | 763 | void Hid::SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) { |
@@ -813,7 +800,7 @@ void Hid::DeactivateNpad(Kernel::HLERequestContext& ctx) { | |||
813 | void Hid::AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx) { | 800 | void Hid::AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx) { |
814 | IPC::RequestParser rp{ctx}; | 801 | IPC::RequestParser rp{ctx}; |
815 | struct Parameters { | 802 | struct Parameters { |
816 | u32 npad_id; | 803 | Core::HID::NpadIdType npad_id; |
817 | INSERT_PADDING_WORDS_NOINIT(1); | 804 | INSERT_PADDING_WORDS_NOINIT(1); |
818 | u64 applet_resource_user_id; | 805 | u64 applet_resource_user_id; |
819 | u64 unknown; | 806 | u64 unknown; |
@@ -833,7 +820,7 @@ void Hid::AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx) { | |||
833 | void Hid::DisconnectNpad(Kernel::HLERequestContext& ctx) { | 820 | void Hid::DisconnectNpad(Kernel::HLERequestContext& ctx) { |
834 | IPC::RequestParser rp{ctx}; | 821 | IPC::RequestParser rp{ctx}; |
835 | struct Parameters { | 822 | struct Parameters { |
836 | u32 npad_id; | 823 | Core::HID::NpadIdType npad_id; |
837 | INSERT_PADDING_WORDS_NOINIT(1); | 824 | INSERT_PADDING_WORDS_NOINIT(1); |
838 | u64 applet_resource_user_id; | 825 | u64 applet_resource_user_id; |
839 | }; | 826 | }; |
@@ -852,7 +839,7 @@ void Hid::DisconnectNpad(Kernel::HLERequestContext& ctx) { | |||
852 | 839 | ||
853 | void Hid::GetPlayerLedPattern(Kernel::HLERequestContext& ctx) { | 840 | void Hid::GetPlayerLedPattern(Kernel::HLERequestContext& ctx) { |
854 | IPC::RequestParser rp{ctx}; | 841 | IPC::RequestParser rp{ctx}; |
855 | const auto npad_id{rp.Pop<u32>()}; | 842 | const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()}; |
856 | 843 | ||
857 | LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id); | 844 | LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id); |
858 | 845 | ||
@@ -867,7 +854,7 @@ void Hid::ActivateNpadWithRevision(Kernel::HLERequestContext& ctx) { | |||
867 | // Should have no effect with how our npad sets up the data | 854 | // Should have no effect with how our npad sets up the data |
868 | IPC::RequestParser rp{ctx}; | 855 | IPC::RequestParser rp{ctx}; |
869 | struct Parameters { | 856 | struct Parameters { |
870 | u32 unknown; | 857 | s32 revision; |
871 | INSERT_PADDING_WORDS_NOINIT(1); | 858 | INSERT_PADDING_WORDS_NOINIT(1); |
872 | u64 applet_resource_user_id; | 859 | u64 applet_resource_user_id; |
873 | }; | 860 | }; |
@@ -876,7 +863,7 @@ void Hid::ActivateNpadWithRevision(Kernel::HLERequestContext& ctx) { | |||
876 | 863 | ||
877 | applet_resource->ActivateController(HidController::NPad); | 864 | applet_resource->ActivateController(HidController::NPad); |
878 | 865 | ||
879 | LOG_DEBUG(Service_HID, "called, unknown={}, applet_resource_user_id={}", parameters.unknown, | 866 | LOG_DEBUG(Service_HID, "called, revision={}, applet_resource_user_id={}", parameters.revision, |
880 | parameters.applet_resource_user_id); | 867 | parameters.applet_resource_user_id); |
881 | 868 | ||
882 | IPC::ResponseBuilder rb{ctx, 2}; | 869 | IPC::ResponseBuilder rb{ctx, 2}; |
@@ -885,6 +872,7 @@ void Hid::ActivateNpadWithRevision(Kernel::HLERequestContext& ctx) { | |||
885 | 872 | ||
886 | void Hid::SetNpadJoyHoldType(Kernel::HLERequestContext& ctx) { | 873 | void Hid::SetNpadJoyHoldType(Kernel::HLERequestContext& ctx) { |
887 | IPC::RequestParser rp{ctx}; | 874 | IPC::RequestParser rp{ctx}; |
875 | // TODO(german77): Confirm the order of these parameters | ||
888 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 876 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
889 | const auto hold_type{rp.PopEnum<Controller_NPad::NpadJoyHoldType>()}; | 877 | const auto hold_type{rp.PopEnum<Controller_NPad::NpadJoyHoldType>()}; |
890 | 878 | ||
@@ -911,7 +899,7 @@ void Hid::GetNpadJoyHoldType(Kernel::HLERequestContext& ctx) { | |||
911 | void Hid::SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx) { | 899 | void Hid::SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx) { |
912 | IPC::RequestParser rp{ctx}; | 900 | IPC::RequestParser rp{ctx}; |
913 | struct Parameters { | 901 | struct Parameters { |
914 | u32 npad_id; | 902 | Core::HID::NpadIdType npad_id; |
915 | INSERT_PADDING_WORDS_NOINIT(1); | 903 | INSERT_PADDING_WORDS_NOINIT(1); |
916 | u64 applet_resource_user_id; | 904 | u64 applet_resource_user_id; |
917 | }; | 905 | }; |
@@ -932,7 +920,7 @@ void Hid::SetNpadJoyAssignmentModeSingle(Kernel::HLERequestContext& ctx) { | |||
932 | // TODO: Check the differences between this and SetNpadJoyAssignmentModeSingleByDefault | 920 | // TODO: Check the differences between this and SetNpadJoyAssignmentModeSingleByDefault |
933 | IPC::RequestParser rp{ctx}; | 921 | IPC::RequestParser rp{ctx}; |
934 | struct Parameters { | 922 | struct Parameters { |
935 | u32 npad_id; | 923 | Core::HID::NpadIdType npad_id; |
936 | INSERT_PADDING_WORDS_NOINIT(1); | 924 | INSERT_PADDING_WORDS_NOINIT(1); |
937 | u64 applet_resource_user_id; | 925 | u64 applet_resource_user_id; |
938 | u64 npad_joy_device_type; | 926 | u64 npad_joy_device_type; |
@@ -955,7 +943,7 @@ void Hid::SetNpadJoyAssignmentModeSingle(Kernel::HLERequestContext& ctx) { | |||
955 | void Hid::SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) { | 943 | void Hid::SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) { |
956 | IPC::RequestParser rp{ctx}; | 944 | IPC::RequestParser rp{ctx}; |
957 | struct Parameters { | 945 | struct Parameters { |
958 | u32 npad_id; | 946 | Core::HID::NpadIdType npad_id; |
959 | INSERT_PADDING_WORDS_NOINIT(1); | 947 | INSERT_PADDING_WORDS_NOINIT(1); |
960 | u64 applet_resource_user_id; | 948 | u64 applet_resource_user_id; |
961 | }; | 949 | }; |
@@ -974,8 +962,8 @@ void Hid::SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) { | |||
974 | 962 | ||
975 | void Hid::MergeSingleJoyAsDualJoy(Kernel::HLERequestContext& ctx) { | 963 | void Hid::MergeSingleJoyAsDualJoy(Kernel::HLERequestContext& ctx) { |
976 | IPC::RequestParser rp{ctx}; | 964 | IPC::RequestParser rp{ctx}; |
977 | const auto npad_id_1{rp.Pop<u32>()}; | 965 | const auto npad_id_1{rp.PopEnum<Core::HID::NpadIdType>()}; |
978 | const auto npad_id_2{rp.Pop<u32>()}; | 966 | const auto npad_id_2{rp.PopEnum<Core::HID::NpadIdType>()}; |
979 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 967 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
980 | 968 | ||
981 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 969 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
@@ -1041,8 +1029,8 @@ void Hid::GetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx) { | |||
1041 | 1029 | ||
1042 | void Hid::SwapNpadAssignment(Kernel::HLERequestContext& ctx) { | 1030 | void Hid::SwapNpadAssignment(Kernel::HLERequestContext& ctx) { |
1043 | IPC::RequestParser rp{ctx}; | 1031 | IPC::RequestParser rp{ctx}; |
1044 | const auto npad_id_1{rp.Pop<u32>()}; | 1032 | const auto npad_id_1{rp.PopEnum<Core::HID::NpadIdType>()}; |
1045 | const auto npad_id_2{rp.Pop<u32>()}; | 1033 | const auto npad_id_2{rp.PopEnum<Core::HID::NpadIdType>()}; |
1046 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1034 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
1047 | 1035 | ||
1048 | const bool res = applet_resource->GetController<Controller_NPad>(HidController::NPad) | 1036 | const bool res = applet_resource->GetController<Controller_NPad>(HidController::NPad) |
@@ -1063,7 +1051,7 @@ void Hid::SwapNpadAssignment(Kernel::HLERequestContext& ctx) { | |||
1063 | void Hid::IsUnintendedHomeButtonInputProtectionEnabled(Kernel::HLERequestContext& ctx) { | 1051 | void Hid::IsUnintendedHomeButtonInputProtectionEnabled(Kernel::HLERequestContext& ctx) { |
1064 | IPC::RequestParser rp{ctx}; | 1052 | IPC::RequestParser rp{ctx}; |
1065 | struct Parameters { | 1053 | struct Parameters { |
1066 | u32 npad_id; | 1054 | Core::HID::NpadIdType npad_id; |
1067 | INSERT_PADDING_WORDS_NOINIT(1); | 1055 | INSERT_PADDING_WORDS_NOINIT(1); |
1068 | u64 applet_resource_user_id; | 1056 | u64 applet_resource_user_id; |
1069 | }; | 1057 | }; |
@@ -1084,7 +1072,7 @@ void Hid::EnableUnintendedHomeButtonInputProtection(Kernel::HLERequestContext& c | |||
1084 | struct Parameters { | 1072 | struct Parameters { |
1085 | bool unintended_home_button_input_protection; | 1073 | bool unintended_home_button_input_protection; |
1086 | INSERT_PADDING_BYTES_NOINIT(3); | 1074 | INSERT_PADDING_BYTES_NOINIT(3); |
1087 | u32 npad_id; | 1075 | Core::HID::NpadIdType npad_id; |
1088 | u64 applet_resource_user_id; | 1076 | u64 applet_resource_user_id; |
1089 | }; | 1077 | }; |
1090 | 1078 | ||
@@ -1106,20 +1094,15 @@ void Hid::EnableUnintendedHomeButtonInputProtection(Kernel::HLERequestContext& c | |||
1106 | 1094 | ||
1107 | void Hid::SetNpadAnalogStickUseCenterClamp(Kernel::HLERequestContext& ctx) { | 1095 | void Hid::SetNpadAnalogStickUseCenterClamp(Kernel::HLERequestContext& ctx) { |
1108 | IPC::RequestParser rp{ctx}; | 1096 | IPC::RequestParser rp{ctx}; |
1109 | struct Parameters { | 1097 | const auto analog_stick_use_center_clamp{rp.Pop<bool>()}; |
1110 | bool analog_stick_use_center_clamp; | 1098 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
1111 | u64 applet_resource_user_id; | ||
1112 | }; | ||
1113 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
1114 | |||
1115 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
1116 | 1099 | ||
1117 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 1100 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
1118 | .SetAnalogStickUseCenterClamp(parameters.analog_stick_use_center_clamp); | 1101 | .SetAnalogStickUseCenterClamp(analog_stick_use_center_clamp); |
1119 | 1102 | ||
1120 | LOG_WARNING(Service_HID, | 1103 | LOG_WARNING(Service_HID, |
1121 | "(STUBBED) called, analog_stick_use_center_clamp={}, applet_resource_user_id={}", | 1104 | "(STUBBED) called, analog_stick_use_center_clamp={}, applet_resource_user_id={}", |
1122 | parameters.analog_stick_use_center_clamp, parameters.applet_resource_user_id); | 1105 | analog_stick_use_center_clamp, applet_resource_user_id); |
1123 | 1106 | ||
1124 | IPC::ResponseBuilder rb{ctx, 2}; | 1107 | IPC::ResponseBuilder rb{ctx, 2}; |
1125 | rb.Push(ResultSuccess); | 1108 | rb.Push(ResultSuccess); |
@@ -1127,7 +1110,7 @@ void Hid::SetNpadAnalogStickUseCenterClamp(Kernel::HLERequestContext& ctx) { | |||
1127 | 1110 | ||
1128 | void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) { | 1111 | void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) { |
1129 | IPC::RequestParser rp{ctx}; | 1112 | IPC::RequestParser rp{ctx}; |
1130 | const auto vibration_device_handle{rp.PopRaw<Controller_NPad::DeviceHandle>()}; | 1113 | const auto vibration_device_handle{rp.PopRaw<Core::HID::VibrationDeviceHandle>()}; |
1131 | 1114 | ||
1132 | Core::HID::VibrationDeviceInfo vibration_device_info; | 1115 | Core::HID::VibrationDeviceInfo vibration_device_info; |
1133 | 1116 | ||
@@ -1149,13 +1132,13 @@ void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) { | |||
1149 | } | 1132 | } |
1150 | 1133 | ||
1151 | switch (vibration_device_handle.device_index) { | 1134 | switch (vibration_device_handle.device_index) { |
1152 | case Controller_NPad::DeviceIndex::Left: | 1135 | case Core::HID::DeviceIndex::Left: |
1153 | vibration_device_info.position = Core::HID::VibrationDevicePosition::Left; | 1136 | vibration_device_info.position = Core::HID::VibrationDevicePosition::Left; |
1154 | break; | 1137 | break; |
1155 | case Controller_NPad::DeviceIndex::Right: | 1138 | case Core::HID::DeviceIndex::Right: |
1156 | vibration_device_info.position = Core::HID::VibrationDevicePosition::Right; | 1139 | vibration_device_info.position = Core::HID::VibrationDevicePosition::Right; |
1157 | break; | 1140 | break; |
1158 | case Controller_NPad::DeviceIndex::None: | 1141 | case Core::HID::DeviceIndex::None: |
1159 | default: | 1142 | default: |
1160 | UNREACHABLE_MSG("DeviceIndex should never be None!"); | 1143 | UNREACHABLE_MSG("DeviceIndex should never be None!"); |
1161 | vibration_device_info.position = Core::HID::VibrationDevicePosition::None; | 1144 | vibration_device_info.position = Core::HID::VibrationDevicePosition::None; |
@@ -1173,8 +1156,8 @@ void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) { | |||
1173 | void Hid::SendVibrationValue(Kernel::HLERequestContext& ctx) { | 1156 | void Hid::SendVibrationValue(Kernel::HLERequestContext& ctx) { |
1174 | IPC::RequestParser rp{ctx}; | 1157 | IPC::RequestParser rp{ctx}; |
1175 | struct Parameters { | 1158 | struct Parameters { |
1176 | Controller_NPad::DeviceHandle vibration_device_handle; | 1159 | Core::HID::VibrationDeviceHandle vibration_device_handle; |
1177 | Controller_NPad::VibrationValue vibration_value; | 1160 | Core::HID::VibrationValue vibration_value; |
1178 | INSERT_PADDING_WORDS_NOINIT(1); | 1161 | INSERT_PADDING_WORDS_NOINIT(1); |
1179 | u64 applet_resource_user_id; | 1162 | u64 applet_resource_user_id; |
1180 | }; | 1163 | }; |
@@ -1197,7 +1180,7 @@ void Hid::SendVibrationValue(Kernel::HLERequestContext& ctx) { | |||
1197 | void Hid::GetActualVibrationValue(Kernel::HLERequestContext& ctx) { | 1180 | void Hid::GetActualVibrationValue(Kernel::HLERequestContext& ctx) { |
1198 | IPC::RequestParser rp{ctx}; | 1181 | IPC::RequestParser rp{ctx}; |
1199 | struct Parameters { | 1182 | struct Parameters { |
1200 | Controller_NPad::DeviceHandle vibration_device_handle; | 1183 | Core::HID::VibrationDeviceHandle vibration_device_handle; |
1201 | INSERT_PADDING_WORDS_NOINIT(1); | 1184 | INSERT_PADDING_WORDS_NOINIT(1); |
1202 | u64 applet_resource_user_id; | 1185 | u64 applet_resource_user_id; |
1203 | }; | 1186 | }; |
@@ -1251,10 +1234,10 @@ void Hid::SendVibrationValues(Kernel::HLERequestContext& ctx) { | |||
1251 | const auto handles = ctx.ReadBuffer(0); | 1234 | const auto handles = ctx.ReadBuffer(0); |
1252 | const auto vibrations = ctx.ReadBuffer(1); | 1235 | const auto vibrations = ctx.ReadBuffer(1); |
1253 | 1236 | ||
1254 | std::vector<Controller_NPad::DeviceHandle> vibration_device_handles( | 1237 | std::vector<Core::HID::VibrationDeviceHandle> vibration_device_handles( |
1255 | handles.size() / sizeof(Controller_NPad::DeviceHandle)); | 1238 | handles.size() / sizeof(Core::HID::VibrationDeviceHandle)); |
1256 | std::vector<Controller_NPad::VibrationValue> vibration_values( | 1239 | std::vector<Core::HID::VibrationValue> vibration_values(vibrations.size() / |
1257 | vibrations.size() / sizeof(Controller_NPad::VibrationValue)); | 1240 | sizeof(Core::HID::VibrationValue)); |
1258 | 1241 | ||
1259 | std::memcpy(vibration_device_handles.data(), handles.data(), handles.size()); | 1242 | std::memcpy(vibration_device_handles.data(), handles.data(), handles.size()); |
1260 | std::memcpy(vibration_values.data(), vibrations.data(), vibrations.size()); | 1243 | std::memcpy(vibration_values.data(), vibrations.data(), vibrations.size()); |
@@ -1271,7 +1254,8 @@ void Hid::SendVibrationValues(Kernel::HLERequestContext& ctx) { | |||
1271 | void Hid::SendVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { | 1254 | void Hid::SendVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { |
1272 | IPC::RequestParser rp{ctx}; | 1255 | IPC::RequestParser rp{ctx}; |
1273 | struct Parameters { | 1256 | struct Parameters { |
1274 | Controller_NPad::DeviceHandle vibration_device_handle; | 1257 | Core::HID::VibrationDeviceHandle vibration_device_handle; |
1258 | INSERT_PADDING_WORDS_NOINIT(1); | ||
1275 | u64 applet_resource_user_id; | 1259 | u64 applet_resource_user_id; |
1276 | Core::HID::VibrationGcErmCommand gc_erm_command; | 1260 | Core::HID::VibrationGcErmCommand gc_erm_command; |
1277 | }; | 1261 | }; |
@@ -1288,25 +1272,25 @@ void Hid::SendVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { | |||
1288 | const auto vibration_value = [parameters] { | 1272 | const auto vibration_value = [parameters] { |
1289 | switch (parameters.gc_erm_command) { | 1273 | switch (parameters.gc_erm_command) { |
1290 | case Core::HID::VibrationGcErmCommand::Stop: | 1274 | case Core::HID::VibrationGcErmCommand::Stop: |
1291 | return Controller_NPad::VibrationValue{ | 1275 | return Core::HID::VibrationValue{ |
1292 | .amp_low = 0.0f, | 1276 | .low_amplitude = 0.0f, |
1293 | .freq_low = 160.0f, | 1277 | .low_frequency = 160.0f, |
1294 | .amp_high = 0.0f, | 1278 | .high_amplitude = 0.0f, |
1295 | .freq_high = 320.0f, | 1279 | .high_frequency = 320.0f, |
1296 | }; | 1280 | }; |
1297 | case Core::HID::VibrationGcErmCommand::Start: | 1281 | case Core::HID::VibrationGcErmCommand::Start: |
1298 | return Controller_NPad::VibrationValue{ | 1282 | return Core::HID::VibrationValue{ |
1299 | .amp_low = 1.0f, | 1283 | .low_amplitude = 1.0f, |
1300 | .freq_low = 160.0f, | 1284 | .low_frequency = 160.0f, |
1301 | .amp_high = 1.0f, | 1285 | .high_amplitude = 1.0f, |
1302 | .freq_high = 320.0f, | 1286 | .high_frequency = 320.0f, |
1303 | }; | 1287 | }; |
1304 | case Core::HID::VibrationGcErmCommand::StopHard: | 1288 | case Core::HID::VibrationGcErmCommand::StopHard: |
1305 | return Controller_NPad::VibrationValue{ | 1289 | return Core::HID::VibrationValue{ |
1306 | .amp_low = 0.0f, | 1290 | .low_amplitude = 0.0f, |
1307 | .freq_low = 0.0f, | 1291 | .low_frequency = 0.0f, |
1308 | .amp_high = 0.0f, | 1292 | .high_amplitude = 0.0f, |
1309 | .freq_high = 0.0f, | 1293 | .high_frequency = 0.0f, |
1310 | }; | 1294 | }; |
1311 | default: | 1295 | default: |
1312 | return Controller_NPad::DEFAULT_VIBRATION_VALUE; | 1296 | return Controller_NPad::DEFAULT_VIBRATION_VALUE; |
@@ -1331,7 +1315,7 @@ void Hid::SendVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { | |||
1331 | void Hid::GetActualVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { | 1315 | void Hid::GetActualVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { |
1332 | IPC::RequestParser rp{ctx}; | 1316 | IPC::RequestParser rp{ctx}; |
1333 | struct Parameters { | 1317 | struct Parameters { |
1334 | Controller_NPad::DeviceHandle vibration_device_handle; | 1318 | Core::HID::VibrationDeviceHandle vibration_device_handle; |
1335 | INSERT_PADDING_WORDS_NOINIT(1); | 1319 | INSERT_PADDING_WORDS_NOINIT(1); |
1336 | u64 applet_resource_user_id; | 1320 | u64 applet_resource_user_id; |
1337 | }; | 1321 | }; |
@@ -1342,7 +1326,7 @@ void Hid::GetActualVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { | |||
1342 | .GetLastVibration(parameters.vibration_device_handle); | 1326 | .GetLastVibration(parameters.vibration_device_handle); |
1343 | 1327 | ||
1344 | const auto gc_erm_command = [last_vibration] { | 1328 | const auto gc_erm_command = [last_vibration] { |
1345 | if (last_vibration.amp_low != 0.0f || last_vibration.amp_high != 0.0f) { | 1329 | if (last_vibration.low_amplitude != 0.0f || last_vibration.high_amplitude != 0.0f) { |
1346 | return Core::HID::VibrationGcErmCommand::Start; | 1330 | return Core::HID::VibrationGcErmCommand::Start; |
1347 | } | 1331 | } |
1348 | 1332 | ||
@@ -1352,7 +1336,7 @@ void Hid::GetActualVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { | |||
1352 | * SendVibrationGcErmCommand, in order to differentiate between Stop and StopHard commands. | 1336 | * SendVibrationGcErmCommand, in order to differentiate between Stop and StopHard commands. |
1353 | * This is done to reuse the controller vibration functions made for regular controllers. | 1337 | * This is done to reuse the controller vibration functions made for regular controllers. |
1354 | */ | 1338 | */ |
1355 | if (last_vibration.freq_low == 0.0f && last_vibration.freq_high == 0.0f) { | 1339 | if (last_vibration.low_frequency == 0.0f && last_vibration.high_frequency == 0.0f) { |
1356 | return Core::HID::VibrationGcErmCommand::StopHard; | 1340 | return Core::HID::VibrationGcErmCommand::StopHard; |
1357 | } | 1341 | } |
1358 | 1342 | ||
@@ -1396,7 +1380,7 @@ void Hid::EndPermitVibrationSession(Kernel::HLERequestContext& ctx) { | |||
1396 | void Hid::IsVibrationDeviceMounted(Kernel::HLERequestContext& ctx) { | 1380 | void Hid::IsVibrationDeviceMounted(Kernel::HLERequestContext& ctx) { |
1397 | IPC::RequestParser rp{ctx}; | 1381 | IPC::RequestParser rp{ctx}; |
1398 | struct Parameters { | 1382 | struct Parameters { |
1399 | Controller_NPad::DeviceHandle vibration_device_handle; | 1383 | Core::HID::VibrationDeviceHandle vibration_device_handle; |
1400 | INSERT_PADDING_WORDS_NOINIT(1); | 1384 | INSERT_PADDING_WORDS_NOINIT(1); |
1401 | u64 applet_resource_user_id; | 1385 | u64 applet_resource_user_id; |
1402 | }; | 1386 | }; |
@@ -1430,18 +1414,17 @@ void Hid::ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { | |||
1430 | void Hid::StartConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { | 1414 | void Hid::StartConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { |
1431 | IPC::RequestParser rp{ctx}; | 1415 | IPC::RequestParser rp{ctx}; |
1432 | struct Parameters { | 1416 | struct Parameters { |
1433 | Controller_NPad::DeviceHandle sixaxis_handle; | 1417 | Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle; |
1434 | INSERT_PADDING_WORDS_NOINIT(1); | 1418 | INSERT_PADDING_WORDS_NOINIT(1); |
1435 | u64 applet_resource_user_id; | 1419 | u64 applet_resource_user_id; |
1436 | }; | 1420 | }; |
1437 | 1421 | ||
1438 | const auto parameters{rp.PopRaw<Parameters>()}; | 1422 | const auto parameters{rp.PopRaw<Parameters>()}; |
1439 | 1423 | ||
1440 | LOG_WARNING( | 1424 | LOG_WARNING(Service_HID, |
1441 | Service_HID, | 1425 | "(STUBBED) called, unknown_1={}, unknown_2={}, applet_resource_user_id={}", |
1442 | "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 1426 | parameters.console_sixaxis_handle.unknown_1, |
1443 | parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 1427 | parameters.console_sixaxis_handle.unknown_2, parameters.applet_resource_user_id); |
1444 | parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | ||
1445 | 1428 | ||
1446 | IPC::ResponseBuilder rb{ctx, 2}; | 1429 | IPC::ResponseBuilder rb{ctx, 2}; |
1447 | rb.Push(ResultSuccess); | 1430 | rb.Push(ResultSuccess); |
@@ -1450,18 +1433,17 @@ void Hid::StartConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { | |||
1450 | void Hid::StopConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { | 1433 | void Hid::StopConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { |
1451 | IPC::RequestParser rp{ctx}; | 1434 | IPC::RequestParser rp{ctx}; |
1452 | struct Parameters { | 1435 | struct Parameters { |
1453 | Controller_NPad::DeviceHandle sixaxis_handle; | 1436 | Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle; |
1454 | INSERT_PADDING_WORDS_NOINIT(1); | 1437 | INSERT_PADDING_WORDS_NOINIT(1); |
1455 | u64 applet_resource_user_id; | 1438 | u64 applet_resource_user_id; |
1456 | }; | 1439 | }; |
1457 | 1440 | ||
1458 | const auto parameters{rp.PopRaw<Parameters>()}; | 1441 | const auto parameters{rp.PopRaw<Parameters>()}; |
1459 | 1442 | ||
1460 | LOG_WARNING( | 1443 | LOG_WARNING(Service_HID, |
1461 | Service_HID, | 1444 | "(STUBBED) called, unknown_1={}, unknown_2={}, applet_resource_user_id={}", |
1462 | "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", | 1445 | parameters.console_sixaxis_handle.unknown_1, |
1463 | parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, | 1446 | parameters.console_sixaxis_handle.unknown_2, parameters.applet_resource_user_id); |
1464 | parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); | ||
1465 | 1447 | ||
1466 | IPC::ResponseBuilder rb{ctx, 2}; | 1448 | IPC::ResponseBuilder rb{ctx, 2}; |
1467 | rb.Push(ResultSuccess); | 1449 | rb.Push(ResultSuccess); |
@@ -1615,10 +1597,8 @@ void Hid::SetNpadCommunicationMode(Kernel::HLERequestContext& ctx) { | |||
1615 | 1597 | ||
1616 | void Hid::GetNpadCommunicationMode(Kernel::HLERequestContext& ctx) { | 1598 | void Hid::GetNpadCommunicationMode(Kernel::HLERequestContext& ctx) { |
1617 | IPC::RequestParser rp{ctx}; | 1599 | IPC::RequestParser rp{ctx}; |
1618 | const auto applet_resource_user_id{rp.Pop<u64>()}; | ||
1619 | 1600 | ||
1620 | LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", | 1601 | LOG_WARNING(Service_HID, "(STUBBED) called"); |
1621 | applet_resource_user_id); | ||
1622 | 1602 | ||
1623 | IPC::ResponseBuilder rb{ctx, 4}; | 1603 | IPC::ResponseBuilder rb{ctx, 4}; |
1624 | rb.Push(ResultSuccess); | 1604 | rb.Push(ResultSuccess); |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 24f0f868f..c20a735f9 100755 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
@@ -627,7 +627,8 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() { | |||
627 | return; | 627 | return; |
628 | } | 628 | } |
629 | 629 | ||
630 | const auto devices = emulated_controller->GetMappedDevices(Core::HID::DeviceIndex::AllDevices); | 630 | const auto devices = |
631 | emulated_controller->GetMappedDevices(Core::HID::EmulatedDeviceIndex::AllDevices); | ||
631 | UpdateInputDevices(); | 632 | UpdateInputDevices(); |
632 | 633 | ||
633 | if (devices.empty()) { | 634 | if (devices.empty()) { |
@@ -846,7 +847,6 @@ void ConfigureInputPlayer::SetConnectableControllers() { | |||
846 | 847 | ||
847 | if (!is_powered_on) { | 848 | if (!is_powered_on) { |
848 | add_controllers(true); | 849 | add_controllers(true); |
849 | return; | ||
850 | } | 850 | } |
851 | 851 | ||
852 | add_controllers(false, hid_core.GetSupportedStyleTag()); | 852 | add_controllers(false, hid_core.GetSupportedStyleTag()); |
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp index ff40f57f5..6630321cb 100755 --- a/src/yuzu/configuration/configure_input_player_widget.cpp +++ b/src/yuzu/configuration/configure_input_player_widget.cpp | |||
@@ -357,7 +357,8 @@ void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center) | |||
357 | DrawCircle(p, center + QPoint(26, 71), 5); | 357 | DrawCircle(p, center + QPoint(26, 71), 5); |
358 | 358 | ||
359 | // Draw battery | 359 | // Draw battery |
360 | DrawBattery(p, center + QPoint(-170, -140), battery_values[Core::HID::DeviceIndex::LeftIndex]); | 360 | DrawBattery(p, center + QPoint(-170, -140), |
361 | battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); | ||
361 | } | 362 | } |
362 | 363 | ||
363 | void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center) { | 364 | void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center) { |
@@ -483,7 +484,8 @@ void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center | |||
483 | DrawSymbol(p, center + QPoint(-26, 66), Symbol::House, 5); | 484 | DrawSymbol(p, center + QPoint(-26, 66), Symbol::House, 5); |
484 | 485 | ||
485 | // Draw battery | 486 | // Draw battery |
486 | DrawBattery(p, center + QPoint(110, -140), battery_values[Core::HID::DeviceIndex::RightIndex]); | 487 | DrawBattery(p, center + QPoint(110, -140), |
488 | battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]); | ||
487 | } | 489 | } |
488 | 490 | ||
489 | void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center) { | 491 | void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center) { |
@@ -619,8 +621,10 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center) | |||
619 | DrawSymbol(p, center + QPoint(50, 60), Symbol::House, 4.2f); | 621 | DrawSymbol(p, center + QPoint(50, 60), Symbol::House, 4.2f); |
620 | 622 | ||
621 | // Draw battery | 623 | // Draw battery |
622 | DrawBattery(p, center + QPoint(-100, -160), battery_values[Core::HID::DeviceIndex::LeftIndex]); | 624 | DrawBattery(p, center + QPoint(-100, -160), |
623 | DrawBattery(p, center + QPoint(40, -160), battery_values[Core::HID::DeviceIndex::RightIndex]); | 625 | battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); |
626 | DrawBattery(p, center + QPoint(40, -160), | ||
627 | battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]); | ||
624 | } | 628 | } |
625 | 629 | ||
626 | void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF center) { | 630 | void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF center) { |
@@ -721,8 +725,10 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen | |||
721 | DrawSymbol(p, center + QPoint(161, 37), Symbol::House, 2.75f); | 725 | DrawSymbol(p, center + QPoint(161, 37), Symbol::House, 2.75f); |
722 | 726 | ||
723 | // Draw battery | 727 | // Draw battery |
724 | DrawBattery(p, center + QPoint(-200, 110), battery_values[Core::HID::DeviceIndex::LeftIndex]); | 728 | DrawBattery(p, center + QPoint(-200, 110), |
725 | DrawBattery(p, center + QPoint(130, 110), battery_values[Core::HID::DeviceIndex::RightIndex]); | 729 | battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); |
730 | DrawBattery(p, center + QPoint(130, 110), | ||
731 | battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]); | ||
726 | } | 732 | } |
727 | 733 | ||
728 | void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center) { | 734 | void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center) { |
@@ -812,7 +818,8 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center) | |||
812 | DrawSymbol(p, center + QPoint(29, -56), Symbol::House, 3.9f); | 818 | DrawSymbol(p, center + QPoint(29, -56), Symbol::House, 3.9f); |
813 | 819 | ||
814 | // Draw battery | 820 | // Draw battery |
815 | DrawBattery(p, center + QPoint(-30, -160), battery_values[Core::HID::DeviceIndex::LeftIndex]); | 821 | DrawBattery(p, center + QPoint(-30, -160), |
822 | battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); | ||
816 | } | 823 | } |
817 | 824 | ||
818 | void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) { | 825 | void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) { |
@@ -868,7 +875,8 @@ void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) { | |||
868 | DrawCircleButton(p, center + QPoint(0, -44), button_values[Plus], 8); | 875 | DrawCircleButton(p, center + QPoint(0, -44), button_values[Plus], 8); |
869 | 876 | ||
870 | // Draw battery | 877 | // Draw battery |
871 | DrawBattery(p, center + QPoint(-30, -165), battery_values[Core::HID::DeviceIndex::LeftIndex]); | 878 | DrawBattery(p, center + QPoint(-30, -165), |
879 | battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); | ||
872 | } | 880 | } |
873 | 881 | ||
874 | constexpr std::array<float, 13 * 2> symbol_a = { | 882 | constexpr std::array<float, 13 * 2> symbol_a = { |