bsiever / microbit-pxt-blehid

Micro:bit MakeCode support to act as a Human Interface Devices (keyboard, mouse, etc.) over Bluetooth
https://bsiever.github.io/microbit-pxt-blehid/
MIT License
31 stars 11 forks source link

Gamepad support #6

Closed bsiever closed 2 years ago

bsiever commented 2 years ago

Add Gamepad support.

Some examples to draw from:

bsiever commented 2 years ago

See https://learn.adafruit.com/custom-hid-devices-in-circuitpython/report-descriptors

bsiever commented 2 years ago

Add Hats: https://github.com/NicoHood/HID/blob/master/src/MultiReport/Gamepad.cpp

bsiever commented 2 years ago

Seems to have sticks / buttons, but not D-pad/arrow support.

bsiever commented 2 years ago

See: http://www.freebsddiary.org/APC/usb_hid_usages.php for D-pad support.

bsiever commented 2 years ago

Nintendo controllers with HID report details: http://45.55.158.144/p/usb/

bsiever commented 2 years ago

See https://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/ for x/y/z/rx issues.

bsiever commented 2 years ago

Maybe: https://github.com/RandomInsano/HID/blob/319bb4ee6f646b96f239008d306e94451547069a/src/MultiReport/Gamepad.cpp

bsiever commented 2 years ago

Semantics: Figure out a good way to do bitfields for buttons.

Testing: Do more...

bsiever commented 2 years ago

Windows may need to use a re-mapper or install a driver (Remapper: https://github.com/x360ce/x360ce)

bsiever commented 2 years ago

iOS only does MFi approved, Xbox, and Playstation. Is a "good enough" HID descriptor enough or does it do other things to authenticate the controller? (Well, it truly authenticates the MFi ones.)

Apple's support page: https://support.apple.com/en-us/HT210414 XBox descriptor: https://www.psdevwiki.com/ps4/DS4-USB (Multiple report IDs)

bsiever commented 2 years ago

I'm marking this "kinda done". It works for some games (not on iOS). May have to revisit the full XBox controller behavior at some point.