mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-03-22 05:40:39 +01:00
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>
This commit is contained in:
parent
71f703c50c
commit
2ca425dc28
1 changed files with 15 additions and 7 deletions
22
src/evdev.c
22
src/evdev.c
|
|
@ -570,6 +570,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)
|
||||
{
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue