diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-02-17 14:53:51 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-02-17 14:54:17 +1000 |
commit | 9620fe7765b340213a552b5656d9d10bbbefd4cb (patch) | |
tree | 84709a8ef8119d4a7f9f8b20bcacea9c93d90097 /src | |
parent | a1714cac5242e5f8320ed7212efca481351355a2 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/evdev.c | 31 |
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)) |