Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIDDeviceInfo - Structure prints the HID Report descriptor #96

Merged
merged 6 commits into from Aug 20, 2022

Conversation

KurtE
Copy link
Contributor

@KurtE KurtE commented Aug 5, 2022

@PaulStoffregen @mjs513,

As I mentioned in a thread today, I have been wanting to print out additional information about a HID device. Before I would use Linux, and plug in a device and use USBHID-dump plus another few commands to print out a structured ouput. But that second app is no longer in Ubuntu releases since about 18.04... So decided to try to use our own sketches to provide this
type of output.

I added two methods to the USBHIDParser class to allow caller code to query it for the Report Descriptor data as well as the length.

I then added code to the example sketch HIDDeviceInfo that when one of my HIDDumper classes is claimed it asks for the descriptor data and tries to do a structured listing of it.

This hopefully will help users to be able to provide enough data to better integrate different HID
Devices.

Some debug output from a Keyboard I plugged in

HIDDumpController Claim: 4d9:a06b usage: 10080HID Report Descritor (0x20009790) size: 81
  05 01	// Usage Page(1) - Generic Desktop
  09 80	// Usage(80) -(?)
  A1 01	// Collection(1) top Usage(10080)
    85 02	// Report ID(2)
    19 81	// Usage Minimum(81) - (System Power Down)
    29 83	// Usage Maximum(83) - (System Wake Up)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 03	// Report Count(3)
    81 02	// Input(2)
    95 05	// Report Count(5)
    81 01	// Input(1)
    C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 03	// Report ID(3)
    19 00	// Usage Minimum(0) - (?)
    2A FF 02	// Usage Maximum(2ff) - (?)
    15 00	// Logical Minimum(0)
    26 FF 7F	// Logical maximum(7fff)
    95 01	// Report Count(1)
    75 10	// Report Size(10)
    81 00	// Input(0)
    C0	// End Collection
  06 00 FF	// Usage Page(ff00) - Vendor Defined
  09 01	// Usage(1) -
  A1 01	// Collection(1) top Usage(ff000000)
    85 06	// Report ID(6)
    15 00	// Logical Minimum(0)
    26 FF 00	// Logical maximum(ff)
    09 2F	// Usage(2f) -
    75 08	// Report Size(8)
    95 03	// Report Count(3)
    81 02	// Input(2)
    09 30	// Usage(30) -
    95 07	// Report Count(7)
    B1 02	// Feature(2)
    C0	// End Collection
 - Yes
HIDDumpController Claim: 4d9:a06b usage: c0001 - NO (Usage: 10080)
HIDDumpController Claim: 4d9:a06b usage: c0001HID Report Descritor (0x20009790) size: 81
  05 01	// Usage Page(1) - Generic Desktop
  09 80	// Usage(80) -(?)
  A1 01	// Collection(1) top Usage(10080)
    85 02	// Report ID(2)
    19 81	// Usage Minimum(81) - (System Power Down)
    29 83	// Usage Maximum(83) - (System Wake Up)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 03	// Report Count(3)
    81 02	// Input(2)
    95 05	// Report Count(5)
    81 01	// Input(1)
    C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 03	// Report ID(3)
    19 00	// Usage Minimum(0) - (?)
    2A FF 02	// Usage Maximum(2ff) - (?)
    15 00	// Logical Minimum(0)
    26 FF 7F	// Logical maximum(7fff)
    95 01	// Report Count(1)
    75 10	// Report Size(10)
    81 00	// Input(0)
    C0	// End Collection
  06 00 FF	// Usage Page(ff00) - Vendor Defined
  09 01	// Usage(1) -
  A1 01	// Collection(1) top Usage(ff000000)
    85 06	// Report ID(6)
    15 00	// Logical Minimum(0)
    26 FF 00	// Logical maximum(ff)
    09 2F	// Usage(2f) -
    75 08	// Report Size(8)
    95 03	// Report Count(3)
    81 02	// Input(2)
    09 30	// Usage(30) -
    95 07	// Report Count(7)
    B1 02	// Feature(2)
    C0	// End Collection
 - Yes
