input: fixup mouse check for flipping x / y (#9529)

This commit is contained in:
nyx
2025-03-06 11:33:01 -05:00
committed by GitHub
parent 7a84317f33
commit 4435f5c546
3 changed files with 16 additions and 8 deletions

View File

@@ -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<IPointer> self;
};

View File

@@ -14,6 +14,11 @@ CMouse::CMouse(SP<Aquamarine::IPointer> 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();

View File

@@ -93,7 +93,8 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) {
Vector2D delta = e.delta;
Vector2D unaccel = e.unaccel;
if (!e.mouse && e.device) {
if (e.device) {
if (e.device->isTouchpad) {
if (e.device->flipX) {
delta.x = -delta.x;
unaccel.x = -unaccel.x;
@@ -103,6 +104,7 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) {
unaccel.y = -unaccel.y;
}
}
}
const auto DELTA = *PNOACCEL == 1 ? unaccel : delta;