# Notes for installation: # On older versions of RetroPie, you may need to update (sudo apt-get update) # Install python-pip (sudo apt-get install python{,3}-pip # Install GPIOZERO (sudo apt-get install python-gpiozero # Install uinput (sudo pip install python-uinput) # Copy script to the /home/pi/ folder # Confirm that the extension of the script is .py # Confirm permissions of the script file is set to 0755 (or higher) # Go to the /etc/ folder and edit the rc.local file # At the bottom of the file add in this line above the "exit 0" line: python /home/pi/reset.py & # Reboot from gpiozero import Button from subprocess import check_call from signal import pause import uinput import time device = uinput.Device([uinput.KEY_F12, uinput.KEY_F1]) def press_Reset(): # F12-Reset event when button is pressed and released before hold timer is reached device.emit(uinput.KEY_F12, 1) time.sleep(0.1) device.emit(uinput.KEY_F12, 0) def hold_Reset(): # F1-Quit event when button is pressed longer than the hold timer device.emit(uinput.KEY_F1, 1) time.sleep(0.1) device.emit(uinput.KEY_F1, 0) #define the GPIO and its parameters - hold_time is in seconds unit Reset_button = Button(21, pull_up=True, hold_time=2) #Process the Reset button detection Reset_button.when_released = press_Reset Reset_button.when_held = hold_Reset pause()