Recommendations for programming HID in FreeBSD 9
Alexander Motin
mav at FreeBSD.org
Mon Jun 4 08:21:20 UTC 2012
On 06/04/12 01:29, Engineering wrote:
>>> 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));
>>
>> 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.
>
> Thanks to all for your help, I have it working, and am very happy to be up
> to date in BSD.
>
> For the record, one of my HID had different report IDs AND different report
> sizes, so I had to add my hack to send the size for it to work correctly.
That should also work fine now. uhid driver only enforces maximal
transfer sizes calculated from the descriptor. User can request smaller
transfers, specifying size in ugd.ugd_maxlen field. Look at
hid_(get|set)_report() functions in lib/libusbhid sources.
> The bonus with that is that my touchscreen, which has badly ported HID code
> from the original USB firmware, and does not correctly report its report
> sizes, can also work with uhid.
--
Alexander Motin
More information about the freebsd-usb
mailing list