At this point you should have one (or more) games playable from the keyboard. The next step is adding nifty controls…
Let’s look at arcade-style controls first, since they’re physically larger and thus easier to work with…
Just as there are USB console-style controllers, so too are there USB arcade-style setups. They’re often a bit costly though…also, nearly all of them are laid out for 1990s fighting games. If the ready-mades meet your needs, fantastic. But maybe you want something simpler, or may have ergonomic preferences (I’ve always prefered right-handed joysticking, for example). Making your own control box (or even a whole cabinet) is a satisfying DIY project!
This is where things take a creative turn. There’s no One Right Way™ to arrange controls that can cover every game. Instead, pick a few favorites and devise a layout that handles the most frequently-used inputs well. For everything else, you can still use a keyboard.
You’ll also need to build your control panel using the materials and tools best suited to your own skills. I’m fortunate to have access to a laser cutter that can work with acrylic, but that’s a tall order for most. Scrap plywood or a metal project box are viable materials (a cigar box works great too!), while a drill, hole saw, Dremel tool or wood rasp are all reasonable tools for making holes. Improvise!
We have a nice assortment of arcade-style controls in the shop…
Our Small Arcade Joystick is the gamer’s equivalent of the IBM Model M keyboard — clicky and built like a tank!
Our 30mm Arcade Button is available in six different colors and is similarly industrial-grade. Any momentary push-type button (“normally open” contacts) will also work.
A classic Atari or Commodore joystick can also be used, since these are just passive switches internally. Most later gaming consoles used serial protocols for their controls…unfortnately those won’t work here…but as mentioned previously, USB clones exist for most.
The controls will be wired to the 40-pin GPIO (general-purpose input/output) header on the Raspberry Pi board.
Early model Raspberry Pi boards had a 26-pin header…same idea, just with fewer spots to connect things.
Each pin on this header has a unique “GPIO number” …not in-order, but we provide a map below for translating. Buttons and a joystick (each of 4 directions) will connect between any available GPIO pin and a ground (GND) pin.
This map is turned 90- degrees from the photo above…so the 5V pins are nearest the corner of the board, while GPIO21 is nearest the USB connectors:
- All of the green pins are fair game for connecting buttons.
- Yellow pins may or may not be available for controls, depending what hardware features are enabled on the system:
- GPIO2 and GPIO3 are off-limits if using any I2C peripherals (for example, most real-time clock boards).
- GPIO14 and GPIO15 are off-limits if using the TTL serial port (for example, with a serial console cable, or thermal printer).
- If using one of our PiTFT displays (as most of our portable gaming projects do), another seven GPIO pins are out of commission: GPIO7-GPIO11 and GPIO24-25.
- Our I2S audio amplifier board needs GPIO pins 18, 19 and 21.
- Avoid red pins, these carry power and aren’t suitable for controls.
- Black pins are ground points. The other leg of each button (and the “common” pin from a joystick) will need to connect to one of these. There are several scattered around…if you need more, one of our small Perma-Proto boards can be used to provide a single large “ground rail” where one side of all the buttons can be connected. Alternately, if you have extra unused GPIO pins and just need a couple extra ground connections, we’ll show a software work-around for this.
You do not need external pull-up resistors for the buttons or arcade controller…they can wire direct to the GPIO pins and grounds. The Raspberry Pi has its own “internal” pull-ups.
Just as the layout and build technique of the control panel requires creative interpretation, so too will you need to decide on your own wiring methodology. We have some parts that can help. Aside from the aforementioned Perma-Proto board, there are quick-connect wires that work with the buttons and jumper wires in various lengths that can be used with a joystick or plug directly into the GPIO pins (without a Perma-Proto board). Options abound! You’ll likely need some combination of these, and may need to solder some connections.
If using quick-connect wires for buttons: the end plug tends to block adjacent pins on the GPIO header. You can trim it down a bit using an X-Acto knife or Dremel tool, or cut the plugs off and solder the wires to a Perma Proto board, or simply plan out your wiring to avoid nearby pins…
- Joystick UP: GPIO10
- Joystick DOWN: GPIO17
- Joystick LEFT: GPIO23
- Joystick RIGHT: GPIO9
- Button A (one contact): GPIO23
- Button B (one contact): GPIO 7
- Joystick Ground, Button A & B second contacts: GND (theres a bunch of GND pins available)
Here’s an example layout if we want to add six buttons plus a joystick, using the same button quick-connects:
For handheld projects, the principles are the same as above, just squeezed into a very constrained space. Smaller components are used and the connections are a bit more challenging.
Most of these use a PiTFT display, so there’s a set of GPIO pins that are off-limits. Otherwise, it’s all the same idea…buttons wired to GPIO and ground pins.
The Raspberry Gear project uses a different approach…a microcontroller acts as an intermediary to the Pi’s USB port.
In earlier projects, we’d hack apart an actual game controller to repurpose the buttons and circuit boards. More recently, we’ve started producing custom gamepad PCBs to which buttons and wires can be soldered: