[PATCH 1/2 weston] evdev: Only use device as pointer if EV_REL and EV_KEY are set.

Scott Moreau oreaus at gmail.com
Mon Aug 6 00:27:07 PDT 2012


A standard mouse should not have EV_ABS as part of its capabilities, however it
should have both EV_REL and EV_KEY. This attempts to avoid erroneously detecting
devices as pointers, such as joysticks for example.
---
 src/evdev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 7d93564..c08a4ae 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -372,7 +372,7 @@ evdev_configure_device(struct evdev_input_device *device)
 	unsigned long rel_bits[NBITS(REL_MAX)];
 	unsigned long key_bits[NBITS(KEY_MAX)];
 	int has_key, has_abs;
-	unsigned int i;
+	unsigned int i, pointer_caps_mask;
 
 	has_key = 0;
 	has_abs = 0;
@@ -453,8 +453,9 @@ evdev_configure_device(struct evdev_input_device *device)
 		return -1;
 	}
 
-	if ((device->caps &
-	     (EVDEV_MOTION_ABS | EVDEV_MOTION_REL | EVDEV_BUTTON))) {
+	pointer_caps_mask = (EVDEV_MOTION_REL | EVDEV_BUTTON);
+
+	if ((device->caps & pointer_caps_mask) == pointer_caps_mask) {
 		weston_seat_init_pointer(device->seat);
 		weston_log("input device %s, %s is a pointer\n",
 			   device->devname, device->devnode);
-- 
1.7.11.2



More information about the wayland-devel mailing list