From d7e7a292613a4f20218074ff8299dff099a80098 Mon Sep 17 00:00:00 2001 From: nyx Date: Mon, 3 Mar 2025 15:56:01 -0500 Subject: input: add flip_x and flip_y for touchpad (#9481) --- src/devices/IPointer.hpp | 9 ++++++--- src/devices/Mouse.cpp | 1 + src/devices/VirtualPointer.cpp | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/devices') diff --git a/src/devices/IPointer.hpp b/src/devices/IPointer.hpp index ea9cb9f4..19d91c6c 100644 --- a/src/devices/IPointer.hpp +++ b/src/devices/IPointer.hpp @@ -17,9 +17,10 @@ class IPointer : public IHID { virtual SP aq() = 0; struct SMotionEvent { - uint32_t timeMs = 0; - Vector2D delta, unaccel; - bool mouse = false; + uint32_t timeMs = 0; + Vector2D delta, unaccel; + bool mouse = false; + SP device; }; struct SMotionAbsoluteEvent { @@ -109,6 +110,8 @@ class IPointer : public IHID { bool connected = false; // means connected to the cursor std::string boundOutput = ""; + bool flipX = false; // decide to invert horizontal movement + bool flipY = false; // decide to invert vertical movement WP self; }; diff --git a/src/devices/Mouse.cpp b/src/devices/Mouse.cpp index 41652ce4..87f6d33b 100644 --- a/src/devices/Mouse.cpp +++ b/src/devices/Mouse.cpp @@ -27,6 +27,7 @@ CMouse::CMouse(SP mouse_) : mouse(mouse_) { .delta = E.delta, .unaccel = E.unaccel, .mouse = true, + .device = self.lock(), }); }); diff --git a/src/devices/VirtualPointer.cpp b/src/devices/VirtualPointer.cpp index 7cfb0631..e98acd04 100644 --- a/src/devices/VirtualPointer.cpp +++ b/src/devices/VirtualPointer.cpp @@ -19,7 +19,11 @@ CVirtualPointer::CVirtualPointer(SP resource) : point events.destroy.emit(); }); - listeners.motion = pointer->events.move.registerListener([this](std::any d) { pointerEvents.motion.emit(d); }); + listeners.motion = pointer->events.move.registerListener([this](std::any d) { + auto E = std::any_cast(d); + E.device = self.lock(); + pointerEvents.motion.emit(E); + }); listeners.motionAbsolute = pointer->events.warp.registerListener([this](std::any d) { // we need to unpack the event and add our device here because it's required to calculate the position correctly auto E = std::any_cast(d); -- cgit v1.2.3