aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-02-17 14:53:51 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-02-17 14:54:17 +1000
commit9620fe7765b340213a552b5656d9d10bbbefd4cb (patch)
tree84709a8ef8119d4a7f9f8b20bcacea9c93d90097
parentAdd dynamic axis labelling for absolute devices. (diff)
downloadxf86-input-evdev-9620fe7765b340213a552b5656d9d10bbbefd4cb.tar.gz
xf86-input-evdev-9620fe7765b340213a552b5656d9d10bbbefd4cb.tar.bz2
xf86-input-evdev-9620fe7765b340213a552b5656d9d10bbbefd4cb.zip
Add generic axis support for relative axes.
Just query the kernel what axes we actually have, rather than hard-coding x/y. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/evdev.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/evdev.c b/src/evdev.c
index 765cd90..0fe3610 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -954,23 +954,40 @@ static int
EvdevAddRelClass(DeviceIntPtr device)
{
InputInfoPtr pInfo;
+ EvdevPtr pEvdev;
+ int num_axes, axis, i = 0;
pInfo = device->public.devicePrivate;
+ pEvdev = pInfo->private;
+
+ if (!TestBit(EV_REL, pEvdev->bitmask))
+ return !Success;
- if (!InitValuatorClassDeviceStruct(device, 2,
+ num_axes = CountBits(pEvdev->rel_bitmask, NLONGS(REL_MAX));
+ if (num_axes < 1)
+ return !Success;
+
+ pEvdev->num_vals = num_axes;
+ memset(pEvdev->vals, 0, num_axes * sizeof(int));
+
+ if (!InitValuatorClassDeviceStruct(device, num_axes,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3
GetMotionHistory,
#endif
GetMotionHistorySize(), Relative))
return !Success;
- /* X valuator */
- xf86InitValuatorAxisStruct(device, 0, -1, -1, 1, 0, 1);
- xf86InitValuatorDefaults(device, 0);
+ for (axis = REL_X; axis <= REL_MAX; axis++)
+ {
+ pEvdev->axis_map[axis] = -1;
+ if (!TestBit(axis, pEvdev->rel_bitmask))
+ continue;
+ pEvdev->axis_map[axis] = i;
+ xf86InitValuatorAxisStruct(device, i, -1, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(device, i);
+ i++;
+ }
- /* Y valuator */
- xf86InitValuatorAxisStruct(device, 1, -1, -1, 1, 0, 1);
- xf86InitValuatorDefaults(device, 1);
xf86MotionHistoryAllocate(pInfo);
if (!InitPtrFeedbackClassDeviceStruct(device, EvdevPtrCtrlProc))