Skip to content

XBox Adaptive Controller needs custom HID Descriptor & tweaks #1696

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

Closed
ATMakersBill opened this issue Mar 25, 2019 · 3 comments · Fixed by #2185
Closed

XBox Adaptive Controller needs custom HID Descriptor & tweaks #1696

ATMakersBill opened this issue Mar 25, 2019 · 3 comments · Fixed by #2185

Comments

@ATMakersBill
Copy link
Collaborator

ATMakersBill commented Mar 25, 2019

[Note: @dhalbert requested this issue even though it's really not a bug in CP, but in the XAC]

I spent a great deal of time getting the XBox Adaptive Controller (XAC) to work with CircuitPython. I found that there were a number of issues with the XAC's implementation of HID that I had to work around.

I have reported those issues to Microsoft, but I've heard back that there will not be a quick resolution to them. So, in the meantime, if we want to be able to use CP on the XAC (which I do!), it would be great to have my modifications available to other CP users.

Note: YES, I agree this is "coding to the bugs" and not a good long-term solution. But the XAC is making real strides in the AT community, and what we can do with an XAC and $10 of Adafruit parts is amazing: https://www.youtube.com/watch?time_continue=1&v=pJfZb7XVAfM

To make the XAC work with CP, I made the following changes:

  • Modify the HID Descriptor to have ONLY a Gamepad, no Keyboard, Mouse, or Media devices
  • Modify the Gamepad classes to expose only a single Joystick (not two) and 8 buttons (not 16)
  • Modify the range of the Joystick values. CP defaults to -127 through 127 and the XAC requires 0 through 255
  • Remove Logical Minimum and Maximum from the HID Descriptor (not sure this was necessary)

I have a build that works that I forked from an early 4.x build. I have NOT gotten the same code to work on 3.x (although I could try further - once the 4.x works, I dropped it). I will try to bring that up to the latest 4.x build and share that as a fork.

As for how to proceed, here's an approach that I think will work (not sure it's ideal).

  1. Create an XBoxAC class that extends Gamepad and changes the ranges, joystick counts, and buttons.
  2. Create an alternative descriptor that does not expose the Keyboard, Mouse, and Consumer components, but instead declares a Gamepad descriptor with the modifications I made above.
  3. Create a method to switch between the two descriptor. Two options here: Build flags are fine if we're OK with sharing UF2 files with every guide. Alternatively, it should be possible to choose which descriptor to use in boot.py.

Personally, I'd like to see the switch possible at runtime, and I'd like it available on every target board. I have made XAC controllers from CPXs, Trinkets, ItsyM4s and I would like to make them from an NRF52. If we have to share custom builds it will be messy.

Again, I recognize this is a hack. I have pushed on Microsoft on this (and will continue to), but the response has been a clear "don't wait for those changes"..

Thanks
Bill

@ATMakersBill
Copy link
Collaborator Author

Here are the issues I sent to Microsoft (Bryce Johnson) about how they could improve the HID support in the XAC. He thanked me and it's in the pipeline, but honestly it's not going to be a speedy fix.
XBox Feedback.pdf

@tannewt
Copy link
Member

tannewt commented Mar 26, 2019

For now please make a fork available that bakes in the other descriptor.

I would like to support this through custom USB descriptors in boot.py in the long run. We'll re-prioritize issues after 4.0.0 and hopefully have a better timeline for this then. I'd like to do it sometime this year because it will close #231, our second oldest bug too.

@hathach
Copy link
Member

hathach commented May 29, 2019

comment to subscribe since I am doing hid gamepad example in arduino :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants