summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Hauberg <hauberg@gmail.com>2008-10-01 11:07:57 +0930
committerPeter Hutterer <peter.hutterer@redhat.com>2008-10-03 14:41:58 +0930
commit3985d423204217a1f072fa6e0145cba547f79a97 (patch)
treefd280d850bf02e056c87888e5ad9edf359067e13
parente138e4b79a750e22712802b84bf36a70a929d12f (diff)
Add support for axis inversion.
-rw-r--r--src/evdev.c21
-rw-r--r--src/evdev.h2
2 files changed, 20 insertions, 3 deletions
diff --git a/src/evdev.c b/src/evdev.c
index 149f95d..b24dc50 100644
--- a/src/evdev.c
+++ b/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);
diff --git a/src/evdev.h b/src/evdev.h
index c145fbc..525acb1 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -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;