Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #81579
    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
    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
    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
    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
    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
    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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Everything else related to the RetroPie Project’ is closed to new topics and replies.