summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Cristau <jcristau@debian.org>2009-12-23 18:44:08 +0100
committerJulien Cristau <jcristau@debian.org>2009-12-23 19:08:51 +0100
commit3decf4b2be56db837dd1b35a338b3db21372c968 (patch)
tree6fcdda6a5ecfdbf95f8ea6bac73a144a930e284b
parent387e1c169d138ee1605f3d6bea79688533ba9277 (diff)
config/udev: fill in InputAttributes
Requires udev 148 for the input_id helper and ID_INPUT* properties. Signed-off-by: Julien Cristau <jcristau@debian.org>
-rw-r--r--config/udev.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/config/udev.c b/config/udev.c
index 1a1c0df16..1c84f2bc4 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -47,6 +47,7 @@ device_added(struct udev_device *udev_device)
const char *syspath;
const char *key, *value, *tmp;
InputOption *options = NULL, *tmpo;
+ InputAttributes attrs = {};
DeviceIntPtr dev = NULL;
struct udev_list_entry *set, *entry;
struct udev_device *parent;
@@ -56,14 +57,12 @@ device_added(struct udev_device *udev_device)
syspath = udev_device_get_syspath(udev_device);
- parent = udev_device_get_parent(udev_device);
- if (parent)
- name = udev_device_get_property_value(parent, "NAME");
- if (!name)
- name = "(unnamed)";
-
if (!path || !syspath)
return;
+
+ if (!udev_device_get_property_value(udev_device, "ID_INPUT"))
+ return;
+
options = xcalloc(sizeof(*options), 1);
if (!options)
return;
@@ -73,8 +72,18 @@ device_added(struct udev_device *udev_device)
if (!options->key || !options->value)
goto unwind;
+ parent = udev_device_get_parent(udev_device);
+ if (parent)
+ name = udev_device_get_property_value(parent, "NAME");
+ if (!name)
+ name = "(unnamed)";
+ else
+ attrs.product = xstrdup(name);
+ add_option(&options, "name", name);
+
add_option(&options, "path", path);
add_option(&options, "device", path);
+ attrs.device = xstrdup(path);
config_info = Xprintf("udev:%s", syspath);
if (!config_info)
@@ -91,10 +100,10 @@ device_added(struct udev_device *udev_device)
key = udev_list_entry_get_name(entry);
if (!key)
continue;
+ value = udev_list_entry_get_value(entry);
if (!strncasecmp(key, UDEV_XKB_PROP_KEY,
sizeof(UDEV_XKB_PROP_KEY) - 1)) {
tmp = key + sizeof(UDEV_XKB_PROP_KEY) - 1;
- value = udev_list_entry_get_value(entry);
if (!strcasecmp(tmp, "rules"))
add_option(&options, "xkb_rules", value);
else if (!strcasecmp(tmp, "layout"))
@@ -105,12 +114,25 @@ device_added(struct udev_device *udev_device)
add_option(&options, "xkb_model", value);
else if (!strcasecmp(tmp, "options"))
add_option(&options, "xkb_options", value);
+ } else if (!strcmp(key, "ID_VENDOR")) {
+ attrs.vendor = xstrdup(value);
+ } else if (!strcmp(key, "ID_INPUT_KEY")) {
+ attrs.flags |= ATTR_KEYBOARD;
+ } else if (!strcmp(key, "ID_INPUT_MOUSE")) {
+ attrs.flags |= ATTR_POINTER;
+ } else if (!strcmp(key, "ID_INPUT_JOYSTICK")) {
+ attrs.flags |= ATTR_JOYSTICK;
+ } else if (!strcmp(key, "ID_INPUT_TABLET")) {
+ attrs.flags |= ATTR_TABLET;
+ } else if (!strcmp(key, "ID_INPUT_TOUCHPAD")) {
+ attrs.flags |= ATTR_TOUCHPAD;
+ } else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")) {
+ attrs.flags |= ATTR_TOUCHSCREEN;
}
}
- add_option(&options, "name", name);
LogMessage(X_INFO, "config/udev: Adding input device %s (%s)\n",
name, path);
- rc = NewInputDeviceRequest(options, NULL, &dev);
+ rc = NewInputDeviceRequest(options, &attrs, &dev);
if (rc != Success)
goto unwind;