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

hidboot: Composite support cosidaration #7

Open
tmk opened this issue Jun 28, 2021 · 1 comment
Open

hidboot: Composite support cosidaration #7

tmk opened this issue Jun 28, 2021 · 1 comment

Comments

@tmk
Copy link
Owner

tmk commented Jun 28, 2021

This issue is related to #6 too.

Support for composite of keyboard and mouse was introduced at commit 2432379 d17e1f9

This allows one instance of HIDBoot to handle keyboard and mouse using two HIDReprotParsers like below.

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

HidComposite.SetReportParser(0, &KbdPrs);
HidComposite.SetReportParser(1, &MousePrs);

Problem

Current implement assmums that keyboard is located on interface0 and mouse is on interface1.
And it won't work with device using other interface than 0 or 1.

Workaround

Use two instances instead, one for keyboard and other for mouse.
This allows us to keep hidboot implementation simple.
This should work even if keyboard or mouse is located on any interface.

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

HidKeyboard.SetReportParser(0, &KbdPrs); 
HidMouse.SetReportParser(0, &MousePrs); 

Note that this workaround requires fix for #6 at same time.

EDIT: This workaround doesn't work because only one driver is assigned for a device.

@tmk
Copy link
Owner Author

tmk commented Jun 28, 2021

In USBHIDBootKbdAndMouse.ino

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);

Three drivers are registered to USBCore and it attempt to load the drivers in order when device is detected.
This example can handle three devices; composite device, keyboard-only device and mouse-only device by the drivers respectively.

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

No branches or pull requests

1 participant