mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-14 11:44:16 +00:00
Add support for axis inversion.
This commit is contained in:
committed by
Peter Hutterer
parent
e138e4b79a
commit
3985d42320
21
src/evdev.c
21
src/evdev.c
@@ -348,8 +348,13 @@ EvdevReadInput(InputInfoPtr pInfo)
|
||||
}
|
||||
}
|
||||
|
||||
if (dx != 0 || dy != 0)
|
||||
if (dx != 0 || dy != 0) {
|
||||
if (pEvdev->invert_x)
|
||||
dx *= -1;
|
||||
if (pEvdev->invert_y)
|
||||
dy *= -1;
|
||||
xf86PostMotionEvent(pInfo->dev, FALSE, 0, 2, dx, dy);
|
||||
}
|
||||
|
||||
/*
|
||||
* Some devices only generate valid abs coords when BTN_DIGI is
|
||||
@@ -361,8 +366,15 @@ EvdevReadInput(InputInfoPtr pInfo)
|
||||
* just works.
|
||||
*/
|
||||
if (abs && pEvdev->tool) {
|
||||
xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2,
|
||||
pEvdev->abs_x, pEvdev->abs_y);
|
||||
int abs_x, abs_y;
|
||||
abs_x = pEvdev->abs_x;
|
||||
abs_y = pEvdev->abs_y;
|
||||
if (pEvdev->invert_x)
|
||||
abs_x = pEvdev->max_x - abs_x;
|
||||
if (pEvdev->invert_y)
|
||||
abs_y = pEvdev->max_y - abs_y;
|
||||
|
||||
xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2, abs_x, abs_y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1337,6 +1349,9 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
|
||||
pEvdev->noXkb = noXkbExtension;
|
||||
/* parse the XKB options during kbd setup */
|
||||
|
||||
pEvdev->invert_x = xf86SetBoolOption(pInfo->options, "InvertX", FALSE);
|
||||
pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
|
||||
|
||||
if (EvdevProbe(pInfo)) {
|
||||
close(pInfo->fd);
|
||||
xf86DeleteInput(pInfo, 0);
|
||||
|
||||
@@ -65,6 +65,8 @@ typedef struct {
|
||||
int flags;
|
||||
int tool;
|
||||
int buttons; /* number of buttons */
|
||||
BOOL invert_x;
|
||||
BOOL invert_y;
|
||||
|
||||
/* XKB stuff has to be per-device rather than per-driver */
|
||||
int noXkb;
|
||||
|
||||
Reference in New Issue
Block a user