diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-01-13 09:51:36 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-01-18 16:47:16 +1000 |
commit | 9d9c9870c88f2c636799a68cde8efcab59a4a2a5 (patch) | |
tree | 0688149f7fa1e68bda634d394a5915c323695956 | |
parent | 5c5b2c8db851df7921cedd888222a6630a007fd8 (diff) |
Prefere relative axis labelling over absolute axis labelling
If a device has both relative and absolute axes, we'd initialise the
relative axes but label them with the absolute labels.
The current code is broken for mixed mode devices. Most of these devices
operate primarily in relative mode, but have some absolute axes available
for secondary functionality. For now, label the relative axes properly. We
can fix the absolute axes later.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r-- | src/evdev.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/evdev.c b/src/evdev.c index effac40..1cdba41 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -117,13 +117,13 @@ static int EvdevCache(InputInfoPtr pInfo); static void EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl); static int EvdevSwitchMode(ClientPtr client, DeviceIntPtr device, int mode); static BOOL EvdevGrabDevice(InputInfoPtr pInfo, int grab, int ungrab); static void EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4]); static int EvdevOpenDevice(InputInfoPtr pInfo); -static void EvdevInitAxesLabels(EvdevPtr pEvdev, int natoms, Atom *atoms); +static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms); static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms); static void EvdevInitProperty(DeviceIntPtr dev); static int EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, BOOL checkonly); static Atom prop_product_id; static Atom prop_invert; @@ -1294,13 +1294,13 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device) #endif pEvdev->axis_map[axis] = mapping; if (mapping == i) i++; } - EvdevInitAxesLabels(pEvdev, pEvdev->num_vals + num_mt_axes, atoms); + EvdevInitAxesLabels(pEvdev, Absolute, pEvdev->num_vals + num_mt_axes, atoms); if (!InitValuatorClassDeviceStruct(device, num_axes + num_mt_axes, atoms, GetMotionHistorySize(), Absolute)) { xf86IDrvMsg(pInfo, X_ERROR, "failed to initialize valuator class device.\n"); goto out; } @@ -1493,13 +1493,13 @@ EvdevAddRelValuatorClass(DeviceIntPtr device) if (!EvdevBitIsSet(pEvdev->rel_bitmask, axis)) continue; pEvdev->axis_map[axis] = i; i++; } - EvdevInitAxesLabels(pEvdev, pEvdev->num_vals, atoms); + EvdevInitAxesLabels(pEvdev, Relative, pEvdev->num_vals, atoms); if (!InitValuatorClassDeviceStruct(device, num_axes, atoms, GetMotionHistorySize(), Relative)) { xf86IDrvMsg(pInfo, X_ERROR, "failed to initialize valuator class device.\n"); goto out; } @@ -2634,24 +2634,24 @@ static char* btn_labels[][16] = { { /* BTN_WHEEL group offset 0x150 */ BTN_LABEL_PROP_BTN_GEAR_DOWN, /* 0x00 */ BTN_LABEL_PROP_BTN_GEAR_UP /* 0x01 */ } }; -static void EvdevInitAxesLabels(EvdevPtr pEvdev, int natoms, Atom *atoms) +static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms) { Atom atom; int axis; char **labels; int labels_len = 0; - if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS) + if (mode == Absolute) { labels = abs_labels; labels_len = ArrayLength(abs_labels); - } else if ((pEvdev->flags & EVDEV_RELATIVE_EVENTS)) + } else if (mode == Relative) { labels = rel_labels; labels_len = ArrayLength(rel_labels); } else return; @@ -2807,14 +2807,25 @@ EvdevInitProperty(DeviceIntPtr dev) XISetDevicePropertyDeletable(dev, prop_swap, FALSE); /* Axis labelling */ if ((pEvdev->num_vals > 0) && (prop_axis_label = XIGetKnownProperty(AXIS_LABEL_PROP))) { + int mode; Atom atoms[pEvdev->num_vals]; - EvdevInitAxesLabels(pEvdev, pEvdev->num_vals, atoms); + + if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS) + mode = Absolute; + else if (pEvdev->flags & EVDEV_RELATIVE_EVENTS) + mode = Relative; + else { + xf86IDrvMsg(pInfo, X_ERROR, "BUG: mode is neither absolute nor relative\n"); + mode = Absolute; + } + + EvdevInitAxesLabels(pEvdev, mode, pEvdev->num_vals, atoms); XIChangeDeviceProperty(dev, prop_axis_label, XA_ATOM, 32, PropModeReplace, pEvdev->num_vals, atoms, FALSE); XISetDevicePropertyDeletable(dev, prop_axis_label, FALSE); } /* Button labelling */ if ((pEvdev->num_buttons > 0) && (prop_btn_label = XIGetKnownProperty(BTN_LABEL_PROP))) |