[PATCH 3/3] evdev: Implement axes swapping for absolute events
Rob Bradford
rob at robster.org.uk
Fri Sep 21 07:04:17 PDT 2012
From: Rob Bradford <rob at linux.intel.com>
This quirk is designed for hardware that has the X and Y axes swapped for
absolute events. Do this by rewriting the event such that the X and Y events
are swapped.
---
src/evdev.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index 8848736..344974f 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -129,6 +129,17 @@ evdev_process_absolute_motion(struct evdev_device *device,
const int screen_width = device->output->current->width;
const int screen_height = device->output->current->height;
+ if (device->quirks & EVDEV_QUIRK_SWAP_AXES) {
+ switch (e->code) {
+ case ABS_X:
+ e->code = ABS_Y;
+ break;
+ case ABS_Y:
+ e->code = ABS_X;
+ break;
+ }
+ }
+
switch (e->code) {
case ABS_X:
device->abs.x =
@@ -395,12 +406,22 @@ evdev_configure_device(struct evdev_device *device)
if (TEST_BIT(abs_bits, ABS_MT_SLOT)) {
ioctl(device->fd, EVIOCGABS(ABS_MT_POSITION_X),
&absinfo);
- device->abs.min_x = absinfo.minimum;
- device->abs.max_x = absinfo.maximum;
+ if (device->quirks & EVDEV_QUIRK_SWAP_AXES) {
+ device->abs.min_y = absinfo.minimum;
+ device->abs.max_y = absinfo.maximum;
+ } else {
+ device->abs.min_x = absinfo.minimum;
+ device->abs.max_x = absinfo.maximum;
+ }
ioctl(device->fd, EVIOCGABS(ABS_MT_POSITION_Y),
&absinfo);
- device->abs.min_y = absinfo.minimum;
- device->abs.max_y = absinfo.maximum;
+ if (device->quirks & EVDEV_QUIRK_SWAP_AXES) {
+ device->abs.min_x = absinfo.minimum;
+ device->abs.max_x = absinfo.maximum;
+ } else {
+ device->abs.min_y = absinfo.minimum;
+ device->abs.max_y = absinfo.maximum;
+ }
device->is_mt = 1;
device->mt.slot = 0;
device->caps |= EVDEV_TOUCH;
--
1.7.11.2
More information about the wayland-devel
mailing list