Date: Fri, 1 Jun 2012 18:23:30 +0200 From: Hans Petter Selasky <hselasky@c2i.net> To: "Engineering" <ee@athyriogames.com>, Alexander Motin <mav@freebsd.org> Cc: freebsd-usb@freebsd.org Subject: Re: Recommendations for programming HID in FreeBSD 9 Message-ID: <201206011823.30527.hselasky@c2i.net> In-Reply-To: <027901cd4011$53ec4ff0$fbc4efd0$@com> References: <201205280640.q4S6e6L0035127@freefall.freebsd.org> <201206011730.31081.hselasky@c2i.net> <027901cd4011$53ec4ff0$fbc4efd0$@com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 01 June 2012 18:12:20 Engineering wrote:
> From: Hans Petter Selasky [mailto:hselasky@c2i.net]
>
> >> uhid is not going to get obsoleted, though using libraries from
>
> user-space is sometimes more convenient.
>
> Thanks HPS (and Xiaofan)
>
> I definitely agree with that, but I've got legacy code...
>
> Last question - I've updated my code to convert the old 'usb_ctl_report'
> and such to the new generic descriptors at runtime, and I've got two HIDs
> up and running.
>
> As I read uhid.c, it seems to assume only one feature report ID and size. I
> have devices that have multiple feature report sizes. And one device which
> I'm pretty sure has bad device descriptors, so the size is wrong.
>
> In the BSD7, I added the following fakery to uhid.c:
>
> case USB_SET_REPORTZ: // report id and size are in first two bytes
> re = (struct usb_ctl_report *)addr;
> id = re->ucr_data[0];
> size = re->ucr_data[1];
> err = usbd_set_report(sc->sc_iface, re->ucr_report, id,
> &re->ucr_data[2],size);
> if (err)
> {
> return (EIO);
> }
> break;
>
> Do you think it would make sense to do this again with the BSD9 uhid.c?
I think mav @ did some work in that area?
Are you sure you cannot use:
case USB_SET_REPORT:
if (!(fflags & FWRITE)) {
error = EPERM;
break;
}
ugd = addr;
switch (ugd->ugd_report_type) {
case UHID_INPUT_REPORT:
size = sc->sc_isize;
id = sc->sc_iid;
break;
case UHID_OUTPUT_REPORT:
size = sc->sc_osize;
id = sc->sc_oid;
break;
case UHID_FEATURE_REPORT:
size = sc->sc_fsize;
id = sc->sc_fid;
break;
default:
return (EINVAL);
}
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;
--HPS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206011823.30527.hselasky>
