diff options
| author | 2021-11-22 22:15:34 -0600 | |
|---|---|---|
| committer | 2021-11-24 20:30:29 -0600 | |
| commit | 23bf2e3bb6fe0881e28767e768ad9c0a9f851d57 (patch) | |
| tree | 16a462ef05c12d1f5a420886e1b5452fdb999330 | |
| parent | yuzu: Fix TAS from rebase (diff) | |
| download | yuzu-23bf2e3bb6fe0881e28767e768ad9c0a9f851d57.tar.gz yuzu-23bf2e3bb6fe0881e28767e768ad9c0a9f851d57.tar.xz yuzu-23bf2e3bb6fe0881e28767e768ad9c0a9f851d57.zip | |
service/hid: Finish converting LIFO objects and address some nits
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 2 | ||||
| -rw-r--r-- | src/core/hid/hid_types.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.cpp | 31 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.h | 31 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/controller_base.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/debug_pad.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/gesture.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/keyboard.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/mouse.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 56 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/xpad.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/ring_lifo.h | 3 |
14 files changed, 50 insertions, 95 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 54c1a2324..54d4ed93d 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -723,7 +723,7 @@ void EmulatedController::SetBattery(Common::Input::CallbackStatus callback, std: | |||
| 723 | 723 | ||
| 724 | bool is_charging = false; | 724 | bool is_charging = false; |
| 725 | bool is_powered = false; | 725 | bool is_powered = false; |
| 726 | BatteryLevel battery_level = 0; | 726 | NpadBatteryLevel battery_level = 0; |
| 727 | switch (controller.battery_values[index]) { | 727 | switch (controller.battery_values[index]) { |
| 728 | case Common::Input::BatteryLevel::Charging: | 728 | case Common::Input::BatteryLevel::Charging: |
| 729 | is_charging = true; | 729 | is_charging = true; |
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h index 3cbe16260..acf54e233 100644 --- a/src/core/hid/hid_types.h +++ b/src/core/hid/hid_types.h | |||
| @@ -346,15 +346,15 @@ struct NpadGcTriggerState { | |||
| 346 | static_assert(sizeof(NpadGcTriggerState) == 0x10, "NpadGcTriggerState is an invalid size"); | 346 | static_assert(sizeof(NpadGcTriggerState) == 0x10, "NpadGcTriggerState is an invalid size"); |
| 347 | 347 | ||
| 348 | // This is nn::hid::system::NpadBatteryLevel | 348 | // This is nn::hid::system::NpadBatteryLevel |
| 349 | using BatteryLevel = u32; | 349 | using NpadBatteryLevel = u32; |
| 350 | static_assert(sizeof(BatteryLevel) == 0x4, "BatteryLevel is an invalid size"); | 350 | static_assert(sizeof(NpadBatteryLevel) == 0x4, "NpadBatteryLevel is an invalid size"); |
| 351 | 351 | ||
| 352 | // This is nn::hid::system::NpadPowerInfo | 352 | // This is nn::hid::system::NpadPowerInfo |
| 353 | struct NpadPowerInfo { | 353 | struct NpadPowerInfo { |
| 354 | bool is_powered; | 354 | bool is_powered; |
| 355 | bool is_charging; | 355 | bool is_charging; |
| 356 | INSERT_PADDING_BYTES(0x6); | 356 | INSERT_PADDING_BYTES(0x6); |
| 357 | BatteryLevel battery_level; | 357 | NpadBatteryLevel battery_level; |
| 358 | }; | 358 | }; |
| 359 | static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size"); | 359 | static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size"); |
| 360 | 360 | ||
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.cpp b/src/core/hle/service/hid/controllers/console_sixaxis.cpp index ea7e8f18f..f0f3105dc 100644 --- a/src/core/hle/service/hid/controllers/console_sixaxis.cpp +++ b/src/core/hle/service/hid/controllers/console_sixaxis.cpp | |||
| @@ -24,34 +24,25 @@ void Controller_ConsoleSixAxis::OnRelease() {} | |||
| 24 | 24 | ||
| 25 | void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, | 25 | void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, |
| 26 | std::size_t size) { | 26 | std::size_t size) { |
| 27 | seven_six_axis.header.timestamp = core_timing.GetCPUTicks(); | ||
| 28 | seven_six_axis.header.total_entry_count = 17; | ||
| 29 | |||
| 30 | if (!IsControllerActivated() || !is_transfer_memory_set) { | 27 | if (!IsControllerActivated() || !is_transfer_memory_set) { |
| 31 | seven_six_axis.header.entry_count = 0; | 28 | seven_sixaxis_lifo.buffer_count = 0; |
| 32 | seven_six_axis.header.last_entry_index = 0; | 29 | seven_sixaxis_lifo.buffer_tail = 0; |
| 33 | return; | 30 | return; |
| 34 | } | 31 | } |
| 35 | seven_six_axis.header.entry_count = 16; | ||
| 36 | |||
| 37 | const auto& last_entry = | ||
| 38 | seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; | ||
| 39 | seven_six_axis.header.last_entry_index = (seven_six_axis.header.last_entry_index + 1) % 17; | ||
| 40 | auto& cur_entry = seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; | ||
| 41 | 32 | ||
| 42 | cur_entry.sampling_number = last_entry.sampling_number + 1; | 33 | const auto& last_entry = seven_sixaxis_lifo.ReadCurrentEntry().state; |
| 43 | cur_entry.sampling_number2 = cur_entry.sampling_number; | 34 | next_seven_sixaxis_state.sampling_number = last_entry.sampling_number + 1; |
| 44 | 35 | ||
| 45 | // Try to read sixaxis sensor states | 36 | // Try to read sixaxis sensor states |
| 46 | const auto motion_status = console->GetMotion(); | 37 | const auto motion_status = console->GetMotion(); |
| 47 | 38 | ||
| 48 | console_six_axis.is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest; | 39 | console_six_axis.is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest; |
| 49 | 40 | ||
| 50 | cur_entry.accel = motion_status.accel; | 41 | next_seven_sixaxis_state.accel = motion_status.accel; |
| 51 | // Zero gyro values as they just mess up with the camera | 42 | // Zero gyro values as they just mess up with the camera |
| 52 | // Note: Probably a correct sensivity setting must be set | 43 | // Note: Probably a correct sensivity setting must be set |
| 53 | cur_entry.gyro = {}; | 44 | next_seven_sixaxis_state.gyro = {}; |
| 54 | cur_entry.quaternion = { | 45 | next_seven_sixaxis_state.quaternion = { |
| 55 | { | 46 | { |
| 56 | motion_status.quaternion.xyz.y, | 47 | motion_status.quaternion.xyz.y, |
| 57 | motion_status.quaternion.xyz.x, | 48 | motion_status.quaternion.xyz.x, |
| @@ -68,7 +59,8 @@ void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_ti | |||
| 68 | // Update console six axis shared memory | 59 | // Update console six axis shared memory |
| 69 | std::memcpy(data + SHARED_MEMORY_OFFSET, &console_six_axis, sizeof(console_six_axis)); | 60 | std::memcpy(data + SHARED_MEMORY_OFFSET, &console_six_axis, sizeof(console_six_axis)); |
| 70 | // Update seven six axis transfer memory | 61 | // Update seven six axis transfer memory |
| 71 | std::memcpy(transfer_memory, &seven_six_axis, sizeof(seven_six_axis)); | 62 | seven_sixaxis_lifo.WriteNextEntry(next_seven_sixaxis_state); |
| 63 | std::memcpy(transfer_memory, &seven_sixaxis_lifo, sizeof(seven_sixaxis_lifo)); | ||
| 72 | } | 64 | } |
| 73 | 65 | ||
| 74 | void Controller_ConsoleSixAxis::SetTransferMemoryPointer(u8* t_mem) { | 66 | void Controller_ConsoleSixAxis::SetTransferMemoryPointer(u8* t_mem) { |
| @@ -77,8 +69,7 @@ void Controller_ConsoleSixAxis::SetTransferMemoryPointer(u8* t_mem) { | |||
| 77 | } | 69 | } |
| 78 | 70 | ||
| 79 | void Controller_ConsoleSixAxis::ResetTimestamp() { | 71 | void Controller_ConsoleSixAxis::ResetTimestamp() { |
| 80 | auto& cur_entry = seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; | 72 | seven_sixaxis_lifo.buffer_count = 0; |
| 81 | cur_entry.sampling_number = 0; | 73 | seven_sixaxis_lifo.buffer_tail = 0; |
| 82 | cur_entry.sampling_number2 = 0; | ||
| 83 | } | 74 | } |
| 84 | } // namespace Service::HID | 75 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.h b/src/core/hle/service/hid/controllers/console_sixaxis.h index 7c92413e8..279241858 100644 --- a/src/core/hle/service/hid/controllers/console_sixaxis.h +++ b/src/core/hle/service/hid/controllers/console_sixaxis.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "common/quaternion.h" | 10 | #include "common/quaternion.h" |
| 11 | #include "core/hid/hid_types.h" | 11 | #include "core/hid/hid_types.h" |
| 12 | #include "core/hle/service/hid/controllers/controller_base.h" | 12 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 13 | #include "core/hle/service/hid/ring_lifo.h" | ||
| 13 | 14 | ||
| 14 | namespace Core::HID { | 15 | namespace Core::HID { |
| 15 | class EmulatedConsole; | 16 | class EmulatedConsole; |
| @@ -40,50 +41,30 @@ private: | |||
| 40 | struct SevenSixAxisState { | 41 | struct SevenSixAxisState { |
| 41 | INSERT_PADDING_WORDS(4); // unused | 42 | INSERT_PADDING_WORDS(4); // unused |
| 42 | s64 sampling_number{}; | 43 | s64 sampling_number{}; |
| 43 | s64 sampling_number2{}; | ||
| 44 | u64 unknown{}; | 44 | u64 unknown{}; |
| 45 | Common::Vec3f accel{}; | 45 | Common::Vec3f accel{}; |
| 46 | Common::Vec3f gyro{}; | 46 | Common::Vec3f gyro{}; |
| 47 | Common::Quaternion<f32> quaternion{}; | 47 | Common::Quaternion<f32> quaternion{}; |
| 48 | }; | 48 | }; |
| 49 | static_assert(sizeof(SevenSixAxisState) == 0x50, "SevenSixAxisState is an invalid size"); | 49 | static_assert(sizeof(SevenSixAxisState) == 0x48, "SevenSixAxisState is an invalid size"); |
| 50 | |||
| 51 | struct CommonHeader { | ||
| 52 | s64 timestamp; | ||
| 53 | s64 total_entry_count; | ||
| 54 | s64 last_entry_index; | ||
| 55 | s64 entry_count; | ||
| 56 | }; | ||
| 57 | static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size"); | ||
| 58 | |||
| 59 | // TODO(german77): SevenSixAxisMemory doesn't follow the standard lifo. Investigate | ||
| 60 | struct SevenSixAxisMemory { | ||
| 61 | CommonHeader header{}; | ||
| 62 | std::array<SevenSixAxisState, 0x21> sevensixaxis_states{}; | ||
| 63 | }; | ||
| 64 | static_assert(sizeof(SevenSixAxisMemory) == 0xA70, "SevenSixAxisMemory is an invalid size"); | ||
| 65 | 50 | ||
| 66 | // This is nn::hid::detail::ConsoleSixAxisSensorSharedMemoryFormat | 51 | // This is nn::hid::detail::ConsoleSixAxisSensorSharedMemoryFormat |
| 67 | struct ConsoleSharedMemory { | 52 | struct ConsoleSharedMemory { |
| 68 | u64 sampling_number{}; | 53 | u64 sampling_number{}; |
| 69 | bool is_seven_six_axis_sensor_at_rest{}; | 54 | bool is_seven_six_axis_sensor_at_rest{}; |
| 55 | INSERT_PADDING_BYTES(4); // padding | ||
| 70 | f32 verticalization_error{}; | 56 | f32 verticalization_error{}; |
| 71 | Common::Vec3f gyro_bias{}; | 57 | Common::Vec3f gyro_bias{}; |
| 72 | }; | 58 | }; |
| 73 | static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size"); | 59 | static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size"); |
| 74 | 60 | ||
| 75 | struct MotionDevice { | 61 | Lifo<SevenSixAxisState, 0x21> seven_sixaxis_lifo{}; |
| 76 | Common::Vec3f accel; | 62 | static_assert(sizeof(seven_sixaxis_lifo) == 0xA70, "SevenSixAxisState is an invalid size"); |
| 77 | Common::Vec3f gyro; | ||
| 78 | Common::Vec3f rotation; | ||
| 79 | std::array<Common::Vec3f, 3> orientation; | ||
| 80 | Common::Quaternion<f32> quaternion; | ||
| 81 | }; | ||
| 82 | 63 | ||
| 83 | Core::HID::EmulatedConsole* console; | 64 | Core::HID::EmulatedConsole* console; |
| 84 | u8* transfer_memory = nullptr; | 65 | u8* transfer_memory = nullptr; |
| 85 | bool is_transfer_memory_set = false; | 66 | bool is_transfer_memory_set = false; |
| 86 | ConsoleSharedMemory console_six_axis{}; | 67 | ConsoleSharedMemory console_six_axis{}; |
| 87 | SevenSixAxisMemory seven_six_axis{}; | 68 | SevenSixAxisState next_seven_sixaxis_state{}; |
| 88 | }; | 69 | }; |
| 89 | } // namespace Service::HID | 70 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/controller_base.h b/src/core/hle/service/hid/controllers/controller_base.h index 8125bbc84..7450eb20a 100644 --- a/src/core/hle/service/hid/controllers/controller_base.h +++ b/src/core/hle/service/hid/controllers/controller_base.h | |||
| @@ -41,6 +41,8 @@ public: | |||
| 41 | 41 | ||
| 42 | bool IsControllerActivated() const; | 42 | bool IsControllerActivated() const; |
| 43 | 43 | ||
| 44 | static const std::size_t hid_entry_count = 17; | ||
| 45 | |||
| 44 | protected: | 46 | protected: |
| 45 | bool is_activated{false}; | 47 | bool is_activated{false}; |
| 46 | 48 | ||
diff --git a/src/core/hle/service/hid/controllers/debug_pad.h b/src/core/hle/service/hid/controllers/debug_pad.h index 15b3afb7a..afe374fc2 100644 --- a/src/core/hle/service/hid/controllers/debug_pad.h +++ b/src/core/hle/service/hid/controllers/debug_pad.h | |||
| @@ -54,7 +54,7 @@ private: | |||
| 54 | static_assert(sizeof(DebugPadState) == 0x20, "DebugPadState is an invalid state"); | 54 | static_assert(sizeof(DebugPadState) == 0x20, "DebugPadState is an invalid state"); |
| 55 | 55 | ||
| 56 | // This is nn::hid::detail::DebugPadLifo | 56 | // This is nn::hid::detail::DebugPadLifo |
| 57 | Lifo<DebugPadState> debug_pad_lifo{}; | 57 | Lifo<DebugPadState, hid_entry_count> debug_pad_lifo{}; |
| 58 | static_assert(sizeof(debug_pad_lifo) == 0x2C8, "debug_pad_lifo is an invalid size"); | 58 | static_assert(sizeof(debug_pad_lifo) == 0x2C8, "debug_pad_lifo is an invalid size"); |
| 59 | DebugPadState next_state{}; | 59 | DebugPadState next_state{}; |
| 60 | 60 | ||
diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h index f924464e0..0936a3fa3 100644 --- a/src/core/hle/service/hid/controllers/gesture.h +++ b/src/core/hle/service/hid/controllers/gesture.h | |||
| @@ -136,7 +136,7 @@ private: | |||
| 136 | GestureProperties GetGestureProperties(); | 136 | GestureProperties GetGestureProperties(); |
| 137 | 137 | ||
| 138 | // This is nn::hid::detail::GestureLifo | 138 | // This is nn::hid::detail::GestureLifo |
| 139 | Lifo<GestureState> gesture_lifo{}; | 139 | Lifo<GestureState, hid_entry_count> gesture_lifo{}; |
| 140 | static_assert(sizeof(gesture_lifo) == 0x708, "gesture_lifo is an invalid size"); | 140 | static_assert(sizeof(gesture_lifo) == 0x708, "gesture_lifo is an invalid size"); |
| 141 | GestureState next_state{}; | 141 | GestureState next_state{}; |
| 142 | 142 | ||
diff --git a/src/core/hle/service/hid/controllers/keyboard.h b/src/core/hle/service/hid/controllers/keyboard.h index 0d61cb470..cf62d3896 100644 --- a/src/core/hle/service/hid/controllers/keyboard.h +++ b/src/core/hle/service/hid/controllers/keyboard.h | |||
| @@ -44,7 +44,7 @@ private: | |||
| 44 | static_assert(sizeof(KeyboardState) == 0x30, "KeyboardState is an invalid size"); | 44 | static_assert(sizeof(KeyboardState) == 0x30, "KeyboardState is an invalid size"); |
| 45 | 45 | ||
| 46 | // This is nn::hid::detail::KeyboardLifo | 46 | // This is nn::hid::detail::KeyboardLifo |
| 47 | Lifo<KeyboardState> keyboard_lifo{}; | 47 | Lifo<KeyboardState, hid_entry_count> keyboard_lifo{}; |
| 48 | static_assert(sizeof(keyboard_lifo) == 0x3D8, "keyboard_lifo is an invalid size"); | 48 | static_assert(sizeof(keyboard_lifo) == 0x3D8, "keyboard_lifo is an invalid size"); |
| 49 | KeyboardState next_state{}; | 49 | KeyboardState next_state{}; |
| 50 | 50 | ||
diff --git a/src/core/hle/service/hid/controllers/mouse.h b/src/core/hle/service/hid/controllers/mouse.h index 1ac69aa6f..7559fc78d 100644 --- a/src/core/hle/service/hid/controllers/mouse.h +++ b/src/core/hle/service/hid/controllers/mouse.h | |||
| @@ -34,7 +34,7 @@ public: | |||
| 34 | 34 | ||
| 35 | private: | 35 | private: |
| 36 | // This is nn::hid::detail::MouseLifo | 36 | // This is nn::hid::detail::MouseLifo |
| 37 | Lifo<Core::HID::MouseState> mouse_lifo{}; | 37 | Lifo<Core::HID::MouseState, hid_entry_count> mouse_lifo{}; |
| 38 | static_assert(sizeof(mouse_lifo) == 0x350, "mouse_lifo is an invalid size"); | 38 | static_assert(sizeof(mouse_lifo) == 0x350, "mouse_lifo is an invalid size"); |
| 39 | Core::HID::MouseState next_state{}; | 39 | Core::HID::MouseState next_state{}; |
| 40 | 40 | ||
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 4b23230e1..dd4d954aa 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -157,6 +157,7 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) { | |||
| 157 | shared_memory.system_properties.is_vertical.Assign(1); | 157 | shared_memory.system_properties.is_vertical.Assign(1); |
| 158 | shared_memory.system_properties.use_plus.Assign(1); | 158 | shared_memory.system_properties.use_plus.Assign(1); |
| 159 | shared_memory.system_properties.use_minus.Assign(1); | 159 | shared_memory.system_properties.use_minus.Assign(1); |
| 160 | shared_memory.system_properties.use_directional_buttons.Assign(1); | ||
| 160 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual; | 161 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual; |
| 161 | shared_memory.applet_footer.type = AppletFooterUiType::HandheldJoyConLeftJoyConRight; | 162 | shared_memory.applet_footer.type = AppletFooterUiType::HandheldJoyConLeftJoyConRight; |
| 162 | break; | 163 | break; |
| @@ -167,6 +168,7 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) { | |||
| 167 | shared_memory.system_properties.is_vertical.Assign(1); | 168 | shared_memory.system_properties.is_vertical.Assign(1); |
| 168 | shared_memory.system_properties.use_plus.Assign(1); | 169 | shared_memory.system_properties.use_plus.Assign(1); |
| 169 | shared_memory.system_properties.use_minus.Assign(1); | 170 | shared_memory.system_properties.use_minus.Assign(1); |
| 171 | shared_memory.system_properties.use_directional_buttons.Assign(1); | ||
| 170 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual; | 172 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual; |
| 171 | shared_memory.applet_footer.type = AppletFooterUiType::JoyDual; | 173 | shared_memory.applet_footer.type = AppletFooterUiType::JoyDual; |
| 172 | break; | 174 | break; |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 3798c037f..9fa113bb6 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -339,26 +339,6 @@ private: | |||
| 339 | static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18, | 339 | static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18, |
| 340 | "NfcXcdDeviceHandleStateImpl is an invalid size"); | 340 | "NfcXcdDeviceHandleStateImpl is an invalid size"); |
| 341 | 341 | ||
| 342 | // nn::hid::detail::NfcXcdDeviceHandleStateImplAtomicStorage | ||
| 343 | struct NfcXcdDeviceHandleStateImplAtomicStorage { | ||
| 344 | u64 sampling_number; | ||
| 345 | NfcXcdDeviceHandleStateImpl nfc_xcd_device_handle_state; | ||
| 346 | }; | ||
| 347 | static_assert(sizeof(NfcXcdDeviceHandleStateImplAtomicStorage) == 0x20, | ||
| 348 | "NfcXcdDeviceHandleStateImplAtomicStorage is an invalid size"); | ||
| 349 | |||
| 350 | // This is nn::hid::detail::NfcXcdDeviceHandleState | ||
| 351 | struct NfcXcdDeviceHandleState { | ||
| 352 | // TODO(german77): Make this struct a ring lifo object | ||
| 353 | INSERT_PADDING_BYTES(0x8); // Unused | ||
| 354 | s64 total_buffer_count = max_buffer_size; | ||
| 355 | s64 buffer_tail{}; | ||
| 356 | s64 buffer_count{}; | ||
| 357 | std::array<NfcXcdDeviceHandleStateImplAtomicStorage, 2> nfc_xcd_device_handle_storage; | ||
| 358 | }; | ||
| 359 | static_assert(sizeof(NfcXcdDeviceHandleState) == 0x60, | ||
| 360 | "NfcXcdDeviceHandleState is an invalid size"); | ||
| 361 | |||
| 362 | // This is nn::hid::system::AppletFooterUiAttributesSet | 342 | // This is nn::hid::system::AppletFooterUiAttributesSet |
| 363 | struct AppletFooterUiAttributes { | 343 | struct AppletFooterUiAttributes { |
| 364 | INSERT_PADDING_BYTES(0x4); | 344 | INSERT_PADDING_BYTES(0x4); |
| @@ -433,32 +413,32 @@ private: | |||
| 433 | NpadJoyAssignmentMode assignment_mode; | 413 | NpadJoyAssignmentMode assignment_mode; |
| 434 | NpadFullKeyColorState fullkey_color; | 414 | NpadFullKeyColorState fullkey_color; |
| 435 | NpadJoyColorState joycon_color; | 415 | NpadJoyColorState joycon_color; |
| 436 | Lifo<NPadGenericState> fullkey_lifo; | 416 | Lifo<NPadGenericState, hid_entry_count> fullkey_lifo; |
| 437 | Lifo<NPadGenericState> handheld_lifo; | 417 | Lifo<NPadGenericState, hid_entry_count> handheld_lifo; |
| 438 | Lifo<NPadGenericState> joy_dual_lifo; | 418 | Lifo<NPadGenericState, hid_entry_count> joy_dual_lifo; |
| 439 | Lifo<NPadGenericState> joy_left_lifo; | 419 | Lifo<NPadGenericState, hid_entry_count> joy_left_lifo; |
| 440 | Lifo<NPadGenericState> joy_right_lifo; | 420 | Lifo<NPadGenericState, hid_entry_count> joy_right_lifo; |
| 441 | Lifo<NPadGenericState> palma_lifo; | 421 | Lifo<NPadGenericState, hid_entry_count> palma_lifo; |
| 442 | Lifo<NPadGenericState> system_ext_lifo; | 422 | Lifo<NPadGenericState, hid_entry_count> system_ext_lifo; |
| 443 | Lifo<SixAxisSensorState> sixaxis_fullkey_lifo; | 423 | Lifo<SixAxisSensorState, hid_entry_count> sixaxis_fullkey_lifo; |
| 444 | Lifo<SixAxisSensorState> sixaxis_handheld_lifo; | 424 | Lifo<SixAxisSensorState, hid_entry_count> sixaxis_handheld_lifo; |
| 445 | Lifo<SixAxisSensorState> sixaxis_dual_left_lifo; | 425 | Lifo<SixAxisSensorState, hid_entry_count> sixaxis_dual_left_lifo; |
| 446 | Lifo<SixAxisSensorState> sixaxis_dual_right_lifo; | 426 | Lifo<SixAxisSensorState, hid_entry_count> sixaxis_dual_right_lifo; |
| 447 | Lifo<SixAxisSensorState> sixaxis_left_lifo; | 427 | Lifo<SixAxisSensorState, hid_entry_count> sixaxis_left_lifo; |
| 448 | Lifo<SixAxisSensorState> sixaxis_right_lifo; | 428 | Lifo<SixAxisSensorState, hid_entry_count> sixaxis_right_lifo; |
| 449 | DeviceType device_type; | 429 | DeviceType device_type; |
| 450 | INSERT_PADDING_BYTES(0x4); // Reserved | 430 | INSERT_PADDING_BYTES(0x4); // Reserved |
| 451 | NPadSystemProperties system_properties; | 431 | NPadSystemProperties system_properties; |
| 452 | NpadSystemButtonProperties button_properties; | 432 | NpadSystemButtonProperties button_properties; |
| 453 | Core::HID::BatteryLevel battery_level_dual; | 433 | Core::HID::NpadBatteryLevel battery_level_dual; |
| 454 | Core::HID::BatteryLevel battery_level_left; | 434 | Core::HID::NpadBatteryLevel battery_level_left; |
| 455 | Core::HID::BatteryLevel battery_level_right; | 435 | Core::HID::NpadBatteryLevel battery_level_right; |
| 456 | union { | 436 | union { |
| 457 | NfcXcdDeviceHandleState nfc_xcd_device_handle; | 437 | Lifo<NfcXcdDeviceHandleStateImpl, 0x2> nfc_xcd_device_lifo{}; |
| 458 | AppletFooterUi applet_footer; | 438 | AppletFooterUi applet_footer; |
| 459 | }; | 439 | }; |
| 460 | INSERT_PADDING_BYTES(0x20); // Unknown | 440 | INSERT_PADDING_BYTES(0x20); // Unknown |
| 461 | Lifo<NpadGcTriggerState> gc_trigger_lifo; | 441 | Lifo<NpadGcTriggerState, hid_entry_count> gc_trigger_lifo; |
| 462 | NpadLarkType lark_type_l_and_main; | 442 | NpadLarkType lark_type_l_and_main; |
| 463 | NpadLarkType lark_type_r; | 443 | NpadLarkType lark_type_r; |
| 464 | NpadLuciaType lucia_type; | 444 | NpadLuciaType lucia_type; |
diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index 135c2bf13..708dde4f0 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h | |||
| @@ -61,7 +61,7 @@ private: | |||
| 61 | static_assert(sizeof(TouchScreenState) == 0x290, "TouchScreenState is an invalid size"); | 61 | static_assert(sizeof(TouchScreenState) == 0x290, "TouchScreenState is an invalid size"); |
| 62 | 62 | ||
| 63 | // This is nn::hid::detail::TouchScreenLifo | 63 | // This is nn::hid::detail::TouchScreenLifo |
| 64 | Lifo<TouchScreenState> touch_screen_lifo{}; | 64 | Lifo<TouchScreenState, hid_entry_count> touch_screen_lifo{}; |
| 65 | static_assert(sizeof(touch_screen_lifo) == 0x2C38, "touch_screen_lifo is an invalid size"); | 65 | static_assert(sizeof(touch_screen_lifo) == 0x2C38, "touch_screen_lifo is an invalid size"); |
| 66 | TouchScreenState next_state{}; | 66 | TouchScreenState next_state{}; |
| 67 | 67 | ||
diff --git a/src/core/hle/service/hid/controllers/xpad.h b/src/core/hle/service/hid/controllers/xpad.h index 54dae0be1..ba8db8d9d 100644 --- a/src/core/hle/service/hid/controllers/xpad.h +++ b/src/core/hle/service/hid/controllers/xpad.h | |||
| @@ -102,7 +102,7 @@ private: | |||
| 102 | static_assert(sizeof(BasicXpadState) == 0x20, "BasicXpadState is an invalid size"); | 102 | static_assert(sizeof(BasicXpadState) == 0x20, "BasicXpadState is an invalid size"); |
| 103 | 103 | ||
| 104 | // This is nn::hid::detail::BasicXpadLifo | 104 | // This is nn::hid::detail::BasicXpadLifo |
| 105 | Lifo<BasicXpadState> basic_xpad_lifo{}; | 105 | Lifo<BasicXpadState, hid_entry_count> basic_xpad_lifo{}; |
| 106 | static_assert(sizeof(basic_xpad_lifo) == 0x2C8, "basic_xpad_lifo is an invalid size"); | 106 | static_assert(sizeof(basic_xpad_lifo) == 0x2C8, "basic_xpad_lifo is an invalid size"); |
| 107 | BasicXpadState next_state{}; | 107 | BasicXpadState next_state{}; |
| 108 | }; | 108 | }; |
diff --git a/src/core/hle/service/hid/ring_lifo.h b/src/core/hle/service/hid/ring_lifo.h index f0e0bab7f..44c20d967 100644 --- a/src/core/hle/service/hid/ring_lifo.h +++ b/src/core/hle/service/hid/ring_lifo.h | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | 10 | ||
| 11 | namespace Service::HID { | 11 | namespace Service::HID { |
| 12 | constexpr std::size_t max_buffer_size = 17; | ||
| 13 | 12 | ||
| 14 | template <typename State> | 13 | template <typename State> |
| 15 | struct AtomicStorage { | 14 | struct AtomicStorage { |
| @@ -17,7 +16,7 @@ struct AtomicStorage { | |||
| 17 | State state; | 16 | State state; |
| 18 | }; | 17 | }; |
| 19 | 18 | ||
| 20 | template <typename State> | 19 | template <typename State, std::size_t max_buffer_size> |
| 21 | struct Lifo { | 20 | struct Lifo { |
| 22 | s64 timestamp{}; | 21 | s64 timestamp{}; |
| 23 | s64 total_buffer_count = static_cast<s64>(max_buffer_size); | 22 | s64 total_buffer_count = static_cast<s64>(max_buffer_size); |