diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2010-04-29 10:06:24 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-04-29 22:05:23 +1000 |
commit | 7bbbce9a834f2549168b63d1c5993440ef325f87 (patch) | |
tree | a36c63fb72428cbb07e27d7ec30bbbd4ed6d1210 | |
parent | 35b6085bf8feb9e6d3d3020db868a6e285dec38a (diff) |
Read the device resolution from the kernel.
For earlier kernels, use the previous hardcoded resolution in place.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
-rw-r--r-- | src/evdev.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/evdev.c b/src/evdev.c index 205d6c6..6d16611 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -36,6 +36,7 @@ #include <X11/keysym.h> #include <X11/extensions/XI.h> +#include <linux/version.h> #include <sys/stat.h> #include <unistd.h> #include <errno.h> @@ -1187,15 +1188,24 @@ EvdevAddAbsClass(DeviceIntPtr device) for (axis = ABS_X; axis <= ABS_MAX; axis++) { int axnum = pEvdev->axis_map[axis]; + int resolution = 10000; + if (axnum == -1) continue; + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 30) + /* Kernel provides units/mm, X wants units/m */ + if (pEvdev->absinfo[axis].resolution) + resolution = pEvdev->absinfo[axis].resolution * 1000; +#endif + xf86InitValuatorAxisStruct(device, axnum, #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 atoms[axnum], #endif pEvdev->absinfo[axis].minimum, pEvdev->absinfo[axis].maximum, - 10000, 0, 10000); + resolution, 0, resolution); xf86InitValuatorDefaults(device, axnum); pEvdev->old_vals[axnum] = -1; } |