[PATCH libinput v2 04/11] evdev: Add evdev_any_button_down helper function

Hans de Goede hdegoede at redhat.com
Mon Nov 10 02:59:15 PST 2014


Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/evdev.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 9ce93fe..8ae2785 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -580,6 +580,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))
@@ -772,16 +785,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;
 }
-- 
2.1.0



More information about the wayland-devel mailing list