With all the configuration finished on the Pi and some test games installed we are ready to get something actually working - at least as a prototype. A big part of this process is configuring the joysticks. Be warned - it is time consuming and involves a lot of testing and tweaking so it is best to build a simple prototype and wire the joysticks all up. This way you can plug your joystick USB into your Pi and complete all configuration before everything is mounted inside the table. This is a much more comfortable setup then being hunched over your arcade table for hours on end. We will save that for when you are actually playing games on it!

For my prototype, I built a simple joystick rack and drilled all the holes for the joysticks and buttons. As a side note, it isn't a bad idea to do this step before drilling the holes in your actual joystick control box of the table - treat this as a practise run.

The joystick I bought from Ultracabs came with a simple instruction sheet, a USB connector hub-like circuit board, and a whack load of wires. There was no easy way to wire this up and not look like a mess. The instructions are pretty clear, but if you want a bit more guidance the folks at Ultracabs put together a helpful video of the entire process. See picture of finished prototype.

That is the easy part - now on to configuring the joysticks.

Configuring Joysticks with RetroArch (Most Emulators)

The configuration of your joysticks depends on what emulators of the RetroPie you are going to use. Most people will gravitate towards a small handful of them - I am only interested in Commodore 64 / MAME / NES / SNES. Obviously the more emulators you use the longer you will be configuring and testing - BUT there is a shortcut. RetroPie implements a system called RetroArch which is a global configuration that most of the emulators will use for the joysticks. In a nutshell, RetroArch is the tool we use to map the select button, the start button, A, B, etc. to specific buttons you have installed in the arcade table. It is done by updating a text file.

Enough talk - let's do this!

Plug in your prototype joysticks into the Pi and start it up. Raspbian starts up (OS) and then Emulation Station. Emulation Station will recognize this is the first load and require you to configure your joysticks.

Go through and follow the instructions with either one of your joysticks. By default, it assumes that the controller is a game pad so you will need to skip some of the button mappings; you can press and hold any button to skip.

That was crazy easy?! This process does configure your joysticks to work with Emulation Station and also sets up defaults for RetroArch - but there is one thing about the defaults I didn't like. An intuitive way to exit an emulator and get back to Emulation Station when the user is done playing a game. By default RetroArch is configured so that pressing select (the hotkey button) and start (the emulator shut down button) at the same time will exit the emulator. That works, but I find it TOO easy to press that combination of buttons by accident while in the middle of the game. Instead I wanted to setup my player one button (which is on the front edge of the table and not on the deck of the joystick control box) to be the hotkey button and one of my yellow buttons to be the exit emulator button. This would ensure no accidental emulator exit could occur.

To make this change we simply need to edit the RetroArch text file with the corresponding id numbers for the desired buttons - BUT What the heck are those button's id numbers? This is where the jstest tool saves the day (We already installed it in a previous step).

Run jstest by typing in the command:

jstest /dev/input/js0

Note that the js0 might be js1 if you have a keyboard hooked up since it takes the js0 identifier.

The second joystick (if you have one) will be js2, in this case

When jstest is running you will see a display of all the detected buttons for that joystick. This display will also change when you press any of the buttons or mess with the joystick. It is essentially a testing tool, but more importantly you will be able to see the ID numbers that are assigned to each button. Press the button you wish to be your hotkey button and note the id number. Do the same for the button you wish to be the exit emulator button.

Now onto the edit of RetroArch text file. Type the following into the command prompt:

cd /opt/retropie/configs/all ls

This will dump out a list of all files and folders. Among the list you should see a folder called retroarch-joypads (It is possible the folder might have a different name). This was setup when you did the initial control configuration with Emulation Station. Type the follow commands:

cd retroarch-joypads sudo nano [whatever the name of the CFG file is].cfg

This will open the nano editor once again. To change the hotkey and emulator exit buttons, two lines need to be adjusted to the id numbers you noted from the jstest:

input_exit_emulator_btn = "4" input_enable_hotkey_btn = "8"

Where 8 is the id number of your hotkey button and 4 is the id number of your exit emulator button.

Run a game (anything except MAME) and this button combination should exit the game.

Here is a great YouTube video on this process.

The RetroArch documentation can be found here.

Configuring Joysticks for MAME

RetroArch sets up joystick configuration for most of the emulators of Emulation Station, but MAME seems to be a beast of its own. To configure MAME games you need to run any MAME game and press the TAB button to open the menu. From there you can edit the "general controls" (which are global to all MAME games) and configure all the joysticks and buttons for all games.

To add the same button combination to exit the MAME emulator (just like in RetroArch) scroll down the list to UI Cancel and set it to the same key combinations (it allows combinations of buttons as input!)

You may find you need to adjust the "game controls" to customize controls for certain games. Unlike "general controls" these changes only apply to the game in question.

With that you should have a working prototype of your arcade table that should keep your gaming needs at bay while you finish the rest of the table build :)