Recalbox Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • recalbox.com
    • Gitlab repository
    • Documentation
    • Discord

    Emulator Exit button GPIO

    GamePad/GPIO/USB encoder
    button gpio stop emulator
    4
    22
    13310
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Substring
      Substring last edited by Substring

      haha i'm the man 😄

      Seriously, most of emulators are listed in the recalboxFiles.py. Would need to improve it because all bins are not listed there. But I really like this idea : kill the running emulator, or even reset the game (there is a topic on it somewhere, will gid this and update my post) -> https://forum.recalbox.com/topic/3435/game-reset/6

      Former dev - Please reply with @substring so that i am notified when you answer me
      Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

      1 Reply Last reply Reply Quote 0
      • supernature2k
        supernature2k last edited by

        solution via python with network commands:

        import os
        import RPi.GPIO as GPIO
        import time
        import socket
        import sys
        # addressing information of target
        IPADDR = "127.0.0.1"
        PORTNUM = 55355
         
        # enter the data content of the UDP packet
        PACKETDATA = "RESET"
         
        # initialize a socket, think of it as a cable
        # SOCK_DGRAM specifies that this is UDP
        try:
            s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        except socket.error:
            print 'Failed to create socket'
            sys.exit()
        #s.connect((IPADDR, PORTNUM))
         
        # connect the socket, think of it as connecting the cable to the address location
        
        data = bytes(PACKETDATA)
        
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        
        def exitEmulator(channel):
        	print("exitEmulator")
        	print(IPADDR)
        	print(PORTNUM)
        	print(PACKETDATA)
        	s.sendto(PACKETDATA, (IPADDR, PORTNUM))
            
        GPIO.add_event_detect(3, GPIO.FALLING, callback=exitEmulator, bouncetime=500)
        
        while True:
            time.sleep(10)
        

        Pi powered NES | Gameboy HD | RecalStation | RecalDrive
        Upvote messages if it has been useful ;)

        OyyoDams 1 Reply Last reply Reply Quote 1
        • OyyoDams
          OyyoDams Staff @supernature2k last edited by OyyoDams

          @supernature2k Hi,

          I'm replying to this old topic because I'm currently working on a project that needs such a feature. I tried your last script, I just removed GPIO code at for now to test, so here is my code:

          import os
          import time
          import socket
          import sys
          # addressing information of target
          IPADDR = "127.0.0.1"
          PORTNUM = 55355
          
          # enter the data content of the UDP packet
          PACKETDATA = "RESET"
          
          # initialize a socket, think of it as a cable
          # SOCK_DGRAM specifies that this is UDP
          try:
              s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
          except socket.error:
              print 'Failed to create socket'
              sys.exit()
          #s.connect((IPADDR, PORTNUM))
          
          # connect the socket, think of it as connecting the cable to the address location
          
          data = bytes(PACKETDATA)
          
          print("exitEmulator")
          print(IPADDR)
          print(PORTNUM)
          print(PACKETDATA)
          s.sendto(PACKETDATA, (IPADDR, PORTNUM))
          

          So to try it, I start a retroarch game then I launch the script:

          # python rpi-exit-emulator.py 
          exitEmulator
          127.0.0.1
          55355
          RESET
          

          But in fact it does nothing, I'm still in the game (with no reset). Any idea ? 🙂

          Substring 1 Reply Last reply Reply Quote 0
          • Substring
            Substring @OyyoDams last edited by

            @oyyodams it's RESET, not exit 😉

            Former dev - Please reply with @substring so that i am notified when you answer me
            Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

            OyyoDams 1 Reply Last reply Reply Quote 0
            • OyyoDams
              OyyoDams Staff @Substring last edited by

              @substring yes that's it's supposed to do... but no reset by the way...

              Substring 1 Reply Last reply Reply Quote 0
              • Substring
                Substring @OyyoDams last edited by

                @oyyodams check on command line if you can connect to the port 😉 some netcat commands should do it

                Former dev - Please reply with @substring so that i am notified when you answer me
                Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                OyyoDams 1 Reply Last reply Reply Quote 0
                • OyyoDams
                  OyyoDams Staff @Substring last edited by

                  @substring Well I found a great doc on the wiki. But...

                  • I can't use netcast: nc is not include in this buildroot build (and I can't rebuild by now)
                  • It seems retroarch doesn't respond to any command. I tried to edit retroarch.cfg to add network_cmd_enable = "true", nothing better (even after reboot)

                  I will not let go;)

                  Substring 1 Reply Last reply Reply Quote 0
                  • Substring
                    Substring @OyyoDams last edited by

                    @oyyodams hold the door !!!

                    Former dev - Please reply with @substring so that i am notified when you answer me
                    Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                    OyyoDams 1 Reply Last reply Reply Quote 1
                    • OyyoDams
                      OyyoDams Staff @Substring last edited by

                      @substring Hodor

                      Don't worry I keep up the good work, things begin to be better, news soon 😉

                      1 Reply Last reply Reply Quote 0
                      • OyyoDams
                        OyyoDams Staff last edited by

                        Ok solution:

                        network_cmd_enable = "true" has to be added in /recalbox/share/system/configs/retroarch/retroarchcustom.cfg

                        supernature2k 1 Reply Last reply Reply Quote 0
                        • supernature2k
                          supernature2k @OyyoDams last edited by

                          @oyyodams sorry I'm late...
                          Does it work now?

                          Pi powered NES | Gameboy HD | RecalStation | RecalDrive
                          Upvote messages if it has been useful ;)

                          OyyoDams 1 Reply Last reply Reply Quote 0
                          • OyyoDams
                            OyyoDams Staff @supernature2k last edited by

                            @supernature2k yes, see my post above 😉 Thanks a lot for your scripts!

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post

                            Want to support us ?

                            79
                            Online

                            99.6k
                            Users

                            28.1k
                            Topics

                            187.1k
                            Posts

                            Copyright © 2021 recalbox.com