HIDDumpController Claim: 4d9:a06b usage: 10006HID Report Descritor (0x20009e50) size: 37
  05 01	// Usage Page(1) - Generic Desktop
  09 06	// Usage(6) -(Keyboard)
  A1 01	// Collection(1) top Usage(10000)
    05 07	// Usage Page(7) - Keycode
    19 E0	// Usage Minimum(e0) - (Left Control)
    29 E7	// Usage Maximum(e7) - (Right)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 08	// Report Count(8)
    81 02	// Input(2)
    19 00	// Usage Minimum(0) - (Keycode 0)
    29 6F	// Usage Maximum(6f) - (Keycode 111)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 70	// Report Count(70)
    81 02	// Input(2)
    C0	// End Collection
 - Yes

I added two methods to the USBHIDParser class to allow caller code to query it for the Report Descriptor data as well as the length.

I then added code to the example sketch HIDDeviceInfo that when one of my HIDDumper classes is claimed it asks for the descriptor data and tries to do a structured listing of it.

This hopefully will help users to be able to provide enough data to better integrate different HID
Devices.

Some debug output from a Keyboard I plugged in

```
HIDDumpController Claim: 4d9:a06b usage: 10080HID Report Descritor (0x20009790) size: 81
  05 01	// Usage Page(1) - Generic Desktop
  09 80	// Usage(80) -(?)
  A1 01	// Collection(1) top Usage(10080)
    85 02	// Report ID(2)
    19 81	// Usage Minimum(81) - (System Power Down)
    29 83	// Usage Maximum(83) - (System Wake Up)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 03	// Report Count(3)
    81 02	// Input(2)
    95 05	// Report Count(5)
    81 01	// Input(1)
    C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 03	// Report ID(3)
    19 00	// Usage Minimum(0) - (?)
    2A FF 02	// Usage Maximum(2ff) - (?)
    15 00	// Logical Minimum(0)
    26 FF 7F	// Logical maximum(7fff)
    95 01	// Report Count(1)
    75 10	// Report Size(10)
    81 00	// Input(0)
    C0	// End Collection
  06 00 FF	// Usage Page(ff00) - Vendor Defined
  09 01	// Usage(1) -
  A1 01	// Collection(1) top Usage(ff000000)
    85 06	// Report ID(6)
    15 00	// Logical Minimum(0)
    26 FF 00	// Logical maximum(ff)
    09 2F	// Usage(2f) -
    75 08	// Report Size(8)
    95 03	// Report Count(3)
    81 02	// Input(2)
    09 30	// Usage(30) -
    95 07	// Report Count(7)
    B1 02	// Feature(2)
    C0	// End Collection
 - Yes
HIDDumpController Claim: 4d9:a06b usage: c0001 - NO (Usage: 10080)
HIDDumpController Claim: 4d9:a06b usage: c0001HID Report Descritor (0x20009790) size: 81
  05 01	// Usage Page(1) - Generic Desktop
  09 80	// Usage(80) -(?)
  A1 01	// Collection(1) top Usage(10080)
    85 02	// Report ID(2)
    19 81	// Usage Minimum(81) - (System Power Down)
    29 83	// Usage Maximum(83) - (System Wake Up)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 03	// Report Count(3)
    81 02	// Input(2)
    95 05	// Report Count(5)
    81 01	// Input(1)
    C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 03	// Report ID(3)
    19 00	// Usage Minimum(0) - (?)
    2A FF 02	// Usage Maximum(2ff) - (?)
    15 00	// Logical Minimum(0)
    26 FF 7F	// Logical maximum(7fff)
    95 01	// Report Count(1)
    75 10	// Report Size(10)
    81 00	// Input(0)
    C0	// End Collection
  06 00 FF	// Usage Page(ff00) - Vendor Defined
  09 01	// Usage(1) -
  A1 01	// Collection(1) top Usage(ff000000)
    85 06	// Report ID(6)
    15 00	// Logical Minimum(0)
    26 FF 00	// Logical maximum(ff)
    09 2F	// Usage(2f) -
    75 08	// Report Size(8)
    95 03	// Report Count(3)
    81 02	// Input(2)
    09 30	// Usage(30) -
    95 07	// Report Count(7)
    B1 02	// Feature(2)
    C0	// End Collection
 - Yes
HIDDumpController Claim: 4d9:a06b usage: 10006HID Report Descritor (0x20009e50) size: 37
  05 01	// Usage Page(1) - Generic Desktop
  09 06	// Usage(6) -(Keyboard)
  A1 01	// Collection(1) top Usage(10000)
    05 07	// Usage Page(7) - Keycode
    19 E0	// Usage Minimum(e0) - (Left Control)
    29 E7	// Usage Maximum(e7) - (Right)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 08	// Report Count(8)
    81 02	// Input(2)
    19 00	// Usage Minimum(0) - (Keycode 0)
    29 6F	// Usage Maximum(6f) - (Keycode 111)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 70	// Report Count(70)
    81 02	// Input(2)
    C0	// End Collection
 - Yes
```
@KurtE
Copy link
Contributor Author

