Skip to content

HID gamepad support #776

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 2 commits into from
Apr 24, 2018
Merged

HID gamepad support #776

merged 2 commits into from
Apr 24, 2018

Conversation

dhalbert
Copy link
Collaborator

@dhalbert dhalbert commented Apr 24, 2018

Adds a simple gamepad HID device to the devices that share a common endpoint: mouse, keyboard, consumer controls, and now gamepad.

The gamepad shows up to varying degrees in various operating systems:

  • Linux: visible as a /dev/input/js* device and a /dev/input/event* device. Events can be seen via evtest and jstest. Firefox and Chrome do not see the gamepad via https://html5gamepad.com, but that appears to be due to limited gamepad support/compatibility between the browsers and Linux
  • Windows: can be seen via Control Panel > Hardware and Sound > Devices and Printers > Metro M4 Express (for example). It appears as a keyboard icon, but if you right-click, you'll see a choice of HID devices, and can choose the game controller and get dialog boxes.
    Firefox and Chrome can see the gamepad via http://html5gamepad.com. You may need to send some events before it shows up.
  • MacOS: Firefox and Chrome can see the gamepad via http://html5gamepad.com. You may need to send some events before it shows up.

This PR also includes latent support for a stylus-based digitizer as well, but it conflicts with other devices, so it's turned off until we have dynamic USB HID devices. I had hoped to add a little dynamic boot.py support to allow turning the HID devices on and off before USB comes up, but this requires dynamic construction of both the report descriptors and the HID descriptor, so deferred for now.

Needs adafruit/Adafruit_CircuitPython_HID#19 to have a Python library for the gamepad support.

@dhalbert dhalbert requested a review from tannewt April 24, 2018 04:22

from adafruit_usb_descriptor import hid

class HIDReportDescriptors:
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need a wrapper class? I'd expect the module to be enough.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Originally it had a helper function which ended up not being needed. I'll make it just a module.

Copy link
Member

@tannewt tannewt 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 to me! Folks will be excited for this.

@dglaude
Copy link

dglaude commented Apr 24, 2018

I just want to say that the HTTP version @dhalbert dhalbert refer to https://html5gamepad.com/ say "Connection Refused" where the HTTP version http://html5gamepad.com/ works for me.

@dhalbert
Copy link
Collaborator Author

@dglaude URL's fixed. Thanks!

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.

3 participants