diff options
| author | 2021-05-28 07:14:14 -0400 | |
|---|---|---|
| committer | 2021-05-28 08:12:49 -0400 | |
| commit | 8171ad65cd9f170dd9f72d1256415ebd34979d36 (patch) | |
| tree | 4d8e7de9508fb37c6779c9d2e92875a12626bb26 /src/core | |
| parent | Merge pull request #6375 from lioncash/iofs (diff) | |
| download | yuzu-8171ad65cd9f170dd9f72d1256415ebd34979d36.tar.gz yuzu-8171ad65cd9f170dd9f72d1256415ebd34979d36.tar.xz yuzu-8171ad65cd9f170dd9f72d1256415ebd34979d36.zip | |
common: Extract point into a common struct
This is generic enough that it can be moved into the Common class for
reuse.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/hid/controllers/gesture.h | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h index eecfeaad5..7e7ae6625 100644 --- a/src/core/hle/service/hid/controllers/gesture.h +++ b/src/core/hle/service/hid/controllers/gesture.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include "common/bit_field.h" | 8 | #include "common/bit_field.h" |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/point.h" | ||
| 10 | #include "core/frontend/input.h" | 11 | #include "core/frontend/input.h" |
| 11 | #include "core/hle/service/hid/controllers/controller_base.h" | 12 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 12 | 13 | ||
| @@ -63,44 +64,21 @@ private: | |||
| 63 | }; | 64 | }; |
| 64 | static_assert(sizeof(Attribute) == 4, "Attribute is an invalid size"); | 65 | static_assert(sizeof(Attribute) == 4, "Attribute is an invalid size"); |
| 65 | 66 | ||
| 66 | template <typename T> | ||
| 67 | struct Point { | ||
| 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; | ||
| 86 | }; | ||
| 87 | static_assert(sizeof(Point<s32_le>) == 8, "Point is an invalid size"); | ||
| 88 | |||
| 89 | struct GestureState { | 67 | struct GestureState { |
| 90 | s64_le sampling_number; | 68 | s64_le sampling_number; |
| 91 | s64_le sampling_number2; | 69 | s64_le sampling_number2; |
| 92 | s64_le detection_count; | 70 | s64_le detection_count; |
| 93 | TouchType type; | 71 | TouchType type; |
| 94 | Direction direction; | 72 | Direction direction; |
| 95 | Point<s32_le> pos; | 73 | Common::Point<s32_le> pos; |
| 96 | Point<s32_le> delta; | 74 | Common::Point<s32_le> delta; |
| 97 | f32 vel_x; | 75 | f32 vel_x; |
| 98 | f32 vel_y; | 76 | f32 vel_y; |
| 99 | Attribute attributes; | 77 | Attribute attributes; |
| 100 | f32 scale; | 78 | f32 scale; |
| 101 | f32 rotation_angle; | 79 | f32 rotation_angle; |
| 102 | s32_le point_count; | 80 | s32_le point_count; |
| 103 | std::array<Point<s32_le>, 4> points; | 81 | std::array<Common::Point<s32_le>, 4> points; |
| 104 | }; | 82 | }; |
| 105 | static_assert(sizeof(GestureState) == 0x68, "GestureState is an invalid size"); | 83 | static_assert(sizeof(GestureState) == 0x68, "GestureState is an invalid size"); |
| 106 | 84 | ||
| @@ -111,14 +89,14 @@ private: | |||
| 111 | static_assert(sizeof(SharedMemory) == 0x708, "SharedMemory is an invalid size"); | 89 | static_assert(sizeof(SharedMemory) == 0x708, "SharedMemory is an invalid size"); |
| 112 | 90 | ||
| 113 | struct Finger { | 91 | struct Finger { |
| 114 | Point<f32> pos{}; | 92 | Common::Point<f32> pos{}; |
| 115 | bool pressed{}; | 93 | bool pressed{}; |
| 116 | }; | 94 | }; |
| 117 | 95 | ||
| 118 | struct GestureProperties { | 96 | struct GestureProperties { |
| 119 | std::array<Point<s32_le>, MAX_POINTS> points{}; | 97 | std::array<Common::Point<s32_le>, MAX_POINTS> points{}; |
| 120 | std::size_t active_points{}; | 98 | std::size_t active_points{}; |
| 121 | Point<s32_le> mid_point{}; | 99 | Common::Point<s32_le> mid_point{}; |
| 122 | s64_le detection_count{}; | 100 | s64_le detection_count{}; |
| 123 | u64_le delta_time{}; | 101 | u64_le delta_time{}; |
| 124 | f32 average_distance{}; | 102 | f32 average_distance{}; |