mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 22:10:25 +01:00
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>
This commit is contained in:
parent
927ad51fad
commit
555ee1a989
2 changed files with 13 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1176,11 +1176,15 @@ START_TEST(pointer_scroll_defaults_logitech_marble)
|
|||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput_device *device = dev->libinput_device;
|
||||
enum libinput_config_scroll_method method;
|
||||
uint32_t button;
|
||||
|
||||
method = libinput_device_config_scroll_get_method(device);
|
||||
ck_assert_int_eq(method, LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
|
||||
method = libinput_device_config_scroll_get_default_method(device);
|
||||
ck_assert_int_eq(method, LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
|
||||
|
||||
button = libinput_device_config_scroll_get_button(device);
|
||||
ck_assert_int_eq(button, BTN_SIDE);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue