USB Host Mouse Driver

Status
Not open for further replies.

wwatson

Well-known member
Hi, I new to this forum even though I have been following it for a few years now.

I have been working on a USB Host mouse driver for the Teensy 3.6 for a few months now when I get the time.
I cloned Pauls USBHost_t36 off of GITHUB and added a working USB mouse driver to it. I have used both wired and
wireless mouse and keyboard combinations with it. I have tested several Logitech mice and keyboards and they all
work.

I don't have a GITHUB account. Can I send the zip file as an attachment?

Thanks
 
Sure, perfectly fine to just post the files here. If using "Quick Reply", click the "Go Advanced" button. The full feature editor has a place to attach files to your message.
 
Looked interesting and a nice addition, so downloaded updated version.

Also today my USB Host adapter arrived so thought I would try it out. First tried with simple keyboard and test program worked fine. Then plugged in simple USB HUB and keyboard into it and keyboard still worked. So then plugged in a wired mouse (Belkin) and tried plugging it either direct or through HUB. Also running new Mouse example program) and I am not getting any mouse events... It still prints out keyboard keys (at least for all of the standard alpha numeric keys)...

I turned on the debug printing and it did print out some 900 lines of debug info including some stuff about mouse. But no debug information when I press any button or move it or... But debug info is printed when I press keys on keyboard...

Something else I should try? Like find a powered USB hub? and/or should I grab either a Microsoft or Logitech wireless keyboard/mouse combo and try it?
 
I played around with a couple of keyboards, Mice and combo wireless...

Example: a wired mouse came with hP computer... Did not appear to work. Also tried with simple MouseTest.ino that was in zip file. Also verified files in zip semi match files on github... I see Paul made some minor () changes...

With this mouse not getting any serial stuff printed for moving, or button presses. packet size(mouse) = 8 Every so many seconds i am getting some messages spewed out like:
Code:
ISR: C08C
 Port Change
port change: 1C00100A
    disconnect
