diff options
23 files changed, 117 insertions, 136 deletions
diff --git a/src/core/core.h b/src/core/core.h index 5a031efb0..645e5c241 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -289,7 +289,7 @@ public: | |||
| 289 | /// Provides a constant reference to the kernel instance. | 289 | /// Provides a constant reference to the kernel instance. |
| 290 | [[nodiscard]] const Kernel::KernelCore& Kernel() const; | 290 | [[nodiscard]] const Kernel::KernelCore& Kernel() const; |
| 291 | 291 | ||
| 292 | /// Gets a mutable reference to the HID interface | 292 | /// Gets a mutable reference to the HID interface. |
| 293 | [[nodiscard]] HID::HIDCore& HIDCore(); | 293 | [[nodiscard]] HID::HIDCore& HIDCore(); |
| 294 | 294 | ||
| 295 | /// Gets an immutable reference to the HID interface. | 295 | /// Gets an immutable reference to the HID interface. |
diff --git a/src/core/frontend/applets/controller.cpp b/src/core/frontend/applets/controller.cpp index 30500ef1e..212ace892 100644 --- a/src/core/frontend/applets/controller.cpp +++ b/src/core/frontend/applets/controller.cpp | |||
| @@ -13,8 +13,7 @@ namespace Core::Frontend { | |||
| 13 | 13 | ||
| 14 | ControllerApplet::~ControllerApplet() = default; | 14 | ControllerApplet::~ControllerApplet() = default; |
| 15 | 15 | ||
| 16 | DefaultControllerApplet::DefaultControllerApplet(HID::HIDCore& hid_core_) | 16 | DefaultControllerApplet::DefaultControllerApplet(HID::HIDCore& hid_core_) : hid_core{hid_core_} {} |
| 17 | : hid_core{hid_core_} {} | ||
| 18 | 17 | ||
| 19 | DefaultControllerApplet::~DefaultControllerApplet() = default; | 18 | DefaultControllerApplet::~DefaultControllerApplet() = default; |
| 20 | 19 | ||
| @@ -26,7 +25,7 @@ void DefaultControllerApplet::ReconfigureControllers(std::function<void()> callb | |||
| 26 | parameters.enable_single_mode ? 1 : parameters.min_players; | 25 | parameters.enable_single_mode ? 1 : parameters.min_players; |
| 27 | 26 | ||
| 28 | // Disconnect Handheld first. | 27 | // Disconnect Handheld first. |
| 29 | auto* handheld =hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld); | 28 | auto* handheld = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld); |
| 30 | handheld->Disconnect(); | 29 | handheld->Disconnect(); |
| 31 | 30 | ||
| 32 | // Deduce the best configuration based on the input parameters. | 31 | // Deduce the best configuration based on the input parameters. |
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp index 540fd107b..d1d4a5355 100644 --- a/src/core/hid/emulated_console.cpp +++ b/src/core/hid/emulated_console.cpp | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | #include "core/hid/input_converter.h" | 6 | #include "core/hid/input_converter.h" |
| 7 | 7 | ||
| 8 | namespace Core::HID { | 8 | namespace Core::HID { |
| 9 | EmulatedConsole::EmulatedConsole() {} | 9 | EmulatedConsole::EmulatedConsole() = default; |
| 10 | 10 | ||
| 11 | EmulatedConsole::~EmulatedConsole() = default; | 11 | EmulatedConsole::~EmulatedConsole() = default; |
| 12 | 12 | ||
| @@ -191,7 +191,7 @@ TouchFingerState EmulatedConsole::GetTouch() const { | |||
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | void EmulatedConsole::TriggerOnChange(ConsoleTriggerType type) { | 193 | void EmulatedConsole::TriggerOnChange(ConsoleTriggerType type) { |
| 194 | for (const std::pair<int, ConsoleUpdateCallback> poller_pair : callback_list) { | 194 | for (const auto& poller_pair : callback_list) { |
| 195 | const ConsoleUpdateCallback& poller = poller_pair.second; | 195 | const ConsoleUpdateCallback& poller = poller_pair.second; |
| 196 | if (poller.on_change) { | 196 | if (poller.on_change) { |
| 197 | poller.on_change(type); | 197 | poller.on_change(type); |
diff --git a/src/core/hid/emulated_console.h b/src/core/hid/emulated_console.h index c48d25794..f26f24f2e 100644 --- a/src/core/hid/emulated_console.h +++ b/src/core/hid/emulated_console.h | |||
| @@ -20,7 +20,7 @@ | |||
| 20 | namespace Core::HID { | 20 | namespace Core::HID { |
| 21 | 21 | ||
| 22 | struct ConsoleMotionInfo { | 22 | struct ConsoleMotionInfo { |
| 23 | Input::MotionStatus raw_status; | 23 | Input::MotionStatus raw_status{}; |
| 24 | MotionInput emulated{}; | 24 | MotionInput emulated{}; |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| @@ -34,21 +34,21 @@ using ConsoleMotionValues = ConsoleMotionInfo; | |||
| 34 | using TouchValues = std::array<Input::TouchStatus, 16>; | 34 | using TouchValues = std::array<Input::TouchStatus, 16>; |
| 35 | 35 | ||
| 36 | struct TouchFinger { | 36 | struct TouchFinger { |
| 37 | u64_le last_touch{}; | 37 | u64 last_touch{}; |
| 38 | Common::Point<float> position{}; | 38 | Common::Point<float> position{}; |
| 39 | u32_le id{}; | 39 | u32 id{}; |
| 40 | bool pressed{}; | ||
| 41 | TouchAttribute attribute{}; | 40 | TouchAttribute attribute{}; |
| 41 | bool pressed{}; | ||
| 42 | }; | 42 | }; |
| 43 | 43 | ||
| 44 | // Contains all motion related data that is used on the services | 44 | // Contains all motion related data that is used on the services |
| 45 | struct ConsoleMotion { | 45 | struct ConsoleMotion { |
| 46 | bool is_at_rest{}; | ||
| 47 | Common::Vec3f accel{}; | 46 | Common::Vec3f accel{}; |
| 48 | Common::Vec3f gyro{}; | 47 | Common::Vec3f gyro{}; |
| 49 | Common::Vec3f rotation{}; | 48 | Common::Vec3f rotation{}; |
| 50 | std::array<Common::Vec3f, 3> orientation{}; | 49 | std::array<Common::Vec3f, 3> orientation{}; |
| 51 | Common::Quaternion<f32> quaternion{}; | 50 | Common::Quaternion<f32> quaternion{}; |
| 51 | bool is_at_rest{}; | ||
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | using TouchFingerState = std::array<TouchFinger, 16>; | 54 | using TouchFingerState = std::array<TouchFinger, 16>; |
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index d59758e99..228f80183 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -865,10 +865,10 @@ BatteryLevelState EmulatedController::GetBattery() const { | |||
| 865 | return controller.battery_state; | 865 | return controller.battery_state; |
| 866 | } | 866 | } |
| 867 | 867 | ||
| 868 | void EmulatedController::TriggerOnChange(ControllerTriggerType type, bool is_service_update) { | 868 | void EmulatedController::TriggerOnChange(ControllerTriggerType type, bool is_npad_service_update) { |
| 869 | for (const std::pair<int, ControllerUpdateCallback> poller_pair : callback_list) { | 869 | for (const auto& poller_pair : callback_list) { |
| 870 | const ControllerUpdateCallback& poller = poller_pair.second; | 870 | const ControllerUpdateCallback& poller = poller_pair.second; |
| 871 | if (!is_service_update && poller.is_service) { | 871 | if (!is_npad_service_update && poller.is_npad_service) { |
| 872 | continue; | 872 | continue; |
| 873 | } | 873 | } |
| 874 | if (poller.on_change) { | 874 | if (poller.on_change) { |
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index 50f21ccd9..d66768549 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -20,7 +20,7 @@ | |||
| 20 | namespace Core::HID { | 20 | namespace Core::HID { |
| 21 | 21 | ||
| 22 | struct ControllerMotionInfo { | 22 | struct ControllerMotionInfo { |
| 23 | Input::MotionStatus raw_status; | 23 | Input::MotionStatus raw_status{}; |
| 24 | MotionInput emulated{}; | 24 | MotionInput emulated{}; |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| @@ -51,28 +51,28 @@ using BatteryValues = std::array<Input::BatteryStatus, 3>; | |||
| 51 | using VibrationValues = std::array<Input::VibrationStatus, 2>; | 51 | using VibrationValues = std::array<Input::VibrationStatus, 2>; |
| 52 | 52 | ||
| 53 | struct AnalogSticks { | 53 | struct AnalogSticks { |
| 54 | AnalogStickState left; | 54 | AnalogStickState left{}; |
| 55 | AnalogStickState right; | 55 | AnalogStickState right{}; |
| 56 | }; | 56 | }; |
| 57 | 57 | ||
| 58 | struct ControllerColors { | 58 | struct ControllerColors { |
| 59 | NpadControllerColor fullkey; | 59 | NpadControllerColor fullkey{}; |
| 60 | NpadControllerColor left; | 60 | NpadControllerColor left{}; |
| 61 | NpadControllerColor right; | 61 | NpadControllerColor right{}; |
| 62 | }; | 62 | }; |
| 63 | 63 | ||
| 64 | struct BatteryLevelState { | 64 | struct BatteryLevelState { |
| 65 | NpadPowerInfo dual; | 65 | NpadPowerInfo dual{}; |
| 66 | NpadPowerInfo left; | 66 | NpadPowerInfo left{}; |
| 67 | NpadPowerInfo right; | 67 | NpadPowerInfo right{}; |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | struct ControllerMotion { | 70 | struct ControllerMotion { |
| 71 | bool is_at_rest; | ||
| 72 | Common::Vec3f accel{}; | 71 | Common::Vec3f accel{}; |
| 73 | Common::Vec3f gyro{}; | 72 | Common::Vec3f gyro{}; |
| 74 | Common::Vec3f rotation{}; | 73 | Common::Vec3f rotation{}; |
| 75 | std::array<Common::Vec3f, 3> orientation{}; | 74 | std::array<Common::Vec3f, 3> orientation{}; |
| 75 | bool is_at_rest{}; | ||
| 76 | }; | 76 | }; |
| 77 | 77 | ||
| 78 | using MotionState = std::array<ControllerMotion, 2>; | 78 | using MotionState = std::array<ControllerMotion, 2>; |
| @@ -113,7 +113,7 @@ enum class ControllerTriggerType { | |||
| 113 | 113 | ||
| 114 | struct ControllerUpdateCallback { | 114 | struct ControllerUpdateCallback { |
| 115 | std::function<void(ControllerTriggerType)> on_change; | 115 | std::function<void(ControllerTriggerType)> on_change; |
| 116 | bool is_service; | 116 | bool is_npad_service; |
| 117 | }; | 117 | }; |
| 118 | 118 | ||
| 119 | class EmulatedController { | 119 | class EmulatedController { |
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp index 54a753d8a..1c4065cd8 100644 --- a/src/core/hid/emulated_devices.cpp +++ b/src/core/hid/emulated_devices.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | 9 | ||
| 10 | namespace Core::HID { | 10 | namespace Core::HID { |
| 11 | 11 | ||
| 12 | EmulatedDevices::EmulatedDevices() {} | 12 | EmulatedDevices::EmulatedDevices() = default; |
| 13 | 13 | ||
| 14 | EmulatedDevices::~EmulatedDevices() = default; | 14 | EmulatedDevices::~EmulatedDevices() = default; |
| 15 | 15 | ||
| @@ -332,7 +332,7 @@ MousePosition EmulatedDevices::GetMousePosition() const { | |||
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) { | 334 | void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) { |
| 335 | for (const std::pair<int, InterfaceUpdateCallback> poller_pair : callback_list) { | 335 | for (const auto& poller_pair : callback_list) { |
| 336 | const InterfaceUpdateCallback& poller = poller_pair.second; | 336 | const InterfaceUpdateCallback& poller = poller_pair.second; |
| 337 | if (poller.on_change) { | 337 | if (poller.on_change) { |
| 338 | poller.on_change(type); | 338 | poller.on_change(type); |
diff --git a/src/core/hid/hid_core.cpp b/src/core/hid/hid_core.cpp index cc1b3c295..3cb26e1e7 100644 --- a/src/core/hid/hid_core.cpp +++ b/src/core/hid/hid_core.cpp | |||
| @@ -113,8 +113,8 @@ NpadStyleTag HIDCore::GetSupportedStyleTag() const { | |||
| 113 | 113 | ||
| 114 | s8 HIDCore::GetPlayerCount() const { | 114 | s8 HIDCore::GetPlayerCount() const { |
| 115 | s8 active_players = 0; | 115 | s8 active_players = 0; |
| 116 | for (std::size_t player_index = 0; player_index < available_controllers -2; player_index++) { | 116 | for (std::size_t player_index = 0; player_index < available_controllers - 2; ++player_index) { |
| 117 | const auto* controller = GetEmulatedControllerByIndex(player_index); | 117 | const auto* const controller = GetEmulatedControllerByIndex(player_index); |
| 118 | if (controller->IsConnected()) { | 118 | if (controller->IsConnected()) { |
| 119 | active_players++; | 119 | active_players++; |
| 120 | } | 120 | } |
| @@ -123,8 +123,8 @@ s8 HIDCore::GetPlayerCount() const { | |||
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | NpadIdType HIDCore::GetFirstNpadId() const { | 125 | NpadIdType HIDCore::GetFirstNpadId() const { |
| 126 | for (std::size_t player_index = 0; player_index < available_controllers; player_index++) { | 126 | for (std::size_t player_index = 0; player_index < available_controllers; ++player_index) { |
| 127 | const auto* controller = GetEmulatedControllerByIndex(player_index); | 127 | const auto* const controller = GetEmulatedControllerByIndex(player_index); |
| 128 | if (controller->IsConnected()) { | 128 | if (controller->IsConnected()) { |
| 129 | return controller->GetNpadIdType(); | 129 | return controller->GetNpadIdType(); |
| 130 | } | 130 | } |
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h index 539436283..59ec593b8 100644 --- a/src/core/hid/hid_types.h +++ b/src/core/hid/hid_types.h | |||
| @@ -100,7 +100,7 @@ enum class NpadType : u8 { | |||
| 100 | // This is nn::hid::NpadStyleTag | 100 | // This is nn::hid::NpadStyleTag |
| 101 | struct NpadStyleTag { | 101 | struct NpadStyleTag { |
| 102 | union { | 102 | union { |
| 103 | u32_le raw{}; | 103 | u32 raw{}; |
| 104 | 104 | ||
| 105 | BitField<0, 1, u32> fullkey; | 105 | BitField<0, 1, u32> fullkey; |
| 106 | BitField<1, 1, u32> handheld; | 106 | BitField<1, 1, u32> handheld; |
| @@ -132,35 +132,35 @@ static_assert(sizeof(TouchAttribute) == 0x4, "TouchAttribute is an invalid size" | |||
| 132 | 132 | ||
| 133 | // This is nn::hid::TouchState | 133 | // This is nn::hid::TouchState |
| 134 | struct TouchState { | 134 | struct TouchState { |
| 135 | u64_le delta_time; | 135 | u64 delta_time; |
| 136 | TouchAttribute attribute; | 136 | TouchAttribute attribute; |
| 137 | u32_le finger; | 137 | u32 finger; |
| 138 | Common::Point<u32_le> position; | 138 | Common::Point<u32> position; |
| 139 | u32_le diameter_x; | 139 | u32 diameter_x; |
| 140 | u32_le diameter_y; | 140 | u32 diameter_y; |
| 141 | u32_le rotation_angle; | 141 | u32 rotation_angle; |
| 142 | }; | 142 | }; |
| 143 | static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size"); | 143 | static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size"); |
| 144 | 144 | ||
| 145 | // This is nn::hid::NpadControllerColor | 145 | // This is nn::hid::NpadControllerColor |
| 146 | struct NpadControllerColor { | 146 | struct NpadControllerColor { |
| 147 | u32_le body; | 147 | u32 body; |
| 148 | u32_le button; | 148 | u32 button; |
| 149 | }; | 149 | }; |
| 150 | static_assert(sizeof(NpadControllerColor) == 8, "NpadControllerColor is an invalid size"); | 150 | static_assert(sizeof(NpadControllerColor) == 8, "NpadControllerColor is an invalid size"); |
| 151 | 151 | ||
| 152 | // This is nn::hid::AnalogStickState | 152 | // This is nn::hid::AnalogStickState |
| 153 | struct AnalogStickState { | 153 | struct AnalogStickState { |
| 154 | s32_le x; | 154 | s32 x; |
| 155 | s32_le y; | 155 | s32 y; |
| 156 | }; | 156 | }; |
| 157 | static_assert(sizeof(AnalogStickState) == 8, "AnalogStickState is an invalid size"); | 157 | static_assert(sizeof(AnalogStickState) == 8, "AnalogStickState is an invalid size"); |
| 158 | 158 | ||
| 159 | // This is nn::hid::server::NpadGcTriggerState | 159 | // This is nn::hid::server::NpadGcTriggerState |
| 160 | struct NpadGcTriggerState { | 160 | struct NpadGcTriggerState { |
| 161 | s64_le sampling_number{}; | 161 | s64 sampling_number{}; |
| 162 | s32_le left{}; | 162 | s32 left{}; |
| 163 | s32_le right{}; | 163 | s32 right{}; |
| 164 | }; | 164 | }; |
| 165 | static_assert(sizeof(NpadGcTriggerState) == 0x10, "NpadGcTriggerState is an invalid size"); | 165 | static_assert(sizeof(NpadGcTriggerState) == 0x10, "NpadGcTriggerState is an invalid size"); |
| 166 | 166 | ||
| @@ -286,7 +286,7 @@ static_assert(sizeof(NpadButtonState) == 0x8, "NpadButtonState has incorrect siz | |||
| 286 | // This is nn::hid::DebugPadButton | 286 | // This is nn::hid::DebugPadButton |
| 287 | struct DebugPadButton { | 287 | struct DebugPadButton { |
| 288 | union { | 288 | union { |
| 289 | u32_le raw{}; | 289 | u32 raw{}; |
| 290 | BitField<0, 1, u32> a; | 290 | BitField<0, 1, u32> a; |
| 291 | BitField<1, 1, u32> b; | 291 | BitField<1, 1, u32> b; |
| 292 | BitField<2, 1, u32> x; | 292 | BitField<2, 1, u32> x; |
| @@ -345,7 +345,7 @@ static_assert(sizeof(VibrationDeviceInfo) == 0x8, "VibrationDeviceInfo has incor | |||
| 345 | // This is nn::hid::KeyboardModifier | 345 | // This is nn::hid::KeyboardModifier |
| 346 | struct KeyboardModifier { | 346 | struct KeyboardModifier { |
| 347 | union { | 347 | union { |
| 348 | u32_le raw{}; | 348 | u32 raw{}; |
| 349 | BitField<0, 1, u32> control; | 349 | BitField<0, 1, u32> control; |
| 350 | BitField<1, 1, u32> shift; | 350 | BitField<1, 1, u32> shift; |
| 351 | BitField<2, 1, u32> left_alt; | 351 | BitField<2, 1, u32> left_alt; |
| @@ -383,7 +383,7 @@ static_assert(sizeof(MouseButton) == 0x4, "MouseButton is an invalid size"); | |||
| 383 | // This is nn::hid::MouseAttribute | 383 | // This is nn::hid::MouseAttribute |
| 384 | struct MouseAttribute { | 384 | struct MouseAttribute { |
| 385 | union { | 385 | union { |
| 386 | u32_le raw{}; | 386 | u32 raw{}; |
| 387 | BitField<0, 1, u32> transferable; | 387 | BitField<0, 1, u32> transferable; |
| 388 | BitField<1, 1, u32> is_connected; | 388 | BitField<1, 1, u32> is_connected; |
| 389 | }; | 389 | }; |
| @@ -392,13 +392,13 @@ static_assert(sizeof(MouseAttribute) == 0x4, "MouseAttribute is an invalid size" | |||
| 392 | 392 | ||
| 393 | // This is nn::hid::detail::MouseState | 393 | // This is nn::hid::detail::MouseState |
| 394 | struct MouseState { | 394 | struct MouseState { |
| 395 | s64_le sampling_number; | 395 | s64 sampling_number; |
| 396 | s32_le x; | 396 | s32 x; |
| 397 | s32_le y; | 397 | s32 y; |
| 398 | s32_le delta_x; | 398 | s32 delta_x; |
| 399 | s32_le delta_y; | 399 | s32 delta_y; |
| 400 | s32_le delta_wheel_x; | 400 | s32 delta_wheel_x; |
| 401 | s32_le delta_wheel_y; | 401 | s32 delta_wheel_y; |
| 402 | MouseButton button; | 402 | MouseButton button; |
| 403 | MouseAttribute attribute; | 403 | MouseAttribute attribute; |
| 404 | }; | 404 | }; |
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp index 128a48ec9..b3c8913ce 100644 --- a/src/core/hid/input_converter.cpp +++ b/src/core/hid/input_converter.cpp | |||
| @@ -142,8 +142,8 @@ Input::StickStatus TransformToStick(const Input::CallbackStatus& callback) { | |||
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | SanitizeStick(status.x, status.y, true); | 144 | SanitizeStick(status.x, status.y, true); |
| 145 | const Input::AnalogProperties& properties_x = status.x.properties; | 145 | const auto& properties_x = status.x.properties; |
| 146 | const Input::AnalogProperties& properties_y = status.y.properties; | 146 | const auto& properties_y = status.y.properties; |
| 147 | const float x = status.x.value; | 147 | const float x = status.x.value; |
| 148 | const float y = status.y.value; | 148 | const float y = status.y.value; |
| 149 | 149 | ||
| @@ -213,7 +213,7 @@ Input::TriggerStatus TransformToTrigger(const Input::CallbackStatus& callback) { | |||
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | SanitizeAnalog(status.analog, true); | 215 | SanitizeAnalog(status.analog, true); |
| 216 | const Input::AnalogProperties& properties = status.analog.properties; | 216 | const auto& properties = status.analog.properties; |
| 217 | float& value = status.analog.value; | 217 | float& value = status.analog.value; |
| 218 | 218 | ||
| 219 | // Set button status | 219 | // Set button status |
| @@ -231,7 +231,7 @@ Input::TriggerStatus TransformToTrigger(const Input::CallbackStatus& callback) { | |||
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | void SanitizeAnalog(Input::AnalogStatus& analog, bool clamp_value) { | 233 | void SanitizeAnalog(Input::AnalogStatus& analog, bool clamp_value) { |
| 234 | const Input::AnalogProperties& properties = analog.properties; | 234 | const auto& properties = analog.properties; |
| 235 | float& raw_value = analog.raw_value; | 235 | float& raw_value = analog.raw_value; |
| 236 | float& value = analog.value; | 236 | float& value = analog.value; |
| 237 | 237 | ||
| @@ -271,8 +271,8 @@ void SanitizeAnalog(Input::AnalogStatus& analog, bool clamp_value) { | |||
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | void SanitizeStick(Input::AnalogStatus& analog_x, Input::AnalogStatus& analog_y, bool clamp_value) { | 273 | void SanitizeStick(Input::AnalogStatus& analog_x, Input::AnalogStatus& analog_y, bool clamp_value) { |
| 274 | const Input::AnalogProperties& properties_x = analog_x.properties; | 274 | const auto& properties_x = analog_x.properties; |
| 275 | const Input::AnalogProperties& properties_y = analog_y.properties; | 275 | const auto& properties_y = analog_y.properties; |
| 276 | float& raw_x = analog_x.raw_value; | 276 | float& raw_x = analog_x.raw_value; |
| 277 | float& raw_y = analog_y.raw_value; | 277 | float& raw_y = analog_y.raw_value; |
| 278 | float& x = analog_x.value; | 278 | float& x = analog_x.value; |
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.h b/src/core/hle/service/hid/controllers/console_sixaxis.h index 6d18d2ce0..95729e6b2 100644 --- a/src/core/hle/service/hid/controllers/console_sixaxis.h +++ b/src/core/hle/service/hid/controllers/console_sixaxis.h | |||
| @@ -35,8 +35,8 @@ public: | |||
| 35 | private: | 35 | private: |
| 36 | struct SevenSixAxisState { | 36 | struct SevenSixAxisState { |
| 37 | INSERT_PADDING_WORDS(4); // unused | 37 | INSERT_PADDING_WORDS(4); // unused |
| 38 | s64_le sampling_number{}; | 38 | s64 sampling_number{}; |
| 39 | s64_le sampling_number2{}; | 39 | s64 sampling_number2{}; |
| 40 | u64 unknown{}; | 40 | u64 unknown{}; |
| 41 | Common::Vec3f accel{}; | 41 | Common::Vec3f accel{}; |
| 42 | Common::Vec3f gyro{}; | 42 | Common::Vec3f gyro{}; |
| @@ -45,10 +45,10 @@ private: | |||
| 45 | static_assert(sizeof(SevenSixAxisState) == 0x50, "SevenSixAxisState is an invalid size"); | 45 | static_assert(sizeof(SevenSixAxisState) == 0x50, "SevenSixAxisState is an invalid size"); |
| 46 | 46 | ||
| 47 | struct CommonHeader { | 47 | struct CommonHeader { |
| 48 | s64_le timestamp; | 48 | s64 timestamp; |
| 49 | s64_le total_entry_count; | 49 | s64 total_entry_count; |
| 50 | s64_le last_entry_index; | 50 | s64 last_entry_index; |
| 51 | s64_le entry_count; | 51 | s64 entry_count; |
| 52 | }; | 52 | }; |
| 53 | static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size"); | 53 | static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size"); |
| 54 | 54 | ||
| @@ -61,7 +61,7 @@ private: | |||
| 61 | 61 | ||
| 62 | // This is nn::hid::detail::ConsoleSixAxisSensorSharedMemoryFormat | 62 | // This is nn::hid::detail::ConsoleSixAxisSensorSharedMemoryFormat |
| 63 | struct ConsoleSharedMemory { | 63 | struct ConsoleSharedMemory { |
| 64 | u64_le sampling_number{}; | 64 | u64 sampling_number{}; |
| 65 | bool is_seven_six_axis_sensor_at_rest{}; | 65 | bool is_seven_six_axis_sensor_at_rest{}; |
| 66 | f32 verticalization_error{}; | 66 | f32 verticalization_error{}; |
| 67 | Common::Vec3f gyro_bias{}; | 67 | Common::Vec3f gyro_bias{}; |
diff --git a/src/core/hle/service/hid/controllers/debug_pad.h b/src/core/hle/service/hid/controllers/debug_pad.h index 11b6c669b..bd0f15eaa 100644 --- a/src/core/hle/service/hid/controllers/debug_pad.h +++ b/src/core/hle/service/hid/controllers/debug_pad.h | |||
| @@ -38,7 +38,7 @@ private: | |||
| 38 | // This is nn::hid::DebugPadAttribute | 38 | // This is nn::hid::DebugPadAttribute |
| 39 | struct DebugPadAttribute { | 39 | struct DebugPadAttribute { |
| 40 | union { | 40 | union { |
| 41 | u32_le raw{}; | 41 | u32 raw{}; |
| 42 | BitField<0, 1, u32> connected; | 42 | BitField<0, 1, u32> connected; |
| 43 | }; | 43 | }; |
| 44 | }; | 44 | }; |
| @@ -46,7 +46,7 @@ private: | |||
| 46 | 46 | ||
| 47 | // This is nn::hid::DebugPadState | 47 | // This is nn::hid::DebugPadState |
| 48 | struct DebugPadState { | 48 | struct DebugPadState { |
| 49 | s64_le sampling_number; | 49 | s64 sampling_number; |
| 50 | DebugPadAttribute attribute; | 50 | DebugPadAttribute attribute; |
| 51 | Core::HID::DebugPadButton pad_state; | 51 | Core::HID::DebugPadButton pad_state; |
| 52 | Core::HID::AnalogStickState r_stick; | 52 | Core::HID::AnalogStickState r_stick; |
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index a82d04b3b..7a7bc68a2 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp | |||
| @@ -65,10 +65,7 @@ void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u | |||
| 65 | void Controller_Gesture::ReadTouchInput() { | 65 | void Controller_Gesture::ReadTouchInput() { |
| 66 | const auto touch_status = console->GetTouch(); | 66 | const auto touch_status = console->GetTouch(); |
| 67 | for (std::size_t id = 0; id < fingers.size(); ++id) { | 67 | for (std::size_t id = 0; id < fingers.size(); ++id) { |
| 68 | const Core::HID::TouchFinger& status = touch_status[id]; | 68 | fingers[id] = touch_status[id]; |
| 69 | Finger& finger = fingers[id]; | ||
| 70 | finger.pos = status.position; | ||
| 71 | finger.pressed = status.pressed; | ||
| 72 | } | 69 | } |
| 73 | } | 70 | } |
| 74 | 71 | ||
| @@ -315,14 +312,14 @@ const Controller_Gesture::GestureState& Controller_Gesture::GetLastGestureEntry( | |||
| 315 | 312 | ||
| 316 | Controller_Gesture::GestureProperties Controller_Gesture::GetGestureProperties() { | 313 | Controller_Gesture::GestureProperties Controller_Gesture::GetGestureProperties() { |
| 317 | GestureProperties gesture; | 314 | GestureProperties gesture; |
| 318 | std::array<Finger, MAX_POINTS> active_fingers; | 315 | std::array<Core::HID::TouchFinger, MAX_POINTS> active_fingers; |
| 319 | const auto end_iter = std::copy_if(fingers.begin(), fingers.end(), active_fingers.begin(), | 316 | const auto end_iter = std::copy_if(fingers.begin(), fingers.end(), active_fingers.begin(), |
| 320 | [](const auto& finger) { return finger.pressed; }); | 317 | [](const auto& finger) { return finger.pressed; }); |
| 321 | gesture.active_points = | 318 | gesture.active_points = |
| 322 | static_cast<std::size_t>(std::distance(active_fingers.begin(), end_iter)); | 319 | static_cast<std::size_t>(std::distance(active_fingers.begin(), end_iter)); |
| 323 | 320 | ||
| 324 | for (size_t id = 0; id < gesture.active_points; ++id) { | 321 | for (size_t id = 0; id < gesture.active_points; ++id) { |
| 325 | const auto& [active_x, active_y] = active_fingers[id].pos; | 322 | const auto& [active_x, active_y] = active_fingers[id].position; |
| 326 | gesture.points[id] = { | 323 | gesture.points[id] = { |
| 327 | .x = static_cast<s32>(active_x * Layout::ScreenUndocked::Width), | 324 | .x = static_cast<s32>(active_x * Layout::ScreenUndocked::Width), |
| 328 | .y = static_cast<s32>(active_y * Layout::ScreenUndocked::Height), | 325 | .y = static_cast<s32>(active_y * Layout::ScreenUndocked::Height), |
diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h index 6f5abaa4f..58139a5cf 100644 --- a/src/core/hle/service/hid/controllers/gesture.h +++ b/src/core/hle/service/hid/controllers/gesture.h | |||
| @@ -60,7 +60,7 @@ private: | |||
| 60 | // This is nn::hid::GestureAttribute | 60 | // This is nn::hid::GestureAttribute |
| 61 | struct GestureAttribute { | 61 | struct GestureAttribute { |
| 62 | union { | 62 | union { |
| 63 | u32_le raw{}; | 63 | u32 raw{}; |
| 64 | 64 | ||
| 65 | BitField<4, 1, u32> is_new_touch; | 65 | BitField<4, 1, u32> is_new_touch; |
| 66 | BitField<8, 1, u32> is_double_tap; | 66 | BitField<8, 1, u32> is_double_tap; |
| @@ -70,33 +70,28 @@ private: | |||
| 70 | 70 | ||
| 71 | // This is nn::hid::GestureState | 71 | // This is nn::hid::GestureState |
| 72 | struct GestureState { | 72 | struct GestureState { |
| 73 | s64_le sampling_number; | 73 | s64 sampling_number; |
| 74 | s64_le detection_count; | 74 | s64 detection_count; |
| 75 | GestureType type; | 75 | GestureType type; |
| 76 | GestureDirection direction; | 76 | GestureDirection direction; |
| 77 | Common::Point<s32_le> pos; | 77 | Common::Point<s32> pos; |
| 78 | Common::Point<s32_le> delta; | 78 | Common::Point<s32> delta; |
| 79 | f32 vel_x; | 79 | f32 vel_x; |
| 80 | f32 vel_y; | 80 | f32 vel_y; |
| 81 | GestureAttribute attributes; | 81 | GestureAttribute attributes; |
| 82 | f32 scale; | 82 | f32 scale; |
| 83 | f32 rotation_angle; | 83 | f32 rotation_angle; |
| 84 | s32_le point_count; | 84 | s32 point_count; |
| 85 | std::array<Common::Point<s32_le>, 4> points; | 85 | std::array<Common::Point<s32>, 4> points; |
| 86 | }; | 86 | }; |
| 87 | static_assert(sizeof(GestureState) == 0x60, "GestureState is an invalid size"); | 87 | static_assert(sizeof(GestureState) == 0x60, "GestureState is an invalid size"); |
| 88 | 88 | ||
| 89 | struct Finger { | ||
| 90 | Common::Point<f32> pos{}; | ||
| 91 | bool pressed{}; | ||
| 92 | }; | ||
| 93 | |||
| 94 | struct GestureProperties { | 89 | struct GestureProperties { |
| 95 | std::array<Common::Point<s32_le>, MAX_POINTS> points{}; | 90 | std::array<Common::Point<s32>, MAX_POINTS> points{}; |
| 96 | std::size_t active_points{}; | 91 | std::size_t active_points{}; |
| 97 | Common::Point<s32_le> mid_point{}; | 92 | Common::Point<s32> mid_point{}; |
| 98 | s64_le detection_count{}; | 93 | s64 detection_count{}; |
| 99 | u64_le delta_time{}; | 94 | u64 delta_time{}; |
| 100 | f32 average_distance{}; | 95 | f32 average_distance{}; |
| 101 | f32 angle{}; | 96 | f32 angle{}; |
| 102 | }; | 97 | }; |
| @@ -150,10 +145,10 @@ private: | |||
| 150 | 145 | ||
| 151 | Core::HID::EmulatedConsole* console; | 146 | Core::HID::EmulatedConsole* console; |
| 152 | 147 | ||
| 153 | std::array<Finger, MAX_POINTS> fingers{}; | 148 | std::array<Core::HID::TouchFinger, MAX_POINTS> fingers{}; |
| 154 | GestureProperties last_gesture{}; | 149 | GestureProperties last_gesture{}; |
| 155 | s64_le last_update_timestamp{}; | 150 | s64 last_update_timestamp{}; |
| 156 | s64_le last_tap_timestamp{}; | 151 | s64 last_tap_timestamp{}; |
| 157 | f32 last_pan_time_difference{}; | 152 | f32 last_pan_time_difference{}; |
| 158 | bool force_update{false}; | 153 | bool force_update{false}; |
| 159 | bool enable_press_and_tap{false}; | 154 | bool enable_press_and_tap{false}; |
diff --git a/src/core/hle/service/hid/controllers/keyboard.h b/src/core/hle/service/hid/controllers/keyboard.h index 6919e092a..aba4f123e 100644 --- a/src/core/hle/service/hid/controllers/keyboard.h +++ b/src/core/hle/service/hid/controllers/keyboard.h | |||
| @@ -37,7 +37,7 @@ public: | |||
| 37 | private: | 37 | private: |
| 38 | // This is nn::hid::detail::KeyboardState | 38 | // This is nn::hid::detail::KeyboardState |
| 39 | struct KeyboardState { | 39 | struct KeyboardState { |
| 40 | s64_le sampling_number; | 40 | s64 sampling_number; |
| 41 | Core::HID::KeyboardModifier modifier; | 41 | Core::HID::KeyboardModifier modifier; |
| 42 | Core::HID::KeyboardKey key; | 42 | Core::HID::KeyboardKey key; |
| 43 | }; | 43 | }; |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index aad298364..7bf31f63a 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -106,7 +106,7 @@ Controller_NPad::Controller_NPad(Core::System& system_, | |||
| 106 | Core::HID::ControllerUpdateCallback engine_callback{ | 106 | Core::HID::ControllerUpdateCallback engine_callback{ |
| 107 | .on_change = [this, | 107 | .on_change = [this, |
| 108 | i](Core::HID::ControllerTriggerType type) { ControllerUpdate(type, i); }, | 108 | i](Core::HID::ControllerTriggerType type) { ControllerUpdate(type, i); }, |
| 109 | .is_service = true, | 109 | .is_npad_service = true, |
| 110 | }; | 110 | }; |
| 111 | controller.callback_key = controller.device->SetCallback(engine_callback); | 111 | controller.callback_key = controller.device->SetCallback(engine_callback); |
| 112 | } | 112 | } |
| @@ -157,7 +157,6 @@ void Controller_NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, | |||
| 157 | 157 | ||
| 158 | void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | 158 | void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { |
| 159 | auto& controller = controller_data[controller_idx]; | 159 | auto& controller = controller_data[controller_idx]; |
| 160 | LOG_WARNING(Service_HID, "Connect {} {}", controller_idx, controller.is_connected); | ||
| 161 | const auto controller_type = controller.device->GetNpadType(); | 160 | const auto controller_type = controller.device->GetNpadType(); |
| 162 | auto& shared_memory = controller.shared_memory_entry; | 161 | auto& shared_memory = controller.shared_memory_entry; |
| 163 | if (controller_type == Core::HID::NpadType::None) { | 162 | if (controller_type == Core::HID::NpadType::None) { |
| @@ -892,7 +891,6 @@ void Controller_NPad::DisconnectNpad(u32 npad_id) { | |||
| 892 | 891 | ||
| 893 | void Controller_NPad::DisconnectNpadAtIndex(std::size_t npad_index) { | 892 | void Controller_NPad::DisconnectNpadAtIndex(std::size_t npad_index) { |
| 894 | auto& controller = controller_data[npad_index]; | 893 | auto& controller = controller_data[npad_index]; |
| 895 | LOG_WARNING(Service_HID, "Disconnect {} {}", npad_index, controller.is_connected); | ||
| 896 | for (std::size_t device_idx = 0; device_idx < controller.vibration.size(); ++device_idx) { | 894 | for (std::size_t device_idx = 0; device_idx < controller.vibration.size(); ++device_idx) { |
| 897 | // Send an empty vibration to stop any vibrations. | 895 | // Send an empty vibration to stop any vibrations. |
| 898 | VibrateControllerAtIndex(npad_index, device_idx, {}); | 896 | VibrateControllerAtIndex(npad_index, device_idx, {}); |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 7c534a32f..0a2dc6992 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -195,7 +195,7 @@ public: | |||
| 195 | 195 | ||
| 196 | private: | 196 | private: |
| 197 | // This is nn::hid::detail::ColorAttribute | 197 | // This is nn::hid::detail::ColorAttribute |
| 198 | enum class ColorAttribute : u32_le { | 198 | enum class ColorAttribute : u32 { |
| 199 | Ok = 0, | 199 | Ok = 0, |
| 200 | ReadError = 1, | 200 | ReadError = 1, |
| 201 | NoController = 2, | 201 | NoController = 2, |
| @@ -220,7 +220,7 @@ private: | |||
| 220 | // This is nn::hid::NpadAttribute | 220 | // This is nn::hid::NpadAttribute |
| 221 | struct NpadAttribute { | 221 | struct NpadAttribute { |
| 222 | union { | 222 | union { |
| 223 | u32_le raw{}; | 223 | u32 raw{}; |
| 224 | BitField<0, 1, u32> is_connected; | 224 | BitField<0, 1, u32> is_connected; |
| 225 | BitField<1, 1, u32> is_wired; | 225 | BitField<1, 1, u32> is_wired; |
| 226 | BitField<2, 1, u32> is_left_connected; | 226 | BitField<2, 1, u32> is_left_connected; |
| @@ -251,7 +251,7 @@ private: | |||
| 251 | // This is nn::hid::SixAxisSensorAttribute | 251 | // This is nn::hid::SixAxisSensorAttribute |
| 252 | struct SixAxisSensorAttribute { | 252 | struct SixAxisSensorAttribute { |
| 253 | union { | 253 | union { |
| 254 | u32_le raw{}; | 254 | u32 raw{}; |
| 255 | BitField<0, 1, u32> is_connected; | 255 | BitField<0, 1, u32> is_connected; |
| 256 | BitField<1, 1, u32> is_interpolated; | 256 | BitField<1, 1, u32> is_interpolated; |
| 257 | }; | 257 | }; |
| @@ -260,8 +260,8 @@ private: | |||
| 260 | 260 | ||
| 261 | // This is nn::hid::SixAxisSensorState | 261 | // This is nn::hid::SixAxisSensorState |
| 262 | struct SixAxisSensorState { | 262 | struct SixAxisSensorState { |
| 263 | s64_le delta_time{}; | 263 | s64 delta_time{}; |
| 264 | s64_le sampling_number{}; | 264 | s64 sampling_number{}; |
| 265 | Common::Vec3f accel{}; | 265 | Common::Vec3f accel{}; |
| 266 | Common::Vec3f gyro{}; | 266 | Common::Vec3f gyro{}; |
| 267 | Common::Vec3f rotation{}; | 267 | Common::Vec3f rotation{}; |
| @@ -273,16 +273,16 @@ private: | |||
| 273 | 273 | ||
| 274 | // This is nn::hid::server::NpadGcTriggerState | 274 | // This is nn::hid::server::NpadGcTriggerState |
| 275 | struct NpadGcTriggerState { | 275 | struct NpadGcTriggerState { |
| 276 | s64_le sampling_number{}; | 276 | s64 sampling_number{}; |
| 277 | s32_le l_analog{}; | 277 | s32 l_analog{}; |
| 278 | s32_le r_analog{}; | 278 | s32 r_analog{}; |
| 279 | }; | 279 | }; |
| 280 | static_assert(sizeof(NpadGcTriggerState) == 0x10, "NpadGcTriggerState is an invalid size"); | 280 | static_assert(sizeof(NpadGcTriggerState) == 0x10, "NpadGcTriggerState is an invalid size"); |
| 281 | 281 | ||
| 282 | // This is nn::hid::NpadSystemProperties | 282 | // This is nn::hid::NpadSystemProperties |
| 283 | struct NPadSystemProperties { | 283 | struct NPadSystemProperties { |
| 284 | union { | 284 | union { |
| 285 | s64_le raw{}; | 285 | s64 raw{}; |
| 286 | BitField<0, 1, s64> is_charging_joy_dual; | 286 | BitField<0, 1, s64> is_charging_joy_dual; |
| 287 | BitField<1, 1, s64> is_charging_joy_left; | 287 | BitField<1, 1, s64> is_charging_joy_left; |
| 288 | BitField<2, 1, s64> is_charging_joy_right; | 288 | BitField<2, 1, s64> is_charging_joy_right; |
| @@ -303,7 +303,7 @@ private: | |||
| 303 | // This is nn::hid::NpadSystemButtonProperties | 303 | // This is nn::hid::NpadSystemButtonProperties |
| 304 | struct NpadSystemButtonProperties { | 304 | struct NpadSystemButtonProperties { |
| 305 | union { | 305 | union { |
| 306 | s32_le raw{}; | 306 | s32 raw{}; |
| 307 | BitField<0, 1, s32> is_home_button_protection_enabled; | 307 | BitField<0, 1, s32> is_home_button_protection_enabled; |
| 308 | }; | 308 | }; |
| 309 | }; | 309 | }; |
| @@ -313,7 +313,7 @@ private: | |||
| 313 | // This is nn::hid::system::DeviceType | 313 | // This is nn::hid::system::DeviceType |
| 314 | struct DeviceType { | 314 | struct DeviceType { |
| 315 | union { | 315 | union { |
| 316 | u32_le raw{}; | 316 | u32 raw{}; |
| 317 | BitField<0, 1, s32> fullkey; | 317 | BitField<0, 1, s32> fullkey; |
| 318 | BitField<1, 1, s32> debug_pad; | 318 | BitField<1, 1, s32> debug_pad; |
| 319 | BitField<2, 1, s32> handheld_left; | 319 | BitField<2, 1, s32> handheld_left; |
diff --git a/src/core/hle/service/hid/controllers/stubbed.h b/src/core/hle/service/hid/controllers/stubbed.h index 29f95a100..10aecad4c 100644 --- a/src/core/hle/service/hid/controllers/stubbed.h +++ b/src/core/hle/service/hid/controllers/stubbed.h | |||
| @@ -26,10 +26,10 @@ public: | |||
| 26 | 26 | ||
| 27 | private: | 27 | private: |
| 28 | struct CommonHeader { | 28 | struct CommonHeader { |
| 29 | s64_le timestamp; | 29 | s64 timestamp; |
| 30 | s64_le total_entry_count; | 30 | s64 total_entry_count; |
| 31 | s64_le last_entry_index; | 31 | s64 last_entry_index; |
| 32 | s64_le entry_count; | 32 | s64 entry_count; |
| 33 | }; | 33 | }; |
| 34 | static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size"); | 34 | static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size"); |
| 35 | 35 | ||
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index e0a44d06b..5ba8d96a8 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp | |||
| @@ -66,7 +66,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin | |||
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | std::array<Finger, MAX_FINGERS> active_fingers; | 69 | std::array<Core::HID::TouchFinger, MAX_FINGERS> active_fingers; |
| 70 | const auto end_iter = std::copy_if(fingers.begin(), fingers.end(), active_fingers.begin(), | 70 | const auto end_iter = std::copy_if(fingers.begin(), fingers.end(), active_fingers.begin(), |
| 71 | [](const auto& finger) { return finger.pressed; }); | 71 | [](const auto& finger) { return finger.pressed; }); |
| 72 | const auto active_fingers_count = | 72 | const auto active_fingers_count = |
| @@ -76,7 +76,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin | |||
| 76 | const auto& last_entry = touch_screen_lifo.ReadCurrentEntry().state; | 76 | const auto& last_entry = touch_screen_lifo.ReadCurrentEntry().state; |
| 77 | 77 | ||
| 78 | next_state.sampling_number = last_entry.sampling_number + 1; | 78 | next_state.sampling_number = last_entry.sampling_number + 1; |
| 79 | next_state.entry_count = static_cast<s32_le>(active_fingers_count); | 79 | next_state.entry_count = static_cast<s32>(active_fingers_count); |
| 80 | 80 | ||
| 81 | for (std::size_t id = 0; id < MAX_FINGERS; ++id) { | 81 | for (std::size_t id = 0; id < MAX_FINGERS; ++id) { |
| 82 | auto& touch_entry = next_state.states[id]; | 82 | auto& touch_entry = next_state.states[id]; |
diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index bcf79237d..fa4dfa1a2 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h | |||
| @@ -50,27 +50,19 @@ private: | |||
| 50 | 50 | ||
| 51 | // This is nn::hid::TouchScreenState | 51 | // This is nn::hid::TouchScreenState |
| 52 | struct TouchScreenState { | 52 | struct TouchScreenState { |
| 53 | s64_le sampling_number; | 53 | s64 sampling_number; |
| 54 | s32_le entry_count; | 54 | s32 entry_count; |
| 55 | INSERT_PADDING_BYTES(4); // Reserved | 55 | INSERT_PADDING_BYTES(4); // Reserved |
| 56 | std::array<Core::HID::TouchState, MAX_FINGERS> states; | 56 | std::array<Core::HID::TouchState, MAX_FINGERS> states; |
| 57 | }; | 57 | }; |
| 58 | static_assert(sizeof(TouchScreenState) == 0x290, "TouchScreenState is an invalid size"); | 58 | static_assert(sizeof(TouchScreenState) == 0x290, "TouchScreenState is an invalid size"); |
| 59 | 59 | ||
| 60 | struct Finger { | ||
| 61 | u64_le last_touch{}; | ||
| 62 | Common::Point<float> position; | ||
| 63 | u32_le id{}; | ||
| 64 | bool pressed{}; | ||
| 65 | Core::HID::TouchAttribute attribute; | ||
| 66 | }; | ||
| 67 | |||
| 68 | // This is nn::hid::detail::TouchScreenLifo | 60 | // This is nn::hid::detail::TouchScreenLifo |
| 69 | Lifo<TouchScreenState> touch_screen_lifo{}; | 61 | Lifo<TouchScreenState> touch_screen_lifo{}; |
| 70 | static_assert(sizeof(touch_screen_lifo) == 0x2C38, "touch_screen_lifo is an invalid size"); | 62 | static_assert(sizeof(touch_screen_lifo) == 0x2C38, "touch_screen_lifo is an invalid size"); |
| 71 | TouchScreenState next_state{}; | 63 | TouchScreenState next_state{}; |
| 72 | 64 | ||
| 73 | std::array<Finger, MAX_FINGERS> fingers; | 65 | std::array<Core::HID::TouchFinger, MAX_FINGERS> fingers; |
| 74 | Core::HID::EmulatedConsole* console; | 66 | Core::HID::EmulatedConsole* console; |
| 75 | }; | 67 | }; |
| 76 | } // namespace Service::HID | 68 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/xpad.h b/src/core/hle/service/hid/controllers/xpad.h index a5421f93b..75e0d2911 100644 --- a/src/core/hle/service/hid/controllers/xpad.h +++ b/src/core/hle/service/hid/controllers/xpad.h | |||
| @@ -31,7 +31,7 @@ private: | |||
| 31 | // This is nn::hid::BasicXpadAttributeSet | 31 | // This is nn::hid::BasicXpadAttributeSet |
| 32 | struct BasicXpadAttributeSet { | 32 | struct BasicXpadAttributeSet { |
| 33 | union { | 33 | union { |
| 34 | u32_le raw{}; | 34 | u32 raw{}; |
| 35 | BitField<0, 1, u32> is_connected; | 35 | BitField<0, 1, u32> is_connected; |
| 36 | BitField<1, 1, u32> is_wired; | 36 | BitField<1, 1, u32> is_wired; |
| 37 | BitField<2, 1, u32> is_left_connected; | 37 | BitField<2, 1, u32> is_left_connected; |
| @@ -45,7 +45,7 @@ private: | |||
| 45 | // This is nn::hid::BasicXpadButtonSet | 45 | // This is nn::hid::BasicXpadButtonSet |
| 46 | struct BasicXpadButtonSet { | 46 | struct BasicXpadButtonSet { |
| 47 | union { | 47 | union { |
| 48 | u32_le raw{}; | 48 | u32 raw{}; |
| 49 | // Button states | 49 | // Button states |
| 50 | BitField<0, 1, u32> a; | 50 | BitField<0, 1, u32> a; |
| 51 | BitField<1, 1, u32> b; | 51 | BitField<1, 1, u32> b; |
| @@ -93,7 +93,7 @@ private: | |||
| 93 | 93 | ||
| 94 | // This is nn::hid::detail::BasicXpadState | 94 | // This is nn::hid::detail::BasicXpadState |
| 95 | struct BasicXpadState { | 95 | struct BasicXpadState { |
| 96 | s64_le sampling_number; | 96 | s64 sampling_number; |
| 97 | BasicXpadAttributeSet attributes; | 97 | BasicXpadAttributeSet attributes; |
| 98 | BasicXpadButtonSet pad_states; | 98 | BasicXpadButtonSet pad_states; |
| 99 | Core::HID::AnalogStickState l_stick; | 99 | Core::HID::AnalogStickState l_stick; |
diff --git a/src/core/hle/service/hid/ring_lifo.h b/src/core/hle/service/hid/ring_lifo.h index 1cc2a194f..f68d82762 100644 --- a/src/core/hle/service/hid/ring_lifo.h +++ b/src/core/hle/service/hid/ring_lifo.h | |||
| @@ -12,16 +12,16 @@ constexpr std::size_t max_entry_size = 17; | |||
| 12 | 12 | ||
| 13 | template <typename State> | 13 | template <typename State> |
| 14 | struct AtomicStorage { | 14 | struct AtomicStorage { |
| 15 | s64_le sampling_number; | 15 | s64 sampling_number; |
| 16 | State state; | 16 | State state; |
| 17 | }; | 17 | }; |
| 18 | 18 | ||
| 19 | template <typename State> | 19 | template <typename State> |
| 20 | struct Lifo { | 20 | struct Lifo { |
| 21 | s64_le timestamp{}; | 21 | s64 timestamp{}; |
| 22 | s64_le total_entry_count = max_entry_size; | 22 | s64 total_entry_count = max_entry_size; |
| 23 | s64_le last_entry_index{}; | 23 | s64 last_entry_index{}; |
| 24 | s64_le entry_count{}; | 24 | s64 entry_count{}; |
| 25 | std::array<AtomicStorage<State>, max_entry_size> entries{}; | 25 | std::array<AtomicStorage<State>, max_entry_size> entries{}; |
| 26 | 26 | ||
| 27 | const AtomicStorage<State>& ReadCurrentEntry() const { | 27 | const AtomicStorage<State>& ReadCurrentEntry() const { |
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp index be87204fc..3f179150d 100644 --- a/src/yuzu/configuration/configure_input_player_widget.cpp +++ b/src/yuzu/configuration/configure_input_player_widget.cpp | |||
| @@ -28,7 +28,7 @@ void PlayerControlPreview::SetController(Core::HID::EmulatedController* controll | |||
| 28 | controller = controller_; | 28 | controller = controller_; |
| 29 | Core::HID::ControllerUpdateCallback engine_callback{ | 29 | Core::HID::ControllerUpdateCallback engine_callback{ |
| 30 | .on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); }, | 30 | .on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); }, |
| 31 | .is_service = false, | 31 | .is_npad_service = false, |
| 32 | }; | 32 | }; |
| 33 | callback_key = controller->SetCallback(engine_callback); | 33 | callback_key = controller->SetCallback(engine_callback); |
| 34 | ControllerUpdate(Core::HID::ControllerTriggerType::All); | 34 | ControllerUpdate(Core::HID::ControllerTriggerType::All); |