Exit emulators via gpio signal?

Home Forums RetroPie Project Everything else related to the RetroPie Project Exit emulators via gpio signal?

RetroPie has a new website and forum. Please visit https://retropie.org.uk/ for the new site. The new forum is located at https://retropie.org.uk/forum/. This forum is left here as a read-only archive.

This topic contains 5 replies, has 4 voices, and was last updated by Profile photo of brunchero brunchero 2 years ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #81579
    Profile photo of ronan
    ronan
    Participant

    Hi,

    I’m mounting a retropie based game station in an old NES case, and I’d like to use the nes reset switch to exit the current game and return to emulationstation.

    Is there any way to send this kind signal to emulationstation via a python script? I already have a script running for the mausberry shutdown circuit, if possible it would be great to have this on the same script.

    I use usb controllers, so I don’t need a full gpio/controller mapping; I just need to simulate an escape key press, or send directly a signal to emulationstation or the current running emulator to exit.

    #81624
    Profile photo of ronan
    ronan
    Participant

    So I tried to simulate an ESC key press with python-uinput, and while it works the emulators doesn’t react.

    So I found a simpler way: I look at all the running processes, and if I find one with a command path starting with “/opt/retropie/emulators/” I send it a “kill -INT [pid]”.

    Not really future-proof if the emulators path change, but good enough.

    #81962
    Profile photo of ronan
    ronan
    Participant

    My script is on github, feel free to use it or suggest improvements: https://github.com/RonanL/retropie-mausberry-switch/blob/master/python/nespi.py

    #81963
    Profile photo of imnew
    imnew
    Participant

    I’m yet to receive a response on this site – can someone reply to this please as I’m not sure whether theres some bat shit invisible mode on or something.

    thanks

    #83495
    Profile photo of tool212
    tool212
    Participant

    This is what I want mine to do. I am Working on one for a Xmas gift and I am 99% complete. Everything works including the power button on the NES. I am stuck on the shutdown I have everything soldered to the mausberry switch and I am using gpio 23 and gpio 24. on boot up i can see error erc/switch.sh line9, line 11 echo write error device not responding or busy.
    In your code it appears you are using 23 24 and 25. could you send me a pic or diagram on how you have it wired.
    Thanks

    #94577
    Profile photo of brunchero
    brunchero
    Participant

    Thanks Ronan, your script was the code I needed for my Retro RPi2!

    I adjusted it to fit my GPIO stuff with some LEDs added, and attached my version in case anyone is interested. (I use the retropi 2.6 image.)

    My changes:
    – made it a very basic python daemon, so I could add it to init-scripts
    – use BCM GPIO 3 for shutdown, since it also can startup the rpi when pulled low
    – for that reason, use FALLING interrupts
    – use SIG TERM for emulator, to allow clean exit (save srm?), wait 5 seconds and then send SIG KILL to the process in case TERM did not help
    – added LED when nespi.py daemon is running
    – added LED when emulator is running, check every second

    To simplify the emulator LED, I hacked runcommand.sh to write its own PID into a temp file on start, and remove it on script end.

    I also wanted my own ACT LED for sd card activity, which, as turned out, is super easy using the device tree overlay in config.txt.
    dtoverlay=act_led_gpio=22

    Retro gaming, rpg and adventure fan. arduino and raspberry tinkerer.

    • This reply was modified 2 years ago by Profile photo of brunchero brunchero. Reason: Python file uploads not allowed, trying text
    • This reply was modified 2 years ago by Profile photo of brunchero brunchero.
    Attachments:
    1. nespi.py_.txt
Viewing 6 posts - 1 through 6 (of 6 total)

Forums are currently read only - please visit the new RetroPie forums at https://retropie.org.uk/forums/

Skip to toolbar