Configuring a trackball and spinner with Retropie
Recently I've been taking a look at one of our new products, the Atari USB Spinner. The Atari USB Spinner can replace one of the arcade buttons, or it can be mounted in a 1 1/8” hole drilled in the control panel. It's connected to your Rapberry Pi or other computer via USB and acts as a mouse. This article focuses on configuring your games so you can use both the trackball and spinner. Although I’m using the Ultimate Fight Stick with Trackball, these instructions will work for any setup with both a trackball and spinner such as a full size cabinet with a trackball installed.
If you’re using a controller without a trackball the spinner is plug and play, but getting both the trackball and spinner working together takes a little more work. Before we get started I want to explain the technical issue using both at once causes- skip the next paragraph if you just want to get to the fix.
The trackball and spinner are both seen by the Raspberry Pi as a mouse. The trackball is essentially an old school ball mouse flipped upside down, and the spinner uses an optical encoder and microcontroller to emulate a mouse that only provides one dimension of motion. These devices are known to the Linux side of the Raspberry Pi as “mouse1” and “mouse0”. Each game listens to one mouse at a time. The default global setting is mouse0. Since we want some games to listen to mouse0 and some to listen to mouse1, we need to create per game configuration files for each game that should be using mouse1. While there is a way to get the names of each mouse used by the Linux operating system from the command line, Retroarch (the program running the emulators) aliases the mice differently so it’s best to determine which device is which by plugging both in and loading up a game.
The instructions below were written for Micro Center’s Retropie image that is distributed with our retro gaming kits (like the Atari Pi Kit and Stand Up Arcade kits) and the Atari Games SD card. These instructions might not work perfectly for other images, but should give you a good starting point.
In addition to a Retropie setup you’ll also need a USB
keyboard connected to the Raspberry Pi. You can also SSH into the Pi using terminal on Linux or macOS or PuTTy, WSL, or another terminal or SSH program on Windows, but setting up an SSH connection won't be covered in this guide.
First, we need to identify which device is the default. Hook
up both the spinner and track ball with the system powered off, then boot it
up. You can determine which device is the default by opening a game like
Avalanche or Crystal Castles and trying both controllers. One should allow you
to move, and one should be unresponsive. Make note of which one works, as this
is the default “mouse” with index 0. In my case this was the track ball, so
I’ll be creating config files for games I want to play with the spinner. If neither are working, it's possible you've selected a game that
doesn't support mouse inputs. Many home consoles (Like the Atari 2600) will not work with
either controller. Exit
the game and return to the main menu.
Most of the screenshots in this guide end with the command raspi2png –p screenshots/#.png. You can ignore these lines, it’s just the command I used to take screenshots of the terminal.
Type the following command, which will move us into the directory our roms are stored in:
cd RetroPie/romsNext, type ls to get a list of files and sub directories in this directory. You should see a sub directory for each game system:
We’ll use nano to create a new file, so use the command below to open an empty file for our game:
nano <game name>.cfg
Nano is a command line text editor that’s great for quick changes like these. Make sure the file extension for the rom (.zip in the case of arcade games) and .cfg are included in the filename. In my case, I used nano avalnche.zip.cfg. Note the misspelling of “avalanche”- this is how the rom is named, and it’s important to use the exact name of the rom.
After running this command you should be greeted by a mostly empty window. There will be a list of commands at the bottom and a banner at the top that says “GNU Nano” and the file name, like this:
This is our empty file. Add the following lines:
input_player1_mouse_index = “2”
config_save_on_exit = false
This tells our game to listen to the mouse with index 2, and not to overwrite the config file when the game is exited. Press ctrl+x to exit nano, press y to save changes, and press enter to save the file. You can verify the file was created using `ls`. Reboot the system from the command line with this command:
Load up the game you just configured and try out the controllers. Your default controller should be unresponsive, but the second controller should work now. In my case I could move the tower in Avalanche with the joystick or spinner, but not the trackball.
Creating files for more games is even easier. The cp command lets us make a copy of a file. All we need to do is use cd to get back into the directory our games are stored in and copy the config file we just made. For example, I wanted to use the spinner for Tempest as well, so I used the following commands:
cp avalanche.zip.cfg tempest.zip.cfg
Here I’ve used the ls command before and after using cp to duplicate a config file. This let me verify the copy was successfully created:
Those of you with a bit of Linux experience might be tempted to find the mouse indexes in /dev/input/, but I found the information listed here doesn’t match the index used by Retroarch. Retroarch assigns its own indexes to the mice which don’t match the indexes assigned by Linux.
The new spinner feels much more natural for games that only involve 1 dimension of movement like Tempest and Avalanche, but isn’t great for games like Crystal Castles that involve 2 dimensional movement. Having both mounted in your cabinet is the best of both worlds, and a few minutes of configuration is all it takes to get both controllers up and running.