[libhid-discuss] Bug in hid_opening: hid_compare_usb_device()

Warren Jasper wjasper at tx.ncsu.edu
Tue Feb 5 03:15:09 UTC 2008


Charles,

If there is a device with product ID 0x7f, and you want to open a device 
with product ID 0x7d, what value of the "mask" or "match" do you
suggest I use so that if 0x7f exists but 0x7d does not exist it will not 
try to open a handle to the wrong device?  Is this a feature?

Warren




Charles Lepple wrote:
> On Feb 4, 2008, at 1:36 PM, Warren Jasper wrote:
>
>>          if (dev->descriptor.idVendor & match->vendor_id) ==
>> match->vendor_id) {
>>
>> and
>>
>>   if ((dev->descriptor.idProduct & match->product_id) ==
>> match->product_id) {
>>
>> are wrong.
>
> "Not the way I would do it" does not always equal "wrong". This makes 
> it easy to open up any device whose product ID matches a mask 
> (although I admit the names do not immediately suggest that the 
> match->*_id members are masks-- this was more obvious in the old 
> libHID code).
>
> Is anyone else depending on this behavior? (Martin, I cc'd you because 
> of libphidgets - does it still use libhid as-is?)
>
> This is something that a custom matching function can take care of, 
> though.
>





More information about the libhid-discuss mailing list