summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-02-27 11:20:14 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-04-24 10:27:32 +1000
commit555ee1a9898d4c19d138b9a5fe77138abfe47283 (patch)
tree9d4dfe73d5d8e177682acbdff9ffc971f96771ea /src
parent927ad51fad1ad25497d7a2cbc538fcff742d5a6c (diff)
evdev: improve default scroll button detection
Try to guess the default scroll buttons a bit better. Right now we default to scroll button 0 (disabled) whenever a device doesn't have a middle button but we might as well cast a wider net here as setting a scroll button only has a direct effect when button scrolling is enabled. Use the first extra button we find or fall back onto the right button if we don't have any extra buttons. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/evdev.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/evdev.c b/src/evdev.c
index 2d18bed..7fd8478 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1536,10 +1536,19 @@ static uint32_t
evdev_scroll_get_default_button(struct libinput_device *device)
{
struct evdev_device *evdev = evdev_device(device);
+ unsigned int code;
if (libevdev_has_event_code(evdev->evdev, EV_KEY, BTN_MIDDLE))
return BTN_MIDDLE;
+ for (code = BTN_SIDE; code <= BTN_TASK; code++) {
+ if (libevdev_has_event_code(evdev->evdev, EV_KEY, code))
+ return code;
+ }
+
+ if (libevdev_has_event_code(evdev->evdev, EV_KEY, BTN_RIGHT))
+ return BTN_RIGHT;
+
return 0;
}