summaryrefslogtreecommitdiff
path: root/tools/libinput-record.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-03-08 09:31:02 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-03-08 09:42:44 +1000
commite9e134a18d46da20ddf835efe3df1dab2b29e9f1 (patch)
treee01ea4f563ea4bc706d571839d1242ee746f10ba /tools/libinput-record.c
parentcd96646039822324a2a736c2531c7c678bcd3012 (diff)
tools: record udev properties in libinput-record
Only the ones we care about in libinput but for those it's handy to know which ones are set (especially the LIBINPUT_MODEL ones). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools/libinput-record.c')
-rw-r--r--tools/libinput-record.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/libinput-record.c b/tools/libinput-record.c
index aaaa6cae..b0f11e8b 100644
--- a/tools/libinput-record.c
+++ b/tools/libinput-record.c
@@ -26,13 +26,16 @@
#include <errno.h>
#include <linux/input.h>
#include <libevdev/libevdev.h>
+#include <libudev.h>
#include <sys/signalfd.h>
#include <sys/utsname.h>
+#include <sys/stat.h>
#include <string.h>
#include <dirent.h>
#include <fcntl.h>
#include <getopt.h>
#include <poll.h>
+#include <unistd.h>
#include <signal.h>
#include <stdbool.h>
@@ -552,11 +555,60 @@ print_evdev_description(struct record_context *ctx, struct record_device *dev)
}
static inline void
+print_udev_properties(struct record_context *ctx, struct record_device *dev)
+{
+ struct udev *udev = NULL;
+ struct udev_device *udev_device = NULL;
+ struct udev_list_entry *entry;
+ struct stat st;
+
+ if (stat(dev->devnode, &st) < 0)
+ return;
+
+ udev = udev_new();
+ if (!udev)
+ goto out;
+
+ udev_device = udev_device_new_from_devnum(udev, 'c', st.st_rdev);
+ if (!udev_device)
+ goto out;
+
+ iprintf(ctx, "udev:\n");
+ indent_push(ctx);
+
+ iprintf(ctx, "properties:\n");
+ indent_push(ctx);
+
+ entry = udev_device_get_properties_list_entry(udev_device);
+ while (entry) {
+ const char *key, *value;
+
+ key = udev_list_entry_get_name(entry);
+
+ if (strneq(key, "ID_INPUT", 8) ||
+ strneq(key, "LIBINPUT", 8) ||
+ strneq(key, "EV_ABS", 6)) {
+ value = udev_list_entry_get_value(entry);
+ iprintf(ctx, "- %s=%s\n", key, value);
+ }
+
+ entry = udev_list_entry_get_next(entry);
+ }
+
+ indent_pop(ctx);
+ indent_pop(ctx);
+out:
+ udev_device_unref(udev_device);
+ udev_unref(udev);
+}
+
+static inline void
print_device_description(struct record_context *ctx, struct record_device *dev)
{
iprintf(ctx, "- node: %s\n", dev->devnode);
print_evdev_description(ctx, dev);
+ print_udev_properties(ctx, dev);
}
static int is_event_node(const struct dirent *dir) {