felis / USB_Host_Shield_2.0

Revision 2.0 of USB Host Library for Arduino.
https://chome.nerpa.tech
1.76k stars 780 forks source link

USB Hub - Confusing behavior with HIDBoot initialization code and USBHIDKbdAndMouse.ino when using a USB Hub #547

Open nathanielhudson opened 3 years ago

nathanielhudson commented 3 years ago

Hello!

I just spent quite a few hours going crazy trying to debug an issue. I'm trying to connect a mouse and keyboard via a USB hub to an arduino uno. I had everything connected correctly (with a powered USB hub), but was seeing no output from mouse or keyboard events using the USBHIDKbdAndMouse.ino example.

Original code: In this case, nothing works

HIDBoot < USB_HID_PROTOCOL_KEYBOARD | USB_HID_PROTOCOL_MOUSE > HidComposite(&Usb);
HIDBoot<USB_HID_PROTOCOL_KEYBOARD>    HidKeyboard(&Usb);
HIDBoot<USB_HID_PROTOCOL_MOUSE>    HidMouse(&Usb);

However, if I reorder the lines as follows the mouse+kbd start working.

HIDBoot<USB_HID_PROTOCOL_MOUSE>    HidMouse(&Usb);
HIDBoot<USB_HID_PROTOCOL_KEYBOARD>    HidKeyboard(&Usb);
HIDBoot < USB_HID_PROTOCOL_KEYBOARD | USB_HID_PROTOCOL_MOUSE > HidComposite(&Usb);

Is it intended behavior that order on these matters? If this is intended: The behavior here is a bit confusing, and adding it to the comments on that ino file might save others the trouble I had.

Cybirbug commented 2 weeks ago

Wow that fixed it, had the same problem. Thank-you.

At least changing the order in the example would help if this bug isn't going to be addressed.