Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Mar 2009 03:13:01 +0800
From:      Henry Hu <henry.hu.sh@gmail.com>
To:        freebsd-stable@freebsd.org
Subject:   Re: Problems about usbhidaction
Message-ID:  <53a1e0710903061113x6f8130bdvab131a69094a694b@mail.gmail.com>
In-Reply-To: <53a1e0710903061057o1bb897e3y7793af39b4be6914@mail.gmail.com>
References:  <53a1e0710903061057o1bb897e3y7793af39b4be6914@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

Today I got a new USB keyboard,
ukbd0: <Microsoft Natural\M-. Ergonomic Keyboard 4000, class 0/0, rev
2.00/1.73, addr 2> on uhub3
kbd2 at ukbd0
uhid0: <Microsoft Natural\M-. Ergonomic Keyboard 4000, class 0/0, rev
2.00/1.73, addr 2> on uhub3

Normal keys are sent through ukbd0, and special keys (volume up, etc)
are sent through uhid0.
I tried to use usbhidaction to make the special keys functional, and I
found that there are some problems about usbhidaction:
1. The length of data it tried to read is wrong.
According to the UHID Device Class Definition, if Report ID tags are
used in the Report descriptor, there would be a 1-byte report ID
prefix before the report data. But if no Report ID tags are used, then
the report ID prefix is omitted.
But usbhidaction does not admit this (I modified libusbhid to allow
client program to know if Report ID tags have appeared), and always
reads one byte less than the data received, and the parse of the data
received leads to a wrong result. However I found that usbhidctl
somewhere admit this (although the way it handles it seems like a
hack).
I modified usbhidaction to read one more byte if it found that Report
ID tags had appeared. This also needs some modification to libusbhid.
2. There's no way to specify report ID.
There should be one way to specify which Report ID one item is
referring to, and usbhidaction should check the report ID prefix to
determine if the item is corresponding to it.
3. ioctl USB_GET_REPORT_ID returns 0
According to the Definition, report ID 0 is reserved and should not be used.
In fact, this keyboard sent its special key events with report ID = 1.
So I have to hack usbhidaction to set reportid to 1. I think this is
not right and should be fixed.
In the Definition, there might be multiple report IDs, so why there's
such an ioctl?
4. usbhidctl does not set reportid.
reportid in usbhidctl is always zero. There's even no ioctl to set it.
So to use it to listen to events I had manually changed reportid to 1.
I think there should be an option to set which report ID to listen to.

PS. Sorry for the incomplete mail. I've not been used to the new
keyboard yet....

Cheers,
Henry



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53a1e0710903061113x6f8130bdvab131a69094a694b>