From 9620fe7765b340213a552b5656d9d10bbbefd4cb Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 17 Feb 2009 14:53:51 +1000 Subject: 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 --- src/evdev.c | 31 ++++++++++++++++++++++++------- 1 file 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)) -- cgit v1.2.1