diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-06-18 15:33:33 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-06-18 15:33:48 +1000 |
commit | 88eedea281a710008a82f1e6af4bdffd19477f46 (patch) | |
tree | 16834aceec9ab94d159cf31d26110fb942fce6b9 /src | |
parent | 9a5a4fed3acae87c89694a9ef8bf905ca0d6a6dd (diff) |
Cope with ABI_XINPUT_VERSION 7 - requires button + axes labels.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/evdev.c | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/src/evdev.c b/src/evdev.c index ed92ff0..7dc8eb4 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1000,6 +1000,7 @@ EvdevAddAbsClass(DeviceIntPtr device) InputInfoPtr pInfo; EvdevPtr pEvdev; int num_axes, axis, i = 0; + Atom *atoms; pInfo = device->public.devicePrivate; pEvdev = pInfo->private; @@ -1013,8 +1014,14 @@ EvdevAddAbsClass(DeviceIntPtr device) pEvdev->num_vals = num_axes; memset(pEvdev->vals, 0, num_axes * sizeof(int)); memset(pEvdev->old_vals, -1, num_axes * sizeof(int)); + atoms = xalloc(pEvdev->num_vals * sizeof(Atom)); + + EvdevInitAxesLabels(pEvdev, pEvdev->num_vals, atoms); if (!InitValuatorClassDeviceStruct(device, num_axes, +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 + atoms, +#endif #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3 GetMotionHistory, #endif @@ -1026,7 +1033,7 @@ EvdevAddAbsClass(DeviceIntPtr device) if (!TestBit(axis, pEvdev->abs_bitmask)) continue; pEvdev->axis_map[axis] = i; - xf86InitValuatorAxisStruct(device, i, + xf86InitValuatorAxisStruct(device, i, atoms[axis], pEvdev->absinfo[axis].minimum, pEvdev->absinfo[axis].maximum, 10000, 0, 10000); @@ -1035,6 +1042,8 @@ EvdevAddAbsClass(DeviceIntPtr device) i++; } + xfree(atoms); + if (!InitPtrFeedbackClassDeviceStruct(device, EvdevPtrCtrlProc)) return !Success; @@ -1063,6 +1072,7 @@ EvdevAddRelClass(DeviceIntPtr device) InputInfoPtr pInfo; EvdevPtr pEvdev; int num_axes, axis, i = 0; + Atom *atoms; pInfo = device->public.devicePrivate; pEvdev = pInfo->private; @@ -1085,8 +1095,26 @@ EvdevAddRelClass(DeviceIntPtr device) pEvdev->num_vals = num_axes; memset(pEvdev->vals, 0, num_axes * sizeof(int)); + atoms = xalloc(pEvdev->num_vals * sizeof(Atom)); + + for (axis = REL_X; axis <= REL_MAX; axis++) + { + pEvdev->axis_map[axis] = -1; + /* We don't post wheel events, so ignore them here too */ + if (axis == REL_WHEEL || axis == REL_HWHEEL || axis == REL_DIAL) + continue; + if (!TestBit(axis, pEvdev->rel_bitmask)) + continue; + pEvdev->axis_map[axis] = i; + i++; + } + + EvdevInitAxesLabels(pEvdev, pEvdev->num_vals, atoms); if (!InitValuatorClassDeviceStruct(device, num_axes, +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 + atoms, +#endif #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3 GetMotionHistory, #endif @@ -1095,19 +1123,16 @@ EvdevAddRelClass(DeviceIntPtr device) for (axis = REL_X; axis <= REL_MAX; axis++) { + int axnum = pEvdev->axis_map[axis]; - pEvdev->axis_map[axis] = -1; - /* We don't post wheel events, so ignore them here too */ - if (axis == REL_WHEEL || axis == REL_HWHEEL || axis == REL_DIAL) + if (axnum == -1) continue; - if (!TestBit(axis, pEvdev->rel_bitmask)) - continue; - pEvdev->axis_map[axis] = i; - xf86InitValuatorAxisStruct(device, i, -1, -1, 1, 0, 1); - xf86InitValuatorDefaults(device, i); - i++; + xf86InitValuatorAxisStruct(device, axnum, atoms[axnum], -1, -1, 1, 0, 1); + xf86InitValuatorDefaults(device, axnum); } + xfree(atoms); + if (!InitPtrFeedbackClassDeviceStruct(device, EvdevPtrCtrlProc)) return !Success; @@ -1121,13 +1146,18 @@ EvdevAddButtonClass(DeviceIntPtr device) { InputInfoPtr pInfo; EvdevPtr pEvdev; + Atom *labels; pInfo = device->public.devicePrivate; pEvdev = pInfo->private; - if (!InitButtonClassDeviceStruct(device, pEvdev->num_buttons, pEvdev->btnmap)) + labels = xalloc(pEvdev->num_buttons * sizeof(Atom)); + EvdevInitButtonLabels(pEvdev, pEvdev->num_buttons, labels); + + if (!InitButtonClassDeviceStruct(device, pEvdev->num_buttons, labels, pEvdev->btnmap)) return !Success; + xfree(labels); return Success; } |