Recommendations for programming HID in FreeBSD 9

Engineering ee at athyriogames.com
Fri Jun 1 17:11:19 UTC 2012


-----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:

if(ugd->ugd_config_index) // abusing variables to set a flag, use passed in
id and size in lang_id and actlen
	error = uhid_set_report(sc, ugd->ugd_report_type, ugd->ugd_lang_id,
NULL, 
		ugd->ugd_data, ugd->ugd_actlen);
else
	error = uhid_set_report(sc, ugd->ugd_report_type, id, NULL, 
		ugd->ugd_data, size);

Would suit my needs well, as long as I remember to zero out ugd_config_index
on a normal one!

I suppose I need to rebuild the kernel. Thanks for your time and help!

Sam





More information about the freebsd-usb mailing list