How to Use Momentary Switch for Exit Game Button?
-
Hello! I am wanting to hook up a momentary switch to a Raspberry Pi 3b+ with RetroPie (obviously) to use as a dedicated "Exit Game" button. Is there some sort of script I could use that would just run that command whenever the button is pressed? Or is there a better way to do that? Sorry for just asking to be almost spoon fed an answer. I am willing to do some light and basic programming or mess with stuff if need be.
Thank you, -saddlepiggy!
-
You can try @cyperghost's script (https://github.com/crcerror/ES-generic-shutdown) to hook it up to your button press and invoke it with the
--closeemu
parameter to just stop the current emulator instead of shutting down/restarting your Pi.
The topic for the script is at https://retropie.org.uk/forum/topic/17415. -
Oh cool. I was already going to use that for my shutdown button. I didn't know there was a command for closing the emulator. Thank you!
-
@saddlepiggy The
--closeemu
switch is also always used for es reset and the reboots of the system. It is essential to close any running instance of an emulator or port (Kodi and Pixel Desktop also work) BEFORE closing EmulationStation.Most shutdown scripts just use
killall emulationstation
, this works in most cases but you can't restart emulationstation anymore and even worse you can retain broken metadata. -
@cyperghost good to know. Thanks :)
-
@cyperghost Sorry for bothering you again, but does the script work with 2 switches? I would have a latching for power and a momentary for closing the emulator.
-
@saddlepiggy The script provides a generic power button. Just connect your latching button to pin 5 and 6 then you can power down and restart the Pie. The command switch is --generic
Or you can write your own script. I modified the python script for the NesPi+ to demonstrate usage
https://retropie.org.uk/forum/topic/17506
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.