Build an arcade machine: RetroPie and stream from Steam
Use RetroPie as your arcade operating system and add extra emulators with support for Steam Link. Stream games from a powerful PC to Rasbperry Pi
Last month, we used Recalbox for our main arcade cabinet operating system, but it’s not your only choice. In this final instalment of the ‘Build an arcade machine’ series, we’ll use the RetroPie distribution, currently at version 4.7, to provide extra features such as Steam Link support, as well as taking a longer look at where to buy arcade games and how to get them onto your system. This tutorial assumes that you already have a fully assembled and wired arcade cabinet.
As with our DB9 joystick project in issue 101 (magpi.cc/101), we have to tell the GPIO to treat the controls as pull-up switches. Recalbox, by comparison, implements this by default. Create the pullup.sh file we’ve supplied (magpi.cc/pullupfix). You can put it anywhere you like – we stuck ours in /home/pi/. Now open /etc/rc.local on the SD card and, above the exit line, add: /home/pi/pullup.sh This will load your pull-up settings on boot. If you’re setting up your disk on a Linux system, you can set pullup.sh as executable now. Otherwise, we’ll do that on first boot.
Fire up Raspberry Pi Imager, connect your microSD card writer, and install RetroPie from its Choose OS menu. Re-mount the microSD card once you’ve finished flashing it, because we’ve got some changes to make.
Make sure you have a keyboard plugged into your cabinet for this bit. We left ours propped up against the marquee acrylic during setup for easy access. A Bluetooth keyboard is a viable alternative, but it’s easier to start with a wired connection. Plug in Raspberry Pi’s power. It should boot to the EmulationStation interface, but we can’t configure the controls until we’ve set our pull-up script executable. Press F4 to exit to the command line and type: chmod /home/pi/pullup.sh +x While we’re here, let’s enable SSH: sudo raspi-config 1 system option s3 password
Raspberry Pi is powerful enough to run most games, and you can stream classic and modern arcade titles from a separate PC on your network via Steam Link enter a new password 3 interface options enable ssh yes You can now SSH into Raspberry Pi from another PC using a client such as Remmina or PuTTY.
We’ll use the RetroPie distribution to provide extra features such as Steam Link support
Add hotkey button support
If, like ours, your arcade cabinet’s GPIO controller setup has either one or two extra hotkey buttons for easy access to save, load, and exit shortcuts while playing, then the standard version of the mk_arcade_joystick_rpi driver available from RetroPie’s package manager won’t support them. We’ll have to manually add an updated version from maintainer Recalbox’s GitLab repo. At the command line, type: git clone --branch v0.1.9 https://gitlab.com/recalbox/mk_arcade_joystick_rpi.git sudo mkdir /usr/src/mk_arcade_joystick_rpi-0.1.9/ cd mk_arcade_joystick_rpi/ sudo cp -a * /usr/src/mk_arcade_joystick_rpi-0.1.9/ nano /usr/src/mk_arcade_joystick_rpi-0.1.9/dkms.conf In this file, change PACKAGE_VERSION="$MKVERSION" to PACKAGE_VERSION="0.1.9" . Press CTRL+X to exit, then Y to save. Back at the command line, enter: sudo dkms build -m mk_arcade_joystick_rpi -v 0.1.9 sudo dkms install -m mk_arcade_joystick_rpi -v 0.1.9 reboot
sudo ~/RetroPie-Setup/retropie_setup.sh ...to open the ncurses configuration menu. If you did not manually install a hotkey version of the mk_arcade_joystick driver in the previous steps and do not need one, go to: P manage packages driver 819 mkarcadejoystick ...and install it. If you need to connect any Bluetooth keyboards or controllers, go to: C Configuration / tools 804 bluetooth Press R to register a device and follow the pairing instructions. 832 samba in the configuration menu sets up Samba shares so you can easily transfer ROMs and BIOS images over your local network You can add extra emulators here, but we’ll come to that later. For now, select the R Perform reboot option from the main menu.
When RetroPie reboots, it should inform you that it can detect two GPIO controllers
Optional: Load your hotkey driver
When Raspberry Pi has rebooted, SSH back in and type: sudo modprobe mk_arcade_joystick_rpi map=1,2 Go over to the arcade machine and press F4 to get to the command line and test your controllers: jstest /dev/input/js0 jstest /dev/input/js1 If that works, it’s time to load that module on boot. At the command line: sudo nano /etc/modules In this file, add the following on a new line, then save and exit. mk_arcade_joystick_rpi Next, at the command line: sudo nano /etc/modprobe.d/mk_arcade_joystick.conf In this file, add the following: options mk_arcade_joystick_rpi map=1,2 Now save, exit and reboot.
Configure RetroPie
There’s a bit more configuration to do before RetroPie is ready to go. SSH in and type:
Input configuration
When RetroPie reboots, it should inform you that it can detect two GPIO controllers. Press and hold any button on the left-hand button bank to configure controls for player 1. Because arcade controls don’t map perfectly to a gamepad, you’ll have to skip some buttons by pressing and holding any key. Map up, down, left, and right on the arcade stick to the D-pad. Follow our button assignment diagram to map the top row to button Y, X, and L(eft shoulder), and the button below to buttons B, A, R(ight shoulder). Map Start to player 1’s left-hand front function button and Select to their right-hand front function button – this will be their ‘insert coin’ button. In our wiring configuration, our single hotkey button – the last we set – is associated with player 1. Approve your configuration, then set up player 2’s controls in the same way.
Getting to know RetroPie
With your controllers configured, RetroPie’s main interface will open. Press A to select menus and items and B to go back. Press Start to open the main menu and Select to open the options menu. Press the same button again to close each of these. As you have yet to put any games on the system, only the RetroPie menu will be available. Here, you’ll find easy access links to configuration tools, including some we used earlier. Install new emulators and drivers from the RetroPie Setup menu. You’ll probably need to disable overscan to get rid of a black border around the screen. In the ReotroPie menu, select Raspi-config > Display options > Underscan > No and then reboot to solve the problem. Note that button B is mapped to the ENTER key in this set of menus. When you add any new games, ROMs or emulators, you’ll have to restart EmulationStation by pressing Select, going to Quit, and then Restart EmulationStation.
Install more emulators
Although this is an arcade machine, you can play what you like on it. The core lr-mame2003 and lr-fbneo emulators are included, along with those for popular consoles such as the Sega Mega Drive, used in some arcade systems and for which original games are legally available. Some emulators require system BIOS images. Sadly, very few of these have been made legally available to emulation enthusiasts. SNK distributes a UniBIOS compatible BIOS set in its 40th Anniversary Collection. We recommend adding the following: opt > 327 opentyrian – arcade-like DOS shoot-’em’-up Tyrian 2.1 is now freeware. exp > 241 lr-mame – a more up-to-date version of MAME that supports a wider range of ROMs. Install from source for bleeding edge. exp > 307 digger – a sanctioned remaster of Windmill Software’s Dig-Dug. exp > 334 steamlink – this allows you to stream less emulation-friendly titles directly from a Steam installation on a Windows or Linux PC.
Configure your emulator
Once you’ve installed a new emulator, such as lr-mame, you’ll have to configure the libretro back end to use it by default for either all games or selected titles. The easiest way to do this is to browse to the game you want to play in the EmulationStation front end. Go to the Arcade menu, press B to start any game – it doesn’t matter if it currently works or not – and then press B again when you’re briefly prompted to ‘press a button to configure’. Select option 1 to set the default emulator for arcade games and choose lr-mame. Option 2 allows you to select a different emulator for anything that doesn’t work well with this.
Connect Steam Link
Linking Steam to your arcade cabinet lets you stream a wealth of modern and classic arcade games to Raspberry Pi from a more powerful PC, like Melty Blood, Guilty Gear, Horizon Chase Turbo, and Street Fighter V. After you’ve installed it and restarted EmulationStation, go to the Ports menu and select Steam Link. It’ll download updates – you will need a keyboard plugged in to approve these – and then run. Make sure Steam is running on a PC on your local network and that Enable Remote Play is ticked under Settings > Remote Play. On the arcade machine, select the computer you want to link to. Steam Link will show a code. Enter this in your PC’s Steam client when prompted. To avoid a resolution mismatch, run Steam with a monitor that matches the resolution of your arcade machine set as your primary display.
Configure Steam Link
You may want to reconfigure your controls, as Steam Link doesn’t inherit the control layout from RetroPie’s EmulationStation, and some games do better with alternative button assignments – for example, to more closely match an Xbox or Steam Controller, which swaps the position of the B and A buttons. To set these, launch Steam Link, press up to highlight the gear icon, press A (per our button assignment diagram), go right to highlight Controller and press A. Select the controller you wish to configure, then press down and right twice, and select Setup Controller. Hit the button you want to associate with each Steam Controller-style button as it’s displayed on screen. Use a keyboard or your second set of controls to use the skip button at the bottom to bypass extraneous buttons.
Why use Steam Link?
Steam Link is an invaluable tool for arcade emulation enthusiasts, not only because you can play more CPU-intensive games, but also because it’s the best way of ensuring copyright compliance for a number of re-released arcade games. We’ve been playing Ghouls ’N Ghosts from the Capcom Arcade Stadium on our cabinet via Steam Link. Unlike some SNK and Sega re-releases, Capcom doesn’t supply emulator-ready ROM files and the EULA for that compilation doesn’t allow you to extract its PAK files. Neil Brown of decoded.legal opines (magpi.cc/romextractionlegal) that “when even a legitimate Steam purchaser extracts the ROMs and runs them on their own Raspberry Pi, they infringe Capcom’s copyright”, making streaming these titles your best option for fully legal home arcade action.