[PATCH libinput 9/9] Add libinput_device_get_name() to advertise the kernel name

Peter Hutterer peter.hutterer at who-t.net
Thu Mar 27 21:38:52 PDT 2014


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
I didn't end up needing this but it seems a nice to have. However, it does
lead to a discussion on how much of the device should we expose to the
caller through libinput.

Right now libinput hides virtually everthing but the sysname and even that
may not be enough to even get a udev reference. It is enough for now though
because we only handle one subsystem.

If a caller needs settings or get other information on the device, they need
to be able to query udev or the fd, but the latter then needs 
needs open_restricted-like hooks.

 src/libinput.c      |  6 ++++++
 src/libinput.h      | 12 ++++++++++++
 tools/event-debug.c |  5 +++--
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/libinput.c b/src/libinput.c
index 1e31be3..2863f1d 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -1043,6 +1043,12 @@ libinput_device_get_user_data(struct libinput_device *device)
 }
 
 LIBINPUT_EXPORT const char *
+libinput_device_get_name(struct libinput_device *device)
+{
+	return ((struct evdev_device *) device)->devname;
+}
+
+LIBINPUT_EXPORT const char *
 libinput_device_get_sysname(struct libinput_device *device)
 {
 	return evdev_device_get_sysname((struct evdev_device *) device);
diff --git a/src/libinput.h b/src/libinput.h
index 6e43181..f291ce8 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -1158,6 +1158,18 @@ libinput_device_get_user_data(struct libinput_device *device);
 /**
  * @ingroup device
  *
+ * Get the name of the device.
+ *
+ * @param device A previously obtained device
+ * @return The product name of the device
+ *
+ */
+const char*
+libinput_device_get_name(struct libinput_device *device);
+
+/**
+ * @ingroup device
+ *
  * Get the system name of the device.
  *
  * @param device A previously obtained device
diff --git a/tools/event-debug.c b/tools/event-debug.c
index c0a08a7..3d0a383 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -231,9 +231,10 @@ print_device_notify(struct libinput_event *ev)
 	struct libinput_device *dev = libinput_event_get_device(ev);
 	struct libinput_seat *seat = libinput_device_get_seat(dev);
 
-	printf("%s	%s\n",
+	printf("%s	%s	%s\n",
 	       libinput_seat_get_physical_name(seat),
-	       libinput_seat_get_logical_name(seat));
+	       libinput_seat_get_logical_name(seat),
+	       libinput_device_get_name(dev));
 }
 
 static void
-- 
1.8.5.3



More information about the wayland-devel mailing list