summaryrefslogtreecommitdiff
path: root/config/hal.c
diff options
context:
space:
mode:
Diffstat (limited to 'config/hal.c')
-rw-r--r--config/hal.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/config/hal.c b/config/hal.c
index 5938d4e24..8f9aeb8d3 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -129,6 +129,7 @@ static void
device_added(LibHalContext *hal_ctx, const char *udi)
{
char *path = NULL, *driver = NULL, *name = NULL, *config_info = NULL;
+ char *hal_tags, *parent;
InputOption *options = NULL, *tmpo = NULL;
InputAttributes attrs = {0};
DeviceIntPtr dev = NULL;
@@ -164,7 +165,9 @@ device_added(LibHalContext *hal_ctx, const char *udi)
attrs.product = xstrdup(name);
attrs.vendor = get_prop_string(hal_ctx, udi, "info.vendor");
- attrs.tags = xstrtokenize(get_prop_string(hal_ctx, udi, "input.tags"), ",");
+ hal_tags = get_prop_string(hal_ctx, udi, "input.tags");
+ attrs.tags = xstrtokenize(hal_tags, ",");
+ free(hal_tags);
if (libhal_device_query_capability(hal_ctx, udi, "input.keys", NULL))
attrs.flags |= ATTR_KEYBOARD;
@@ -179,6 +182,29 @@ device_added(LibHalContext *hal_ctx, const char *udi)
if (libhal_device_query_capability(hal_ctx, udi, "input.touchscreen", NULL))
attrs.flags |= ATTR_TOUCHSCREEN;
+ parent = get_prop_string(hal_ctx, udi, "info.parent");
+ if (parent) {
+ int usb_vendor, usb_product;
+
+ attrs.pnp_id = get_prop_string(hal_ctx, parent, "pnp.id");
+
+ /* construct USB ID in lowercase - "0000:ffff" */
+ usb_vendor = libhal_device_get_property_int(hal_ctx, parent,
+ "usb.vendor_id", NULL);
+ LogMessageVerb(X_INFO, 10,
+ "config/hal: getting usb.vendor_id on %s "
+ "returned %04x\n", parent, usb_vendor);
+ usb_product = libhal_device_get_property_int(hal_ctx, parent,
+ "usb.product_id", NULL);
+ LogMessageVerb(X_INFO, 10,
+ "config/hal: getting usb.product_id on %s "
+ "returned %04x\n", parent, usb_product);
+ if (usb_vendor && usb_product)
+ attrs.usb_id = Xprintf("%04x:%04x", usb_vendor, usb_product);
+
+ free(parent);
+ }
+
options = calloc(sizeof(*options), 1);
if (!options){
LogMessage(X_ERROR, "config/hal: couldn't allocate space for input options!\n");
@@ -381,6 +407,8 @@ unwind:
free(attrs.product);
free(attrs.vendor);
free(attrs.device);
+ free(attrs.pnp_id);
+ free(attrs.usb_id);
if (attrs.tags) {
char **tag = attrs.tags;
while (*tag) {
@@ -619,7 +647,7 @@ config_hal_init(void)
}
/* verbose message */
- LogMessageVerb(X_INFO,7,"config/hal: initialized");
+ LogMessageVerb(X_INFO,7,"config/hal: initialized\n");
return 1;
}