FeralAI / GP2040

Gamepad firmware for Raspberry Pi Pico and other RP2040 microcontrollers supporting Nintendo Switch, XInput and DirectInput
https://gp2040.info
MIT License
558 stars 124 forks source link

Additional Configuration options. Basic PIO LED Support. #1

Closed jbarket closed 2 years ago

jbarket commented 2 years ago

I've added optional configuration for default mode values so that they can be changed on a per board basis. I've also added optional LED support. It's very basic--blink the pressed button if LEDs are configured for that button--but it's enough to prove things out.

The LED setup has two (future) problems:

We're limited to a single LED per button. There are a number of things out there at the moment that have multiple per button. The big hold up is the inability to create an array with #defines, but I'm hesitant to start storing actual variables in the board configuration files. Open to suggestions here. TOML or something would be more muggle friendly, but it's a lot more work than just defining some constants.

It needs to be migrated out of main.cpp into somewhere we can easily manage the current state for animations. Button presses should be telling this class "hey man, animate this button" and not worrying about handling the actual animation.

FeralAI commented 2 years ago

Awesome! Thanks for the initial LED integration here.

I have a WS2812 LED hat for the Pico, so I'm going to test everything out. I have an older LED controller project here: https://github.com/FeralAI/HitBoxLEDController. I can see what parts we might want to integrate to solve some of the future issues.

jbarket commented 2 years ago

Oh dude, there are some spectacular ideas there. I love the idea of setups related to games or existing systems.

FeralAI commented 2 years ago

Thanks man! I'm going to port what I can from that LED controller project into a private lib, but that's after we finish off this PR.

I tried out the changes against my dev board and everything seems to be working fine. Only issue before merging is the LED code running on the main thread. It has increased the input latency from an average ~0.9 ms to ~6.1 ms. This will need to be refactored onto the 2nd core before we merge to main. Do you want me to take a look at that, or would you like to?

FeralAI commented 2 years ago

Don't worry about it, I've got it offloaded to core1 now. I'm going to merge this then commit my update.