USB HID mouse data packet

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
Reply to
Mike Perkins
Loading thread data ...

formatting link

You might find it useful to look at

formatting link

and at the various USB HID drivers at

formatting link

Reply to
Dave Platt

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.

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.

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
Reply to
Mike Perkins

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:

formatting link

--
Mike Perkins 
Video Solutions Ltd 
www.videosolutions.ltd.uk
Reply to
Mike Perkins

what profiles does the mouse advertise?

--
  Jasen.
Reply to
Jasen Betts

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
Reply to
Mike Perkins

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
Reply to
Mike Perkins

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.