Skip to content

Choose which USB and USB HID devices to include at compile-time #2116

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

Merged
merged 7 commits into from
Sep 5, 2019

Conversation

dhalbert
Copy link
Collaborator

@dhalbert dhalbert commented Sep 4, 2019

Make it easy to enable and disable which USB and USB HID devices to include at build time, using two makefile variables. Defaults are:

USB_DEVICES = "CDC,MSC,AUDIO,HID"
USB_HID_DEVICES = "KEYBOARD,MOUSE,CONSUMER,GAMEPAD"

For instance, in mpconfigboard.mk, you can define those variables:

USB_DEVICES = "CDC,MSC"    # Omit MIDI and HID
USB_HID_DEVICES="KEYBOARD"    # Use only keyboard

A couple of new HID devices have been added, but are not in the default set. The entire set is KEYBOARD,MOUSE,CONSUMER,SYS_CONTROL,GAMEPAD,DIGITIZER,XAC_COMPATIBLE_GAMEPAD,RAW

If only one HID device is chosen, then it will not have a report ID in the generated HID descriptor.

XAC_COMPATIBLE_GAMEPAD is an alternate gamepad that is compatible with the Microsoft XAC controller. RAW is a 64-bit raw HID device, usage page 0xFFAF, usage 0xAF (AF is "AdaFruit"). RAW cannot be used with other HID devices, because it cannot have a report id.

The mechanism for generating the table of usb_hid.Device entries has also been simplified. More code is generated and less is done by tricky Makefile variables.

This partially addresses some needs stated in #1015 but does not allow generation of USB or USB HID descriptors at run-time, in boot.py.

Tagging @ATMakersBill and @hierophect for interest.

Copy link
Collaborator

@hierophect hierophect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low endpoint devices such as the F411 will still have issues with the descriptor file, as they need the MSC endpoints reduced from 2 to 1.

tandard.EndpointDescriptor(
                description="MSC in",
                bEndpointAddress=0x0 | standard.EndpointDescriptor.DIRECTION_IN,
                bmAttributes=standard.EndpointDescriptor.TYPE_BULK,
                bInterval=0),
            standard.EndpointDescriptor(
                description="MSC out",
                bEndpointAddress=0x1 | standard.EndpointDescriptor.DIRECTION_OUT,
                bmAttributes=standard.EndpointDescriptor.TYPE_BULK,
                bInterval=0)

Could we introduce a flag or other condition for this case?

Copy link
Collaborator

@hierophect hierophect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for including this.

@dhalbert dhalbert merged commit 296e858 into adafruit:master Sep 5, 2019
@dhalbert dhalbert deleted the choose-usb-devices-xac branch September 5, 2019 17:25
@ATMakersBill
Copy link
Collaborator

Excited to see this! Will test tomorrow (hopefully) and then share w/friends in the XAC community!

@ATMakersBill
Copy link
Collaborator

@dhalbert is there a version of Gamepad that matches the XAC gamepad?

@dhalbert
Copy link
Collaborator Author

dhalbert commented Sep 6, 2019

@ATMakersBill Yes, see the top post. You can do (in, say, mpconfigboard.mk

USB_HID_DEVICES = XAC_COMPATIBLE_GAMEPAD

and get a single XAC gamepad without a report ID. Use your XAC-compatible Gamepad.py. I plan to test this soon.

@ATMakersBill
Copy link
Collaborator

Sorry, I meant was there an updated HID library with an XAC gamepad. I can test with mine, but was wondering how that would be added to the libs

@dhalbert
Copy link
Collaborator Author

dhalbert commented Sep 6, 2019

Nope, I didn't add anything yet - just use your library for now. It will probably be a separate library, because adding it to frozen HID will make HID even bigger and take more flash, which is a problem on CPX.

@ThomasAtBBTF
Copy link

Yes, a way to control of which devices the USB composite device consists of is very important!
Also, a second UART CDC would be extremely helpful. I hate to use the primary CDC for communication and give the customer access to the REPL!

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.

4 participants