summaryrefslogtreecommitdiff
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authornyx <nnyyxxxx@protonmail.com>2025-03-03 15:56:01 -0500
committerGitHub <noreply@github.com>2025-03-03 21:56:01 +0100
commitd7e7a292613a4f20218074ff8299dff099a80098 (patch)
treecf57d20dfa11d2502115699a7bb36250c813adfc /src/managers/input/InputManager.cpp
parentf1ef724a87b29a7937cfc328e0c7ea9445a90050 (diff)
input: add flip_x and flip_y for touchpad (#9481)
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index dffbddc2..ba0b2df4 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -90,14 +90,28 @@ CInputManager::~CInputManager() {
void CInputManager::onMouseMoved(IPointer::SMotionEvent e) {
static auto PNOACCEL = CConfigValue<Hyprlang::INT>("input:force_no_accel");
- const auto DELTA = *PNOACCEL == 1 ? e.unaccel : e.delta;
+ 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;
+ }
+ }
+
+ const auto DELTA = *PNOACCEL == 1 ? unaccel : delta;
if (g_pSeatManager->isPointerFrameSkipped)
- g_pPointerManager->storeMovement((uint64_t)e.timeMs, DELTA, e.unaccel);
+ g_pPointerManager->storeMovement((uint64_t)e.timeMs, DELTA, unaccel);
else
- g_pPointerManager->setStoredMovement((uint64_t)e.timeMs, DELTA, e.unaccel);
+ g_pPointerManager->setStoredMovement((uint64_t)e.timeMs, DELTA, unaccel);
- PROTO::relativePointer->sendRelativeMotion((uint64_t)e.timeMs * 1000, DELTA, e.unaccel);
+ PROTO::relativePointer->sendRelativeMotion((uint64_t)e.timeMs * 1000, DELTA, unaccel);
if (e.mouse)
recheckMouseWarpOnMouseInput();
@@ -1180,6 +1194,9 @@ void CInputManager::setPointerConfigs() {
const auto LIBINPUTSENS = std::clamp(g_pConfigManager->getDeviceFloat(devname, "sensitivity", "input:sensitivity"), -1.f, 1.f);
libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS);
+ m->flipX = g_pConfigManager->getDeviceInt(devname, "flip_x", "input:touchpad:flip_x") != 0;
+ m->flipY = g_pConfigManager->getDeviceInt(devname, "flip_y", "input:touchpad: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");