diff options
| author | 2021-10-22 23:04:06 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:25 -0600 | |
| commit | b564f024f0be5023cf13fb2fca953ea6c1feeeb6 (patch) | |
| tree | bb2fb272058a239a345856d4b34389791ea0a783 /src/core/hid | |
| parent | service/hid: Match shared memory closer to HW (diff) | |
| download | yuzu-b564f024f0be5023cf13fb2fca953ea6c1feeeb6.tar.gz yuzu-b564f024f0be5023cf13fb2fca953ea6c1feeeb6.tar.xz yuzu-b564f024f0be5023cf13fb2fca953ea6c1feeeb6.zip | |
Morph review first wave
Diffstat (limited to 'src/core/hid')
| -rw-r--r-- | src/core/hid/emulated_console.cpp | 4 | ||||
| -rw-r--r-- | src/core/hid/emulated_console.h | 10 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 6 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 22 | ||||
| -rw-r--r-- | src/core/hid/emulated_devices.cpp | 4 | ||||
| -rw-r--r-- | src/core/hid/hid_core.cpp | 8 | ||||
| -rw-r--r-- | src/core/hid/hid_types.h | 48 | ||||
| -rw-r--r-- | src/core/hid/input_converter.cpp | 12 |
8 files changed, 57 insertions, 57 deletions
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; |