+ /* get the device */
+ udev = udev_new();
+ if (udev == NULL)
+ return 1;
+
+ snprintf(devpath, sizeof(devpath), "%s/%s", udev_get_sys_path(udev), argv[1]);
+ dev = udev_device_new_from_syspath(udev, devpath);
+ if (dev == NULL) {
+ fprintf(stderr, "unable to access '%s'\n", devpath);
+ return 1;
+ }
+
+ /* walk up the parental chain until we find the real input device; the
+ * argument is very likely a subdevice of this, like eventN */
+ while (dev != NULL && udev_device_get_sysattr_value(dev, "capabilities/ev") == NULL)
+ dev = udev_device_get_parent_with_subsystem_devtype(dev, "input", NULL);
+
+ /* not an "input" class device */
+ if (dev == NULL)
+ return 0;
+