summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-11-18 15:41:17 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-11-19 14:40:58 +1000
commitd9c212d2665f2b8c25e5a4cdba29a047bd87d7cd (patch)
treede1e9ecf3acf8e8c7983dca9a363e7494fd38064 /src
parentd48f437aa9d3f3afaa19bd51d15c3f915e1a1fa0 (diff)
Init the right number of buttons for pointer devices
This only makes room for the highest button number present on the device, it doesn't cater for devices with 'holes'. i.e. if a device has only BTN_BACK, it will initialize buttons for all below too. Which is also evdev's current behavior. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/libinput.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libinput.c b/src/libinput.c
index d938a15..91211ca 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -246,11 +246,19 @@ xf86libinput_init_pointer(InputInfoPtr pInfo)
struct xf86libinput *driver_data = pInfo->private;
int min, max, res;
int nbuttons = 7;
+ int i;
unsigned char btnmap[MAX_BUTTONS + 1];
Atom btnlabels[MAX_BUTTONS];
Atom axislabels[TOUCHPAD_NUM_AXES];
+ for (i = BTN_BACK; i >= BTN_SIDE; i--) {
+ if (libinput_device_has_button(driver_data->device, i)) {
+ nbuttons += i - BTN_SIDE + 1;
+ break;
+ }
+ }
+
init_button_map(btnmap, ARRAY_SIZE(btnmap));
init_button_labels(btnlabels, ARRAY_SIZE(btnlabels));
init_axis_labels(axislabels, ARRAY_SIZE(axislabels));