New addon to support controller input from usb host
A new addon is added to the gp2040-ce named ControllerHostAddon, that enables getting input from USB controllers through the added USB host port in PICO and USB Host addon.
Currently supported controllers are:
- Google Stadia controller
- Sony Dualshock 4 controller
Just a few notes and nitpicks.
- Would prefer to not have unnamed bitfields, if possible. The reasons why they're used are understood, but means extra work later for someone trying to understand the code.
- For the sake of not colliding with design patterns of the same name, would prefer to not use
Controllerin the name of the class or related addon assets. GamepadHost might be a better alternative, even if it doesn't cover a full scope of game controllers down the line.
Thank you for the notes, can you elaborate about your first point a little more? About the name I actually like the name you suggested and if everyone agrees I would change the name.
Lines 16-19 in headers/addons/controller_host_listener.h for example. I know why those bitfields are unnamed, but for the sake of having code that can be read & understood, we'd prefer if they were named.
It appears that this is causing main Gamepad inputs to not function when enabled. Your process() function does not check for changes in your own gamepad state, which continuously overwrites the Gamepad's values with your own. This prevents core functionality from occurring, including being able to use shortcuts on boot to load into bootsel or webconfig. I would say to only update Gamepad state when:
- A supported device is connected to USB Host
- The input state from that device has changed since its previous iteration
- If the device is disconnected, no changes are made to Gamepad.
This will need to be addressed before we can determine if it's functional enough to merge.
We're going to push this into the next version of the release. We want functionality like this, but this does open a big can of worms. I think moving our keyboard/mouse/gamepad host into a single host controller with host drivers similar to how we do drivers now is going to be the magic.
Reimplemented in PR#1221!