This Python script for Raspberry Pi allows to use a button to close the emulator by pressing a single GPIO button. It is compatible with any other function or script previously assigned to buttons.
The default button selected is Player ONE Start; it can be changed during installation to any other as it does not remove any previous function.
The emulator closes after holding the button down for at least 0.5 sec. The button activation delay can also be changed.
wget --quiet --show-progress -O /recalbox/share/system/exit-emu-1b https://gist.githubusercontent.com/DjLeChuck/446cd415575f03c927627e378979027d/raw/9ebe3a5e178ff047b536220afd513981095fb41d/exit-emu-1b-installer && chmod 755 /recalbox/share/system/exit-emu-1b && bash /recalbox/share/system/exit-emu-1b install
The installer will display a list of possible GPIO port mappings corresponding to the GPIO mapping for Recalbox, corresponding to the following image:
After selecting the button port you want the script to be assigned to, the installer will ask you for the delay to exit the emulator, you must type the desired delay in seconds (it is important to answer both questions, otherwise the installer will fail).
After a few seconds, if the result is a message on the screen saying "Start button", then everything went well and we now have the button script installed and working.
/recalbox/share/system/exit-emu-1b uninstall
In the default RetroArch configuration, the script shuts down emulators by brute force using a killall command which, depending on the kernel you are using, could cause some emulator configuration changes made during game play to be lost. For example, this happens with Mame2003.
To avoid this, it has been implemented to close the emulator via a network command for RetroArch. Now RetroArch will close properly and you won't lose configuration changes in the emulators.
This change only affects RetroArch, although it covers most emulators on the system, emulators like FBA2x, Scummvm or mupen64plus are still closed by brute force, until I find another way to apply it.
/recalbox/share/system/exit-emu-1b install
and put in the new port number you want./recalbox/share/system/configs/retroarch/retroarchcustom.cfg
file, or in the RetroArch custom configuration file where you use the Network_cmd_enable
parameter set to ``true''./etc/init.d/S98exit-emu-1b restart
. You will have to enter it inside an SSH session.