disconnect_Device:
USBDriver (available_drivers) list: 1FFF2020 -> 1FFF2380 -> 1FFF26E0 -> 1FFF2A60
USBDriver (dev->drivers) list: (empty
USBDriver (available_drivers) list: 1FFF2020 -> 1FFF2380 -> 1FFF26E0 -> 1FFF2A60
delete_Pipe 1FFF3300
  shut down async schedule
removed Device_t from devlist
  disable

ISR: 408C
 Port Change
port change: 14001403
    connect

ISR: 1004088
 Timer0
  begin reset

ISR: 408C
 Port Change
port change: 14001405
  port enabled

ISR: 1004088
 Timer0
  end recovery
new_Device: 1.5 Mbit/sec
new_Pipe
new_Control_Transfer

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF2C40    token=80000200
  Followup 1FFF3360    token=100
  Followup 1FFF33A0    token=8000
enumeration:
new_Control_Transfer
  Followup 1FFF33E0    token=80280
  Followup 1FFF2C40    token=80008180

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF33E0    token=80000200
  Followup 1FFF2C40    token=8100
enumeration:
new_Control_Transfer
  Followup 1FFF3360    token=80280
  Followup 1FFF3420    token=80120180
  Followup 1FFF33A0    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF3360    token=80000200
  Followup 1FFF3420    token=100
  Followup 1FFF33A0    token=8000
enumeration:
new_Control_Transfer
  Followup 1FFF33E0    token=80280
  Followup 1FFF2C40    token=80FC0180
  Followup 1FFF3360    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF33E0    token=80000200
  Followup 1FFF2C40    token=F80100
  Followup 1FFF3360    token=8000
enumeration:
new_Control_Transfer
  Followup 1FFF3420    token=80280
  Followup 1FFF33A0    token=80FC0180
  Followup 1FFF33E0    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF3420    token=80000200
  Followup 1FFF33A0    token=80EE0100
  Followup 1FFF33E0    token=8000
enumeration:
new_Control_Transfer
  Followup 1FFF2C40    token=80280
  Followup 1FFF3360    token=80FC0180
  Followup 1FFF3420    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF2C40    token=80000200
  Followup 1FFF3360    token=80D20100
  Followup 1FFF3420    token=8000
enumeration:
new_Control_Transfer
  Followup 1FFF33A0    token=80280
  Followup 1FFF33E0    token=80090180
  Followup 1FFF2C40    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF33A0    token=80000200
  Followup 1FFF33E0    token=80000100
  Followup 1FFF2C40    token=8000
enumeration:
Config data length = 34
new_Control_Transfer
  Followup 1FFF3360    token=80280
  Followup 1FFF3420    token=80220180
  Followup 1FFF33A0    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF3360    token=80000200
  Followup 1FFF3420    token=100
  Followup 1FFF33A0    token=8000
enumeration:
bNumInterfaces = 1
bConfigurationValue = 1
new_Control_Transfer
  Followup 1FFF33E0    token=80280
  Followup 1FFF3360    token=80008180

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF33E0    token=80000200
  Followup 1FFF3360    token=8100
enumeration:
USBHub memory usage = 864
USBHub claim_device this=1FFF2020
USBHub memory usage = 864
USBHub claim_device this=1FFF2380
USBHub memory usage = 864
USBHub claim_device this=1FFF26E0
MouseController claim this=1FFF2A60
Descriptor 4 = INTERFACE
MouseController claim this=1FFF2A60
ep(mouse) = 81
descriptors[22] = 8
descriptors[23] = 0
packet size(mouse) = 8
Descriptor 33 = HID
Descriptor 5 = ENDPOINT

If I try with Belkin Mouse: It shows packet size(mouse) = 8 as well... But I don't think I am getting the repeated updated messages...

If I try with Microsoft wireless setup, the keyboard is working but again nothing from the mouse... Note this one says packet size(mouse) = 10...

I have Logitech wireless as well, and it is not currently responding either. The Keyboard does, but not the mouse.

Edit: So line 63 in mouse.cpp is bailing us out: if ((size != 20) && (size != 6)) return false;
As all of my mice show up with size of either 8 or 10...

When I comment out this line, starting to get mouse feedback :D However maybe wrong order of processing the data.
Example my Logitech wireless

Press left button: Mouse Data: 02 01 00 00 00 00 00 00
Release left: Mouse Data: 02 00 00 00 00 00 00 00
Right button 02 02...
Wheel button: 02 04
Button on left side: 02 08 ...
Button on right side: 02 10 ...
Wheel forward one detente: 02 00 00 00 00 01 00 00
back Mouse Data: 02 00 00 00 00 FF 00 0
...
Will check other mice as well
 
Last edited:
Hi KurtE

Line 63 is a check on the packet size for the driver type. If size does not equal the reported packet size then it bails.
Add the reported packet size test to line 63. While testing the mice that I have it seemed to to be 20 for wireless and
6 for wired. One of them was a Belkin wired mouse.
 
Hi wwatson,

I have now tried with 4 different Mice, Belkin Wired, HP Wired, Logitech Ergonomic Wireless combo, Microsoft Wireless combo (ergo split into 3 pieces) and none of them report 6 or 20...
Currently 3 of them report 8 and the Microsoft reports 10...

I have been hacking on code a little, where I removed your check, left the size as reported... If it is less than 6 I pass 8 into the other two calls that use it.
I also now dump the complete descriptor in the claim function to look at it and likewise I dump the size of data of the report (not hard coded to 8) in the main function and see lots of differences in the data.

Some extracts from the debug output:
Code:
Belkin: Wired
MouseController claim descriptors
  : 09 04 00 00 01 03 01 02 00 09 21 10 01 00 01 22 34 00 07 05 81 03 08 00 0A 
  LB - 01 00 00 00 00 00 00 00  
  WB - 04...
  Wheel: 00 00 00 FF 00 00 00 00
  Left:  00 FF 00 00 00 00 00 00
  UP:    00 00 FF 00 00 00 00 00

  HP Wired controller: 
  MouseController claim descriptors
  : 09 04 00 00 01 03 01 02 00 09 21 11 01 00 01 22 4F 00 07 05 81 03 08 00 0A 

  Errors out as part of first callback...
  ISR: 8E089
 USB Periodic
Periodic Followup
  Followup 1FFF33E0    token=80008100
MouseController Callback (member)
  Mouse Data: 00 00 01 00 00 00 01 00 
new_Data_Transfer
  Followup 1FFF33A0    token=148180
buttons = 0,  wheel = 0,  mouseXpos = 0,  mouseYpos = 0

ISR: 8E08B
 USB Error
 USB Periodic
Periodic Followup
  Followup 1FFF33A0    token=80048150
MouseController Callback (member)
  Mouse Data: 00 FF 01 00 FF FF 01 00 
new_Data_Transfer
  Followup 1FFF2C00    token=148180
ERROR Followup
buttons = 255,  wheel = -1,  mouseXpos = 1,  mouseYpos = 0


Logitech Wireless combination (Ergonomic...)
MouseController claim descriptors
  : 09 04 00 00 01 03 01 01 00 09 21 10 01 00 01 22 3B 00 07 05 81 03 08 00 0A 09 04 01 00 01 03 01 02 00 09 21 10 01 00 01 22 B1 00 07 05 82 03 08 00 0A 
  LB: 02 01 00 00 00 00 00 00
  RB: 02 02 00 00 00 00 00 00
  WB: 02 04 00 00 00 00 00 00
  Wheel: 02 00 00 00 00 01 00 00
  Note: you can tilt wheel left/right - no reporting happened
  Left:  02 00 FF 0F 00 00 00 00
  Up:    02 00 00 F0 FF 00 00 00

  Microsoft Wireless
MouseController claim descriptors
  : 09 04 00 00 01 03 01 01 00 09 21 11 01 00 01 22 39 00 07 05 81 03 08 00 04 09 04 01 00 01 03 01 02 00 09 21 11 01 00 01 22 DF 00 07 05 82 03 0A 00 01 09 04 02 00 01 03 00 00 00 09 21 11 01 00 01 22 28 01 07 05 83 03 20 00 01

  Buttons: acting different usually only one report per click...
  LB:    1A 00 00 00 01 00 00 00 00 00
  Wheel: 1A 00 00 00 00 00 01 00 00 00
         1A 00 00 00 00 00 FF FF 00 00
  Left:  1A 00 FE FF 00 00 00 00 00 00 
  UP:    1A 00 00 00 FF FF 00 00 00 00

What I see, my belkin wired looks like it has 8 bit X, Y positioning where your assuming 12... The HP one fails completely, the Logitech has 12 bit positions like you are setup for and the Microsoft one has 16 bit positions. Also the position of where the buttons are reported appears to be different for different mice... I am guessing on the wireless ones, that maybe the first byte may be something like the battery level in the mouse, or maybe signal strength...

From my looking around on the web about HID stuff, I am guessing that the descriptors probably contains information on how to decode the reports coming from the device.
For example the information in: http://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/

But so far I don't know enough on how to decode this data...

Notes to self: Looks like the Logitech wireless has two devices or the like and the Microsoft one has 3... Maybe the mouse and keyboard...

So yes, it was showing multiple descriptors.... So if you remove the ones that are not mouse:
Code:
  : 09 04 00 00 01 03 01 02 00 09 21 10 01 00 01 22 34 00 07 05 81 03 08 00 0A 
  : 09 04 00 00 01 03 01 02 00 09 21 11 01 00 01 22 4F 00 07 05 81 03 08 00 0A 
  : 09 04 01 00 01 03 01 02 00 09 21 10 01 00 01 22 B1 00 07 05 82 03 08 00 0A 
  : 09 04 01 00 01 03 01 02 00 09 21 11 01 00 01 22 DF 00 07 05 82 03 0A 00 01
Now need to find out how to get more data about the actual device...
 
Last edited:
I am also not that familiar with descriptors. I know that this is needed to properly identify the mouse, decode mouse report packets and change mouse settings.
I also had a hard time finding information about mouse report packet formats on the net. The X/Y report can be 8 bit, 12 bit and 16 bit.
My Logitech M210 wireless mouse X/Y is packed in 3 bytes holding two 12 bit signed integers. The mouse can be set to a relative or absolute mode as well.

Logitech Wireless combination (Ergonomic...)
MouseController claim descriptors
: 09 04 00 00 01 03 01 01 00 09 21 10 01 00 01 22 3B 00 07 05 81 03 08 00 0A 09 04 01 00 01 03 01 02 00 09 21 10 01 00 01 22 B1 00 07 05 82 03 08 00 0A
LB: 02 01 00 00 00 00 00 00
RB: 02 02 00 00 00 00 00 00
WB: 02 04 00 00 00 00 00 00
Wheel: 02 00 00 00 00 01 00 00
Note: you can tilt wheel left/right - no reporting happened
Left: 02 00 FF 0F 00 00 00 00
Up: 02 00 00 F0 FF 00 00 00

The message that I get when using a model M210 three button wireless Logitech mouse with a packet size of 20 is:

Left: 02 00 00 FF 0F 00 00 00
Right: 02 00 00 01 00 00 00 00
Up: 02 00 00 00 F0 FF 00 00
Down: 02 00 00 00 10 00 00 00
Wheel: 02 00 00 00 00 00 01 00
LB: 02 01 00 00 00 00 00 00
RB: 02 02 00 00 00 00 00 00
WB: 02 04 00 00 00 00 00 00
------------------->| Byte 2 is not in your mouse message. The X/Y and wheel bytes are shifted one byte to the right on my M210 mouse.

For your Logitech mouse line 63 of mouse.cpp could look like this:
Code:
	if ((size != 20) && (size != 10) && (size != 8) && (size != 6) ) return false;

This section is where the report packet is decoded. It is hardcoded (unfortunately).
Code:
	if(packetSize == 20) {
		buttons = report[1];
		mouseX  = ((report[4] & 0x0f) << 8) | ((report[3] & 0xff));
		mouseY  = ((report[5] & 0xff) << 4) | ((report[4] >> 4) & 0x0f);
		wheel   = report[6];
	} else {
		buttons = report[0];
		mouseX  = ((report[2] & 0x0f) << 8) | ((report[1] & 0xff));
		mouseY  = ((report[3] & 0xff) << 4) | ((report[2] >> 4) & 0x0f);
		wheel   = report[4];
	}

You could try this:
The "} else {" section is what we need to change to match your report packet.
Code:
	if(packetSize == 20) { // packet size of 20
		buttons = report[1];
		mouseX  = ((report[4] & 0x0f) << 8) | ((report[3] & 0xff));
		mouseY  = ((report[5] & 0xff) << 4) | ((report[4] >> 4) & 0x0f);
		wheel   = report[6];
	} else {  // packet size of 8 or 10
		buttons = report[1];
		mouseX  = ((report[3] & 0x0f) << 8) | ((report[2] & 0xff));
		mouseY  = ((report[4] & 0xff) << 4) | ((report[3] >> 4) & 0x0f);
		wheel   = report[5];
	}

I hope this will work for your Logitech wireless mouse.
My Belkin wired mouse uses a packet size of 6 instead of 8.
I do not have a wireless Microsoft mouse to test with. I may be able to find one at work to use.
 
Thanks, I am finding that all of my mice are reporting differently and several have packet size the same...

What I am experimenting with right now is trying to retrieve the mouse descriptor object... I believe that this should give all of the information to decode the data. One goal might be, you should be able to plug a T3.2 that is configured as a Mouse (or Mouse/keyboard...) into your T3.6 Host port and have it work.

Looking at the Mouse descriptor for Teensy, I see data like:
Code:
static uint8_t mouse_report_desc[] = {
        0x05, 0x01,                     // Usage Page (Generic Desktop)
        0x09, 0x02,                     // Usage (Mouse)
        0xA1, 0x01,                     // Collection (Application)
        0x85, 0x01,                     //   REPORT_ID (1)
        0x05, 0x09,                     //   Usage Page (Button)
        0x19, 0x01,                     //   Usage Minimum (Button #1)
        0x29, 0x08,                     //   Usage Maximum (Button #8)
        0x15, 0x00,                     //   Logical Minimum (0)
        0x25, 0x01,                     //   Logical Maximum (1)
        0x95, 0x08,                     //   Report Count (8)
        0x75, 0x01,                     //   Report Size (1)
        0x81, 0x02,                     //   Input (Data, Variable, Absolute)
        0x05, 0x01,                     //   Usage Page (Generic Desktop)
        0x09, 0x30,                     //   Usage (X)
        0x09, 0x31,                     //   Usage (Y)
        0x09, 0x38,                     //   Usage (Wheel)
        0x15, 0x81,                     //   Logical Minimum (-127)
        0x25, 0x7F,                     //   Logical Maximum (127)
        0x75, 0x08,                     //   Report Size (8),
        0x95, 0x03,                     //   Report Count (3),
        0x81, 0x06,                     //   Input (Data, Variable, Relative)
        0x05, 0x0C,                     //   Usage Page (Consumer)
        0x0A, 0x38, 0x02,               //   Usage (AC Pan)
        0x15, 0x81,                     //   Logical Minimum (-127)
        0x25, 0x7F,                     //   Logical Maximum (127)
        0x75, 0x08,                     //   Report Size (8),
        0x95, 0x01,                     //   Report Count (1),
        0x81, 0x06,                     //   Input (Data, Variable, Relative)
        0xC0,                           // End Collection
        0x05, 0x01,                     // Usage Page (Generic Desktop)
        0x09, 0x02,                     // Usage (Mouse)
        0xA1, 0x01,                     // Collection (Application)
        0x85, 0x02,                     //   REPORT_ID (2)
        0x05, 0x01,                     //   Usage Page (Generic Desktop)
        0x09, 0x30,                     //   Usage (X)
        0x09, 0x31,                     //   Usage (Y)
        0x15, 0x00,                     //   Logical Minimum (0)
        0x26, 0xFF, 0x7F,               //   Logical Maximum (32767)
        0x75, 0x10,                     //   Report Size (16),
        0x95, 0x02,                     //   Report Count (2),
        0x81, 0x02,                     //   Input (Data, Variable, Absolute)
        0xC0                            // End Collection
};
From this you can see that it is defined for 8 buttons, and the data should be one byte:
Also with this you see the X, Y, and Wheel values are 8 bits signed (-127, 127), relative values...
And it looks like it might have another report where you have X and Y values that are 16 bits absolution positioning...

Need to figure out better on how to get this information. I am thinking I need to grab it probably as part of the enumeration, sort of like how it can grab the serial #, and I see information in the Teensy descriptor stuff which has list... Where you can probably address it by something like:
wValue = 2200, and wIndex probably 2 for mouse... But still playing..
 
How did you get the formated display of the mouse descriptor?
I really need to learn more about USB descriptors.
 
According to the HID 1.1 spec, part B.2 on page 61, any mouse that says it follows the boot protocol in its interface descriptor is supposed to implement this:

Code:
Byte     Bits     Description
----------------------------------------
0        0        Button 1
         1        Button 2
         2        Button 3
         4 to 7   Device-specific
1        0 to 7   X displacement
2        0 to 7   Y displacement
3 to n   0 to 7   Device specific (optional)

The specific report descriptor for this is also given on page 61:

Code:
Usage Page (Generic Desktop),
Usage (Mouse),
Collection (Application),
   Usage (Pointer),
   Collection (Physical),
      Report Count (3),
      Report Size (1),
      Usage Page (Buttons),
      Usage Minimum (1),
      Usage Maximum (3),
      Logical Minimum (0),
      Logical Maximum (1),
      Input (Data, Variable, Absolute),
      Report Count (1),
      Report Size (5),
      Input (Constant),
      Report Size (8),
      Report Count (2),
      Usage Page (Generic Desktop),
      Usage (X),
      Usage (Y),
      Logical Minimum (-127),
      Logical Maximum (127),
      Input (Data, Variable, Relative),
   End Collection,
End Collection
 
If strictly following the HID spec, by checking the boot protocol byte but not the fully parsing the HID report descriptor, my understanding is only these fields from the first 3 bytes should be parsed.

Even though anything beyond the 3rd byte is "Device specific (optional)", from what I've seen almost all mice with 4+ byte reports implement the vertical scroll wheel on the 4th byte. Everything beyond the 4th byte seems to vary quite a lot.

Many mice do not use the boot protocol. Teensy's Mouse device option is one of them. These can't work without hard-coding for specific models, or a full HID report descriptor parser.
 
Hi Paul, and wwatson,

As I mentioned, I have been playing around trying to figure out how to read in the full HID report descriptor and then do some simple parsing.

For the fun of it I decided to look at a couple of the devices using Linux to look at the descriptor. Example my Logitech wireless mouse/keyboard...
And I see:
Code:
kurt@kurt-UP-CHT01:~$ sudo usbhid-dump  -i1 | grep -v : | xxd -r -p | hidrd-convert -o spec Usage Page (Desktop),                   ; Generic desktop controls (01h)
Usage (Mouse),                          ; Mouse (02h, application collection)
Collection (Application),
    Report ID (2),
    Usage (Pointer),                    ; Pointer (01h, physical collection)
    Collection (Physical),
        Usage Page (Button),            ; Button (09h)
        Usage Minimum (01h),
        Usage Maximum (08h),
        Logical Minimum (0),
        Logical Maximum (1),
        Report Count (8),
        Report Size (1),
        Input (Variable),
        Usage Page (Desktop),           ; Generic desktop controls (01h)
        Logical Minimum (-2047),
        Logical Maximum (2047),
        Report Size (12),
        Report Count (2),
        Usage (X),                      ; X (30h, dynamic value)
        Usage (Y),                      ; Y (31h, dynamic value)
        Input (Variable, Relative),
        Logical Minimum (-127),
        Logical Maximum (127),
        Report Size (8),
        Report Count (1),
        Usage (Wheel),                  ; Wheel (38h, dynamic value)
        Input (Variable, Relative),
        Usage Page (Consumer),          ; Consumer (0Ch)
        Usage (AC Pan),                 ; AC pan (0238h, linear control)
        Report Count (1),
        Input (Variable, Relative),
    End Collection,
End Collection,
Usage Page (Consumer),                  ; Consumer (0Ch)
Usage (Consumer Control),               ; Consumer control (01h, application collection)
Collection (Application),
    Report ID (3),
    Report Size (16),
    Report Count (2),
    Logical Minimum (1),
    Logical Maximum (652),
    Usage Minimum (Consumer Control),   ; Consumer control (01h, application collection)
    Usage Maximum (AC Send),            ; AC send (028Ch, selector)
    Input (No Preferred, Null State),
End Collection,
Usage Page (Desktop),                   ; Generic desktop controls (01h)
Usage (Sys Control),                    ; System control (80h, application collection)
Collection (Application),
    Report ID (4),
    Report Size (2),
    Report Count (1),
    Logical Minimum (1),
    Logical Maximum (3),
    Usage (Sys Sleep),                  ; System sleep (82h, one-shot control)
    Usage (Sys Power Down),             ; System power down (81h, one-shot control)
    Usage (Sys Wake Up),                ; System wake up (83h, one-shot control)
    Input (No Preferred, Null State),
    Report Size (6),
    Input (Constant, Variable),
End Collection,
Usage Page (FF00h),                     ; FF00h, vendor-defined
Usage (01h),
Collection (Application),
    Report ID (16),
    Report Size (8),
    Report Count (6),
    Logical Minimum (0),
    Logical Maximum (255),
    Usage (01h),
    Input,
    Usage (01h),
    Output,
End Collection,
Usage Page (FF00h),                     ; FF00h, vendor-defined
Usage (02h),
Collection (Application),
    Report ID (17),
    Report Size (8),
    Report Count (19),
    Logical Minimum (0),
    Logical Maximum (255),
    Usage (02h),
    Input,
    Usage (02h),
    Output,
End Collection
As you can see it is not following the standard format as X, Y values are 12 bit. Note: if I change the command to have -i0 instead of -i it gives me keyboard stuff...
As for the Belkin mouse I have:
Code:
kurt@kurt-UP-CHT01:~$ sudo usbhid-dump  -i1 | grep -v : | xxd -r -p | hidrd-convert -o spec
No matching HID interfaces
kurt@kurt-UP-CHT01:~$ sudo usbhid-dump  -i0 | grep -v : | xxd -r -p | hidrd-convert -o spec Usage Page (Desktop),               ; Generic desktop controls (01h)
Usage (Mouse),                      ; Mouse (02h, application collection)
Collection (Application),
    Usage (Pointer),                ; Pointer (01h, physical collection)
    Collection (Physical),
        Usage Page (Button),        ; Button (09h)
        Usage Minimum (01h),
        Usage Maximum (03h),
        Logical Minimum (0),
        Logical Maximum (1),
        Report Count (3),
        Report Size (1),
        Input (Variable),
        Report Count (1),
        Report Size (5),
        Input (Constant),
        Usage Page (Desktop),       ; Generic desktop controls (01h)
        Usage (X),                  ; X (30h, dynamic value)
        Usage (Y),                  ; Y (31h, dynamic value)
        Usage (Wheel),              ; Wheel (38h, dynamic value)
        Logical Minimum (-127),
        Logical Maximum (127),
        Report Size (8),
        Report Count (3),
        Input (Variable, Relative),
    End Collection,
End Collection
Looks like it is pretty standard (3 buttons, using one byte), followed by X, Y, Z each 1 byte,

HP Mouse came with desktop...
Code:
kurt@kurt-UP-CHT01:~$ sudo usbhid-dump  -i0 | grep -v : | xxd -r -p | hidrd-convert -o spec
Usage Page (Desktop),               ; Generic desktop controls (01h)
Usage (Mouse),                      ; Mouse (02h, application collection)
Collection (Application),
    Usage (Pointer),                ; Pointer (01h, physical collection)
    Collection (Physical),
        Usage Page (Button),        ; Button (09h)
        Usage Minimum (01h),
        Usage Maximum (03h),
        Logical Minimum (0),
        Logical Maximum (1),
        Report Size (1),
        Report Count (3),
        Input (Variable),
        Report Size (5),
        Report Count (1),
        Input (Constant, Variable),
        Usage Page (FF00h),         ; FF00h, vendor-defined
        Usage (40h),
        Report Count (2),
        Report Size (8),
        Logical Minimum (-127),
        Logical Maximum (127),
        Input (Variable),
        Usage Page (Desktop),       ; Generic desktop controls (01h)
        Usage (Wheel),              ; Wheel (38h, dynamic value)
        Logical Minimum (-127),
        Logical Maximum (127),
        Report Size (8),
        Report Count (1),
        Input (Variable, Relative),
        Usage (X),                  ; X (30h, dynamic value)
        Usage (Y),                  ; Y (31h, dynamic value)
        Logical Minimum (-32767),
        Logical Maximum (32767),
        Report Size (16),
        Report Count (2),
        Input (Variable, Relative),
    End Collection,
End Collection
Which appears to be Odd with vendor stuff?

Microsoft Wireless one also has multiple devices so shows up on -i1, also a lot more complex:
Code:
kurt@kurt-UP-CHT01:~$ sudo usbhid-dump  -i1 | grep -v : | xxd -r -p | hidrd-convert -o spec
Usage Page (Desktop),                           ; Generic desktop controls (01h)
Usage (Mouse),                                  ; Mouse (02h, application collection)
Collection (Application),
    Usage Page (Desktop),                       ; Generic desktop controls (01h)
    Usage (Mouse),                              ; Mouse (02h, application collection)
    Collection (Logical),
        Report ID (26),
        Usage (Pointer),                        ; Pointer (01h, physical collection)
        Collection (Physical),
            Usage Page (Button),                ; Button (09h)
            Usage Minimum (01h),
            Usage Maximum (05h),
            Report Count (5),
            Report Size (1),
            Logical Minimum (0),
            Logical Maximum (1),
            Input (Variable),
            Report Size (3),
            Report Count (1),
            Input (Constant),
            Usage Page (Desktop),               ; Generic desktop controls (01h)
            Usage (X),                          ; X (30h, dynamic value)
            Usage (Y),                          ; Y (31h, dynamic value)
            Report Count (2),
            Report Size (16),
            Logical Minimum (-32767),
            Logical Maximum (32767),
            Input (Variable, Relative),
            Collection (Logical),
                Report ID (18),
                Usage (Resolution Multiplier),  ; Resolution multiplier (48h, dynamic value)
                Report Count (1),
                Report Size (2),
                Logical Minimum (0),
                Logical Maximum (1),
                Physical Minimum (1),
                Physical Maximum (12),
                Feature (Variable),
                Report ID (26),
                Usage (Wheel),                  ; Wheel (38h, dynamic value)
                Physical Minimum (0),
                Physical Maximum (0),
                Report Count (1),
                Report Size (16),
                Logical Minimum (-32767),
                Logical Maximum (32767),
                Input (Variable, Relative),
            End Collection,
            Collection (Logical),
                Report ID (18),
                Usage (Resolution Multiplier),  ; Resolution multiplier (48h, dynamic value)
                Report Size (2),
                Logical Minimum (0),
                Logical Maximum (1),
                Physical Minimum (1),
                Physical Maximum (12),
                Feature (Variable),
                Physical Minimum (0),
                Physical Maximum (0),
                Report Size (4),
                Feature (Constant),
                Report ID (26),
                Usage Page (Consumer),          ; Consumer (0Ch)
                Report Count (1),
                Report Size (16),
                Logical Minimum (-32767),
                Logical Maximum (32767),
                Usage (AC Pan),                 ; AC pan (0238h, linear control)
                Input (Variable, Relative),
            End Collection,
        End Collection,
    End Collection,
End Collection,
Usage Page (Consumer),                          ; Consumer (0Ch)
Usage (Consumer Control),                       ; Consumer control (01h, application collection)
Collection (Application),
    Usage Page (Desktop),                       ; Generic desktop controls (01h)
    Usage (Mouse),                              ; Mouse (02h, application collection)
    Collection (Logical),
        Report ID (31),
        Usage Page (Consumer),                  ; Consumer (0Ch)
        Usage (AC Pan),                         ; AC pan (0238h, linear control)
        Report Count (1),
        Report Size (16),
        Logical Minimum (-32767),
        Logical Maximum (32767),
        Input (Variable, Relative),
        Report ID (23),
        Usage Page (FF00h),                     ; FF00h, vendor-defined
        Usage (FF06h),
        Usage (FF0Fh),
        Logical Minimum (0),
        Logical Maximum (1),
        Physical Minimum (1),
        Physical Maximum (12),
        Report Count (2),
        Report Size (2),
        Feature (Variable),
        Usage (FF04h),
        Physical Minimum (0),
        Physical Maximum (0),
        Report Count (1),
        Report Size (1),
        Feature (Variable),
        Report Size (3),
        Feature (Constant),
    End Collection,
End Collection
I am guessing that in my case where I tried this a a returned value showed up as:
Mouse Data: 1A 01 00 00 00 00 00 00 00 00
The 1A is the report ID from above...

And for the fun of it a Teensy 3.2 configured as Serial, Mouse, keyboard, joystick:
Code:
kurt@kurt-UP-CHT01:~$ sudo usbhid-dump  -i3 | grep -v : | xxd -r -p | hidrd-convert -o spec
Usage Page (Desktop),           ; Generic desktop controls (01h)
Usage (Mouse),                  ; Mouse (02h, application collection)
Collection (Application),
    Report ID (1),
    Usage Page (Button),        ; Button (09h)
    Usage Minimum (01h),
    Usage Maximum (08h),
    Logical Minimum (0),
    Logical Maximum (1),
    Report Count (8),
    Report Size (1),
    Input (Variable),
    Usage Page (Desktop),       ; Generic desktop controls (01h)
    Usage (X),                  ; X (30h, dynamic value)
    Usage (Y),                  ; Y (31h, dynamic value)
    Usage (Wheel),              ; Wheel (38h, dynamic value)
    Logical Minimum (-127),
    Logical Maximum (127),
    Report Size (8),
    Report Count (3),
    Input (Variable, Relative),
    Usage Page (Consumer),      ; Consumer (0Ch)
    Usage (AC Pan),             ; AC pan (0238h, linear control)
    Logical Minimum (-127),
    Logical Maximum (127),
    Report Size (8),
    Report Count (1),
    Input (Variable, Relative),
End Collection,
Usage Page (Desktop),           ; Generic desktop controls (01h)
Usage (Mouse),                  ; Mouse (02h, application collection)
Collection (Application),
    Report ID (2),
    Usage Page (Desktop),       ; Generic desktop controls (01h)
    Usage (X),                  ; X (30h, dynamic value)
    Usage (Y),                  ; Y (31h, dynamic value)
    Logical Minimum (0),
    Logical Maximum (32767),
    Report Size (16),
    Report Count (2),
    Input (Variable),
End Collection
Would be interesting to see what the reports are ... Tried, and it appears to hang after the claim... I used the Triangle Mouse example
 
I just fell into that rabbit hole. Searching through storage I found a newer wireless Logitech wireless keyboard/mouse combo. Keyboard model is K520, mouse model is M310.
Packet size is 8. It locks up on 1 mouse movement or with a button press and release:

Code:
USB Host Testing
sizeof Device = 32
sizeof Pipe = 96
sizeof Transfer = 64
power up USBHS PHY

ISR: 4084
 Port Change
port change: 10001803
    connect

ISR: 1004088
 Timer0
  begin reset

ISR: 408C
 Port Change
port change: 10001805
  port enabled

ISR: 1004088
 Timer0
  end recovery
new_Device: 12 Mbit/sec
new_Pipe
new_Control_Transfer

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF4420    token=80000200
  Followup 1FFF4360    token=100
  Followup 1FFF43A0    token=8000
enumeration:
new_Control_Transfer
  Followup 1FFF43E0    token=80280
  Followup 1FFF4420    token=80008180

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF43E0    token=80000200
  Followup 1FFF4420    token=8100
enumeration:
new_Control_Transfer
  Followup 1FFF4360    token=80280
  Followup 1FFF3540    token=80120180
  Followup 1FFF43A0    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF4360    token=80000200
  Followup 1FFF3540    token=100
  Followup 1FFF43A0    token=8000
enumeration:
new_Control_Transfer
  Followup 1FFF43E0    token=80280
  Followup 1FFF4420    token=80FC0180
  Followup 1FFF4360    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF43E0    token=80000200
  Followup 1FFF4420    token=F80100
  Followup 1FFF4360    token=8000
enumeration:
new_Control_Transfer
  Followup 1FFF3540    token=80280
  Followup 1FFF43A0    token=80FC0180
  Followup 1FFF43E0    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF3540    token=80000200
  Followup 1FFF43A0    token=EA0100
  Followup 1FFF43E0    token=8000
enumeration:
new_Control_Transfer
  Followup 1FFF4420    token=80280
  Followup 1FFF4360    token=80FC0180
  Followup 1FFF3540    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF4420    token=80000200
  Followup 1FFF4360    token=80E20100
  Followup 1FFF3540    token=8000
enumeration:
new_Control_Transfer
  Followup 1FFF43A0    token=80280
  Followup 1FFF43E0    token=80090180
  Followup 1FFF4420    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF43A0    token=80000200
  Followup 1FFF43E0    token=80000100
  Followup 1FFF4420    token=8000
enumeration:
Config data length = 84
new_Control_Transfer
  Followup 1FFF4360    token=80280
  Followup 1FFF3540    token=80540180
  Followup 1FFF43A0    token=80008080

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF4360    token=80000200
  Followup 1FFF3540    token=100
  Followup 1FFF43A0    token=8000
enumeration:
bNumInterfaces = 3
bConfigurationValue = 1
new_Control_Transfer
  Followup 1FFF43E0    token=80280
  Followup 1FFF4360    token=80008180

ISR: 4E081
 USB Async
Async Followup
  Followup 1FFF43E0    token=80000200
  Followup 1FFF4360    token=8100
enumeration:
USBHub memory usage = 864
USBHub claim_device this=1FFF2960
USBHub memory usage = 864
USBHub claim_device this=1FFF2CC0
USBHub memory usage = 864
USBHub claim_device this=1FFF3020
KeyboardController claim this=1FFF2560
KeyboardController claim this=1FFF2760
MouseController claim this=1FFF3380
Descriptor 4 = INTERFACE
KeyboardController claim this=1FFF2560
ep = 81
packet size = 8
polling interval = 8
new_Pipe
allocate_interrupt_pipe_bandwidth
 best_bandwidth = 3
, at offset = 0, shift= 0
add_qh_to_periodic_schedule:
  interval = 8
  offset =   0
  add to slot 0
  add to slot 8
  add to slot 16
  add to slot 24
Periodic Schedule:
 0: 1FFF3420
 1: (empty)
 2: (empty)
 3: (empty)
 4: (empty)
 5: (empty)
 6: (empty)
 7: (empty)
 8: 1FFF3420
 9: (empty)
10: (empty)
11: (empty)
12: (empty)
13: (empty)
14: (empty)
15: (empty)
16: 1FFF3420
17: (empty)
18: (empty)
19: (empty)
20: (empty)
21: (empty)
22: (empty)
23: (empty)
24: 1FFF3420
25: (empty)
26: (empty)
27: (empty)
28: (empty)
29: (empty)
30: (empty)
31: (empty)
new_Data_Transfer
new_Control_Transfer
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
Descriptor 4 = INTERFACE
KeyboardController claim this=1FFF2760
MIDIDevice claim this=1FFF2020
len = 50
MouseController claim this=1FFF3380
ep(mouse) = 82
descriptors[22] = 8
descriptors[23] = 0
packet size(mouse) = 8
polling interval = 2
new_Pipe
allocate_interrupt_pipe_bandwidth
 best_bandwidth = 3
, at offset = 2, shift= 0
add_qh_to_periodic_schedule:
  interval = 2
  offset =   2
  add to slot 2
  add to slot 4
  add to slot 6
  traverse list 8
  add to slot 10
  add to slot 12
  add to slot 14
  traverse list 16
  add to slot 18
  add to slot 20
  add to slot 22
  traverse list 24
  add to slot 26
  add to slot 28
  add to slot 30
Periodic Schedule:
 0: 1FFF3420 -> 1FFF33C0
 1: (empty)
 2: 1FFF33C0
 3: (empty)
 4: 1FFF33C0
 5: (empty)
 6: 1FFF33C0
 7: (empty)
 8: 1FFF3420 -> 1FFF33C0
 9: (empty)
10: 1FFF33C0
11: (empty)
12: 1FFF33C0
13: (empty)
14: 1FFF33C0
15: (empty)
16: 1FFF3420 -> 1FFF33C0
17: (empty)
18: 1FFF33C0
19: (empty)
20: 1FFF33C0
21: (empty)
22: 1FFF33C0
23: (empty)
24: 1FFF3420 -> 1FFF33C0
25: (empty)
26: 1FFF33C0
27: (empty)
28: 1FFF33C0
29: (empty)
30: 1FFF33C0
31: (empty)
new_Data_Transfer
new_Control_Transfer
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
Descriptor 4 = INTERFACE
KeyboardController claim this=1FFF2760
MIDIDevice claim this=1FFF2020
len = 25
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
  Followup 1FFF3540    token=80000200
  Followup 1FFF3500    token=8100
  Followup 1FFF4420    token=80000200
  Followup 1FFF24E0    token=8100

ISR: 4C081
 USB Async
Async Followup

ISR: 8E089
 USB Periodic
Periodic Followup
  Followup 1FFF43E0    token=88180
  Followup 1FFF34C0    token=80008100
MouseController Callback (member)
  Mouse Data: 02 00 00 03 30 00 00 00 
new_Data_Transfer
  Followup 1FFF3480    token=148180

ISR: 8E083
 USB Error
 USB Periodic
Periodic Followup
  Followup 1FFF43E0    token=88180
  Followup 1FFF3480    token=80048150
MouseController Callback (member)
  Mouse Data: 02 00 00 05 60 00 00 00 
new_Data_Transfer
  Followup 1FFF24E0    token=148180
ERROR Followup

Apparently the newer wireless keyboard/mouse protocols have changed.
I noticed that the endpoints swapped. 81 for the keyboard and 82 for the mouse. Reversed from before.
Also bNumberInterfaces = 3 instead of 2. Could the first interface be the wireless receiver?
I know that the wireless receivers can be paired with the mouse and keyboard.
 
That's a very deep rabbit hole....

Yep - I was hacking on the enumeration code:
Code:
#if 1
		case 14: // device is now configured
			claim_drivers(dev);
			dev->enum_state = 15;

			mk_setup(enumsetup, 0x80, 6, 0x2200, 3, 255);  // bugbug... need to get the right one... 
			queue_Control_Transfer(dev, &enumsetup, enumbuf, NULL);
			println("************************ Device report desc ******************");
			return;
		case 15: // control transfers for other stuff?
			println("Dev info?");
			print_hexbytes(enumbuf, 32);

#endif
			// unlock exclusive access to enumeration process.  If any
			// more devices are waiting, the hub driver is responsible
			// for resetting their ports and starting their enumeration
			// when the port enables.
			USBHost::enumeration_busy = false;
			return;
		case 16:
This appeared to grab the descriptor... (part inside the #1...)
But the 3 not sure of... My earlier guess would be 2, but that gave me the keyboard info for the T3.2...
Also need to figure out both how to get the correct value here but also how many bytes to receive and know how many were received.

Probably should try with simpler device. As you can see the claim code:
Code:
USBHub claim_device this=1FFF26E0
MouseController claim this=1FFF2A60
MouseController claim descriptors
  : 08 0B 00 02 02 02 01 04 09 04 00 00 01 02 02 01 00 05 24 00 10 01 05 24 01 01 01 04 24 02 06 05 24 06 00 01 07 05 82 03 10 00 40 09 04 01 00 02 0A 00 00 00 07 05 03 02 40 00 00 07 05 84 02 40 00 00 09 04 02 00 01 03 01 01 00 09 21 11 01 00 01 22 3F 00 07 05 81 03 08 00 01 09 04 03 00 01 03 00 00 00 09 21 11 01 00 01 22 54 00 07 05 85 03 08 00 02 09 04 04 00 01 03 00 00 00 09 21 11 01 00 01 22 55 00 07 05 86 03 0C 00 01 09 04 05 00 01 03 00 00 00 09 21 11 01 00 01 22 28 00 07 05 87 03 08 00 04 
Descriptor 11 = IAD
Descriptor 4 = INTERFACE
MouseController claim this=1FFF2A60
MouseController claim descriptors
  : 09 04 00 00 01 02 02 01 00 05 24 00 10 01 05 24 01 01 01 04 24 02 06 05 24 06 00 01 07 05 82 03 10 00 40 09 04 01 00 02 0A 00 00 00 07 05 03 02 40 00 00 07 05 84 02 40 00 00 09 04 02 00 01 03 01 01 00 09 21 11 01 00 01 22 3F 00 07 05 81 03 08 00 01 09 04 03 00 01 03 00 00 00 09 21 11 01 00 01 22 54 00 07 05 85 03 08 00 02 09 04 04 00 01 03 00 00 00 09 21 11 01 00 01 22 55 00 07 05 86 03 0C 00 01 09 04 05 00 01 03 00 00 00 09 21 11 01 00 01 22 28 00 07 05 87 03 08 00 04 
Descriptor 36 =  ???
Descriptor 36 =  ???
Descriptor 36 =  ???
Descriptor 36 =  ???
Descriptor 5 = ENDPOINT
Descriptor 4 = INTERFACE
MouseController claim this=1FFF2A60
MouseController claim descriptors
  : 09 04 01 00 02 0A 00 00 00 07 05 03 02 40 00 00 07 05 84 02 40 00 00 09 04 02 00 01 03 01 01 00 09 21 11 01 00 01 22 3F 00 07 05 81 03 08 00 01 09 04 03 00 01 03 00 00 00 09 21 11 01 00 01 22 54 00 07 05 85 03 08 00 02 09 04 04 00 01 03 00 00 00 09 21 11 01 00 01 22 55 00 07 05 86 03 0C 00 01 09 04 05 00 01 03 00 00 00 09 21 11 01 00 01 22 28 00 07 05 87 03 08 00 04 
Descriptor 5 = ENDPOINT
Descriptor 5 = ENDPOINT
Descriptor 4 = INTERFACE
MouseController claim this=1FFF2A60
MouseController claim descriptors
  : 09 04 02 00 01 03 01 01 00 09 21 11 01 00 01 22 3F 00 07 05 81 03 08 00 01 09 04 03 00 01 03 00 00 00 09 21 11 01 00 01 22 54 00 07 05 85 03 08 00 02 09 04 04 00 01 03 00 00 00 09 21 11 01 00 01 22 55 00 07 05 86 03 0C 00 01 09 04 05 00 01 03 00 00 00 09 21 11 01 00 01 22 28 00 07 05 87 03 08 00 04 
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
Descriptor 4 = INTERFACE
MouseController claim this=1FFF2A60
MouseController claim descriptors
  : 09 04 03 00 01 03 00 00 00 09 21 11 01 00 01 22 54 00 07 05 85 03 08 00 02 09 04 04 00 01 03 00 00 00 09 21 11 01 00 01 22 55 00 07 05 86 03 0C 00 01 09 04 05 00 01 03 00 00 00 09 21 11 01 00 01 22 28 00 07 05 87 03 08 00 04 
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
Descriptor 4 = INTERFACE
MouseController claim this=1FFF2A60
MouseController claim descriptors
  : 09 04 04 00 01 03 00 00 00 09 21 11 01 00 01 22 55 00 07 05 86 03 0C 00 01 09 04 05 00 01 03 00 00 00 09 21 11 01 00 01 22 28 00 07 05 87 03 08 00 04 
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
Descriptor 4 = INTERFACE
MouseController claim this=1FFF2A60
MouseController claim descriptors
  : 09 04 05 00 01 03 00 00 00 09 21 11 01 00 01 22 28 00 07 05 87 03 08 00 04 
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
new_Control_Transfer
************************ Device report desc ******************
  Followup 1FFF3420    token=80000200
  Followup 1FFF33A0    token=80AB0100
  Followup 1FFF3360    token=8000
enumeration:
Dev info?
05 01 09 02 A1 01 85 01 05 09 19 01 29 08 15 00 25 01 95 08 75 01 81 02 05 01 09 30 09 31 09 38 

ISR: 4E081
 USB Async
Async Followup
But if you look at the stuff dumped in the Dev Info stuff, it looks like the start of the debug information.
I am pretty sure I can get the size from the claimed Device info. the bytes: 22 28 00
Is saying the descriptor is: 40 bytes (0x28 LSB 0 MSB)

Not sure yet how best to grab that data as the enumdata buffer is a collection so you would need to know which bytes of it were claimed by the device... Maybe it already does... Will look in the morning
 
Paul, KurtE,

I was able to get my Logitech M310 mouse to work.

In line #67 of mouse.cpp I had to change this:

Code:
	datapipe = new_Pipe(dev, 3, endpoint, 1, packetSize, interval);

To this:

Code:
	datapipe = new_Pipe(dev, 3, endpoint, 1, packetSize+1, interval);

This stopped the "ERROR Followup" message.
 
Hi Again,

I am still working on the Deep Rabbit Hole ;)

At least so far with my Belkin mouse, I am trying it where it reads in the USB Hid descriptor. and I now have code that is starting to decode enough of the data to figure out Where the
Button, X, Y, Wheel fields are within the returned data as well as the size information and type... I don't have the code yet saving away this information and using it to parse the packets coming in.

But here is a debug output for it:
Code:
MouseController control (static)
1FFF2A60
  Setup: 681 2200 0 34
Control Data: 05 01 09 02 A1 01 09 01 A1 00 05 09 19 01 29 03 15 00 25 01 95 03 75 01 81 02 95 01 75 05 81 01 05 01 09 30 09 31 09 38 15 81 25 7F 75 08 95 03 81 06 C0 C0 
  Collection: 1
    Usage: 1
    Collection: 0
      Other:5 9
      Other:19 1
      Other:29 3
      Other:15 0
      Other:25 1
      Report count: 3
      Report size: 1
      Input: Variable 2
Button: 0 1
      Report count: 1
      Report size: 5
      Input: Constant 1
      Other:5 1
      Usage: 30
      Usage: 31
      Usage: 38
      Other:15 81
      Other:25 7F
      Report size: 8
      Report count: 3
      Input: Variable Relative 6
X: 8 8
Y: 16 8
Wheel: 24 8
End Collection
End Collection
At the top shows the actual data that was returned., Then shows my parsing of the data... Some of the stuff I am ignoring, like Min/Max values, which for example are the parts:
Other:15 81
Other:25 7F
Which I may look at later as to know if the data is signed or unsigned.

So the areas printing out showing Where fields start by Bit position:
Button starts at offset 0
X starts at offset 8 and is 8 bits long
Y 16 8
Wheel 24 8

Next up probably dumping more data for the HP mouse which adds new wrinkle, has vendor data in middle...

Then Logitech/Microsoft, which adds other new things like REPORT ID - which often implies the device might send data in different formats, and so may need to save away offsets and configurations for a few different formats: Example the Teensy Mouse code I believe has two formats: The first for the normal mouse operations where it has the buttons, x, y, wheel with the values as relative values. But also has a second report where only send X, Y values in absolute position.

But first I installed the released IDE and code did not Link, lots of Print stuff not included... Went back to last beta, it builds... Now try to reinstall the release and see if it works.

Update: reinstall appears to be working better?

Added more stuff, now with Logitech wireless, I had to put the code in that detects the descriptor was not for the Mouse and then ask for the next index... So now gets it... Then added code to detect a "report number" which gives an 8 bit ID for the report...

Code:
MouseController control (static)
1FFF2A60
  Setup: 681 2200 1 B1
Control Data: 05 01 09 02 A1 01 85 02 09 01 A1 00 05 09 19 01 29 08 15 00 25 01 95 08 75 01 81 02 05 01 16 01 F8 26 FF 07 75 0C 95 02 09 30 09 31 81 06 15 81 25 7F 75 08 95 01 09 38 81 06 05 0C 0A 38 02 95 01 81 06 C0 C0 05 0C 09 01 A1 01 85 03 75 10 95 02 15 01 26 8C 02 19 01 2A 8C 02 81 60 C0 05 01 09 80 A1 01 85 04 75 02 95 01 15 01 25 03 09 82 09 81 09 83 81 60 75 06 81 03 C0 06 00 FF 09 01 A1 01 85 10 75 08 95 06 15 00 26 FF 00 09 01 81 00 09 01 91 00 C0 06 00 FF 09 02 A1 01 85 11 75 08 95 13 15 00 26 FF 00 09 02 81 00 09 02 91 00 C0 
  Collection: 1
    Report ID: 2 0
    Usage: 1
    Collection: 0
      Other:5 9
      Other:19 1
      Other:29 8
      Other:15 0
      Other:25 1
      Report count: 8
      Report size: 1
      Input: Variable 2
Button: 8 1
      Other:5 1
      Other:16 1 F8
      Other:26 FF 7
      Report size: C
      Report count: 2
      Usage: 30
      Usage: 31
      Input: Variable Relative 6
X: 16 12
Y: 28 12
      Other:15 81
      Other:25 7F
      Report size: 8
      Report count: 1
      Usage: 38
      Input: Variable Relative 6
Wheel: 40 8
      Other:5 C
      Other:A 38 2
      Report count: 1
      Input: Variable Relative 6
End Collection
End Collection
  Other:5 C
  Usage: 1
  Collection: 1
    Report ID: 3 56
    Report size: 10
    Report count: 2
    Other:15 1
    Other:26 8C 2
    Other:19 1
    Other:2A 8C 2
    Input: 60
End Collection
  Other:5 1
  Usage: 80
  Collection: 1
    Report ID: 4 96
    Report size: 2
    Report count: 1
    Other:15 1
    Other:25 3
    Usage: 82
    Usage: 81
    Usage: 83
    Input: 60
    Report size: 6
    Input: Constant Variable 3
End Collection
  Other:6 0 FF
  Usage: 1
  Collection: 1
    Report ID: 10 106
    Report size: 8
    Report count: 6
    Other:15 0
    Other:26 FF 0
    Usage: 1
    Input: 0
    Usage: 1
    Other:91 0
End Collection
  Other:6 0 FF
  Usage: 2
  Collection: 1
    Report ID: 11 162
    Report size: 8
    Report count: 13
    Other:15 0
    Other:26 FF 0
    Usage: 2
    Input: 0
    Usage: 2
    Other:91 0
End Collection
So far not saving report information. Only the first one appears to be one I expect to process....
 
Last edited:
More work on the "Rabbit Hole"

I now have it parsing through the descriptor data for many of the fields, to gather hopefully enough info to figure out the positions sizes and types of the different fields.

There are interesting complications with several of the different mice that I have, especially the Microsoft sculpt ergo desktop...

The code is now actually extracting the data from where I think each device is providing it.

Right now my branch in my fork: https://github.com/KurtE/USBHost_t36/tree/Mouse-Rabbit-Hole
Has all of the debug printing turned on... So lots of debug stuff printing.

But I think I have working:
Belkin Wired Mouse: Pretty standard: 8 bit buttons, 8 bit X, Y, wheel

HP Wired mouse: Sort of Funky with Buttons, 2 8 bit vendor fields, 16 bit Wheel, 16 bit X, 16 bit Y - I think the 2 vendor fields are 8 bit versions of X and Y

A logitech wireless mouse (and keyboard) (12 bit X, Y outputs) plus report ID, 8 bit wheel

Microsoft Sculpted Wireless, lots of junk, with nested collections, interleaved report data... But I think I picked out enough stuff to get it working.

It might be interesting if others tried out several more mice to see how well I am handling them.

Here is showing the data I output as walking through HP mouse:
Code:
Control Data: 05 01 09 02 A1 01 09 01 A1 00 05 09 19 01 29 03 15 00 25 01 75 01 95 03 81 02 75 05 95 01 81 03 06 00 FF 09 40 95 02 75 08 15 81 25 7F 81 02 05 01 09 38 15 81 25 7F 75 08 95 01 81 06 09 30 09 31 16 01 80 26 FF 7F 75 10 95 02 81 06 C0 C0 
  Collection: Application
    Usage: 1 +
    Collection: Physical
      Usage page: 9
      Other:19 1
      Other:29 3
      Other:15 0
      Other:25 1
      Report size: 1
      Report count: 3
      Input: Variable 2
      ### Button: 0 1
      Report size: 5
      Report count: 1
      Input: Constant Variable 3
      Usage page: FF00
      Usage: 40 +
      Report count: 2
      Report size: 8
      Other:15 81
      Other:25 7F
      Input: Variable 2
      ??? Other: 8 8
      Usage page: 1
      Usage: 38 +
      Other:15 81
      Other:25 7F
      Report size: 8
      Report count: 1
      Input: Variable Relative 6
      ### Wheel: 24 8
      Usage: 30 +
      Usage: 31 +
      Other:16 1 80
      Other:26 FF 7F
      Report size: 10
      Report count: 2
      Input: Variable Relative 6
      ### X: 32 16
      ### Y: 48 16
      End Collection
    End Collection
From this you can deduce:
Code:
      ### Button: 0 1
      ??? Other: 8 8 *2
      ### Wheel: 24 8
      ### X: 32 16
      ### Y: 48 16
The first numbers are the bit offset, and second one is size... Button is special cased to 8 later... The??? other only shows up once but there is a report count 2...

Code has been updated in the github mentioned... Next up figure out why T3.2 hangs...
 
It would be great if a few people could try this out with some different mice to see how well it is working.

I cleaned it up a little this morning, and I turned off the total USB host debug setting, to get rid of all of the debug output...

I added in a member: connected()
Which returns true if there is a mouse currently connected, which I use with a new debug member I added: printDeviceInfo()
Which prints out debug information about what was detected about the current mouse.
I added a new example program Mouse_Only which makes use of it...

So for example If I run this program, lets say starting off with Belkin mouse plugged in:
Do a few things, unplug the mouse and then plug in the wireless adapter for Logitech and do a few thing, you see:
Code:
USB Host Mouse Testing


*** Mouse Connected ***

Mouse Information
  Packet Size: 8
  Buttons: Bit offset:0 Bit Size:8
  X: Bit offset:8 Bit Size:8 Relative 
  Y: Bit offset:16 Bit Size:8 Relative 
  Wheel: Bit offset:24 Bit Size:8 Relative 
buttons = 0,  wheel = 0,  mouseXpos = 0,  mouseYpos = 0
buttons = 0,  wheel = 0,  mouseXpos = 1,  mouseYpos = 0
buttons = 0,  wheel = 0,  mouseXpos = 2,  mouseYpos = 0
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 0
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 1
buttons = 0,  wheel = -1,  mouseXpos = 3,  mouseYpos = 1
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 1
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 1
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 1
buttons = 1,  wheel = 0,  mouseXpos = 3,  mouseYpos = 1
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 1
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 1


*** Mouse Disconnected ***


*** Mouse Connected ***

Mouse Information
  Packet Size: 8
  Report: 2
  Buttons: Bit offset:8 Bit Size:8
  X: Bit offset:16 Bit Size:12 Relative 
  Y: Bit offset:28 Bit Size:12 Relative 
  Wheel: Bit offset:40 Bit Size:8 Relative 
buttons = 1,  wheel = 0,  mouseXpos = 3,  mouseYpos = 1
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 1
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 0
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 0
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 0
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 0
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 0
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 0
buttons = 0,  wheel = 0,  mouseXpos = 3,  mouseYpos = 0
Note the code does not print the Mouse information, until it does first report as there can be a slight delay of time between when the mouse is detected and when it has retrieved and processed the HID descriptor info.

I updated github and squashed the changes into one commit... If it all works reasonably well for others, will issue Pull Request

Note: Will still try to figure out what is happening with using T3.2 as a mouse. Also maybe cleanup, I have a static buffer I created of 256 bytes, to read in descriptor, not sure clean way to handle here. Could maybe reuse the enumeration buffer, could make member data, But would be nice not to have to hang on to field like this, but know that malloc or new or ... is probably not wanted here.
 
KurtE - I was going to ask about testing a few mice yesterday - but time is limited. I tried 10 times with Github - it would never complete the sync - first I had to remove the PJRC prior download - then it just never liked the rabbit hole name - certainly confused on Windows. The Third example was never installed like it was grabbing PJRC's?

First note - Since the USB_HOST can hot swap at anytime it seems having a safe static area for your processing might be best? Having it come and go later could be less than ideal.

Pulled the ZIP and extracted - first build the IDE used the PJRC source - didn't like the rabbit hole either? So I renamed and finally got:
Multiple libraries were found for "USBHost_t36.h"
Used: i:\tcode\libraries\USBHost_t36
Not used: I:\arduino-1.8.4\hardware\teensy\avr\libraries\USBHost_t36

Here is the first wired Logitech I have handy - has left/right/wheel/wheel button. The X/Y-pos look odd? As does the wheel value from rolling it:
*** Mouse Connected ***

Mouse Information
Packet Size: 5
Buttons: Bit offset:0 Bit Size:8
X: Bit offset:8 Bit Size:8 Relative
Y: Bit offset:16 Bit Size:8 Relative
Wheel: Bit offset:24 Bit Size:8 Relative
buttons = 1, wheel = 0, mouseXpos = 626, mouseYpos = 413
buttons = 0, wheel = 0, mouseXpos = 626, mouseYpos = 413
buttons = 2, wheel = 0, mouseXpos = 626, mouseYpos = 413
buttons = 0, wheel = 0, mouseXpos = 626, mouseYpos = 413
buttons = 0, wheel = -1, mouseXpos = 626, mouseYpos = 413
buttons = 0, wheel = -1, mouseXpos = 626, mouseYpos = 413
buttons = 0, wheel = 1, mouseXpos = 626, mouseYpos = 413
buttons = 4, wheel = 0, mouseXpos = 626, mouseYpos = 413
buttons = 0, wheel = 0, mouseXpos = 626, mouseYpos = 413
buttons = 0, wheel = 0, mouseXpos = 625, mouseYpos = 413
buttons = 0, wheel = 0, mouseXpos = 623, mouseYpos = 412
buttons = 0, wheel = 0, mouseXpos = 621, mouseYpos = 412
buttons = 0, wheel = 0, mouseXpos = 619, mouseYpos = 412
buttons = 0, wheel = 0, mouseXpos = 615, mouseYpos = 412
buttons = 0, wheel = 0, mouseXpos = 609, mouseYpos = 412
buttons = 0, wheel = 0, mouseXpos = 603, mouseYpos = 412
buttons = 0, wheel = 0, mouseXpos = 596, mouseYpos = 412
buttons = 0, wheel = 0, mouseXpos = 586, mouseYpos = 413
buttons = 0, wheel = 0, mouseXpos = 577, mouseYpos = 414
buttons = 0, wheel = 0, mouseXpos = 568, mouseYpos = 414
buttons = 0, wheel = 0, mouseXpos = 561, mouseYpos = 414
buttons = 0, wheel = 0, mouseXpos = 554, mouseYpos = 414
buttons = 0, wheel = 0, mouseXpos = 548, mouseYpos = 414
buttons = 0, wheel = 0, mouseXpos = 542, mouseYpos = 414
buttons = 0, wheel = 0, mouseXpos = 536, mouseYpos = 415
buttons = 0, wheel = 0, mouseXpos = 530, mouseYpos = 417
buttons = 0, wheel = 0, mouseXpos = 527, mouseYpos = 418
buttons = 0, wheel = 0, mouseXpos = 525, mouseYpos = 417
buttons = 0, wheel = 0, mouseXpos = 511, mouseYpos = 417
buttons = 0, wheel = 0, mouseXpos = 491, mouseYpos = 418
buttons = 0, wheel = 0, mouseXpos = 466, mouseYpos = 419
buttons = 0, wheel = 0, mouseXpos = 440, mouseYpos = 419
buttons = 0, wheel = 0, mouseXpos = 418, mouseYpos = 419
buttons = 0, wheel = 0, mouseXpos = 402, mouseYpos = 419
buttons = 0, wheel = 0, mouseXpos = 393, mouseYpos = 420
buttons = 0, wheel = 0, mouseXpos = 388, mouseYpos = 420
buttons = 0, wheel = 0, mouseXpos = 391, mouseYpos = 420
buttons = 0, wheel = 0, mouseXpos = 401, mouseYpos = 418
buttons = 0, wheel = 0, mouseXpos = 423, mouseYpos = 415
buttons = 0, wheel = 0, mouseXpos = 449, mouseYpos = 411
buttons = 0, wheel = 0, mouseXpos = 479, mouseYpos = 407
buttons = 0, wheel = 0, mouseXpos = 509, mouseYpos = 403
buttons = 0, wheel = 0, mouseXpos = 533, mouseYpos = 402
buttons = 0, wheel = 0, mouseXpos = 547, mouseYpos = 400
buttons = 0, wheel = 0, mouseXpos = 555, mouseYpos = 400
buttons = 0, wheel = 0, mouseXpos = 559, mouseYpos = 394
buttons = 0, wheel = 0, mouseXpos = 564, mouseYpos = 377
buttons = 0, wheel = 0, mouseXpos = 570, mouseYpos = 349
buttons = 0, wheel = 0, mouseXpos = 580, mouseYpos = 317
buttons = 0, wheel = 0, mouseXpos = 591, mouseYpos = 283
buttons = 0, wheel = 0, mouseXpos = 599, mouseYpos = 250
buttons = 0, wheel = 0, mouseXpos = 606, mouseYpos = 219
buttons = 0, wheel = 0, mouseXpos = 611, mouseYpos = 192
buttons = 0, wheel = 0, mouseXpos = 616, mouseYpos = 175
buttons = 0, wheel = 0, mouseXpos = 619, mouseYpos = 166
buttons = 0, wheel = 0, mouseXpos = 620, mouseYpos = 164
buttons = 0, wheel = 0, mouseXpos = 621, mouseYpos = 173
buttons = 0, wheel = 0, mouseXpos = 621, mouseYpos = 191
buttons = 0, wheel = 0, mouseXpos = 621, mouseYpos = 214
buttons = 0, wheel = 0, mouseXpos = 621, mouseYpos = 239
buttons = 0, wheel = 0, mouseXpos = 621, mouseYpos = 266
buttons = 0, wheel = 0, mouseXpos = 622, mouseYpos = 291
buttons = 0, wheel = 0, mouseXpos = 623, mouseYpos = 313
buttons = 0, wheel = 0, mouseXpos = 624, mouseYpos = 333
buttons = 0, wheel = 0, mouseXpos = 625, mouseYpos = 350
buttons = 0, wheel = 0, mouseXpos = 625, mouseYpos = 362
buttons = 0, wheel = 0, mouseXpos = 625, mouseYpos = 370
buttons = 0, wheel = 0, mouseXpos = 626, mouseYpos = 374
buttons = 0, wheel = 0, mouseXpos = 626, mouseYpos = 375


*** Mouse Disconnected ***
 
May have to play around more with the test app. This started off as part of the zip file from @wwatson, I have not played around at all with the scaling and the like, nor initial values.

I simply verified if I move the mouse up and down, it increments and decrements the Y, likewise left and right the Y, and the wheel works like 0 and +-1 for the most part...
 
I tried a Microsoft Optical Mouse Blue and a Logitech G400s, both work correctly (with the Mouse-Rabbit-Hole branch).
 
Status
Not open for further replies.
Back
Top