These are the source files for an arcade-style gamepad designed for Tetris gameplay. Work in progress (things will break!)
Disclaimer: Tetris is a trademark of The Tetris Company, and I am not affiliated in any way with them. I'm just a fan of the game, and wanted to make this cool project for fun (and not profit). If you're a TTC lawyer and want me to rename this project, just let me know and I'll gladly do so. (No need to DMCA 😛)
src
: Source files for the firmware (licensed under MIT)design
: PCB and enclosure design files (licensed under CC-BY-SA 4.0)- Note: The KiCad files may require you to install the DigiKey library
License: CC-BY-SA 4.0
This project is intended to be used with the Adafruit HUZZAH32 board (mostly because that's what I had lying around), but with minor tweaks could be modified to use any ESP32 board, or even a raw ESP32 chip. The design is pretty simple; it just uses the GPIO pins in either INPUT_PULLUP
mode (for the button inputs) or OUTPUT
mode (for the button LEDs). Since it uses the INPUT_PULLUP
mode, and the button LEDs have an inbuilt 200ohm resistor, no additional resistors are required.
If you want to build one yourself, here are the components you will need:
- 1x Adafruit HUZZAH32
- 8x Arcade Button (get creative with the colors!)
- 16x Arcade Button Quick Connect Wire Pairs
- 16x B2B-XH-A JST Connector
You can find the KiCad files for the PCB design in the design/pcb
directory, or if you want to quickly order some, here's a fancy button that will take you to the OSH Park page for the project:
License: CC-BY-SA 4.0
The enclosure is a pretty simple box with fingers to assemble it, generated by MakerCase. There are holes in the top of the box that should fit the buttons snugly, along with some engravings near the buttons to indicate what they're for.
You can find the design files for the enclosure in the design/enclosure
directory if you want to cut one out yourself.
License: MIT
The firmware development workflow is powered by PlatformIO, so you will need to get that set up if you want to modify or flash the firmware. All the dependencies are listed in the platformio.ini
file so you shouldn't need to download anything manually.
The mode you are currently in will be indicated by how many times the startup animation loops (one cycle of the startup animation is all the LEDs turning on in order, then turning off).
- 1 time: gamepad mode
- 2 times: keyboard mode
- 3 times: Switch Pro Controller mode
You can switch between the modes by holding down a certain button during startup:
- HOLD: Switch to gamepad mode
- CCW: Switch to keyboard mode
- CW: Switch to Pro Controller mode
The default is gamepad mode. It will remember what mode you last selected on startup, so you don't need to hold the button down every time.
In gamepad mode, the device will broadcast itself as a BLE gamepad. By default, the buttons are defined as such:
Physical Button | Virtual Button |
---|---|
Hold | Button 0 |
CCW | Button 1 |
CW | Button 2 |
Left | Button 3 |
Right | Button 4 |
Hard Drop | Button 5 |
Soft Drop | Button 6 |
Zone | Button 7 |
This does not follow a standard layout for e.g., an Xbox controller, so you will probably need to set up custom bindings in the game you are playing. You can also change the button assignments in the modes/gamepad.h
file.
In keyboard mode, the device will broadcast itself as a BLE keyboard. This mode is not as stable as gamepad or Pro Controller mode, so it should be used only as a backup method if those don't work.
The default bindings are:
Button | Key |
---|---|
Hold | Left Shift |
CCW | Z |
CW | X |
Left | Left Arrow |
Right | Right Arrow |
Hard Drop | Space |
Soft Drop | Down Arrow |
Zone | A |
They follow normal the normal Guideline layout, so you should be fine with most games, but if you need to change them, you can do so in the modes/keyboard.h
file.
Since the Switch does not support using generic Bluetooth gamepads, this is a special mode which imitates a Pro Controller.
Note: To use the gamepad with your Switch in Pro Controller mode, you will need to go to Controllers > Change Grip/Order
every time you connect the controller. It's annoying, but I haven't figured out how to persist the pairing with the console.
The default bindings are:
Physical Button | Virtual Button |
---|---|
Hold | L |
CCW | B |
CW | A |
Left | D-Pad Left |
Right | D-Pad Right |
Hard Drop | D-Pad Up |
Soft Drop | D-Pad Down |
Zone | ZL |
Similar to the keyboard mode, these bindings also follow the Guideline layout, but can be changed in modes/switch.h
.
If you want to modify which pins correspond to which buttons, you can do that in the config.h
file. For convenience, pins.h
defines a list of which JST connectors (labeled on the PCB) correspond to which GPIO pins (you can also modify this if need be).
You can also change which buttons you need to press to switch between modes.
There are a few other useful config options here as well; I'll document them eventually.
Thanks to...
- The kind folks at NYC Resistor for hosting their public craft nights, which opened up a bunch of resources and tools (namely, the laser cutter!) to me, helping make this project a reality
- The creator of MakerCase for making laser cut boxes easy
- The creator of both the ESP32 gamepad and ESP32 keyboard libraries, which are basically the entire basis for the firmware
- The BlueCubeMod project, which is what the Pro Controller mode is largely based on