Convincing a modern game console such as a PlayStation 4 or the Nintendo Switch that a microcontroller is a legitimate gamepad is much trickier than typical USB HID keyboard and mouse techniques we use on computers. This is where the GP2040-CE firmware comes in.
GP2040-CE is an open source gamepad firmware that's compatible with PC, PS3/PS4, Nintendo Switch, Xbox, and more. It runs on a number of microcontrollers that use the RP2040 chip, such as Pico, KB2040 Kee Boar, and more.
Flash the Pico with a drag-and-drop .uf2 file and then customize settings with a web editor.
Download Firmware
From the GP2040-CE Downloads page, click the Download button for the Raspberry Pi Pico firmware (or the KB2040 link if using that board).
This will save a file named GP2040-CE_0.7.5_Pico.uf2
(or later) to your download location.
Firmware Installation
This page gives detailed instructions on installation, but the basic steps are:
- While holding the BOOTSEL button down, plug the Pico into your computer with a known good data and power USB cable -- this puts the board into BOOTSEL/USB drive mode
- A new removeable drive named
RPI-RP2
will appear on your computer - Drag-and-drop the CP2040-CE v0.7.5.uf2 (or later) firmware .uf2 file onto the
RPI-RP2
drive and wait for it to copy the file and reboot itself
Your Pico reboots as a generic controller, which may work on a Windows PC or Xbox right out of the gate, but you'll want to reconfigure it as a Switch controller with specific behaviors. To do this, we'll launch the built-in Web Configurator!
Web Configurator
Unplug the Pico from your computer's USB cable. Then, you'll use a short wire to jumper Pico pin GP17 to a GND pin (see attached diagram for physical pin locations).
Plug the Pico into your computer's USB cable while pin GP17 is shorted to ground. After a couple of seconds you can remove the wire. This action has caused the Pico's GP2040-CE firmware to launch a web server you can access from your computer's web browser by visiting http://192.168.7.1
Settings
You can now update the controller settings. Click on the Settings menu item and then switch the Input Mode to Nintendo Switch.
To do the Auto Spin hack we need to be able to automatically press the left analog stick. Change the D-Pad Mode to Left Analog.
Then, scroll to the bottom of the settings page and press Save.
Switch Button Test
This is a great time to test the controller on your Switch to make sure basic button presses are working.
The pinout diagram below shows the default GPIO-pin to button mapping.
Plug the Pico into your switch with a known good USB-C to Micro-B data and power cable.
You can now use a jumper wire to short any mapped GPIO pin to ground -- those button presses will register on the Switch!
Auto Spin Macro
The secret sauce for our Pokéball is the Macro Settings section of the configurator. Click the Configuration menu item and then click on Macro.
- click the Enabled button to turn on macro support
- you need to assign a free GPIO pin to be the Macro button (see pinout chart above), set this to
22
- click the Activated button next to the first macro slot
- for clarity, name the macro Label
spin
- Turn off Interruptible so that the Auto Spin will run without interruption
- Leave Exclusive on so other controls won't join the mix by accident if buttons are pressed
- you can turn on Show Frames if you prefer frame counts for button press timings (vs. milliseconds)
- change the mode dropdown from Press to Hold Repeat -- this will loop the macro endlessly as long as the button is held
- Click the green + button to add a macro line (you can add up to 50 lines!) set it as shown above. This will press Left for
6
frames - Repeat the above step three more times to add Up, Right, and Down events
- Click the Save button at the bottom of the page to write the configuration to the Pico
Reboot
Click the Reboot button at the top of the page in order to reboot the Pico.
If you are done changing settings, click Controller so the Pico will boot to the regular use mode, then unplug the Pico.
Macro Pin Jumper
To invoke the Auto Spin Macro, short the GPIO 22 pin to GND with a jumper cable.
Then, plug the Pico into the Switch as before -- the Switch we act like you're rapidly spinning the left analog stick!
Next, you'll house the device in a Pokéball.
Page last edited April 30, 2024
Text editor powered by tinymce.