diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/arm_interface.h | 2 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_32.cpp | 4 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_32.h | 1 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_64.cpp | 4 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_64.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/gesture.cpp | 92 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/gesture.h | 54 |
7 files changed, 79 insertions, 79 deletions
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index 9a0151736..77094b48f 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h | |||
| @@ -159,8 +159,6 @@ public: | |||
| 159 | */ | 159 | */ |
| 160 | virtual void SetTPIDR_EL0(u64 value) = 0; | 160 | virtual void SetTPIDR_EL0(u64 value) = 0; |
| 161 | 161 | ||
| 162 | virtual void ChangeProcessorID(std::size_t new_core_id) = 0; | ||
| 163 | |||
| 164 | virtual void SaveContext(ThreadContext32& ctx) = 0; | 162 | virtual void SaveContext(ThreadContext32& ctx) = 0; |
| 165 | virtual void SaveContext(ThreadContext64& ctx) = 0; | 163 | virtual void SaveContext(ThreadContext64& ctx) = 0; |
| 166 | virtual void LoadContext(const ThreadContext32& ctx) = 0; | 164 | virtual void LoadContext(const ThreadContext32& ctx) = 0; |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 93d43e22e..e401fa825 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp | |||
| @@ -255,10 +255,6 @@ void ARM_Dynarmic_32::SetTPIDR_EL0(u64 value) { | |||
| 255 | cp15->uprw = static_cast<u32>(value); | 255 | cp15->uprw = static_cast<u32>(value); |
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | void ARM_Dynarmic_32::ChangeProcessorID(std::size_t new_core_id) { | ||
| 259 | jit->ChangeProcessorID(new_core_id); | ||
| 260 | } | ||
| 261 | |||
| 262 | void ARM_Dynarmic_32::SaveContext(ThreadContext32& ctx) { | 258 | void ARM_Dynarmic_32::SaveContext(ThreadContext32& ctx) { |
| 263 | Dynarmic::A32::Context context; | 259 | Dynarmic::A32::Context context; |
| 264 | jit->SaveContext(context); | 260 | jit->SaveContext(context); |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.h b/src/core/arm/dynarmic/arm_dynarmic_32.h index 42778c02c..b882b0c59 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.h +++ b/src/core/arm/dynarmic/arm_dynarmic_32.h | |||
| @@ -48,7 +48,6 @@ public: | |||
| 48 | void SetTlsAddress(VAddr address) override; | 48 | void SetTlsAddress(VAddr address) override; |
| 49 | void SetTPIDR_EL0(u64 value) override; | 49 | void SetTPIDR_EL0(u64 value) override; |
| 50 | u64 GetTPIDR_EL0() const override; | 50 | u64 GetTPIDR_EL0() const override; |
| 51 | void ChangeProcessorID(std::size_t new_core_id) override; | ||
| 52 | 51 | ||
| 53 | bool IsInThumbMode() const { | 52 | bool IsInThumbMode() const { |
| 54 | return (GetPSTATE() & 0x20) != 0; | 53 | return (GetPSTATE() & 0x20) != 0; |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 08fa85904..157051d69 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp | |||
| @@ -296,10 +296,6 @@ void ARM_Dynarmic_64::SetTPIDR_EL0(u64 value) { | |||
| 296 | cb->tpidr_el0 = value; | 296 | cb->tpidr_el0 = value; |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | void ARM_Dynarmic_64::ChangeProcessorID(std::size_t new_core_id) { | ||
| 300 | jit->ChangeProcessorID(new_core_id); | ||
| 301 | } | ||
| 302 | |||
| 303 | void ARM_Dynarmic_64::SaveContext(ThreadContext64& ctx) { | 299 | void ARM_Dynarmic_64::SaveContext(ThreadContext64& ctx) { |
| 304 | ctx.cpu_registers = jit->GetRegisters(); | 300 | ctx.cpu_registers = jit->GetRegisters(); |
| 305 | ctx.sp = jit->GetSP(); | 301 | ctx.sp = jit->GetSP(); |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.h b/src/core/arm/dynarmic/arm_dynarmic_64.h index b81fbcc66..92f715f19 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.h +++ b/src/core/arm/dynarmic/arm_dynarmic_64.h | |||
| @@ -45,7 +45,6 @@ public: | |||
| 45 | void SetTlsAddress(VAddr address) override; | 45 | void SetTlsAddress(VAddr address) override; |
| 46 | void SetTPIDR_EL0(u64 value) override; | 46 | void SetTPIDR_EL0(u64 value) override; |
| 47 | u64 GetTPIDR_EL0() const override; | 47 | u64 GetTPIDR_EL0() const override; |
| 48 | void ChangeProcessorID(std::size_t new_core_id) override; | ||
| 49 | 48 | ||
| 50 | void SaveContext(ThreadContext32& ctx) override {} | 49 | void SaveContext(ThreadContext32& ctx) override {} |
| 51 | void SaveContext(ThreadContext64& ctx) override; | 50 | void SaveContext(ThreadContext64& ctx) override; |
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index d311f754b..764abb5b6 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp | |||
| @@ -91,8 +91,7 @@ bool Controller_Gesture::ShouldUpdateGesture(const GestureProperties& gesture, | |||
| 91 | 91 | ||
| 92 | // Update if coordinates change | 92 | // Update if coordinates change |
| 93 | for (size_t id = 0; id < MAX_POINTS; id++) { | 93 | for (size_t id = 0; id < MAX_POINTS; id++) { |
| 94 | if (gesture.points[id].x != last_gesture.points[id].x || | 94 | if (gesture.points[id] != last_gesture.points[id]) { |
| 95 | gesture.points[id].y != last_gesture.points[id].y) { | ||
| 96 | return true; | 95 | return true; |
| 97 | } | 96 | } |
| 98 | } | 97 | } |
| @@ -124,8 +123,7 @@ void Controller_Gesture::UpdateGestureSharedMemory(u8* data, std::size_t size, | |||
| 124 | cur_entry.sampling_number2 = cur_entry.sampling_number; | 123 | cur_entry.sampling_number2 = cur_entry.sampling_number; |
| 125 | 124 | ||
| 126 | // Reset values to default | 125 | // Reset values to default |
| 127 | cur_entry.delta_x = 0; | 126 | cur_entry.delta = {}; |
| 128 | cur_entry.delta_y = 0; | ||
| 129 | cur_entry.vel_x = 0; | 127 | cur_entry.vel_x = 0; |
| 130 | cur_entry.vel_y = 0; | 128 | cur_entry.vel_y = 0; |
| 131 | cur_entry.direction = Direction::None; | 129 | cur_entry.direction = Direction::None; |
| @@ -146,13 +144,9 @@ void Controller_Gesture::UpdateGestureSharedMemory(u8* data, std::size_t size, | |||
| 146 | cur_entry.detection_count = gesture.detection_count; | 144 | cur_entry.detection_count = gesture.detection_count; |
| 147 | cur_entry.type = type; | 145 | cur_entry.type = type; |
| 148 | cur_entry.attributes = attributes; | 146 | cur_entry.attributes = attributes; |
| 149 | cur_entry.x = gesture.mid_point.x; | 147 | cur_entry.pos = gesture.mid_point; |
| 150 | cur_entry.y = gesture.mid_point.y; | ||
| 151 | cur_entry.point_count = static_cast<s32>(gesture.active_points); | 148 | cur_entry.point_count = static_cast<s32>(gesture.active_points); |
| 152 | for (size_t id = 0; id < MAX_POINTS; id++) { | 149 | cur_entry.points = gesture.points; |
| 153 | cur_entry.points[id].x = gesture.points[id].x; | ||
| 154 | cur_entry.points[id].y = gesture.points[id].y; | ||
| 155 | } | ||
| 156 | last_gesture = gesture; | 150 | last_gesture = gesture; |
| 157 | 151 | ||
| 158 | std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory)); | 152 | std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory)); |
| @@ -160,8 +154,8 @@ void Controller_Gesture::UpdateGestureSharedMemory(u8* data, std::size_t size, | |||
| 160 | 154 | ||
| 161 | void Controller_Gesture::NewGesture(GestureProperties& gesture, TouchType& type, | 155 | void Controller_Gesture::NewGesture(GestureProperties& gesture, TouchType& type, |
| 162 | Attribute& attributes) { | 156 | Attribute& attributes) { |
| 163 | const auto& last_entry = | 157 | const auto& last_entry = GetLastGestureEntry(); |
| 164 | shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; | 158 | |
| 165 | gesture.detection_count++; | 159 | gesture.detection_count++; |
| 166 | type = TouchType::Touch; | 160 | type = TouchType::Touch; |
| 167 | 161 | ||
| @@ -174,13 +168,11 @@ void Controller_Gesture::NewGesture(GestureProperties& gesture, TouchType& type, | |||
| 174 | 168 | ||
| 175 | void Controller_Gesture::UpdateExistingGesture(GestureProperties& gesture, TouchType& type, | 169 | void Controller_Gesture::UpdateExistingGesture(GestureProperties& gesture, TouchType& type, |
| 176 | f32 time_difference) { | 170 | f32 time_difference) { |
| 177 | const auto& last_entry = | 171 | const auto& last_entry = GetLastGestureEntry(); |
| 178 | shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; | ||
| 179 | 172 | ||
| 180 | // Promote to pan type if touch moved | 173 | // Promote to pan type if touch moved |
| 181 | for (size_t id = 0; id < MAX_POINTS; id++) { | 174 | for (size_t id = 0; id < MAX_POINTS; id++) { |
| 182 | if (gesture.points[id].x != last_gesture.points[id].x || | 175 | if (gesture.points[id] != last_gesture.points[id]) { |
| 183 | gesture.points[id].y != last_gesture.points[id].y) { | ||
| 184 | type = TouchType::Pan; | 176 | type = TouchType::Pan; |
| 185 | break; | 177 | break; |
| 186 | } | 178 | } |
| @@ -192,10 +184,7 @@ void Controller_Gesture::UpdateExistingGesture(GestureProperties& gesture, Touch | |||
| 192 | enable_press_and_tap = false; | 184 | enable_press_and_tap = false; |
| 193 | gesture.active_points = 0; | 185 | gesture.active_points = 0; |
| 194 | gesture.mid_point = {}; | 186 | gesture.mid_point = {}; |
| 195 | for (size_t id = 0; id < MAX_POINTS; id++) { | 187 | gesture.points.fill({}); |
| 196 | gesture.points[id].x = 0; | ||
| 197 | gesture.points[id].y = 0; | ||
| 198 | } | ||
| 199 | return; | 188 | return; |
| 200 | } | 189 | } |
| 201 | 190 | ||
| @@ -214,8 +203,8 @@ void Controller_Gesture::UpdateExistingGesture(GestureProperties& gesture, Touch | |||
| 214 | void Controller_Gesture::EndGesture(GestureProperties& gesture, | 203 | void Controller_Gesture::EndGesture(GestureProperties& gesture, |
| 215 | GestureProperties& last_gesture_props, TouchType& type, | 204 | GestureProperties& last_gesture_props, TouchType& type, |
| 216 | Attribute& attributes, f32 time_difference) { | 205 | Attribute& attributes, f32 time_difference) { |
| 217 | const auto& last_entry = | 206 | const auto& last_entry = GetLastGestureEntry(); |
| 218 | shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; | 207 | |
| 219 | if (last_gesture_props.active_points != 0) { | 208 | if (last_gesture_props.active_points != 0) { |
| 220 | switch (last_entry.type) { | 209 | switch (last_entry.type) { |
| 221 | case TouchType::Touch: | 210 | case TouchType::Touch: |
| @@ -265,13 +254,11 @@ void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, | |||
| 265 | GestureProperties& last_gesture_props, TouchType& type, | 254 | GestureProperties& last_gesture_props, TouchType& type, |
| 266 | f32 time_difference) { | 255 | f32 time_difference) { |
| 267 | auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; | 256 | auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; |
| 268 | const auto& last_entry = | 257 | const auto& last_entry = GetLastGestureEntry(); |
| 269 | shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; | ||
| 270 | cur_entry.delta_x = gesture.mid_point.x - last_entry.x; | ||
| 271 | cur_entry.delta_y = gesture.mid_point.y - last_entry.y; | ||
| 272 | 258 | ||
| 273 | cur_entry.vel_x = static_cast<f32>(cur_entry.delta_x) / time_difference; | 259 | cur_entry.delta = gesture.mid_point - last_entry.pos; |
| 274 | cur_entry.vel_y = static_cast<f32>(cur_entry.delta_y) / time_difference; | 260 | cur_entry.vel_x = static_cast<f32>(cur_entry.delta.x) / time_difference; |
| 261 | cur_entry.vel_y = static_cast<f32>(cur_entry.delta.y) / time_difference; | ||
| 275 | last_pan_time_difference = time_difference; | 262 | last_pan_time_difference = time_difference; |
| 276 | 263 | ||
| 277 | // Promote to pinch type | 264 | // Promote to pinch type |
| @@ -295,12 +282,11 @@ void Controller_Gesture::EndPanEvent(GestureProperties& gesture, | |||
| 295 | GestureProperties& last_gesture_props, TouchType& type, | 282 | GestureProperties& last_gesture_props, TouchType& type, |
| 296 | f32 time_difference) { | 283 | f32 time_difference) { |
| 297 | auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; | 284 | auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; |
| 298 | const auto& last_entry = | 285 | const auto& last_entry = GetLastGestureEntry(); |
| 299 | shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; | ||
| 300 | cur_entry.vel_x = | 286 | cur_entry.vel_x = |
| 301 | static_cast<f32>(last_entry.delta_x) / (last_pan_time_difference + time_difference); | 287 | static_cast<f32>(last_entry.delta.x) / (last_pan_time_difference + time_difference); |
| 302 | cur_entry.vel_y = | 288 | cur_entry.vel_y = |
| 303 | static_cast<f32>(last_entry.delta_y) / (last_pan_time_difference + time_difference); | 289 | static_cast<f32>(last_entry.delta.y) / (last_pan_time_difference + time_difference); |
| 304 | const f32 curr_vel = | 290 | const f32 curr_vel = |
| 305 | std::sqrt((cur_entry.vel_x * cur_entry.vel_x) + (cur_entry.vel_y * cur_entry.vel_y)); | 291 | std::sqrt((cur_entry.vel_x * cur_entry.vel_x) + (cur_entry.vel_y * cur_entry.vel_y)); |
| 306 | 292 | ||
| @@ -320,22 +306,22 @@ void Controller_Gesture::EndPanEvent(GestureProperties& gesture, | |||
| 320 | void Controller_Gesture::SetSwipeEvent(GestureProperties& gesture, | 306 | void Controller_Gesture::SetSwipeEvent(GestureProperties& gesture, |
| 321 | GestureProperties& last_gesture_props, TouchType& type) { | 307 | GestureProperties& last_gesture_props, TouchType& type) { |
| 322 | auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; | 308 | auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; |
| 323 | const auto& last_entry = | 309 | const auto& last_entry = GetLastGestureEntry(); |
| 324 | shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; | 310 | |
| 325 | type = TouchType::Swipe; | 311 | type = TouchType::Swipe; |
| 326 | gesture = last_gesture_props; | 312 | gesture = last_gesture_props; |
| 327 | force_update = true; | 313 | force_update = true; |
| 328 | cur_entry.delta_x = last_entry.delta_x; | 314 | cur_entry.delta = last_entry.delta; |
| 329 | cur_entry.delta_y = last_entry.delta_y; | 315 | |
| 330 | if (std::abs(cur_entry.delta_x) > std::abs(cur_entry.delta_y)) { | 316 | if (std::abs(cur_entry.delta.x) > std::abs(cur_entry.delta.y)) { |
| 331 | if (cur_entry.delta_x > 0) { | 317 | if (cur_entry.delta.x > 0) { |
| 332 | cur_entry.direction = Direction::Right; | 318 | cur_entry.direction = Direction::Right; |
| 333 | return; | 319 | return; |
| 334 | } | 320 | } |
| 335 | cur_entry.direction = Direction::Left; | 321 | cur_entry.direction = Direction::Left; |
| 336 | return; | 322 | return; |
| 337 | } | 323 | } |
| 338 | if (cur_entry.delta_y > 0) { | 324 | if (cur_entry.delta.y > 0) { |
| 339 | cur_entry.direction = Direction::Down; | 325 | cur_entry.direction = Direction::Down; |
| 340 | return; | 326 | return; |
| 341 | } | 327 | } |
| @@ -364,6 +350,14 @@ std::optional<std::size_t> Controller_Gesture::GetUnusedFingerID() const { | |||
| 364 | return std::nullopt; | 350 | return std::nullopt; |
| 365 | } | 351 | } |
| 366 | 352 | ||
| 353 | Controller_Gesture::GestureState& Controller_Gesture::GetLastGestureEntry() { | ||
| 354 | return shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; | ||
| 355 | } | ||
| 356 | |||
| 357 | const Controller_Gesture::GestureState& Controller_Gesture::GetLastGestureEntry() const { | ||
| 358 | return shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; | ||
| 359 | } | ||
| 360 | |||
| 367 | std::size_t Controller_Gesture::UpdateTouchInputEvent( | 361 | std::size_t Controller_Gesture::UpdateTouchInputEvent( |
| 368 | const std::tuple<float, float, bool>& touch_input, std::size_t finger_id) { | 362 | const std::tuple<float, float, bool>& touch_input, std::size_t finger_id) { |
| 369 | const auto& [x, y, pressed] = touch_input; | 363 | const auto& [x, y, pressed] = touch_input; |
| @@ -381,8 +375,7 @@ std::size_t Controller_Gesture::UpdateTouchInputEvent( | |||
| 381 | finger_id = first_free_id.value(); | 375 | finger_id = first_free_id.value(); |
| 382 | fingers[finger_id].pressed = true; | 376 | fingers[finger_id].pressed = true; |
| 383 | } | 377 | } |
| 384 | fingers[finger_id].x = x; | 378 | fingers[finger_id].pos = {x, y}; |
| 385 | fingers[finger_id].y = y; | ||
| 386 | return finger_id; | 379 | return finger_id; |
| 387 | } | 380 | } |
| 388 | 381 | ||
| @@ -402,17 +395,18 @@ Controller_Gesture::GestureProperties Controller_Gesture::GetGestureProperties() | |||
| 402 | static_cast<std::size_t>(std::distance(active_fingers.begin(), end_iter)); | 395 | static_cast<std::size_t>(std::distance(active_fingers.begin(), end_iter)); |
| 403 | 396 | ||
| 404 | for (size_t id = 0; id < gesture.active_points; ++id) { | 397 | for (size_t id = 0; id < gesture.active_points; ++id) { |
| 405 | gesture.points[id].x = | 398 | const auto& [active_x, active_y] = active_fingers[id].pos; |
| 406 | static_cast<s32>(active_fingers[id].x * Layout::ScreenUndocked::Width); | 399 | gesture.points[id] = { |
| 407 | gesture.points[id].y = | 400 | .x = static_cast<s32>(active_x * Layout::ScreenUndocked::Width), |
| 408 | static_cast<s32>(active_fingers[id].y * Layout::ScreenUndocked::Height); | 401 | .y = static_cast<s32>(active_y * Layout::ScreenUndocked::Height), |
| 402 | }; | ||
| 409 | 403 | ||
| 410 | // Hack: There is no touch in docked but games still allow it | 404 | // Hack: There is no touch in docked but games still allow it |
| 411 | if (Settings::values.use_docked_mode.GetValue()) { | 405 | if (Settings::values.use_docked_mode.GetValue()) { |
| 412 | gesture.points[id].x = | 406 | gesture.points[id] = { |
| 413 | static_cast<s32>(active_fingers[id].x * Layout::ScreenDocked::Width); | 407 | .x = static_cast<s32>(active_x * Layout::ScreenDocked::Width), |
| 414 | gesture.points[id].y = | 408 | .y = static_cast<s32>(active_y * Layout::ScreenDocked::Height), |
| 415 | static_cast<s32>(active_fingers[id].y * Layout::ScreenDocked::Height); | 409 | }; |
| 416 | } | 410 | } |
| 417 | 411 | ||
| 418 | gesture.mid_point.x += static_cast<s32>(gesture.points[id].x / gesture.active_points); | 412 | gesture.mid_point.x += static_cast<s32>(gesture.points[id].x / gesture.active_points); |
diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h index f46e29411..eecfeaad5 100644 --- a/src/core/hle/service/hid/controllers/gesture.h +++ b/src/core/hle/service/hid/controllers/gesture.h | |||
| @@ -63,11 +63,28 @@ private: | |||
| 63 | }; | 63 | }; |
| 64 | static_assert(sizeof(Attribute) == 4, "Attribute is an invalid size"); | 64 | static_assert(sizeof(Attribute) == 4, "Attribute is an invalid size"); |
| 65 | 65 | ||
| 66 | struct Points { | 66 | template <typename T> |
| 67 | s32_le x; | 67 | struct Point { |
| 68 | s32_le y; | 68 | T x{}; |
| 69 | T y{}; | ||
| 70 | |||
| 71 | friend Point operator+(const Point& lhs, const Point& rhs) { | ||
| 72 | return { | ||
| 73 | .x = lhs.x + rhs.x, | ||
| 74 | .y = lhs.y + rhs.y, | ||
| 75 | }; | ||
| 76 | } | ||
| 77 | |||
| 78 | friend Point operator-(const Point& lhs, const Point& rhs) { | ||
| 79 | return { | ||
| 80 | .x = lhs.x - rhs.x, | ||
| 81 | .y = lhs.y - rhs.y, | ||
| 82 | }; | ||
| 83 | } | ||
| 84 | |||
| 85 | friend bool operator==(const Point&, const Point&) = default; | ||
| 69 | }; | 86 | }; |
| 70 | static_assert(sizeof(Points) == 8, "Points is an invalid size"); | 87 | static_assert(sizeof(Point<s32_le>) == 8, "Point is an invalid size"); |
| 71 | 88 | ||
| 72 | struct GestureState { | 89 | struct GestureState { |
| 73 | s64_le sampling_number; | 90 | s64_le sampling_number; |
| @@ -75,17 +92,15 @@ private: | |||
| 75 | s64_le detection_count; | 92 | s64_le detection_count; |
| 76 | TouchType type; | 93 | TouchType type; |
| 77 | Direction direction; | 94 | Direction direction; |
| 78 | s32_le x; | 95 | Point<s32_le> pos; |
| 79 | s32_le y; | 96 | Point<s32_le> delta; |
| 80 | s32_le delta_x; | ||
| 81 | s32_le delta_y; | ||
| 82 | f32 vel_x; | 97 | f32 vel_x; |
| 83 | f32 vel_y; | 98 | f32 vel_y; |
| 84 | Attribute attributes; | 99 | Attribute attributes; |
| 85 | f32 scale; | 100 | f32 scale; |
| 86 | f32 rotation_angle; | 101 | f32 rotation_angle; |
| 87 | s32_le point_count; | 102 | s32_le point_count; |
| 88 | std::array<Points, 4> points; | 103 | std::array<Point<s32_le>, 4> points; |
| 89 | }; | 104 | }; |
| 90 | static_assert(sizeof(GestureState) == 0x68, "GestureState is an invalid size"); | 105 | static_assert(sizeof(GestureState) == 0x68, "GestureState is an invalid size"); |
| 91 | 106 | ||
| @@ -96,15 +111,14 @@ private: | |||
| 96 | static_assert(sizeof(SharedMemory) == 0x708, "SharedMemory is an invalid size"); | 111 | static_assert(sizeof(SharedMemory) == 0x708, "SharedMemory is an invalid size"); |
| 97 | 112 | ||
| 98 | struct Finger { | 113 | struct Finger { |
| 99 | f32 x{}; | 114 | Point<f32> pos{}; |
| 100 | f32 y{}; | ||
| 101 | bool pressed{}; | 115 | bool pressed{}; |
| 102 | }; | 116 | }; |
| 103 | 117 | ||
| 104 | struct GestureProperties { | 118 | struct GestureProperties { |
| 105 | std::array<Points, MAX_POINTS> points{}; | 119 | std::array<Point<s32_le>, MAX_POINTS> points{}; |
| 106 | std::size_t active_points{}; | 120 | std::size_t active_points{}; |
| 107 | Points mid_point{}; | 121 | Point<s32_le> mid_point{}; |
| 108 | s64_le detection_count{}; | 122 | s64_le detection_count{}; |
| 109 | u64_le delta_time{}; | 123 | u64_le delta_time{}; |
| 110 | f32 average_distance{}; | 124 | f32 average_distance{}; |
| @@ -148,7 +162,11 @@ private: | |||
| 148 | TouchType& type); | 162 | TouchType& type); |
| 149 | 163 | ||
| 150 | // Returns an unused finger id, if there is no fingers available std::nullopt is returned. | 164 | // Returns an unused finger id, if there is no fingers available std::nullopt is returned. |
| 151 | std::optional<size_t> GetUnusedFingerID() const; | 165 | [[nodiscard]] std::optional<size_t> GetUnusedFingerID() const; |
| 166 | |||
| 167 | // Retrieves the last gesture entry, as indicated by shared memory indices. | ||
| 168 | [[nodiscard]] GestureState& GetLastGestureEntry(); | ||
| 169 | [[nodiscard]] const GestureState& GetLastGestureEntry() const; | ||
| 152 | 170 | ||
| 153 | /** | 171 | /** |
| 154 | * If the touch is new it tries to assign a new finger id, if there is no fingers available no | 172 | * If the touch is new it tries to assign a new finger id, if there is no fingers available no |
| @@ -166,10 +184,10 @@ private: | |||
| 166 | std::unique_ptr<Input::TouchDevice> touch_mouse_device; | 184 | std::unique_ptr<Input::TouchDevice> touch_mouse_device; |
| 167 | std::unique_ptr<Input::TouchDevice> touch_udp_device; | 185 | std::unique_ptr<Input::TouchDevice> touch_udp_device; |
| 168 | std::unique_ptr<Input::TouchDevice> touch_btn_device; | 186 | std::unique_ptr<Input::TouchDevice> touch_btn_device; |
| 169 | std::array<size_t, MAX_FINGERS> mouse_finger_id; | 187 | std::array<size_t, MAX_FINGERS> mouse_finger_id{}; |
| 170 | std::array<size_t, MAX_FINGERS> keyboard_finger_id; | 188 | std::array<size_t, MAX_FINGERS> keyboard_finger_id{}; |
| 171 | std::array<size_t, MAX_FINGERS> udp_finger_id; | 189 | std::array<size_t, MAX_FINGERS> udp_finger_id{}; |
| 172 | std::array<Finger, MAX_POINTS> fingers; | 190 | std::array<Finger, MAX_POINTS> fingers{}; |
| 173 | GestureProperties last_gesture{}; | 191 | GestureProperties last_gesture{}; |
| 174 | s64_le last_update_timestamp{}; | 192 | s64_le last_update_timestamp{}; |
| 175 | s64_le last_tap_timestamp{}; | 193 | s64_le last_tap_timestamp{}; |