Exit emulator with one button press vía gpio
-
Thank you! A lot of people would use it
-
@supernature2k I SUMMON YOU !!!
-
@Substring Yep, how can I help?
-
@supernature2k where is your fringing script to kill emulators via GPIO ?
-
@Substring try this:
import RPi.GPIO as GPIO import time import os import thread import datetime import socket import sys from datetime import datetime from configgen import recalboxFiles # this last one retrieves emulators bin names IPADDR = "127.0.0.1" PORTNUM = 55355 # IP and port for retroarch network commands QUIT = 3 GPIO.setwarnings(False) # no warnings GPIO.setmode(GPIO.BCM) # set up BCM GPIO numbering GPIO.setup(QUIT, GPIO.IN, pull_up_down=GPIO.PUD_UP) # GPIO on pin 3 is the GPIO 2 in BCM mode #to Reset+ # Define a threaded callback function to run in another thread when events are detected def button_pressed(channel): nwcommand="QUIT" retroarch(nwcommand) killthats**t(channel) # on quit press, trying to kill all listed emus def killthats**t(channel): if channel == QUIT: for bin in recalboxFiles.recalboxBins: print bin proc = os.path.basename(bin) print proc os.system("killall -9 "+proc) # sending network command to retroarch (only exit and reset atm) def retroarch(nwcommand): try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) except socket.error: print 'Failed to create socket' sys.exit() s.sendto(nwcommand, (IPADDR, PORTNUM)) GPIO.add_event_detect(QUIT, GPIO.BOTH, callback=button_pressed, bouncetime=2) while True: time.sleep(0.2)
-
@supernature2k
Does this automaticly start ES again after killing the Emulator? -
@sevenx no as ES is not killed when you launch an emu
-
@supernature2k
Do you have some time, to talk about a new project from me? Over PM? -
@sevenx ok
-
@8bit_astronaut maybe this article I wrote some time ago can help. I use the script to reset the emulator. But with replacing the RESET with QUIT you should be able to quit it and return to ES.
https://github.com/recalbox/recalbox-os/wiki/Emulator-interactions-via-GPIO-mapping-(EN)
-
@lackyluuk that looks great! Ill check it in a moment, thank you so much!
-
@lackyluuk its necesary to have an internet conection for recalbox???
-
@8bit_astronaut No, I think it should also work without. But it is highly recommended
-
@8bit_astronaut Not at all. The internet connection is only useful for scraping directly with your recalbox or for accessing you share folder through your network.
-
maybe?
exit-emu-1b-installer:
http://webcache.googleusercontent.com/search?q=cache:https://gist.github.com/Phantiss/3e0cab70f7084431e1c389d633e53662rpi-exit-emu-1b .py
http://webcache.googleusercontent.com/search?q=cache:https://gist.github.com/Phantiss/b9248718a208e293d332feed0a9cbc27S98exit-emu-1b
http://webcache.googleusercontent.com/search?q=cache:https://gist.github.com/Phantiss/813037bfd7c9d22a3cd2887714463eda -
@sevenx Haha nice! I update the wiki page and links.
-
-
I think my script is betta (btw, I corrected this RESET instead of QUIT):
- sending network command to retroarch is better
- using sub's list of emulator bins is better (no need to modify script if new emus implemented)
-
@supernature2k Can you update the wiki this way?
-
@DjLeChuck We could include @supernature2k s script into the article i posted above. This article is in general about interacting with emulators through the retroarch network commands. Instead of having multiple articles spreaded around we could have all in the same place. What do you think?