config/udev: Add verbose info when fetching udev properties
Give the user a chance to see why their input devices are being ignored, even if they have to start the server with -logverbose. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
94547b2d14
commit
697c5b010d
|
@ -37,6 +37,17 @@
|
|||
|
||||
#define UDEV_XKB_PROP_KEY "xkb"
|
||||
|
||||
#define LOG_PROPERTY(path, prop, val) \
|
||||
LogMessageVerb(X_INFO, 10, \
|
||||
"config/udev: getting property %s on %s " \
|
||||
"returned \"%s\"\n", \
|
||||
(prop), (path), (val) ? (val) : "(null)")
|
||||
#define LOG_SYSATTR(path, attr, val) \
|
||||
LogMessageVerb(X_INFO, 10, \
|
||||
"config/udev: getting attribute %s on %s " \
|
||||
"returned \"%s\"\n", \
|
||||
(attr), (path), (val) ? (val) : "(null)")
|
||||
|
||||
static struct udev_monitor *udev_monitor;
|
||||
|
||||
static void
|
||||
|
@ -45,6 +56,7 @@ device_added(struct udev_device *udev_device)
|
|||
const char *path, *name = NULL;
|
||||
char *config_info = NULL;
|
||||
const char *syspath;
|
||||
const char *tags_prop;
|
||||
const char *key, *value, *tmp;
|
||||
InputOption *options = NULL, *tmpo;
|
||||
InputAttributes attrs = {};
|
||||
|
@ -60,8 +72,13 @@ device_added(struct udev_device *udev_device)
|
|||
if (!path || !syspath)
|
||||
return;
|
||||
|
||||
if (!udev_device_get_property_value(udev_device, "ID_INPUT"))
|
||||
if (!udev_device_get_property_value(udev_device, "ID_INPUT")) {
|
||||
LogMessageVerb(X_INFO, 10,
|
||||
"config/udev: ignoring device %s without "
|
||||
"property ID_INPUT set\n",
|
||||
path);
|
||||
return;
|
||||
}
|
||||
|
||||
options = calloc(sizeof(*options), 1);
|
||||
if (!options)
|
||||
|
@ -74,9 +91,14 @@ device_added(struct udev_device *udev_device)
|
|||
|
||||
parent = udev_device_get_parent(udev_device);
|
||||
if (parent) {
|
||||
const char *ppath = udev_device_get_devnode(parent);
|
||||
|
||||
name = udev_device_get_sysattr_value(parent, "name");
|
||||
if (!name)
|
||||
LOG_SYSATTR(ppath, "name", name);
|
||||
if (!name) {
|
||||
name = udev_device_get_property_value(parent, "NAME");
|
||||
LOG_PROPERTY(ppath, "NAME", name);
|
||||
}
|
||||
}
|
||||
if (!name)
|
||||
name = "(unnamed)";
|
||||
|
@ -87,7 +109,10 @@ device_added(struct udev_device *udev_device)
|
|||
add_option(&options, "path", path);
|
||||
add_option(&options, "device", path);
|
||||
attrs.device = path;
|
||||
attrs.tags = xstrtokenize(udev_device_get_property_value(udev_device, "ID_INPUT.tags"), ",");
|
||||
|
||||
tags_prop = udev_device_get_property_value(udev_device, "ID_INPUT.tags");
|
||||
LOG_PROPERTY(path, "ID_INPUT.tags", tags_prop);
|
||||
attrs.tags = xstrtokenize(tags_prop, ",");
|
||||
|
||||
config_info = Xprintf("udev:%s", syspath);
|
||||
if (!config_info)
|
||||
|
@ -107,6 +132,7 @@ device_added(struct udev_device *udev_device)
|
|||
value = udev_list_entry_get_value(entry);
|
||||
if (!strncasecmp(key, UDEV_XKB_PROP_KEY,
|
||||
sizeof(UDEV_XKB_PROP_KEY) - 1)) {
|
||||
LOG_PROPERTY(path, key, value);
|
||||
tmp = key + sizeof(UDEV_XKB_PROP_KEY) - 1;
|
||||
if (!strcasecmp(tmp, "rules"))
|
||||
add_option(&options, "xkb_rules", value);
|
||||
|
@ -119,18 +145,25 @@ device_added(struct udev_device *udev_device)
|
|||
else if (!strcasecmp(tmp, "options"))
|
||||
add_option(&options, "xkb_options", value);
|
||||
} else if (!strcmp(key, "ID_VENDOR")) {
|
||||
LOG_PROPERTY(path, key, value);
|
||||
attrs.vendor = value;
|
||||
} else if (!strcmp(key, "ID_INPUT_KEY")) {
|
||||
LOG_PROPERTY(path, key, value);
|
||||
attrs.flags |= ATTR_KEYBOARD;
|
||||
} else if (!strcmp(key, "ID_INPUT_MOUSE")) {
|
||||
LOG_PROPERTY(path, key, value);
|
||||
attrs.flags |= ATTR_POINTER;
|
||||
} else if (!strcmp(key, "ID_INPUT_JOYSTICK")) {
|
||||
LOG_PROPERTY(path, key, value);
|
||||
attrs.flags |= ATTR_JOYSTICK;
|
||||
} else if (!strcmp(key, "ID_INPUT_TABLET")) {
|
||||
LOG_PROPERTY(path, key, value);
|
||||
attrs.flags |= ATTR_TABLET;
|
||||
} else if (!strcmp(key, "ID_INPUT_TOUCHPAD")) {
|
||||
LOG_PROPERTY(path, key, value);
|
||||
attrs.flags |= ATTR_TOUCHPAD;
|
||||
} else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")) {
|
||||
LOG_PROPERTY(path, key, value);
|
||||
attrs.flags |= ATTR_TOUCHSCREEN;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user