Forums

USB HID mouse data packet

Started by Mike Perkins August 27, 2020
It's a while since I last looked at USB but I'm finding it difficult to 
source useful material to explain the data packet I get from a USB mouse.

I have 3 mice I'm looking at for reference and to understand what I have 
to deal with. This is for a USB HID Host application running on a STM MCU.

The only documentation I have is hid1_11.pdf which can be easily found 
and on page 71 this gives the description for the first 3 bytes.

One mouse, a basic USB trackball conforms to these 3 bytes and even the 
"wMaxPacketSize" in the descriptors matches 3.

Another no-name mouse, well specifically a "Beijing Sigmachip Co., Ltd", 
has a "wMaxPacketSize" of 4, I haven't checked it's going to be a near 
certainty/obvious that the 4th byte is going to be the wheel/scroll 
movement.

The last no-name mouse claiming to be "Silicon Laboratories, Inc." has a 
"wMaxPacketSize" of 8 but replies with 6 bytes.

It seems a little inconsistent where most of the time the 6th packet has 
the wheel/scroll movement. As an aside, and as one might, Windows seems 
to support this mouse.

The only other information I could find was a Microsoft document for 
mice and Vista, Wheel.docx dated the 10th November 2010. The "Input 
Report" is inconsistent in having a Report ID as the first byte and AC 
Pan as the last (on page 5).

I have been using Wireshark capturing USB packets so can monitor this 
strangely behaving mouse.

Is there any unofficial/official documentation that might assist in the 
understanding of these data bytes?

-- 
Mike Perkins
Video Solutions Ltd
www.videosolutions.ltd.uk
In article <ri8a61$a4t$1@news2.open-news-network.org>,
Mike Perkins  <spam@spam.com> wrote:

