GP2040-CE icon indicating copy to clipboard operation
GP2040-CE copied to clipboard

New addon to support controller input from usb host

Open smahdink opened this issue 1 year ago • 5 comments

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:

  1. Google Stadia controller
  2. Sony Dualshock 4 controller

smahdink avatar Aug 05 '24 15:08 smahdink

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 Controller in 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.

mikepparks avatar Aug 05 '24 19:08 mikepparks

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.

smahdink avatar Aug 06 '24 19:08 smahdink

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.

mikepparks avatar Aug 07 '24 04:08 mikepparks

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.

mikepparks avatar Sep 03 '24 16:09 mikepparks

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.

arntsonl avatar Sep 17 '24 01:09 arntsonl

Reimplemented in PR#1221!

arntsonl avatar Nov 24 '24 20:11 arntsonl