Start a game in paused mode (Retroarch)?
-
@mitu said in Start a game in paused mode (Retroarch)?:
I don't think there's an option for it in RetroArch. You may be able to use a
runcommand
onstart script to send a toggle pause command to it via the network control interface, but you'll have to time it properly and also bind the Pause command on your gamepad so you can properly resume the gameplay.I saw those commands yesterday but couldn't figure out a way to call them. The runcommand onstart should do the trick. Maybe I can wrap the call in a loop that looks for the retrorarch PID and executes it as soon as it finds it. Or, maybe look for a lock file if RA creates one (researching that now).
-
OK, I need some help with the logic in my script. If I put the below into a test.sh and run it, it behaves exactly as I want. As soon as it finds a process with 'retroarch' in the name, it sleeps 1 and then sends a pause.
However, if I put the same code into runcommand-onstart.sh, retroarch never launches (makes sense) and I am stuck in the loop.
Is there a way to tell the while loop to continue with the script while it waits for the process to appear?
#! /bin/bash while ! pgrep retroarch >/dev/null; do : done sleep 1 echo -n "PAUSE_TOGGLE" | nc -u -w1 127.0.0.1 55355
-
@mitu Thank you for pointing me in the right direction.
I think I may have worked through this unless someone can tell me a cleaner way of doing it with only the runcommand-onstart.sh...
#! /bin/bash ( /opt/retropie/configs/all/pause.sh ) &
The & at the end is key as it allows the onstart script to continue to run in the background.
#! /bin/bash while ! pgrep retroarch >/dev/null; do : done sleep 1 echo -n "PAUSE_TOGGLE" | nc -u -w1 127.0.0.1 55355
-
I'm curious why you need this function?
-
@Rion said in Start a game in paused mode (Retroarch)?:
I'm curious why you need this function?
Glad you asked... :)
I want to start the game paused and show an overlay (bezel) that has game-specific controls. When the RA 'pause_toggle' hotkey is pressed, the game will unpause and display the normal, transparent overlay (bezel). The player can press the pause button at anytime during gameplay to see the controls again. BTW...I have overlay_next and pause_toggle mapped to the same button.
Game paused at start and controls displayed:
Pause toggle button pressed...game unpaused and normal bezel displayed.
Pause toggle button pressed during gameplay pauses the game and displays the controls again.
-
Quick video showing the transitions. Sorry...poor quality and no sound...only intended to show the functionality.
-
@johnodon said in Start a game in paused mode (Retroarch)?:
I think I may have worked through this unless someone can tell me a cleaner way of doing it with only the runcommand-onstart.sh...
You can add the commands in the sub-shell, but it will look ugly. As for the 2nd script, you might want to add a 2nd
sleep 1
inside the loop, so it won't waste resources waiting for RetroArch to show up. -
@mitu said in Start a game in paused mode (Retroarch)?:
@johnodon said in Start a game in paused mode (Retroarch)?:
I think I may have worked through this unless someone can tell me a cleaner way of doing it with only the runcommand-onstart.sh...
You can add the commands in the sub-shell, but it will look ugly. As for the 2nd script, you might want to add a 2nd
sleep 1
inside the loop, so it won't waste resources waiting for RetroArch to show up.I wasn't sure if that was necessary since I was using : which is supposed to do nothing. I'll play safe and take your advice and add the sleep 1 inside the loop.
Thanks
-
Getting closer to a finished product...
-
One final note...
I had been doing all of my testing on an x86 platform. Since moving the scripts/overlays to my RPI4, I had to increase the sleep outside the loop to 2 otherwise it wouldn't pause.
#! /bin/bash while ! pgrep retroarch >/dev/null; do : sleep 1 done sleep 2 echo -n "PAUSE_TOGGLE" | nc -u -w1 127.0.0.1 55355
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.