diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-02-17 15:08:03 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-02-17 15:24:57 +1000 |
commit | acb1d557e216d7fa58ef8dbf3182e6604888ae2a (patch) | |
tree | 390976a163fe89126163778f4555b13c0a69756c | |
parent | Remove superfluous (and duplicate) call to xf86MotionHistoryAllocate. (diff) | |
download | xf86-input-evdev-acb1d557e216d7fa58ef8dbf3182e6604888ae2a.tar.gz xf86-input-evdev-acb1d557e216d7fa58ef8dbf3182e6604888ae2a.tar.bz2 xf86-input-evdev-acb1d557e216d7fa58ef8dbf3182e6604888ae2a.zip |
Add support for arbitrary relative axis labels.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/evdev.c | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/src/evdev.c b/src/evdev.c index ca6aa49..caac640 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1685,7 +1685,7 @@ EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code) #ifdef HAVE_PROPERTIES /* Aligned with linux/input.h */ -static char* labels[] = { +static char* abs_labels[] = { AXIS_LABEL_PROP_ABS_X, AXIS_LABEL_PROP_ABS_Y, AXIS_LABEL_PROP_ABS_Z, @@ -1714,6 +1714,20 @@ static char* labels[] = { AXIS_LABEL_PROP_ABS_MISC }; +static char* rel_labels[] = { + AXIS_LABEL_PROP_REL_X, + AXIS_LABEL_PROP_REL_Y, + AXIS_LABEL_PROP_REL_Z, + AXIS_LABEL_PROP_REL_RX, + AXIS_LABEL_PROP_REL_RY, + AXIS_LABEL_PROP_REL_RZ, + AXIS_LABEL_PROP_REL_HWHEEL, + AXIS_LABEL_PROP_REL_DIAL, + AXIS_LABEL_PROP_REL_WHEEL, + AXIS_LABEL_PROP_REL_MISC +}; + + static void EvdevInitProperty(DeviceIntPtr dev) { @@ -1769,21 +1783,41 @@ EvdevInitProperty(DeviceIntPtr dev) XISetDevicePropertyDeletable(dev, prop_swap, FALSE); /* Axis labelling */ - if ((pEvdev->flags & EVDEV_ABSOLUTE_EVENTS) && - (prop_label = XIGetKnownProperty(AXIS_LABEL_PROP))) + if ((prop_label = XIGetKnownProperty(AXIS_LABEL_PROP))) { Atom atom, atoms[pEvdev->num_vals]; int natoms = pEvdev->num_vals; int axis; + char **labels; + int labels_len = 0; + char *misc_label; + + if (pEvdev->flags & EVDEV_RELATIVE_EVENTS) + { + labels = rel_labels; + labels_len = ArrayLength(rel_labels); + misc_label = AXIS_LABEL_PROP_REL_MISC; + } else if ((pEvdev->flags & EVDEV_ABSOLUTE_EVENTS)) + { + labels = abs_labels; + labels_len = ArrayLength(abs_labels); + misc_label = AXIS_LABEL_PROP_ABS_MISC; + } + + /* First, make sure all atoms are initialized */ + atom = XIGetKnownProperty(misc_label); + for (axis = 0; axis < pEvdev->num_vals; axis++) + atoms[axis] = atom; - for (axis = ABS_X; axis < ArrayLength(labels); axis++) + /* Now fill the ones we know */ + for (axis = 0; axis < labels_len; axis++) { if (pEvdev->axis_map[axis] == -1) continue; atom = XIGetKnownProperty(labels[axis]); if (!atom) /* Should not happen */ - atom = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MISC); + atom = XIGetKnownProperty(misc_label); atoms[pEvdev->axis_map[axis]] = atom; } |