Thursday, February 26, 2015

RetroPie: An All-in-One Retro Game Emulator on the Raspberry Pi

The affordable Raspberry Pie computer that is popular among DIYers and enthusiasts makes an excellent retro console emulator. You can turn it into an all-in-one retro game console that plays hundreds of classic video games and is small enough to fit in your pocket (so to speak). The only thing better than reliving classic video games is bringing it over to a friend's place and enjoying the games you grew up playing together.

The RetroPie Project makes it incredibly easy to get up and running with retro gaming. You can save plenty of time by downloading the RetroPie image that includes all of the emulators you need.

You can buy a Raspberry Pi starter kit which typically includes the following:
  • Raspberry Pie
  • microSD card (for model B+)
  • Power adapter
  • Raspberry Pi case
  • HDMI cable
In addition to the basic components, you can pick up some USB gaming controllers for that retro feel.

If you have all the components, it's a pretty strait forward process:
  • Install the RetroPie image
  • Configure your controllers to work with Emulation Station and the emulators
  • Copy over your ROMs
Of course you may want to do change a few advanced configurations:
There are plenty of guides out there to help you get set up and playing your favorite old school video games on a Raspberry Pi. Here are a few that have helped me:


Sunday, February 15, 2015

Configure a USB SNES Controller for RetroPie

Setting up a USB SNES Controller/Gamepad for RetroPie

Note: This covers how to set up a controller on RetroPie 2.6 for a Raspberry Pi 1 Model B+. The set up steps are different in later versions of RetroPie.

This post will go over how to configure a USB SNES controller for RetroPie [Update - RetroPie 2.6 for a Raspberry Pi 1 Model B+] following the steps below:
  1. Register the controller for RetroArch
  2. Modify the controller to use hotkeys

In the example below, I'm using a USB controller that I purchased from Amazon (Buffalo Classic USB Gamepad for PC). The controller received great reviews and I haven't had an issue with it. I own two of these controllers and use them for playing games on my RetroPie (SNES, NES, Genesis, MasterSystem, and TurboGrafix-16). If you have a different controller, your input numbers may differ, so keep that in mind when modifying the controller configuration file.

This setup/configuration only covers setting up a gamepad for use with the emulators that fall under RetroArch.

Register the Controller for RetroArch

When you boot into the Raspberry Pi, you will be prompted to configure the controller for Emulation Station. 
  1. Press F4 on your keyboard to exit to the command line.
  2. Navigate to the setup script location: "cd RetroPie-Setup"
  3. Load the RetroPie setup screen: "sudo ./retropie_setup.sh"
  4. Go to "SETUP" > "Register RetroArch controller"
  5. Follow the onscreen instructions to map your controller inputs (if your controller doesn't have the buttons, wait a few seconds and it will skip to the next button)
    1. Note the name of the configuration file this setup creates as we will be modifying the file below to add hotkeys.
  6. When the setup finishes, reboot (back out to the previous menu options and select "Perform REBOOT").
To run the controller setup script:
cd RetroPie-Setup
sudo ./retropie_setup.sh


Modify the Controller to Use Hotkeys

Hotkeys can be set up to exit the emulator, reset, the game, save/load states, etc.
Reminder: The configuration below is specific to the controller that I mentioned above. Your input buttons will differ depending on the USB controller you are using.

Steps (starting from the command line):
  1. Navigate to the controller configuration file
  2. Edit the configuration file that you had set up for RetroArch
  3. Save the changes to the configuration file and exit the editor
1. Navigate to the controller configuration file
cd opt/retropie/emulators/RetroArch/configs
sudo nano USB,2-axis8-buttongamepad.cfg

2a. Open the controller configuration file using "nano":
input_device = "USB,2-axis 8-button gamepad  "
input_driver = "udev"
input_b_btn = "1"
input_y_btn = "3"
input_select_btn = "6"
input_start_btn = "7"
input_up_axis = "-1"
input_down_axis = "+1"
input_left_axis = "-0"
input_right_axis = "+0"
input_a_btn = "0"
input_x_btn = "2"
input_l_btn = "4"
input_r_btn = "5"

2b. Add a line to enable the hotkey button (I'm using the select button on my controller):
input_enable_hotkey_btn = "6"
You can add hotkeys to perform the following functions:

#Enable hotkeys
input_enable_hotkey_btn = ""
#Exit the emulator
input_exit_emulator_btn = ""
#Save/Load a state
input_save_state_btn = ""
input_load_state_btn = ""
#Increase/Decrease the save state slot
input_state_slot_increase_axis = ""
input_state_slot_decrease_axis = ""
#Toggle the emulator menu
input_menu_toggle_btn = ""
#Reset the emulated game
input_reset_btn = ""

To use the hotkeys, hold down the button assigned to the "input_enable_hotkey_btn" and press the button assigned to the function you want to perform.

My final controller configuration looks like this:
input_device = "USB,2-axis 8-button gamepad  "
input_driver = "udev"
input_b_btn = "1"
input_y_btn = "3"
input_select_btn = "6"
input_start_btn = "7"
input_up_axis = "-1"
input_down_axis = "+1"
input_left_axis = "-0"
input_right_axis = "+0"
input_a_btn = "0"
input_x_btn = "2"
input_l_btn = "4"
input_r_btn = "5"
input_enable_hotkey_btn = "6"
input_exit_emulator_btn = "7"
input_save_state_btn = "0"
input_load_state_btn = "1"
input_state_slot_increase_axis = "-1"
input_state_slot_decrease_axis = "+1"
input_menu_toggle_btn = "5"
input_reset_btn = "4"

3. Save the changes to the configuration file and exit the editor:

  • Control + X
  • Y
  • Enter
You should now have a working controller configured with functional hotkeys.