diff options
| author | 2021-10-27 18:06:13 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:26 -0600 | |
| commit | 2d3a63b28969089746e43ed232dc74630fbfc3b2 (patch) | |
| tree | f75d3245b6e23815611796c85b96fa4c7674c3e2 | |
| parent | core/hid: Add TAS input (diff) | |
| download | yuzu-2d3a63b28969089746e43ed232dc74630fbfc3b2.tar.gz yuzu-2d3a63b28969089746e43ed232dc74630fbfc3b2.tar.xz yuzu-2d3a63b28969089746e43ed232dc74630fbfc3b2.zip | |
core/hid: Update structs to 13.1.0
Diffstat (limited to '')
| -rw-r--r-- | src/core/hid/hid_types.h | 10 | ||||
| -rw-r--r-- | src/core/hid/input_interpreter.cpp | 14 | ||||
| -rw-r--r-- | src/core/hid/input_interpreter.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/debug_pad.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/gesture.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/keyboard.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/mouse.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 15 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 60 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/xpad.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/hid/ring_lifo.h | 26 |
12 files changed, 107 insertions, 50 deletions
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h index 59ec593b8..f8a0d5edd 100644 --- a/src/core/hid/hid_types.h +++ b/src/core/hid/hid_types.h | |||
| @@ -231,7 +231,12 @@ enum class NpadButton : u64 { | |||
| 231 | RightSR = 1U << 27, | 231 | RightSR = 1U << 27, |
| 232 | 232 | ||
| 233 | Palma = 1U << 28, | 233 | Palma = 1U << 28, |
| 234 | Verification = 1U << 29, | ||
| 234 | HandheldLeftB = 1U << 30, | 235 | HandheldLeftB = 1U << 30, |
| 236 | LagonCLeft = 1U << 31, | ||
| 237 | LagonCUp = 1ULL << 32, | ||
| 238 | LagonCRight = 1ULL << 33, | ||
| 239 | LagonCDown = 1ULL << 34, | ||
| 235 | }; | 240 | }; |
| 236 | DECLARE_ENUM_FLAG_OPERATORS(NpadButton); | 241 | DECLARE_ENUM_FLAG_OPERATORS(NpadButton); |
| 237 | 242 | ||
| @@ -278,7 +283,12 @@ struct NpadButtonState { | |||
| 278 | BitField<27, 1, u64> right_sr; | 283 | BitField<27, 1, u64> right_sr; |
| 279 | 284 | ||
| 280 | BitField<28, 1, u64> palma; | 285 | BitField<28, 1, u64> palma; |
| 286 | BitField<29, 1, u64> verification; | ||
| 281 | BitField<30, 1, u64> handheld_left_b; | 287 | BitField<30, 1, u64> handheld_left_b; |
| 288 | BitField<31, 1, u64> lagon_c_left; | ||
| 289 | BitField<32, 1, u64> lagon_c_up; | ||
| 290 | BitField<33, 1, u64> lagon_c_right; | ||
| 291 | BitField<34, 1, u64> lagon_c_down; | ||
| 282 | }; | 292 | }; |
| 283 | }; | 293 | }; |
| 284 | static_assert(sizeof(NpadButtonState) == 0x8, "NpadButtonState has incorrect size."); | 294 | static_assert(sizeof(NpadButtonState) == 0x8, "NpadButtonState has incorrect size."); |
diff --git a/src/core/hid/input_interpreter.cpp b/src/core/hid/input_interpreter.cpp index 7e7c1816f..870422d82 100644 --- a/src/core/hid/input_interpreter.cpp +++ b/src/core/hid/input_interpreter.cpp | |||
| @@ -20,7 +20,7 @@ InputInterpreter::InputInterpreter(Core::System& system) | |||
| 20 | InputInterpreter::~InputInterpreter() = default; | 20 | InputInterpreter::~InputInterpreter() = default; |
| 21 | 21 | ||
| 22 | void InputInterpreter::PollInput() { | 22 | void InputInterpreter::PollInput() { |
| 23 | const u32 button_state = npad.GetAndResetPressState(); | 23 | const u64 button_state = npad.GetAndResetPressState(); |
| 24 | 24 | ||
| 25 | previous_index = current_index; | 25 | previous_index = current_index; |
| 26 | current_index = (current_index + 1) % button_states.size(); | 26 | current_index = (current_index + 1) % button_states.size(); |
| @@ -32,7 +32,7 @@ void InputInterpreter::ResetButtonStates() { | |||
| 32 | previous_index = 0; | 32 | previous_index = 0; |
| 33 | current_index = 0; | 33 | current_index = 0; |
| 34 | 34 | ||
| 35 | button_states[0] = 0xFFFFFFFF; | 35 | button_states[0] = 0xFFFFFFFFFFFFFFFF; |
| 36 | 36 | ||
| 37 | for (std::size_t i = 1; i < button_states.size(); ++i) { | 37 | for (std::size_t i = 1; i < button_states.size(); ++i) { |
| 38 | button_states[i] = 0; | 38 | button_states[i] = 0; |
| @@ -40,22 +40,22 @@ void InputInterpreter::ResetButtonStates() { | |||
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | bool InputInterpreter::IsButtonPressed(Core::HID::NpadButton button) const { | 42 | bool InputInterpreter::IsButtonPressed(Core::HID::NpadButton button) const { |
| 43 | return (button_states[current_index] & static_cast<u32>(button)) != 0; | 43 | return (button_states[current_index] & static_cast<u64>(button)) != 0; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | bool InputInterpreter::IsButtonPressedOnce(Core::HID::NpadButton button) const { | 46 | bool InputInterpreter::IsButtonPressedOnce(Core::HID::NpadButton button) const { |
| 47 | const bool current_press = (button_states[current_index] & static_cast<u32>(button)) != 0; | 47 | const bool current_press = (button_states[current_index] & static_cast<u64>(button)) != 0; |
| 48 | const bool previous_press = (button_states[previous_index] & static_cast<u32>(button)) != 0; | 48 | const bool previous_press = (button_states[previous_index] & static_cast<u64>(button)) != 0; |
| 49 | 49 | ||
| 50 | return current_press && !previous_press; | 50 | return current_press && !previous_press; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | bool InputInterpreter::IsButtonHeld(Core::HID::NpadButton button) const { | 53 | bool InputInterpreter::IsButtonHeld(Core::HID::NpadButton button) const { |
| 54 | u32 held_buttons{button_states[0]}; | 54 | u64 held_buttons{button_states[0]}; |
| 55 | 55 | ||
| 56 | for (std::size_t i = 1; i < button_states.size(); ++i) { | 56 | for (std::size_t i = 1; i < button_states.size(); ++i) { |
| 57 | held_buttons &= button_states[i]; | 57 | held_buttons &= button_states[i]; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | return (held_buttons & static_cast<u32>(button)) != 0; | 60 | return (held_buttons & static_cast<u64>(button)) != 0; |
| 61 | } | 61 | } |
diff --git a/src/core/hid/input_interpreter.h b/src/core/hid/input_interpreter.h index 1791cf9b7..1c2e02142 100644 --- a/src/core/hid/input_interpreter.h +++ b/src/core/hid/input_interpreter.h | |||
| @@ -105,7 +105,7 @@ private: | |||
| 105 | Service::HID::Controller_NPad& npad; | 105 | Service::HID::Controller_NPad& npad; |
| 106 | 106 | ||
| 107 | /// Stores 9 consecutive button states polled from HID. | 107 | /// Stores 9 consecutive button states polled from HID. |
| 108 | std::array<u32, 9> button_states{}; | 108 | std::array<u64, 9> button_states{}; |
| 109 | 109 | ||
| 110 | std::size_t previous_index{}; | 110 | std::size_t previous_index{}; |
| 111 | std::size_t current_index{}; | 111 | std::size_t current_index{}; |
diff --git a/src/core/hle/service/hid/controllers/debug_pad.cpp b/src/core/hle/service/hid/controllers/debug_pad.cpp index 5b1946f13..345134357 100644 --- a/src/core/hle/service/hid/controllers/debug_pad.cpp +++ b/src/core/hle/service/hid/controllers/debug_pad.cpp | |||
| @@ -30,8 +30,8 @@ void Controller_DebugPad::OnRelease() {} | |||
| 30 | void Controller_DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, | 30 | void Controller_DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, |
| 31 | std::size_t size) { | 31 | std::size_t size) { |
| 32 | if (!IsControllerActivated()) { | 32 | if (!IsControllerActivated()) { |
| 33 | debug_pad_lifo.entry_count = 0; | 33 | debug_pad_lifo.buffer_count = 0; |
| 34 | debug_pad_lifo.last_entry_index = 0; | 34 | debug_pad_lifo.buffer_tail = 0; |
| 35 | std::memcpy(data + SHARED_MEMORY_OFFSET, &debug_pad_lifo, sizeof(debug_pad_lifo)); | 35 | std::memcpy(data + SHARED_MEMORY_OFFSET, &debug_pad_lifo, sizeof(debug_pad_lifo)); |
| 36 | return; | 36 | return; |
| 37 | } | 37 | } |
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index 47760b4f8..00df50f32 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp | |||
| @@ -31,8 +31,8 @@ Controller_Gesture::Controller_Gesture(Core::System& system_) : ControllerBase(s | |||
| 31 | Controller_Gesture::~Controller_Gesture() = default; | 31 | Controller_Gesture::~Controller_Gesture() = default; |
| 32 | 32 | ||
| 33 | void Controller_Gesture::OnInit() { | 33 | void Controller_Gesture::OnInit() { |
| 34 | gesture_lifo.entry_count = 0; | 34 | gesture_lifo.buffer_count = 0; |
| 35 | gesture_lifo.last_entry_index = 0; | 35 | gesture_lifo.buffer_tail = 0; |
| 36 | force_update = true; | 36 | force_update = true; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| @@ -41,8 +41,8 @@ void Controller_Gesture::OnRelease() {} | |||
| 41 | void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, | 41 | void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, |
| 42 | std::size_t size) { | 42 | std::size_t size) { |
| 43 | if (!IsControllerActivated()) { | 43 | if (!IsControllerActivated()) { |
| 44 | gesture_lifo.entry_count = 0; | 44 | gesture_lifo.buffer_count = 0; |
| 45 | gesture_lifo.last_entry_index = 0; | 45 | gesture_lifo.buffer_tail = 0; |
| 46 | std::memcpy(data + SHARED_MEMORY_OFFSET, &gesture_lifo, sizeof(gesture_lifo)); | 46 | std::memcpy(data + SHARED_MEMORY_OFFSET, &gesture_lifo, sizeof(gesture_lifo)); |
| 47 | return; | 47 | return; |
| 48 | } | 48 | } |
diff --git a/src/core/hle/service/hid/controllers/keyboard.cpp b/src/core/hle/service/hid/controllers/keyboard.cpp index 632679a17..f4d49965f 100644 --- a/src/core/hle/service/hid/controllers/keyboard.cpp +++ b/src/core/hle/service/hid/controllers/keyboard.cpp | |||
| @@ -27,8 +27,8 @@ void Controller_Keyboard::OnRelease() {} | |||
| 27 | void Controller_Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, | 27 | void Controller_Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, |
| 28 | std::size_t size) { | 28 | std::size_t size) { |
| 29 | if (!IsControllerActivated()) { | 29 | if (!IsControllerActivated()) { |
| 30 | keyboard_lifo.entry_count = 0; | 30 | keyboard_lifo.buffer_count = 0; |
| 31 | keyboard_lifo.last_entry_index = 0; | 31 | keyboard_lifo.buffer_tail = 0; |
| 32 | std::memcpy(data + SHARED_MEMORY_OFFSET, &keyboard_lifo, sizeof(keyboard_lifo)); | 32 | std::memcpy(data + SHARED_MEMORY_OFFSET, &keyboard_lifo, sizeof(keyboard_lifo)); |
| 33 | return; | 33 | return; |
| 34 | } | 34 | } |
diff --git a/src/core/hle/service/hid/controllers/mouse.cpp b/src/core/hle/service/hid/controllers/mouse.cpp index 6d3bd0a2b..7ec75e8c8 100644 --- a/src/core/hle/service/hid/controllers/mouse.cpp +++ b/src/core/hle/service/hid/controllers/mouse.cpp | |||
| @@ -24,11 +24,9 @@ void Controller_Mouse::OnRelease() {} | |||
| 24 | 24 | ||
| 25 | void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, | 25 | void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, |
| 26 | std::size_t size) { | 26 | std::size_t size) { |
| 27 | mouse_lifo.timestamp = core_timing.GetCPUTicks(); | ||
| 28 | |||
| 29 | if (!IsControllerActivated()) { | 27 | if (!IsControllerActivated()) { |
| 30 | mouse_lifo.entry_count = 0; | 28 | mouse_lifo.buffer_count = 0; |
| 31 | mouse_lifo.last_entry_index = 0; | 29 | mouse_lifo.buffer_tail = 0; |
| 32 | std::memcpy(data + SHARED_MEMORY_OFFSET, &mouse_lifo, sizeof(mouse_lifo)); | 30 | std::memcpy(data + SHARED_MEMORY_OFFSET, &mouse_lifo, sizeof(mouse_lifo)); |
| 33 | return; | 31 | return; |
| 34 | } | 32 | } |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 9f84e20c2..9f82f872a 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -101,7 +101,8 @@ Controller_NPad::Controller_NPad(Core::System& system_, | |||
| 101 | for (std::size_t i = 0; i < controller_data.size(); ++i) { | 101 | for (std::size_t i = 0; i < controller_data.size(); ++i) { |
| 102 | auto& controller = controller_data[i]; | 102 | auto& controller = controller_data[i]; |
| 103 | controller.device = system.HIDCore().GetEmulatedControllerByIndex(i); | 103 | controller.device = system.HIDCore().GetEmulatedControllerByIndex(i); |
| 104 | controller.vibration[Core::HID::DeviceIndex::LeftIndex].latest_vibration_value = DEFAULT_VIBRATION_VALUE; | 104 | controller.vibration[Core::HID::DeviceIndex::LeftIndex].latest_vibration_value = |
| 105 | DEFAULT_VIBRATION_VALUE; | ||
| 105 | controller.vibration[Core::HID::DeviceIndex::RightIndex].latest_vibration_value = | 106 | controller.vibration[Core::HID::DeviceIndex::RightIndex].latest_vibration_value = |
| 106 | DEFAULT_VIBRATION_VALUE; | 107 | DEFAULT_VIBRATION_VALUE; |
| 107 | Core::HID::ControllerUpdateCallback engine_callback{ | 108 | Core::HID::ControllerUpdateCallback engine_callback{ |
| @@ -178,7 +179,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
| 178 | shared_memory.system_properties.use_plus.Assign(1); | 179 | shared_memory.system_properties.use_plus.Assign(1); |
| 179 | shared_memory.system_properties.use_minus.Assign(1); | 180 | shared_memory.system_properties.use_minus.Assign(1); |
| 180 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; | 181 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; |
| 181 | shared_memory.footer_type = AppletFooterUiType::SwitchProController; | 182 | shared_memory.applet_footer.type = AppletFooterUiType::SwitchProController; |
| 182 | break; | 183 | break; |
| 183 | case Core::HID::NpadType::Handheld: | 184 | case Core::HID::NpadType::Handheld: |
| 184 | shared_memory.style_set.handheld.Assign(1); | 185 | shared_memory.style_set.handheld.Assign(1); |
| @@ -188,7 +189,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
| 188 | shared_memory.system_properties.use_plus.Assign(1); | 189 | shared_memory.system_properties.use_plus.Assign(1); |
| 189 | shared_memory.system_properties.use_minus.Assign(1); | 190 | shared_memory.system_properties.use_minus.Assign(1); |
| 190 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual; | 191 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual; |
| 191 | shared_memory.footer_type = AppletFooterUiType::HandheldJoyConLeftJoyConRight; | 192 | shared_memory.applet_footer.type = AppletFooterUiType::HandheldJoyConLeftJoyConRight; |
| 192 | break; | 193 | break; |
| 193 | case Core::HID::NpadType::JoyconDual: | 194 | case Core::HID::NpadType::JoyconDual: |
| 194 | shared_memory.style_set.joycon_dual.Assign(1); | 195 | shared_memory.style_set.joycon_dual.Assign(1); |
| @@ -198,7 +199,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
| 198 | shared_memory.system_properties.use_plus.Assign(1); | 199 | shared_memory.system_properties.use_plus.Assign(1); |
| 199 | shared_memory.system_properties.use_minus.Assign(1); | 200 | shared_memory.system_properties.use_minus.Assign(1); |
| 200 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual; | 201 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual; |
| 201 | shared_memory.footer_type = AppletFooterUiType::JoyDual; | 202 | shared_memory.applet_footer.type = AppletFooterUiType::JoyDual; |
| 202 | break; | 203 | break; |
| 203 | case Core::HID::NpadType::JoyconLeft: | 204 | case Core::HID::NpadType::JoyconLeft: |
| 204 | shared_memory.style_set.joycon_left.Assign(1); | 205 | shared_memory.style_set.joycon_left.Assign(1); |
| @@ -206,7 +207,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
| 206 | shared_memory.system_properties.is_horizontal.Assign(1); | 207 | shared_memory.system_properties.is_horizontal.Assign(1); |
| 207 | shared_memory.system_properties.use_minus.Assign(1); | 208 | shared_memory.system_properties.use_minus.Assign(1); |
| 208 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; | 209 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; |
| 209 | shared_memory.footer_type = AppletFooterUiType::JoyLeftHorizontal; | 210 | shared_memory.applet_footer.type = AppletFooterUiType::JoyLeftHorizontal; |
| 210 | break; | 211 | break; |
| 211 | case Core::HID::NpadType::JoyconRight: | 212 | case Core::HID::NpadType::JoyconRight: |
| 212 | shared_memory.style_set.joycon_right.Assign(1); | 213 | shared_memory.style_set.joycon_right.Assign(1); |
| @@ -214,7 +215,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
| 214 | shared_memory.system_properties.is_horizontal.Assign(1); | 215 | shared_memory.system_properties.is_horizontal.Assign(1); |
| 215 | shared_memory.system_properties.use_plus.Assign(1); | 216 | shared_memory.system_properties.use_plus.Assign(1); |
| 216 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; | 217 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; |
| 217 | shared_memory.footer_type = AppletFooterUiType::JoyRightHorizontal; | 218 | shared_memory.applet_footer.type = AppletFooterUiType::JoyRightHorizontal; |
| 218 | break; | 219 | break; |
| 219 | case Core::HID::NpadType::GameCube: | 220 | case Core::HID::NpadType::GameCube: |
| 220 | shared_memory.style_set.gamecube.Assign(1); | 221 | shared_memory.style_set.gamecube.Assign(1); |
| @@ -919,7 +920,7 @@ void Controller_NPad::DisconnectNpadAtIndex(std::size_t npad_index) { | |||
| 919 | .right = {}, | 920 | .right = {}, |
| 920 | }; | 921 | }; |
| 921 | shared_memory_entry.assignment_mode = NpadJoyAssignmentMode::Dual; | 922 | shared_memory_entry.assignment_mode = NpadJoyAssignmentMode::Dual; |
| 922 | shared_memory_entry.footer_type = AppletFooterUiType::None; | 923 | shared_memory_entry.applet_footer.type = AppletFooterUiType::None; |
| 923 | 924 | ||
| 924 | controller.is_connected = false; | 925 | controller.is_connected = false; |
| 925 | controller.device->Disconnect(); | 926 | controller.device->Disconnect(); |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 0a2dc6992..af4934c55 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -330,10 +330,43 @@ private: | |||
| 330 | BitField<13, 1, s32> handheld_lark_nes_left; | 330 | BitField<13, 1, s32> handheld_lark_nes_left; |
| 331 | BitField<14, 1, s32> handheld_lark_nes_right; | 331 | BitField<14, 1, s32> handheld_lark_nes_right; |
| 332 | BitField<15, 1, s32> lucia; | 332 | BitField<15, 1, s32> lucia; |
| 333 | BitField<16, 1, s32> lagon; | ||
| 334 | BitField<17, 1, s32> lager; | ||
| 333 | BitField<31, 1, s32> system; | 335 | BitField<31, 1, s32> system; |
| 334 | }; | 336 | }; |
| 335 | }; | 337 | }; |
| 336 | 338 | ||
| 339 | // This is nn::hid::detail::NfcXcdDeviceHandleStateImpl | ||
| 340 | struct NfcXcdDeviceHandleStateImpl { | ||
| 341 | u64 handle; | ||
| 342 | bool is_available; | ||
| 343 | bool is_activated; | ||
| 344 | INSERT_PADDING_BYTES(0x6); // Reserved | ||
| 345 | u64 sampling_number; | ||
| 346 | }; | ||
| 347 | static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18, | ||
| 348 | "NfcXcdDeviceHandleStateImpl is an invalid size"); | ||
| 349 | |||
| 350 | // nn::hid::detail::NfcXcdDeviceHandleStateImplAtomicStorage | ||
| 351 | struct NfcXcdDeviceHandleStateImplAtomicStorage { | ||
| 352 | u64 sampling_number; | ||
| 353 | NfcXcdDeviceHandleStateImpl nfc_xcd_device_handle_state; | ||
| 354 | }; | ||
| 355 | static_assert(sizeof(NfcXcdDeviceHandleStateImplAtomicStorage) == 0x20, | ||
| 356 | "NfcXcdDeviceHandleStateImplAtomicStorage is an invalid size"); | ||
| 357 | |||
| 358 | // This is nn::hid::detail::NfcXcdDeviceHandleState | ||
| 359 | struct NfcXcdDeviceHandleState { | ||
| 360 | // TODO(german77): Make this struct a ring lifo object | ||
| 361 | INSERT_PADDING_BYTES(0x8); // Unused | ||
| 362 | s64 total_buffer_count = max_buffer_size; | ||
| 363 | s64 buffer_tail{}; | ||
| 364 | s64 buffer_count{}; | ||
| 365 | std::array<NfcXcdDeviceHandleStateImplAtomicStorage, 2> nfc_xcd_device_handle_storage; | ||
| 366 | }; | ||
| 367 | static_assert(sizeof(NfcXcdDeviceHandleState) == 0x60, | ||
| 368 | "NfcXcdDeviceHandleState is an invalid size"); | ||
| 369 | |||
| 337 | // This is nn::hid::system::AppletFooterUiAttributesSet | 370 | // This is nn::hid::system::AppletFooterUiAttributesSet |
| 338 | struct AppletFooterUiAttributes { | 371 | struct AppletFooterUiAttributes { |
| 339 | INSERT_PADDING_BYTES(0x4); | 372 | INSERT_PADDING_BYTES(0x4); |
| @@ -365,6 +398,14 @@ private: | |||
| 365 | Lagon = 21, | 398 | Lagon = 21, |
| 366 | }; | 399 | }; |
| 367 | 400 | ||
| 401 | struct AppletFooterUi { | ||
| 402 | AppletFooterUiAttributes attributes; | ||
| 403 | AppletFooterUiType type; | ||
| 404 | INSERT_PADDING_BYTES(0x5B); // Reserved | ||
| 405 | }; | ||
| 406 | static_assert(sizeof(AppletFooterUi) == 0x60, | ||
| 407 | "AppletFooterUi is an invalid size"); | ||
| 408 | |||
| 368 | // This is nn::hid::NpadLarkType | 409 | // This is nn::hid::NpadLarkType |
| 369 | enum class NpadLarkType : u32 { | 410 | enum class NpadLarkType : u32 { |
| 370 | Invalid, | 411 | Invalid, |
| @@ -382,6 +423,11 @@ private: | |||
| 382 | U, | 423 | U, |
| 383 | }; | 424 | }; |
| 384 | 425 | ||
| 426 | // This is nn::hid::NpadLagonType | ||
| 427 | enum class NpadLagonType : u32 { | ||
| 428 | Invalid, | ||
| 429 | }; | ||
| 430 | |||
| 385 | // This is nn::hid::NpadLagerType | 431 | // This is nn::hid::NpadLagerType |
| 386 | enum class NpadLagerType : u32 { | 432 | enum class NpadLagerType : u32 { |
| 387 | Invalid, | 433 | Invalid, |
| @@ -416,17 +462,19 @@ private: | |||
| 416 | Core::HID::BatteryLevel battery_level_dual; | 462 | Core::HID::BatteryLevel battery_level_dual; |
| 417 | Core::HID::BatteryLevel battery_level_left; | 463 | Core::HID::BatteryLevel battery_level_left; |
| 418 | Core::HID::BatteryLevel battery_level_right; | 464 | Core::HID::BatteryLevel battery_level_right; |
| 419 | AppletFooterUiAttributes footer_attributes; | 465 | union { |
| 420 | AppletFooterUiType footer_type; | 466 | NfcXcdDeviceHandleState nfc_xcd_device_handle; |
| 421 | // GetXcdHandleForNpadWithNfc needs to be checked switchbrew doesn't match with HW | 467 | AppletFooterUi applet_footer; |
| 422 | INSERT_PADDING_BYTES(0x78); // Unknown | 468 | }; |
| 469 | INSERT_PADDING_BYTES(0x20); // Unknown | ||
| 423 | Lifo<NpadGcTriggerState> gc_trigger_lifo; | 470 | Lifo<NpadGcTriggerState> gc_trigger_lifo; |
| 424 | NpadLarkType lark_type_l; | 471 | NpadLarkType lark_type_l_and_main; |
| 425 | NpadLarkType lark_type_r; | 472 | NpadLarkType lark_type_r; |
| 426 | NpadLuciaType lucia_type; | 473 | NpadLuciaType lucia_type; |
| 474 | NpadLagonType lagon_type; | ||
| 427 | NpadLagerType lager_type; | 475 | NpadLagerType lager_type; |
| 428 | INSERT_PADDING_BYTES( | 476 | INSERT_PADDING_BYTES( |
| 429 | 0x8); // FW 13.x Investigate there is some sort of bitflag related to joycons | 477 | 0x4); // FW 13.x Investigate there is some sort of bitflag related to joycons |
| 430 | INSERT_PADDING_BYTES(0xc08); // Unknown | 478 | INSERT_PADDING_BYTES(0xc08); // Unknown |
| 431 | }; | 479 | }; |
| 432 | static_assert(sizeof(NpadInternalState) == 0x5000, "NpadInternalState is an invalid size"); | 480 | static_assert(sizeof(NpadInternalState) == 0x5000, "NpadInternalState is an invalid size"); |
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index 5ba8d96a8..9ae2bf2b1 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp | |||
| @@ -30,8 +30,8 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin | |||
| 30 | touch_screen_lifo.timestamp = core_timing.GetCPUTicks(); | 30 | touch_screen_lifo.timestamp = core_timing.GetCPUTicks(); |
| 31 | 31 | ||
| 32 | if (!IsControllerActivated()) { | 32 | if (!IsControllerActivated()) { |
| 33 | touch_screen_lifo.entry_count = 0; | 33 | touch_screen_lifo.buffer_count = 0; |
| 34 | touch_screen_lifo.last_entry_index = 0; | 34 | touch_screen_lifo.buffer_tail = 0; |
| 35 | std::memcpy(data, &touch_screen_lifo, sizeof(touch_screen_lifo)); | 35 | std::memcpy(data, &touch_screen_lifo, sizeof(touch_screen_lifo)); |
| 36 | return; | 36 | return; |
| 37 | } | 37 | } |
diff --git a/src/core/hle/service/hid/controllers/xpad.cpp b/src/core/hle/service/hid/controllers/xpad.cpp index aa9f044f1..a2ed1e7c2 100644 --- a/src/core/hle/service/hid/controllers/xpad.cpp +++ b/src/core/hle/service/hid/controllers/xpad.cpp | |||
| @@ -20,8 +20,8 @@ void Controller_XPad::OnRelease() {} | |||
| 20 | void Controller_XPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, | 20 | void Controller_XPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, |
| 21 | std::size_t size) { | 21 | std::size_t size) { |
| 22 | if (!IsControllerActivated()) { | 22 | if (!IsControllerActivated()) { |
| 23 | basic_xpad_lifo.entry_count = 0; | 23 | basic_xpad_lifo.buffer_count = 0; |
| 24 | basic_xpad_lifo.last_entry_index = 0; | 24 | basic_xpad_lifo.buffer_tail = 0; |
| 25 | std::memcpy(data + SHARED_MEMORY_OFFSET, &basic_xpad_lifo, sizeof(basic_xpad_lifo)); | 25 | std::memcpy(data + SHARED_MEMORY_OFFSET, &basic_xpad_lifo, sizeof(basic_xpad_lifo)); |
| 26 | return; | 26 | return; |
| 27 | } | 27 | } |
diff --git a/src/core/hle/service/hid/ring_lifo.h b/src/core/hle/service/hid/ring_lifo.h index f68d82762..382350a2d 100644 --- a/src/core/hle/service/hid/ring_lifo.h +++ b/src/core/hle/service/hid/ring_lifo.h | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include "common/swap.h" | 8 | #include "common/swap.h" |
| 9 | 9 | ||
| 10 | namespace Service::HID { | 10 | namespace Service::HID { |
| 11 | constexpr std::size_t max_entry_size = 17; | 11 | constexpr std::size_t max_buffer_size = 17; |
| 12 | 12 | ||
| 13 | template <typename State> | 13 | template <typename State> |
| 14 | struct AtomicStorage { | 14 | struct AtomicStorage { |
| @@ -19,13 +19,13 @@ struct AtomicStorage { | |||
| 19 | template <typename State> | 19 | template <typename State> |
| 20 | struct Lifo { | 20 | struct Lifo { |
| 21 | s64 timestamp{}; | 21 | s64 timestamp{}; |
| 22 | s64 total_entry_count = max_entry_size; | 22 | s64 total_buffer_count = max_buffer_size; |
| 23 | s64 last_entry_index{}; | 23 | s64 buffer_tail{}; |
| 24 | s64 entry_count{}; | 24 | s64 buffer_count{}; |
| 25 | std::array<AtomicStorage<State>, max_entry_size> entries{}; | 25 | std::array<AtomicStorage<State>, max_buffer_size> entries{}; |
| 26 | 26 | ||
| 27 | const AtomicStorage<State>& ReadCurrentEntry() const { | 27 | const AtomicStorage<State>& ReadCurrentEntry() const { |
| 28 | return entries[last_entry_index]; | 28 | return entries[buffer_tail]; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | const AtomicStorage<State>& ReadPreviousEntry() const { | 31 | const AtomicStorage<State>& ReadPreviousEntry() const { |
| @@ -33,21 +33,21 @@ struct Lifo { | |||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | std::size_t GetPreviuousEntryIndex() const { | 35 | std::size_t GetPreviuousEntryIndex() const { |
| 36 | return (last_entry_index + total_entry_count - 1) % total_entry_count; | 36 | return (buffer_tail + total_buffer_count - 1) % total_buffer_count; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | std::size_t GetNextEntryIndex() const { | 39 | std::size_t GetNextEntryIndex() const { |
| 40 | return (last_entry_index + 1) % total_entry_count; | 40 | return (buffer_tail + 1) % total_buffer_count; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | void WriteNextEntry(const State& new_state) { | 43 | void WriteNextEntry(const State& new_state) { |
| 44 | if (entry_count < total_entry_count - 1) { | 44 | if (buffer_count < total_buffer_count - 1) { |
| 45 | entry_count++; | 45 | buffer_count++; |
| 46 | } | 46 | } |
| 47 | last_entry_index = GetNextEntryIndex(); | 47 | buffer_tail = GetNextEntryIndex(); |
| 48 | const auto& previous_entry = ReadPreviousEntry(); | 48 | const auto& previous_entry = ReadPreviousEntry(); |
| 49 | entries[last_entry_index].sampling_number = previous_entry.sampling_number + 1; | 49 | entries[buffer_tail].sampling_number = previous_entry.sampling_number + 1; |
| 50 | entries[last_entry_index].state = new_state; | 50 | entries[buffer_tail].state = new_state; |
| 51 | } | 51 | } |
| 52 | }; | 52 | }; |
| 53 | 53 | ||