[PATCH] Fix udev population of Bluetooth input device product IDs

Chase Douglas chase.douglas at canonical.com
Mon Aug 30 17:13:23 PDT 2010


On Tue, 2010-08-31 at 10:07 +1000, Peter Hutterer wrote:
> On Mon, Aug 30, 2010 at 05:59:30PM -0400, Chase Douglas wrote:
> > From: Chase Douglas <chase.douglas at ubuntu.com>
> > 
> > The udev device_added function takes the vendor and model IDs of added
> > devices and converts them into an attribute that can be matched for by
> > an InputClass configuration using MatchUSBID. Currently, the udev
> > mechanism works for USB devices, but fails to work properly for
> > Bluetooth devices. The product IDs of the event node are actually the
> > IDs of the Bluetooth receiver instead of the device.
> > 
> > This patch reads the product ID from the PRODUCT property of the parent
> > of the added device. This tag is set correctly for both USB and
> > Bluetooth input devices. The following devices have been tested by
> > specifying individual InputClass sections in xorg.conf:
> > 
> > * Apple Keyboard (Bluetooth)
> > * Apple Magic Trackpad (Bluetooth)
> > * Apple Magic Mouse (Bluetooth)
> > * Microsoft Bluetooth Notebook Mouse 5000 (Bluetooth)
> > * Microsoft IntelliMouse Optical (USB)
> > * N-Trig Touchscreen (USB)
> > * Wacom Bamboo Touch (USB)
> > 
> > Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
> > ---
> >  config/udev.c |   49 ++++++++++++++++++++++++++++++++-----------------
> >  1 files changed, 32 insertions(+), 17 deletions(-)
> > 
> > diff --git a/config/udev.c b/config/udev.c
> > index 9934490..008cfc4 100644
> > --- a/config/udev.c
> > +++ b/config/udev.c
> > @@ -51,6 +51,32 @@
> >  
> >  static struct udev_monitor *udev_monitor;
> >  
> > +static char *parse_usb_id(const char *product)
> > +{
> > +    const char *cur;
> > +    char *next;
> > +    int usb_vendor, usb_model;
> > +
> > +    if (!product)
> > +        return NULL;
> > +
> > +    cur = strchr(product, '/');
> > +    if (!cur)
> > +        return NULL;
> > +
> > +    usb_vendor = strtoul(cur + 1, &next, 16);
> > +    if (!next || next == cur + 1 || usb_vendor > 0xffff)
> > +        return NULL;
> > +
> > +    cur = next;
> > +    usb_model = strtoul(cur + 1, &next, 16);
> > +    if (!next || next == cur + 1 || usb_model > 0xffff)
> > +        return NULL;
> 
> same comment as in last patch, any particular reason you don't use sscanf?
> rest looks good though.

I must have missed your comment. No real reason I didn't use sscanf
other than I didn't think of it :). Thanks for the reminder of its
existence, and I'll resubmit the patch.

-- Chase



More information about the xorg-devel mailing list