input: add flip_x and flip_y for touchpad (#9481)

This commit is contained in:
nyx
2025-03-03 15:56:01 -05:00
committed by GitHub
parent f1ef724a87
commit d7e7a29261
7 changed files with 50 additions and 8 deletions

View File

@@ -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");