Skip to content

Commit

Permalink
feat(input): add flip_x and flip_y for touchpad
Browse files Browse the repository at this point in the history
  • Loading branch information
nnyyxxxx committed Feb 25, 2025
1 parent f085090 commit 13712bd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
14 changes: 14 additions & 0 deletions src/config/ConfigDescriptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,20 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.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},
},

/*
* input:touchdevice:
*/
Expand Down
4 changes: 4 additions & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ 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:touchdevice:transform", Hyprlang::INT{0});
registerConfigVar("input:touchdevice:output", {"[[Auto]]"});
registerConfigVar("input:touchdevice:enabled", Hyprlang::INT{1});
Expand Down Expand Up @@ -716,6 +718,8 @@ CConfigManager::CConfigManager() {
m_pConfig->addSpecialConfigValue("device", "tap-to-click", Hyprlang::INT{1});
m_pConfig->addSpecialConfigValue("device", "tap-and-drag", Hyprlang::INT{1});
m_pConfig->addSpecialConfigValue("device", "drag_lock", Hyprlang::INT{0});
m_pConfig->addSpecialConfigValue("device", "flip_x", Hyprlang::INT{0});
m_pConfig->addSpecialConfigValue("device", "flip_y", Hyprlang::INT{0});
m_pConfig->addSpecialConfigValue("device", "left_handed", Hyprlang::INT{0});
m_pConfig->addSpecialConfigValue("device", "scroll_method", {STRVAL_EMPTY});
m_pConfig->addSpecialConfigValue("device", "scroll_button", Hyprlang::INT{0});
Expand Down
24 changes: 20 additions & 4 deletions src/managers/input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,31 @@ CInputManager::~CInputManager() {

void CInputManager::onMouseMoved(IPointer::SMotionEvent e) {
static auto PNOACCEL = CConfigValue<Hyprlang::INT>("input:force_no_accel");
static auto PFLIPX = CConfigValue<Hyprlang::INT>("input:touchpad:flip_x");
static auto PFLIPY = CConfigValue<Hyprlang::INT>("input:touchpad:flip_y");

const auto DELTA = *PNOACCEL == 1 ? e.unaccel : e.delta;
Vector2D delta = e.delta;
Vector2D unaccel = e.unaccel;

if (!e.mouse) {
if (*PFLIPX) {
delta.x = -delta.x;
unaccel.x = -unaccel.x;
}
if (*PFLIPY) {
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();
Expand Down

0 comments on commit 13712bd

Please sign in to comment.