How to set pause key for libretro emulators?
-
When enabling the hotkey in RetroArch, you can't use a single key for the command, you need to use the hotkey.
However, there is a workaround to that, albeit a bit more convoluted. RetroArch has a network input interface, to which you can send the Pause command through a script. You can trigger said script using thetrigerhappy
service (which is enabled and started by default on a RetroPie image).- Create a file named
pause-retroarch.conf
in the/etc/triggerhappy/triggers.d
and add the following line:
KEY_P /home/pi/pause-ra.sh
You'll need to use
sudo
to create the file, since this is a system file.sudo nano /etc/triggerhappy/triggers.d/pause-retroarch.conf
- Create a script that will send the pause command to RetroArch in
/home/pi/pause-ra.sh
with the following lines
#!/bin/bash echo -n "PAUSE_TOGGLE" | nc -u -w1 127.0.0.1 55355
and then make the script executable
chmod +x /home/pi/pause-ra.sh
- Install
netcat
- used by the script
sudo apt -y install netcat
- Modify the RetroArch configuration configuration file in
\\retropie\configs\all\retroarch.cfg
and add a line at the end with
network_cmd_enable = "true"
Reboot and see if the P key pauses RetroArch.
- Create a file named
-
@mitu Thanks very much. It's a shame RA can't do it without a hotkey!
I tried the script as you mentioned above (checked everything twice) but still pressing the button on its own doesn't do anything. It still works with the hotkey though.
-
I may have omitted something in the
thd
script (pause-retroarch.conf
. The lineKEY_P /home/pi/pause-ra.sh
should be
KEY_P 1 /home/pi/pause-ra.sh
Check if the service is started automatically with
systemctl status triggerhappy.service
-
@mitu thanks again. No luck though. tweaked the .conf file as mentioned, and checked triggerhappy was running, which it was. Still can only get pause to work if I hold the hotkey.
I also ran the script ./pause-ra.sh directly from the terminal while lr-mame2003 was running. This did nothing either.
Cheers
-
@agent4125 Then maybe the network input interface is not enabled. Did you ever used Save Configuration in RetroArch when configuring it ? This would generate a full configuration file that's different than the
.cfg
I mentioned. -
@mitu I had set the network_cmd_enable = "true", is there another setting I should be looking out for. It's "true" in retroarch.cfg.
I may have saved configuration at some point in the past (before I knew better I guess), but manually editing the main retroarch.cfg for other settings works fine.
-
@agent4125 I think I know why it doesn't work - there's an extra parameter in the
pause
script - I amended the original post and removed it. Please re-do thepause-ra.sh
script with the new command and try again. -
Bingo! That works.
Many thanks :)
-
@mitu Many thanks for sharing this information, I know this is an older post but is it possible to map multiple buttons using this script? I'm hoping to not use the pause key but a button combo such as Coin 2 and Player 2 simultaneously. This would allow me to have some consistency between emulators for Pause (libretto mame/advancemame) and avoid using the hotkey.
Thanks again for sharing this information!
-
@jlr2000 I don't know, in theory it knows about multiple key presses allowing for up to 5 modifiers. Just give it a test and see how it behaves.
-
@mitu Will do, thanks!
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.