diff --git a/src/devices/IPointer.hpp b/src/devices/IPointer.hpp index 19d91c6c1..d55412225 100644 --- a/src/devices/IPointer.hpp +++ b/src/devices/IPointer.hpp @@ -112,6 +112,7 @@ class IPointer : public IHID { std::string boundOutput = ""; bool flipX = false; // decide to invert horizontal movement bool flipY = false; // decide to invert vertical movement + bool isTouchpad = false; WP self; }; diff --git a/src/devices/Mouse.cpp b/src/devices/Mouse.cpp index 87f6d33ba..600ae5a89 100644 --- a/src/devices/Mouse.cpp +++ b/src/devices/Mouse.cpp @@ -14,6 +14,11 @@ CMouse::CMouse(SP mouse_) : mouse(mouse_) { if (!mouse) return; + if (auto handle = mouse->getLibinputHandle()) { + double w = 0, h = 0; + isTouchpad = libinput_device_has_capability(handle, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(handle, &w, &h) == 0; + } + listeners.destroy = mouse->events.destroy.registerListener([this](std::any d) { mouse.reset(); events.destroy.emit(); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index ba0b2df43..eb72c7b4b 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -93,14 +93,16 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) { Vector2D delta = e.delta; Vector2D unaccel = e.unaccel; - if (!e.mouse && e.device) { - if (e.device->flipX) { - delta.x = -delta.x; - unaccel.x = -unaccel.x; - } - if (e.device->flipY) { - delta.y = -delta.y; - unaccel.y = -unaccel.y; + if (e.device) { + if (e.device->isTouchpad) { + if (e.device->flipX) { + delta.x = -delta.x; + unaccel.x = -unaccel.x; + } + if (e.device->flipY) { + delta.y = -delta.y; + unaccel.y = -unaccel.y; + } } }