diff options
Diffstat (limited to 'config/udev.c')
-rw-r--r-- | config/udev.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/config/udev.c b/config/udev.c index f7ed4b2de..16c462455 100644 --- a/config/udev.c +++ b/config/udev.c @@ -28,6 +28,7 @@ #endif #include <libudev.h> +#include <ctype.h> #include "input.h" #include "inputstr.h" @@ -57,6 +58,7 @@ device_added(struct udev_device *udev_device) char *config_info = NULL; const char *syspath; const char *tags_prop; + const char *usb_vendor = NULL, *usb_model = NULL; const char *key, *value, *tmp; InputOption *options = NULL, *tmpo; InputAttributes attrs = {}; @@ -150,6 +152,12 @@ device_added(struct udev_device *udev_device) } else if (!strcmp(key, "ID_VENDOR")) { LOG_PROPERTY(path, key, value); attrs.vendor = value; + } else if (!strcmp(key, "ID_VENDOR_ID")) { + LOG_PROPERTY(path, key, value); + usb_vendor = value; + } else if (!strcmp(key, "ID_VENDOR_MODEL")) { + LOG_PROPERTY(path, key, value); + usb_model = value; } else if (!strcmp(key, "ID_INPUT_KEY")) { LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_KEYBOARD; @@ -170,6 +178,17 @@ device_added(struct udev_device *udev_device) attrs.flags |= ATTR_TOUCHSCREEN; } } + + /* construct USB ID in lowercase hex - "0000:ffff" */ + if (usb_vendor && usb_model) { + attrs.usb_id = Xprintf("%s:%s", usb_vendor, usb_model); + if (attrs.usb_id) { + char *cur; + for (cur = attrs.usb_id; *cur; cur++) + *cur = tolower(*cur); + } + } + LogMessage(X_INFO, "config/udev: Adding input device %s (%s)\n", name, path); rc = NewInputDeviceRequest(options, &attrs, &dev); @@ -190,6 +209,7 @@ device_added(struct udev_device *udev_device) free(tmpo); } + free(attrs.usb_id); if (attrs.tags) { char **tag = attrs.tags; while (*tag) { |