summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/hid/controllers/gesture.h
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2021-05-17 21:15:07 +0200
committerLioncash <mathew1800@gmail.com>2021-05-18 09:39:18 +0200
commit74f30c02239e034e065f5f1bd4e249c091f2d97f (patch)
treefa6cbad3998595c29c45ca5cb7cb9180224fbce4 /src/core/hle/service/hid/controllers/gesture.h
parenthid/gesture: Replace x,y members of GestureState with a Point (diff)
downloadyuzu-74f30c02239e034e065f5f1bd4e249c091f2d97f.tar
yuzu-74f30c02239e034e065f5f1bd4e249c091f2d97f.tar.gz
yuzu-74f30c02239e034e065f5f1bd4e249c091f2d97f.tar.bz2
yuzu-74f30c02239e034e065f5f1bd4e249c091f2d97f.tar.lz
yuzu-74f30c02239e034e065f5f1bd4e249c091f2d97f.tar.xz
yuzu-74f30c02239e034e065f5f1bd4e249c091f2d97f.tar.zst
yuzu-74f30c02239e034e065f5f1bd4e249c091f2d97f.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/hid/controllers/gesture.h35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h
index 809303131..b2bcae2b7 100644
--- a/src/core/hle/service/hid/controllers/gesture.h
+++ b/src/core/hle/service/hid/controllers/gesture.h
@@ -63,13 +63,28 @@ private:
};
static_assert(sizeof(Attribute) == 4, "Attribute is an invalid size");
+ template <typename T>
struct Point {
- s32_le x{};
- s32_le y{};
+ T x{};
+ T y{};
+
+ friend Point operator+(const Point& lhs, const Point& rhs) {
+ return {
+ .x = lhs.x + rhs.x,
+ .y = lhs.y + rhs.y,
+ };
+ }
+
+ friend Point operator-(const Point& lhs, const Point& rhs) {
+ return {
+ .x = lhs.x - rhs.x,
+ .y = lhs.y - rhs.y,
+ };
+ }
friend bool operator==(const Point&, const Point&) = default;
};
- static_assert(sizeof(Point) == 8, "Point is an invalid size");
+ static_assert(sizeof(Point<s32_le>) == 8, "Point is an invalid size");
struct GestureState {
s64_le sampling_number;
@@ -77,16 +92,15 @@ private:
s64_le detection_count;
TouchType type;
Direction direction;
- Point pos;
- s32_le delta_x;
- s32_le delta_y;
+ Point<s32_le> pos;
+ Point<s32_le> delta;
f32 vel_x;
f32 vel_y;
Attribute attributes;
f32 scale;
f32 rotation_angle;
s32_le point_count;
- std::array<Point, 4> points;
+ std::array<Point<s32_le>, 4> points;
};
static_assert(sizeof(GestureState) == 0x68, "GestureState is an invalid size");
@@ -97,15 +111,14 @@ private:
static_assert(sizeof(SharedMemory) == 0x708, "SharedMemory is an invalid size");
struct Finger {
- f32 x{};
- f32 y{};
+ Point<f32> pos{};
bool pressed{};
};
struct GestureProperties {
- std::array<Point, MAX_POINTS> points{};
+ std::array<Point<s32_le>, MAX_POINTS> points{};
std::size_t active_points{};
- Point mid_point{};
+ Point<s32_le> mid_point{};
s64_le detection_count{};
u64_le delta_time{};
f32 average_distance{};