diff options
Diffstat (limited to 'rcm-server-main.c')
-rw-r--r-- | rcm-server-main.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/rcm-server-main.c b/rcm-server-main.c index cde13a0..5d9cb20 100644 --- a/rcm-server-main.c +++ b/rcm-server-main.c @@ -699,6 +699,9 @@ add_device(struct manager *mgr, struct udev_device *udev) const char *str; char *path; struct device *device; + struct udev_enumerate *enumerate; + struct udev_list_entry *devices, *dev_list_entry; + struct udev_device *evdev; name = udev_device_get_sysname(udev); if (asprintf(&path, "/org/gnome/RemoteControlManager/%s", name) < 0) { @@ -716,12 +719,49 @@ add_device(struct manager *mgr, struct udev_device *udev) list_init(&device->keymaps); device->path = path; device->name = device->path + strlen("/org/gnome/RemoteControlManager/"); + device->devnode = NULL; if (keymaps_load(device) < 0) { fprintf(stderr, "failed to load keymaps: %m\n"); free(path); free(device); + return; + } + + enumerate = udev_enumerate_new(mgr->udev); + udev_enumerate_add_match_parent(enumerate, udev); + udev_enumerate_add_match_sysname(enumerate, "event*"); + udev_enumerate_scan_devices(enumerate); + devices = udev_enumerate_get_list_entry(enumerate); + + udev_list_entry_foreach(dev_list_entry, devices) { + const char *path; + const char *devnode; + + path = udev_list_entry_get_name(dev_list_entry); + if (!path) { + printf("Failed to get udev name\n"); + continue; + } + + evdev = udev_device_new_from_syspath(mgr->udev, path); + if (!evdev) { + printf("Failed to create udev device\n"); + continue; + } + + devnode = udev_device_get_devnode(evdev); + if (devnode && !device->devnode) { + device->devnode = strdup(devnode); + if (!device->devnode) + printf("Failed to strdup devnode\n"); + else + printf("Devnode is %s\n", device->devnode); + } + + udev_device_unref(evdev); } + udev_enumerate_unref(enumerate); str = udev_device_get_sysattr_value(udev, "uevent"); if (str) { @@ -748,6 +788,7 @@ add_device(struct manager *mgr, struct udev_device *udev) printf("\tAction : %s\n", udev_device_get_action(udev)); printf("\tDriver : %s\n", device->driver_name); printf("\tKernel map: %s\n", device->keymap_name); + printf("\tDevnode : %s\n", device->devnode); printf("\tProtocols : %s\n", udev_device_get_sysattr_value(udev, "protocols")); |