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.

3 comments:

  1. Sigh. Where do I start? I have spent so many hours trying to get this to work. I have the same controllers you do. I started over from scratch and your instructions do not appear complete. When I exit with f4 and follow your instructions, I do not have a choice for "Register RetroArch controller". Closest thing I have to that under setup / config to be used post install is 'configure input devices for retroarch. I did that whit seems to start the joystick config routine you can get to from inside emu station. I also couldnt find the path you provided to the file created. I am using a pi 2 model b+ with retropie 3.0 rc1. Are you on 2.6 or a version1.x pi? If you could weigh in i would appreciate it.

    ReplyDelete
  2. Hi Andyman! Thanks for reaching out. I should have specified the version I used to go through the setup. The instructions are for RetroPie 2.3 on a Raspberry Pi Model B+. I haven't updated the version of RetroPie since I first built it. I believe the guys over at RetroArch also made some updates, so it's possible that the path to the RetroArch config file might have changed.

    With RetroPie version 3 RC1, there is a graphical way to get to the retroarch-setup. Floob posted a video on Youtube that goes through setting up on the new version: https://www.youtube.com/watch?t=727&v=wBgFigRNGyw

    Hope this helps!

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete