From 14ed4a4679eafbcf50ba57d8f4001ef291e0e1ff Mon Sep 17 00:00:00 2001 From: Marko Matovic Date: Sat, 6 Dec 2025 13:07:41 +0100 Subject: [PATCH 1/2] config/input: Invert movement for all pointer devices --- src/config/ConfigDescriptions.hpp | 24 ++++++++++++------------ src/config/ConfigManager.cpp | 8 ++++---- src/devices/IPointer.hpp | 1 - src/devices/Mouse.cpp | 5 ----- src/managers/input/InputManager.cpp | 20 +++++++++----------- 5 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index 85655dfd8..7fa734db1 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -490,6 +490,18 @@ inline static const std::vector CONFIG_OPTIONS = { .type = CONFIG_OPTION_INT, .data = SConfigOptionDescription::SRangeData{0, 0, 359}, }, + SConfigOptionDescription{ + .value = "input:flip_x", + .description = "Inverts the horizontal movement of the pointer device", + .type = CONFIG_OPTION_BOOL, + .data = SConfigOptionDescription::SBoolData{false}, + }, + SConfigOptionDescription{ + .value = "input:flip_y", + .description = "Inverts the vertical movement of the pointer device", + .type = CONFIG_OPTION_BOOL, + .data = SConfigOptionDescription::SBoolData{false}, + }, SConfigOptionDescription{ .value = "input:left_handed", .description = "Switches RMB and LMB", @@ -647,18 +659,6 @@ inline static const std::vector CONFIG_OPTIONS = { .type = CONFIG_OPTION_BOOL, .data = SConfigOptionDescription::SBoolData{false}, }, - SConfigOptionDescription{ - .value = "input:touchpad:flip_x", - .description = "Inverts the horizontal movement of the touchpad", - .type = CONFIG_OPTION_BOOL, - .data = SConfigOptionDescription::SBoolData{false}, - }, - SConfigOptionDescription{ - .value = "input:touchpad:flip_y", - .description = "Inverts the vertical movement of the touchpad", - .type = CONFIG_OPTION_BOOL, - .data = SConfigOptionDescription::SBoolData{false}, - }, SConfigOptionDescription{ .value = "input:touchpad:drag_3fg", .description = "Three Finger Drag 0 -> disabled, 1 -> 3 finger, 2 -> 4 finger", diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index bde4ebc05..49f72511e 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -638,6 +638,8 @@ CConfigManager::CConfigManager() { registerConfigVar("input:sensitivity", {0.f}); registerConfigVar("input:accel_profile", {STRVAL_EMPTY}); registerConfigVar("input:rotation", Hyprlang::INT{0}); + registerConfigVar("input:flip_x", Hyprlang::INT{0}); + registerConfigVar("input:flip_y", Hyprlang::INT{0}); registerConfigVar("input:kb_file", {STRVAL_EMPTY}); registerConfigVar("input:kb_layout", {"us"}); registerConfigVar("input:kb_variant", {STRVAL_EMPTY}); @@ -667,8 +669,6 @@ CConfigManager::CConfigManager() { registerConfigVar("input:touchpad:tap-and-drag", Hyprlang::INT{1}); registerConfigVar("input:touchpad:drag_lock", Hyprlang::INT{0}); registerConfigVar("input:touchpad:scroll_factor", {1.f}); - registerConfigVar("input:touchpad:flip_x", Hyprlang::INT{0}); - registerConfigVar("input:touchpad:flip_y", Hyprlang::INT{0}); registerConfigVar("input:touchpad:drag_3fg", Hyprlang::INT{0}); registerConfigVar("input:touchdevice:transform", Hyprlang::INT{-1}); registerConfigVar("input:touchdevice:output", {"[[Auto]]"}); @@ -805,14 +805,14 @@ CConfigManager::CConfigManager() { m_config->addSpecialConfigValue("device", "transform", Hyprlang::INT{-1}); m_config->addSpecialConfigValue("device", "output", {STRVAL_EMPTY}); m_config->addSpecialConfigValue("device", "enabled", Hyprlang::INT{1}); // only for mice, touchpads, and touchdevices + m_config->addSpecialConfigValue("device", "flip_x", Hyprlang::INT{0}); // only for mice, touchpads, and touchdevices + m_config->addSpecialConfigValue("device", "flip_y", Hyprlang::INT{0}); // only for mice, touchpads, and touchdevices m_config->addSpecialConfigValue("device", "region_position", Hyprlang::VEC2{0, 0}); // only for tablets m_config->addSpecialConfigValue("device", "absolute_region_position", Hyprlang::INT{0}); // only for tablets m_config->addSpecialConfigValue("device", "region_size", Hyprlang::VEC2{0, 0}); // only for tablets m_config->addSpecialConfigValue("device", "relative_input", Hyprlang::INT{0}); // only for tablets m_config->addSpecialConfigValue("device", "active_area_position", Hyprlang::VEC2{0, 0}); // only for tablets m_config->addSpecialConfigValue("device", "active_area_size", Hyprlang::VEC2{0, 0}); // only for tablets - m_config->addSpecialConfigValue("device", "flip_x", Hyprlang::INT{0}); // only for touchpads - m_config->addSpecialConfigValue("device", "flip_y", Hyprlang::INT{0}); // only for touchpads m_config->addSpecialConfigValue("device", "drag_3fg", Hyprlang::INT{0}); // only for touchpads m_config->addSpecialConfigValue("device", "keybinds", Hyprlang::INT{1}); // enable/disable keybinds m_config->addSpecialConfigValue("device", "share_states", Hyprlang::INT{0}); // only for virtualkeyboards diff --git a/src/devices/IPointer.hpp b/src/devices/IPointer.hpp index 197ba123c..645c87b29 100644 --- a/src/devices/IPointer.hpp +++ b/src/devices/IPointer.hpp @@ -112,7 +112,6 @@ class IPointer : public IHID { std::string m_boundOutput = ""; bool m_flipX = false; // decide to invert horizontal movement bool m_flipY = false; // decide to invert vertical movement - bool m_isTouchpad = false; std::optional m_scrollFactor = {}; WP m_self; diff --git a/src/devices/Mouse.cpp b/src/devices/Mouse.cpp index 403b0895d..56e6630b1 100644 --- a/src/devices/Mouse.cpp +++ b/src/devices/Mouse.cpp @@ -14,11 +14,6 @@ CMouse::CMouse(SP mouse_) : m_mouse(mouse_) { if (!m_mouse) return; - if (auto handle = m_mouse->getLibinputHandle()) { - double w = 0, h = 0; - m_isTouchpad = libinput_device_has_capability(handle, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(handle, &w, &h) == 0; - } - m_listeners.destroy = m_mouse->events.destroy.listen([this] { m_mouse.reset(); m_events.destroy.emit(); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index bc631ecd8..55f707c3c 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -117,15 +117,13 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) { Vector2D unaccel = e.unaccel; if (e.device) { - if (e.device->m_isTouchpad) { - if (e.device->m_flipX) { - delta.x = -delta.x; - unaccel.x = -unaccel.x; - } - if (e.device->m_flipY) { - delta.y = -delta.y; - unaccel.y = -unaccel.y; - } + if (e.device->m_flipX) { + delta.x = -delta.x; + unaccel.x = -unaccel.x; + } + if (e.device->m_flipY) { + delta.y = -delta.y; + unaccel.y = -unaccel.y; } } @@ -1274,8 +1272,8 @@ void CInputManager::setPointerConfigs() { libinput_device_config_rotation_set_angle(LIBINPUTDEV, ROTATION); } - m->m_flipX = g_pConfigManager->getDeviceInt(devname, "flip_x", "input:touchpad:flip_x") != 0; - m->m_flipY = g_pConfigManager->getDeviceInt(devname, "flip_y", "input:touchpad:flip_y") != 0; + m->m_flipX = g_pConfigManager->getDeviceInt(devname, "flip_x", "input:flip_x") != 0; + m->m_flipY = g_pConfigManager->getDeviceInt(devname, "flip_y", "input:flip_y") != 0; const auto ACCELPROFILE = g_pConfigManager->getDeviceString(devname, "accel_profile", "input:accel_profile"); const auto SCROLLPOINTS = g_pConfigManager->getDeviceString(devname, "scroll_points", "input:scroll_points"); From d5eba72cade6eec5da990be19587582e3eff1fae Mon Sep 17 00:00:00 2001 From: Marko Matovic Date: Tue, 9 Dec 2025 17:54:38 +0100 Subject: [PATCH 2/2] Restore m_isTouchpad property --- hyprtester/pointer-scroll.txt | 1 + src/devices/IPointer.hpp | 1 + src/devices/Mouse.cpp | 5 +++++ 3 files changed, 7 insertions(+) create mode 100644 hyprtester/pointer-scroll.txt diff --git a/hyprtester/pointer-scroll.txt b/hyprtester/pointer-scroll.txt new file mode 100644 index 000000000..a833923d1 --- /dev/null +++ b/hyprtester/pointer-scroll.txt @@ -0,0 +1 @@ +Failed to connect to wayland display diff --git a/src/devices/IPointer.hpp b/src/devices/IPointer.hpp index 645c87b29..197ba123c 100644 --- a/src/devices/IPointer.hpp +++ b/src/devices/IPointer.hpp @@ -112,6 +112,7 @@ class IPointer : public IHID { std::string m_boundOutput = ""; bool m_flipX = false; // decide to invert horizontal movement bool m_flipY = false; // decide to invert vertical movement + bool m_isTouchpad = false; std::optional m_scrollFactor = {}; WP m_self; diff --git a/src/devices/Mouse.cpp b/src/devices/Mouse.cpp index 56e6630b1..403b0895d 100644 --- a/src/devices/Mouse.cpp +++ b/src/devices/Mouse.cpp @@ -14,6 +14,11 @@ CMouse::CMouse(SP mouse_) : m_mouse(mouse_) { if (!m_mouse) return; + if (auto handle = m_mouse->getLibinputHandle()) { + double w = 0, h = 0; + m_isTouchpad = libinput_device_has_capability(handle, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(handle, &w, &h) == 0; + } + m_listeners.destroy = m_mouse->events.destroy.listen([this] { m_mouse.reset(); m_events.destroy.emit();