On Sun, Apr 3, 2011 at 6:35 PM, Peter Hutterer <peter.hutte...@who-t.net>wrote:

>  >
> > What information can the user use for Uniq to associate the devices,
> which
> > we do not have in the driver? Both devices have the same product ID and
> > name.
>
> I only have one Bamboo, but the test code below gives me the right answer.
> argv[1,2] are the two device nodes (/dev/input/eventX and
> /dev/input/eventY).
>
> static struct udev_device *udev_from_file(struct udev *udev, const char
> *filename)
> {
>    struct stat st;
>    stat(filename, &st);
>    return udev_device_new_from_devnum(udev, 'c', st.st_rdev);
> }
>
> int main(int argc, char** argv)
> {
>    int rc = 1;
>    struct udev *udev = NULL;
>    struct udev_device *dev1, *dev2 = NULL;
>    struct udev_device *parent1, *parent2;
>    const char *syspath1, *syspath2;
>
>    if (argc < 3)
>        goto out;
>
>    udev = udev_new();
>    dev1 = udev_from_file(udev, argv[1]);
>    dev2 = udev_from_file(udev, argv[2]);
>
>    if (!dev1 || !dev2)
>        goto out;
>
>    parent1 = udev_device_get_parent_with_subsystem_devtype(dev1, "usb",
> "usb_device");
>    parent2 = udev_device_get_parent_with_subsystem_devtype(dev2, "usb",
> "usb_device");
>
>    syspath1 = udev_device_get_syspath(parent1);
>    syspath2 = udev_device_get_syspath(parent2);
>


This looks very promising. So, we do not need anything from the user.
Everything could be done inside the driver. Are you going to make a patch?

Thank you for the info.

Ping


>   if (strcmp(syspath1, syspath2) == 0)
>        printf("Yep, they're the same physical device\n");
>    else
>        printf("Nope, different devices\n");
>
> out:
>    udev_device_unref(dev1);
>    udev_device_unref(dev2);
>    udev_unref(udev);
>    return rc;
> }
>
> Cheers,
>  Peter
>
------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to