diff options
author | Hans de Goede <hdegoede@redhat.com> | 2014-11-06 12:47:51 +0100 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2014-11-11 12:08:59 +1000 |
commit | 2ca425dc287171c001c3a58544d0e014346176a4 (patch) | |
tree | a1c8e84317d29cba9f2cc5c2aabd4195bfe5d6b6 /src | |
parent | 71f703c50cbd894d42e10dfbed2cb370b7928ef2 (diff) | |
download | libinput-2ca425dc287171c001c3a58544d0e014346176a4.tar.gz |
evdev: Add evdev_any_button_down helper function
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/evdev.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/evdev.c b/src/evdev.c index 146c1b70..14da3690 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -571,6 +571,19 @@ evdev_process_absolute(struct evdev_device *device, } static inline bool +evdev_any_button_down(struct evdev_device *device) +{ + unsigned int button; + + for (button = BTN_LEFT; button < BTN_JOYSTICK; button++) { + if (libevdev_has_event_code(device->evdev, EV_KEY, button) && + hw_is_key_down(device, button)) + return true; + } + return false; +} + +static inline bool evdev_need_touch_frame(struct evdev_device *device) { if (!(device->seat_caps & EVDEV_DEVICE_TOUCH)) @@ -763,16 +776,11 @@ evdev_left_handed_has(struct libinput_device *device) static void evdev_change_to_left_handed(struct evdev_device *device) { - unsigned int button; - if (device->buttons.want_left_handed == device->buttons.left_handed) return; - for (button = BTN_LEFT; button < BTN_JOYSTICK; button++) { - if (libevdev_has_event_code(device->evdev, EV_KEY, button) && - hw_is_key_down(device, button)) - return; - } + if (evdev_any_button_down(device)) + return; device->buttons.left_handed = device->buttons.want_left_handed; } |