Skip to the content
2 layers66 × 63.5 mmGamepad, the printed circuit board in 3D

Source files for a gamepad designed for Tetris gameplay

Size
66 × 63.5 mm
Copper layers
2
Thickness
1.6 mm
Parts
21
Nets
28
Pads
64
Tracks, vias
79, 0
Pours
2
Routed
Yes
KiCad
KiCad 6 (file 20211014)
Created
22 Feb 2022
Updated
12 Mar 2022

Overview

Gamepad is an open-source printed circuit board by tjhorner, from the tjhorner/tetris-gamepad repository on GitHub. It is a 2-layer board of 66 × 63.5 mm with 21 parts on 28 nets, routed with 79 tracks and 0 vias.

It is built around the B2B-XH-A(LF)(SN). It belongs with the keyboards and input boards and the ESP32 boards of this library.

Main components

1

README

README.md

Tetris Gamepad

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 😛)

Directory Structure

  • src: Source files for the firmware (licensed under MIT)
  • design: PCB and enclosure design files (licensed under CC-BY-SA 4.0)

Hardware

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:

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:

Enclosure

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.

Firmware

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.

Operating Modes

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.

Gamepad Mode

In gamepad mode, the device will broadcast itself as a BLE gamepad. By default, the buttons are defined as such:

Physical ButtonVirtual Button
HoldButton 0
CCWButton 1
CWButton 2
LeftButton 3
RightButton 4
Hard DropButton 5
Soft DropButton 6
ZoneButton 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.

Keyboard Mode

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:

ButtonKey
HoldLeft Shift
CCWZ
CWX
LeftLeft Arrow
RightRight Arrow
Hard DropSpace
Soft DropDown Arrow
ZoneA

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.

Pro Controller Mode

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 ButtonVirtual Button
HoldL
CCWB
CWA
LeftD-Pad Left
RightD-Pad Right
Hard DropD-Pad Up
Soft DropD-Pad Down
ZoneZL

Similar to the keyboard mode, these bindings also follow the Guideline layout, but can be changed in modes/switch.h.

Configuration

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.

Acknowledgements

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

Parts

21
QtyValueFootprintReferences
16B2B-XH-Adigikey-footprints:PinHeader_1x2_P2.5mm_Drill1.1mmJ1, J2, J3, J4, J5, J6, J7, J8, J9, J10, J11, J12, J13, J14, J15, J16
4MountingHole_3mm_PadMountingHole:MountingHole_3mm_PadMH1, MH2, MH3, MH4
1Feather HUZZAH ESP32Module:Adafruit_FeatherA1

Similar boards

  • 4 layers128.5 × 40 mmScalenode cm4-baseboard, the printed circuit board in 3D

    Scalenode cm4-baseboard

    antmicro/scalenode-cm4-baseboard

    Baseboard for Raspberry Pi 4 Compute Module optimized for clustering

    146 parts152Apache-2.0
  • 2 layers52.8 × 55 mmILDAWaveX16, the printed circuit board in 3D

    ILDAWaveX16

    stanleyondrus/ILDAWaveX16

    ILDAWaveX16 is an open-source, high-resolution, wireless laser DAC with SD-card playback, network control, and ILDA output.

    95 parts42
  • 2 layers135 × 100 mmHotPlate V1.0, the printed circuit board in 3D

    HotPlate V1.0

    aitesam961/Reflow_Hotplate

    A reflow Hotplate for DIY SMD assembly

    89 parts23GPL-3.0
  • 2 layers52 × 56.6 mmMuMo v2-Node, the printed circuit board in 3D

    MuMo v2-Node

    Strooom/MuMo-V2-Node-PCB

    PCB design for the Museum Monitor V2

    79 parts17
  • 2 layers197.3 × 121.2 mmTeensyMaestro Main PCB, the printed circuit board in 3D

    TeensyMaestro Main PCB

    rimuadmin/TeensyMaestro-Hardware

    Hardware for the TeensyMaestro

    115 parts13CERN-OHL-P-2.0
  • 2 layers50 × 20 mmM5stack board dynamixel ttl rs3485, the printed circuit board in 3D

    M5stack board dynamixel ttl rs3485

    kim-xps12/m5stack_board_dynamixel_ttl_rs3485

    When using this repository in your own environment, please import HY2.0-4P.kicadmod into the appropriate library. I import it into the global library so that it can be used from other projects as well.

    20 parts6MIT
  • 4 layers100 × 100 mmLabathome pcb, the printed circuit board in 3D

    Labathome pcb

    klaus-liebler/labathome

    Der kleine Bruder von lab@home. Ermöglicht das Experimentieren mit PT1...PTn-Gliedern, die intern als RC-Kombination (entkoppelt über Operationsverstärker) ausgeführt sind.

    292 parts5MIT
  • 4 layers394 × 110 mmGpu cluster backplane, the printed circuit board in 3D

    Gpu cluster backplane

    antmicro/gpu-cluster-backplane

    This project contains open hardware design files for a PCB supporting power distribution in a cluster composed of GPUs. This board has been derived from an open source d1600e-psu-breakout created by Antmicro.

    616 parts4Apache-2.0

Questions

How big is the Gamepad PCB?

It measures 66 × 63.5 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Gamepad use?

21 parts, built around the B2B-XH-A(LF)(SN). The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Gamepad KiCad files?

From the tjhorner/tetris-gamepad repository on GitHub, at the commit this page was made from: the board is design/pcb/gamepad.kicad_pcb and its schematic design/pcb/gamepad.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Gamepad design in my own project?

Its repository states no licence, so its author keeps all rights: ask tjhorner before reusing the design.