>Is there any unofficial/official documentation that might assist in the >understanding of these data bytes?
https://www.usb.org/sites/default/files/hid1_11.pdf You might find it useful to look at https://www.kernel.org/doc/html/latest/usb/gadget_hid.html and at the various USB HID drivers at https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/hid?h=v5.8.5
On 27/08/2020 18:48:09, Dave Platt wrote:
> In article <ri8a61$a4t$1@news2.open-news-network.org>, > Mike Perkins <spam@spam.com> wrote: > >> Is there any unofficial/official documentation that might assist in the >> understanding of these data bytes? > > https://www.usb.org/sites/default/files/hid1_11.pdf
I had found and referred to this document. It is very dated and while it mentions n bytes it only specifies the first 3 in a helpful way.
> You might find it useful to look at > > https://www.kernel.org/doc/html/latest/usb/gadget_hid.html
I'm struggling here. While it may emulate various devices the devices are not specified on this page as to what byte is used for what. Or should I say I can't decipher the info. There are some links but none seem to refer to the basic mouse but to more exotic HID devices.
> and at the various USB HID drivers at > > https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/hid?h=v5.8.5
There is a list of files and while I have looked at a few such as Logitech there isn't a description of the buttons or x and y movement. I don't feel I have moved forward here. -- Mike Perkins Video Solutions Ltd www.videosolutions.ltd.uk
On 28/08/2020 00:43:34, Mike Perkins wrote:
> On 27/08/2020 18:48:09, Dave Platt wrote: >> In article <ri8a61$a4t$1@news2.open-news-network.org>, >> Mike Perkins&nbsp; <spam@spam.com> wrote: >> >>> Is there any unofficial/official documentation that might assist in the >>> understanding of these data bytes? >> >> https://www.usb.org/sites/default/files/hid1_11.pdf > > I had found and referred to this document. It is very dated and while it > mentions n bytes it only specifies the first 3 in a helpful way. > >> You might find it useful to look at >> >> https://www.kernel.org/doc/html/latest/usb/gadget_hid.html > > I'm struggling here. While it may emulate various devices the devices > are not specified on this page as to what byte is used for what. Or > should I say I can't decipher the info. > > There are some links but none seem to refer to the basic mouse but to > more exotic HID devices. > >> and at the various USB HID drivers at >> >> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/hid?h=v5.8.5 >> > > There is a list of files and while I have looked at a few such as > Logitech there isn't a description of the buttons or x and y movement. > > I don't feel I have moved forward here.
After more analysis it seems we have 16 bit data for mouse x and y movements: So we have Byte 0 = buttons Byte 1 = x LSByte Byte 2 = x MSByte Byte 3 = y LSByte Byte 4 = y MSByte Byte 5 = wheel This specifically goes against the spec: https://www.usb.org/sites/default/files/hid1_11.pdf -- Mike Perkins Video Solutions Ltd www.videosolutions.ltd.uk
On 2020-08-28, Mike Perkins <spam@spam.com> wrote:
> After more analysis it seems we have 16 bit data for mouse x and y > movements: > > So we have > > Byte 0 = buttons > Byte 1 = x LSByte > Byte 2 = x MSByte > Byte 3 = y LSByte > Byte 4 = y MSByte > Byte 5 = wheel > > This specifically goes against the spec: > https://www.usb.org/sites/default/files/hid1_11.pdf
what profiles does the mouse advertise? -- Jasen.
On 28/08/2020 05:18:06, Jasen Betts wrote:
> On 2020-08-28, Mike Perkins <spam@spam.com> wrote: >> After more analysis it seems we have 16 bit data for mouse x and y >> movements: >> >> So we have >> >> Byte 0 = buttons >> Byte 1 = x LSByte >> Byte 2 = x MSByte >> Byte 3 = y LSByte >> Byte 4 = y MSByte >> Byte 5 = wheel >> >> This specifically goes against the spec: >> https://www.usb.org/sites/default/files/hid1_11.pdf > > what profiles does the mouse advertise?
After some research the required info is in the HID Report Descriptor. The document hid1.11.pdf isn't much help but an application they produce "dt2_4" is in explaining the setup of this descriptor and the usage setup. I deduce that the number of bytes used by the x and y movement is set by the min and max values in this descriptor. I was hoping to confirm the HID Report Descriptor in Windows but Wireshark seems to discard/ignore this data and I can't see it this packet. -- Mike Perkins Video Solutions Ltd www.videosolutions.ltd.uk
On 28/08/2020 02:19:27, Mike Perkins wrote:
> On 28/08/2020 00:43:34, Mike Perkins wrote: >> On 27/08/2020 18:48:09, Dave Platt wrote: >>> In article <ri8a61$a4t$1@news2.open-news-network.org>, >>> Mike Perkins&nbsp; <spam@spam.com> wrote: >>> >>>> Is there any unofficial/official documentation that might assist in the >>>> understanding of these data bytes? >>> >>> https://www.usb.org/sites/default/files/hid1_11.pdf >> >> I had found and referred to this document. It is very dated and while >> it mentions n bytes it only specifies the first 3 in a helpful way. >> >>> You might find it useful to look at >>> >>> https://www.kernel.org/doc/html/latest/usb/gadget_hid.html >> >> I'm struggling here. While it may emulate various devices the devices >> are not specified on this page as to what byte is used for what. Or >> should I say I can't decipher the info. >> >> There are some links but none seem to refer to the basic mouse but to >> more exotic HID devices. >> >>> and at the various USB HID drivers at >>> >>> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/hid?h=v5.8.5 >>> >> >> There is a list of files and while I have looked at a few such as >> Logitech there isn't a description of the buttons or x and y movement. >> >> I don't feel I have moved forward here. > > After more analysis it seems we have 16 bit data for mouse x and y > movements: > > So we have > > Byte 0 = buttons > Byte 1 = x LSByte > Byte 2 = x MSByte > Byte 3 = y LSByte > Byte 4 = y MSByte > Byte 5 = wheel > > This specifically goes against the spec: > &nbsp;https://www.usb.org/sites/default/files/hid1_11.pdf >
Right: I need to view the HID Report Descriptors. This can be done in Wireshark sniffing the appropriate USB channel and using the filter "usbhid". The descriptor is decoded, albeit rather crudely. Here I can see the x and y movement for this mouse has a maximum of 32767 and a minimum of 32769(which when signed is -3267). These are of course 16 bit numbers. The descriptor is best illustrated by the USG.org application of dt2_4, which when run you can import an example mouse file. -- Mike Perkins Video Solutions Ltd www.videosolutions.ltd.uk