On Thu, Mar 31, 2011 at 11:13:36PM -0700, Ping Cheng wrote:
> On Thu, Mar 31, 2011 at 10:57 PM, Peter Hutterer
> <peter.hutte...@who-t.net>wrote:
> 
> > On Thu, Mar 31, 2011 at 10:37:54PM -0700, Ping Cheng wrote:
> > > On Thu, Mar 31, 2011 at 4:43 PM, Peter Hutterer <
> > peter.hutte...@who-t.net>wrote:
> > >
> > > >        /* FIXME: why strstr and not strcmp? */
> > > >         if (!strstr(device->drv->driverName, "wacom"))
> > > >                 continue;
> > > >
> > >
> > > I guess, the intention was to allow driverName has extra characters
> > instead
> > > of exact "wacom". As long as it has "wacom" in it, we take care of it.
> > Not
> > > sure if it is necessary though.
> >
> > I'd rather be precise on the match. I don't think anyone has a driver that
> > could possibly conflict but substring matches have a nasty habit of finding
> > things humans don't necessarily see.
> >
> > > > would it make sense to have them share the common struct once we've
> > linked
> > > > them?
> > > >
> > >
> > > It makes sense. One issue, even with the current code, is how to tell the
> > > difference between two identical tablets in the driver. How do we know if
> > we
> > > are linking the proper devices together?
> > >
> > > So far, I assume all devices attached to the same system have different
> > > product IDs.
> >
> > maybe we need an Option Uniq then to let the user associate the devices?
> >
> 
> 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);

    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