How to run games programmatically?
-
Hello, I'm trying to get a system daemon to be able to start/stop games and emulationstation. What's the recommended way to do this?
UPDATE
I solved this problem with a script. You can use it too: https://github.com/coderkevin/mini-nes/tree/master/screenThe inspiration I've found for making this work is DaftMike's NESPi, but his script is pretty brute force. (https://github.com/imdaftmike/NESPi/blob/master/nespi.py) It seeks out and kills any and all emulator processes and emulationstation processes, and then uses openvt to run runcommand.sh on console 1 as root. However, I'm even having problems getting this to work right (joystick support not working for me).
I'm thinking there's got to be a better way to transition the system to start an emulator or restart ES. If there's not code to support it, I don't mind putting in some effort, just need a good push in the right direction.
(Here's the repo I've started to work with this, if anyone wants to see where I'm at or track progress: https://github.com/coderkevin/mini-nes)
Thanks!
-
@coderkevin i'm not sure about starting a game within ES.
...but, this might be a way to exit a game remotely: https://github.com/libretro/RetroArch/wiki/Network-Commands
this would only work for lr- emulators, though (which is most of them). retroarch may have a better way of doing this directly. i think RA might trap SIGTERM (rather than SIGKILL) cleanly, which might be a better way as it would save .SRM etc. i've not tested...
-
I'm dreaming up a better way to do this right now.
I'm thinking of replacing the autostart call to emulationstation, and calling a python script instead. And having that python script use
subprocess.Popen
to manage subprocesses to emulationstation and/or runcommand, then being able to send signals to those subprocesses without having to rely on consoleps
andkill
calls.For the actual switching of tasks, I'm thinking about watching a file under
/dev/shm
that could be edited by any other process with permissions to do so. This way, any external process could update that config to point to a rom file, then this python script would see the change and act accordingly.Example:
Autostart runs script
Script by default start emulationstation
Script starts watching/dev/shm
file.Other process receives an event (GPIO button press, NFC tag, whatever)
Other process overwrites/dev/shm
file to point to rom file.Script detects that the
/dev/shm
file has changed and reads it.
Script reads rom in config file, sends signal to terminate current subprocess (emulationstation) and start new subprocess (runcommand)I think something like this could be really useful for projects other than mine. If you're reading this and would file it helpful, let me know here. Whatever changes I do make will be available on my mini-nes github repo (or another repo that it references, I suppose)
-
Okay folks, I've written up a script to handle this exactly the way I described before.
It runs from the
autostart.sh
and watches/dev/shm/screen_manager.cfg
for updates.
That way any other system process can create/modify that file and this script will respond by either starting the rom, or starting the dashboard.Cheers!
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.