Autostart and ROM load by command line
-
Hello all!
I'm facing an issue that might be a non issue but still I can't understand exactly what is happening, so I'm sorry for maybe wasting someone time with this.
So I'm making a project for my 3 yr old and I want it to start a game on startup, which I do now by changing the autostart.sh. I comment the Emulationstation command and added:
/opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ nes '/home/pi/RetroPie/roms/nes/Super Mario Bros. (World).nes'
Which works great and my gamepad is configured and working great.
I then have a small script that I also added to the autostart.sh that by pressing a button it will run another game:
/opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ nes '/home/pi/RetroPie/roms/nes/<another rom>.nes'
(where another rom is a valid file)
The script works as intended and it stops the mario game and starts the other game but the gamepad is not configured. I've tried multiple commands and configurations but it seems that it doesn't load the gamepad configuration.
And is not rom related because even by changing to the autostart.sh rom the second one will not have the gamepad configured.
If I start as emulation station all games work as intented, so I'm for sure doing something wrong.
Can anybody tell me how do I switch roms and keep my gamepads configured by command line?
My retropie is the latest version at this moment (4.2) and the system is Raspeberry Pi 3. The gamepads are generic USB ones.
Thank you in advance
p.s. edited to give more information on the system (thank you BuZz)
-
@pmreis Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first
Put the commands in code blocks or else details will be lost due to markdown formatting.
-
Thank you BuZz, edited my post accordingly.
I've been searching for quite some time about this, in the forums and online. Couldn't find the answer, I read the advice and even read most of the documentation on the retroarch but still I couldn't find the answer specially because the same command doesn't work twice the same way.
Kinda stuck but I'll keep on diggin' :D
-
@pmreis unfortunately i don't know. They should behave the same. Check runcommand log for both to compare the launch commands.
Regarding read me first link, check the list of information to provide for future. Eg don't say "latest" RetroPie. Don't know what system you are on either.
-
How are you killing the game/launching the new one?
Are you killing the RetroArch process?
Also, how are you capturing the button event - aren't they all being handled by RetroArch?
Just some thoughts.
-
@pjftt Thank you for your reply!
I did
sudo pkill retroarch
in the script which kills the current game (overkill maybe), is there any other way? I tried without killing the retroarch and the behaviour is exactly the same with the difference that the previous game is running on the background.Regarding the button capture is a physical momentary button, I'm using GPIO03 which I also use to shut down the pie with a long press. As far as I know RetroArch are not handling the GPIO inputs.
-
@pmreis Got it.
I'd suspect killing retroarch is the way to go, so I'm out of ideas unfortunately. I'd try to read up on the runcommand logic, to see if there's anything you're missing there.
Sorry for not being able to help out more.
-
@pjft Thank you anyway! I think it actually may be because of the way retroarch is "killed", because the runcommand.logs are exactly the same with the difference in the name of the rom... it makes no sense. Can be also the "subprocess" in python that is adding some sugar, but I have no idea what can be.
-
@pmreis send a SIGINT instead of SIGTERM and see if that helps.
-
@BuZz the change didn't help. But I think I've narrowed it down to the way Python calls the command line.
and I even found another post with the same problem but unfortunelly without any answer to it.
https://retropie.org.uk/forum/topic/6167/programmatically-run-game-from-console/6
If I run the command in terminal go to game then back to terminal and again command, everything works fine. The problem is when the terminal call is from python. Might be an issue with the python sandbox or some users permissions somehow.
Also found out that when the gamepad is not detected the keyboard is active and allows to play the game, but that is not optimal as my 3yr old would not understand this.
I'm using
subprocess.call('<link>', shell=True)
and I've triedos.console(<link>)
both have the same behaviour.Not an linux expert to understand exactly what is happening but hopefully somebody had this problem at one point and will see this post. As soon I have an answer I will for sure post it here.
-
@pmreis I'm certainly not a Linux expert either. What happens if you run it with shell=false, out of curiosity?
Could you test out, instead of the script to change games, just explicitly launching two consecutive games in autostart, and exiting the first one via the standard select+start so it launches the second one, and see if the input works or not?
-
@pjft The shell=False doesn't even allow to run the call.
As for the other test seems quite a really good troubleshoot, now I'm on the school run but as soon as I can I'll try it out!
Thank you.
-
@pmreis Just tried it and it works. So clearly the problem is in the way the
runcommand.sh
is called by python.So my workaround is to put a bunch of roms in autostart and when you click the button it will cycle through those games, in the end I just start the emulation station. Not what I was going for but might work for the purpose.
Thank you for your help!
-
@pmreis Great to hear.
Truth be told, then, you might be able to replicate whatever you were going for in the bash script instead. It is quite powerful, for those who know how to make it work.
Alternatively, you may try to have the python script call just one (random?) game, assuming that whatever logic you have there is preserved, and just have the autostart script repeatedly call the python script.
Once again, without knowing what you're trying to do, I'm just guessing, but hope it helps!
-
@pjft true, is very possible to do it in the bash.
My project is very simple, a PI in a wood box with a big push button and 4 leds, and under each led there is a logo of a game. Whenever my kid wants to play he pushes the big button and starts the pi. Whenever he is tired or want a different game press again the button and goes for another game (so the respective led turns on). Whenever he wants to turn off just keeps the big button pressed.
That's it. So I do believe your solution fits the purpose perfectly as I can just put the 4 or 5 games in the autostart and control the leds over the python script or bash or whatever.
Thank you very much!
-
@pmreis said in Autostart and ROM load by command line:
My project is very simple, a PI in a wood box with a big push button and 4 leds, and under each led there is a logo of a game.
Then you can call yourself a frontend developer! :-)
I'm curious about how to get input from those buttons with "pure" bash.
-
@meleu in "pure" bash I don't think is possible but you can call c programs that do that, I've done that for other projects. I was trying to get everything done with a python script (which is totally not my weapon of choice), but with the bash and a couple of tricks this can be done, it fits the purpose.
The issue for me might be if I had multiple physical buttons connected to several GPIO to select specific games, but by having only one button really simplifies the whole thing.
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.