[PATCH 2/3 weston] evdev: Ignore unknown devices.

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


If a device is not detected as a valid input device, ignore all events from it.
---
 src/compositor-drm.c |  1 -
 src/evdev.c          | 14 +++++++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 33bffae..084bebf 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1829,7 +1829,6 @@ device_added(struct udev_device *udev_device, struct drm_seat *master)
 	device = evdev_input_device_create(&master->base, devnode, fd);
 	if (!device) {
 		close(fd);
-		weston_log("not using input device '%s'.\n", devnode);
 		return;
 	}
 
diff --git a/src/evdev.c b/src/evdev.c
index c08a4ae..a0a162c 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -459,17 +459,21 @@ evdev_configure_device(struct evdev_input_device *device)
 		weston_seat_init_pointer(device->seat);
 		weston_log("input device %s, %s is a pointer\n",
 			   device->devname, device->devnode);
-	}
-	if ((device->caps & EVDEV_KEYBOARD)) {
+	} else if ((device->caps & EVDEV_KEYBOARD)) {
 		weston_seat_init_keyboard(device->seat, NULL);
 		weston_log("input device %s, %s is a keyboard\n",
 			   device->devname, device->devnode);
-	}
-	if ((device->caps & EVDEV_TOUCH)) {
+	} else if ((device->caps & EVDEV_TOUCH)) {
 		weston_seat_init_touch(device->seat);
 		weston_log("input device %s, %s is a touch device\n",
 			   device->devname, device->devnode);
-	}
+	} else if (has_abs || has_key || device->is_mt) {
+		weston_log("input device %s, %s "
+			   "ignored: unsupported device type\n",
+			   device->devname, device->devnode);
+		return -1;
+	} else
+		return -1;
 
 	return 0;
 }
-- 
1.7.11.2



More information about the wayland-devel mailing list