Build an Emergency RetroPie (RetroArch/ EmulationStation) Controller Configuration Reset Button

Screw up your controller settings? Reset them with a single press!
Zach Zach (248)
30 minutes

It seems that every time a friend comes over to play games on RetroPie, they invariably screw up the controller settings somehow. Sometimes they'll accidentally press [any] button when a game is loading, panic, and then change the controller settings for a specific ROM. Other times, they'll plug a new controller in and map it incorrectly.

Suddenly, you can't even use the controller to navigate the RetroPie interface correctly. Either way, resetting controller settings for a specific ROM or controller often requires SSHing into the Pi, pulling out the old keyboard, or hoping another controller will work. Not anymore!

Now you can reset all controls, restoring RetroArch/EmulationStation controller mappings to default, with the press of a physical button. :)

How it works

In a nutshell, a normally open (NO) button is connected to the Pi's 40-pin GPIO header. When pressed, it triggers a script that removes your existing controller configuration/mapping files and reboots your Pi. When the Pi reboots, the controller configuration prompt will reappear and all ROM controller configurations will have reset. Nice!

Note: This is meant to be a fun, novel project; there are many other ways to handle and backup your controller configurations.

Soldering IronSoldering Iron ×1
Raspberry PiRaspberry Pi ×1
Jumper wiresJumper wires ×2
Solder ×1 tube
NO momentary switchNO momentary switch ×1
Heat-shrink tubingHeat-shrink tubing ×1

Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.

Raspberry Pi shutdown button wiring

First, we need to create the button that will connect to the Pi. To do this, we'll solder some wires to a normally open (NO) push button, forming a "pigtail". This type of button is an open circuit until it is pressed. You can use any size button you wish, just make sure it's normally open and is a push (not toggle) button.

howchooer Tyler wrote an excellent guide on building a Raspberry Pi power button. We'll use that guide as a base for building our button.

If you have a breadboard, you can use it to prototype and test your button and scripts. If not, no worries; this is a super simple circuit.

Cut the ends off of two jumper wires and solder one of each to each button terminal. Then, use heat-shrink tubing to secure the soldered connections.

Connecting the button to the Pi

Connect one end of the Pi button pigtail to pin 5 (SCL), and the other to pin 6 (GND). If pin 6 is already taken by something else, you can use any other ground pin instead. is a great resource for identifying other ground pins.

Now we'll need to create a few scripts:

  1. The listen script, which will watch for button presses and call the reset script if the button is pressed, and
  2. The reset script, which essentially runs the following commands to reset RetroArch config and reboot the Pi:
rm /opt/retropie/configs/all/emulationstation/es_input.cfg
rm /opt/retropie/configs/all/retroarch-joypads/*
sudo reboot

I'll walk you through the process of creating these scripts.

SSH into your Pi and create the reset script:

sudo nano

Then, paste the following into that file:

#!/usr/bin/env python

import RPi.GPIO as GPIO
import subprocess

GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(3, GPIO.FALLING)['rm', '/opt/retropie/configs/all/emulationstation/es_input.cfg'], shell=False)['rm', '/opt/retropie/configs/all/retroarch-joypads/*'], shell=False)['shutdown', '-r', 'now'], shell=False)

Save and exit. Finally, make the script executable and set it to start on boot:

sudo mv /usr/local/bin/
sudo chmod +x /usr/local/bin/

Now we'll create the listen script that will start/stop our service and watch for button presses. To create the script:

sudo nano

Enter the following:

#! /bin/sh

# Provides:
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
    echo "Starting"
    /usr/local/bin/ &
    echo "Stopping"
    pkill -f /usr/local/bin/
    echo "Usage: /etc/init.d/ {start|stop}"
    exit 1

exit 0

Save and exit. Then, move the file into /etc/init.d and make it executable:

sudo mv /etc/init.d/
sudo chmod +x /etc/init.d/

Finally, tell the script to run on boot:

sudo update-rc.d defaults

Now, you can reboot your Pi to start the script or start it manually:

sudo /etc/init.d/ start
A Raspberry Pi power button mounted in a plastic housing

Find a good place to mount your button. For example, if you built a Retrobox, you can drill a hole on the back for mounting; if you built a Pi Cart, use a tiny reset button and embed it right in the case.

Or, let it hang.

A Raspberry Pi power button connected to a Pi

To test your setup, configure a controller and/or change its configuration from within a ROM. Press the button and after your Pi reboots you will be prompted to configure the connected controller from scratch.

Now your friends (or kids) can mess around with the controller settings all they want and, poof, reset button.

Questions? Comments?

Post in the comments section below and I'll do my best to help you out!

Network troubles? Reset your gateway.
Zach Zach (248)
5 minutes

If your Internet is running slowly or you're experiencing other connectivity issues with your Comcast router or modem, it's a good idea to either reset your gateway to factory defaults or simply restart it. The exact method for resetting your Xfinity router or modem can vary slightly by model. For Comcast router/modem combos, resetting the router to factory settings will also reset the modem -- thus, the terms "router", "modem", and "gateway" are often used interchangeably. Resetting router or modem Resetting your modem will wipe all previous router configuration -- including wifi network name, password, login information, etc. -- thus restoring it to factory defaults. This is different than restarting your router, which does not clear any settings and simply brings your network down and back up. Restarting router or modem To restart your Comcast router (without clearing any settings), simply unplug it, wait at least 30 seconds, and plug it back in. To reset your Comcast router, use the following steps: