Raspberry Pi Pico and RP2040-based controller support in HayBox
The RP2040 is a powerful dual-core microcontroller from Raspberry Pi that offers significant advantages for game controller applications. HayBox has extensive support for RP2040-based boards, with optimizations that take full advantage of the hardware.
void setup1() { // Wait for backend initialization while (backends == nullptr) { tight_loop_contents(); }}void loop1() { // Continuously scan button inputs if (backends != nullptr) { gpio_input.UpdateInputs(backends[0]->GetInputs()); }}
By dedicating Core 1 to button scanning, HayBox achieves consistent, low-latency input processing without interfering with USB communication or game mode logic.
Open the HayBox project in VS Code with PlatformIO
Select your environment (e.g., pico, b0xx_r4) from the bottom toolbar
Click the Build button (checkmark icon)
Output will be in .pio/build/[env_name]/firmware.uf2
# Build for generic Picopio run -e pico# Build for B0XX R4pio run -e b0xx_r4# Build all RP2040 environmentspio run -e pico -e b0xx_r4 -e htangl_v1 -e c53 -e schism
// In setup() - check for bootloader button holdif (inputs.rt2) { reboot_bootloader(); // Re-enter BOOTSEL mode}
To reflash:
Hold the designated button (default: RT2)
Plug in the controller
Pico enters BOOTSEL mode automatically
Drag and drop new .uf2 file
On most configs, RT2 (right thumb button 2) is the bootloader button. Holding this during plugin allows easy reflashing without opening the controller.
RP2040 boards can store configuration in flash memory:
#include "core/Persistence.hpp"// In setup()if (!persistence.LoadConfig(config)) { // No valid config found, save default persistence.SaveConfig(config);}
This allows changing game modes, SOCD settings, and more without recompiling firmware.