Recommendations for programming HID in FreeBSD 9

Alexander Motin mav at FreeBSD.org
Sat Jun 2 06:55:11 UTC 2012


Hi.

On 06/01/12 20:10, Engineering wrote:
> -----Original Message-----
>> From: Hans Petter Selasky [mailto:hselasky at c2i.net]
>>
>> I think mav @ did some work in that area?
>>
>> Are you sure you cannot use:
>> ...
>>           if (id != 0)
>>                        copyin(ugd->ugd_data,&id, 1);
>>                 error = uhid_set_report(sc, ugd->ugd_report_type, id,
>>                     NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size));
>>                 break;
>
> That's definitely cleaner, using the ugd fields to denote a special case.
> I'm not sure about the (id != 0) - I'll need to check my specific devices,
> but something like:

Hans is right. That code should do the trick. Last year I've fixed uhid 
driver to handle multiple report IDs. Even user-level tools are able to 
do it now. "id != 0" should be correct condition. According to HID spec, 
if device has at least one non-zero report ID, report ID should be 
included into any transfer. So now uhid driver assumes that report ID 
should be in the first byte of request, if it found some non-zero ID in 
descriptor.

-- 
Alexander Motin


More information about the freebsd-usb mailing list