KurtE commented Aug 5, 2022

Correct spelling and make sure starts on new line
Hid dumper Show more info on:
input, output, report
@PaulStoffregen
Copy link
Owner

is this ready to merge?

@KurtE
Copy link
Contributor Author

KurtE commented Aug 19, 2022

It could be any time,

Although I have some changes locally for helping debug some more.

The Logitech G Wireless mouse - sets up a Keyboard with 64 byte packets... Which the messages appear to be killing the system.

I have a hack right now that allows the USBHIDParser class optionally claim (BOOT) keyboards which it appears to be making the code work better.

But I am thinking instead of HID Parser allowing to grab all keyboards... Instead, I am thinking of adding a:
maybe a new keyboard class like: HIDKeyboard(), that works with HID input.
Also have a PID/VID table that the HID Parser would check to see if it should claim a BOOT/Keyboard or not.

We have run into this a few times with like the GIGABYTE keyboard.

Hopefully later today or tomorrow should have version to try.

@PaulStoffregen
Copy link
Owner

Please commit whatever else should be part of this improved printing and then I'll merge it.

I have an unopened Gigabyte Force K83 keyboard that's been sitting here next to my USB host stuff for over a year. Is that the one which causes problems?

@KurtE
Copy link
Contributor Author

KurtE commented Aug 19, 2022

I pushed up the current stuff. I don't believe it is depending on other changes that I am testing.

I now do have code in place where the is a list of keyboards to process as HID device.
I have the HID code being able to detect it.

I have some code in place to take a list of keyboards to support by HID, and the USBHIDParser code will now claim it, and the KeyboardController will not.

Next up either extend keyboard and/or add new class to handle these.

Yes I do have a Gigabyte one that we resolved earlier forcing into boot mode. Once I finish this may try seeing if it work better with HID parser.

I am running into a case with the Logitech G Pro Wireless mouse where if a sort of phantom keyboard part of the object was allowed to be claimed by Keyboard, it will kill the Mouse if nothing was processed for a few minutes.

The code now starts off with a VID/PID list part of Keyboard object, that both the Keyboard objects check for as well as USBHidParsers check when HID Boot Keyboard, and if in this list, it allows the HID parser to claim it instead of the Keyboard controller.

Part 2 - will have some class that can process the Keyboard HID data.
@KurtE
Copy link
Contributor Author

KurtE commented Aug 20, 2022

@PaulStoffregen @mjs513 -

I went ahead and pushed up the WIP on allowing a Keyboard to be claimed by the HID Parser instead of Keyboard.

This so far is allowing the underlying Mouse object to run. Before it would more or less die if the mouse had not been used
for a few minutes. I have been running this version with a Mouse/Keyboard forwarder sketch (not part of any github project)

This however does not fix the HUB issue. If I start up another slot with keyboard, the whole thing hangs with the
several of the QH lists creating loops and hanging.

Note: I also checked in a slightly updated version of the print_qh_list
that does a more thorough check for loops. It also will bail if it prints out over 32 items in a list.

If you prefer, I could pull this stuff back out. But this should allow the one forum member to make progress with their mouse.

So now should be a good time to merge

@PaulStoffregen PaulStoffregen merged commit bd0ad7c into PaulStoffregen:master Aug 20, 2022
@KurtE KurtE deleted the HID_info branch August 20, 2022 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants