RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    SNES / SFC original reset button to exit emulator GPIO

    Scheduled Pinned Locked Moved Help and Support
    super nintendosnesreset buttonexitgpio
    9 Posts 4 Posters 3.2k Views
    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.
    • C
      CeEeeEe4
      last edited by

      Hi

      I have nearly completed a SNES build using a Pi Zero, i have both the original controllers working and the original power switch.

      What i need to finish is to set up the original reset button to exit the emulator and go back to the game select menu. i have read several threads but again there is a lot of conflicting info.

      I have the original switch wired up and going to GPIO pin 17 and a GND pin but im a little lost after this.
      Can anyone help me get this setup correctly.?

      1 Reply Last reply Reply Quote 0
      • C
        CeEeeEe4
        last edited by CeEeeEe4

        I believe i have the hardware side ok, i am just finding the software script difficult when the switch is pressed and to exit the emulator.

        1 Reply Last reply Reply Quote 0
        • C
          CeEeeEe4
          last edited by

          with the following code below working off GPIO pin 5, this will initiate a shutdown when the button is pressed. but what do i need to change "shutdown -h now" to, for it to exit the current emulator.

          on the controller it is "start + select" and on an unplugged keyboard it is "space + enter". do i just add that ? or is there any specific syntax?

          ===================================
          #!/usr/bin/python
          import RPi.GPIO as GPIO
          import time
          import subprocess

          GPIO.setmode(GPIO.BOARD)

          GPIO.setup(5, GPIO.IN, pull_up_down = GPIO.PUD_UP)

          oldButtonState1 = True

          while True:

          buttonState1 = GPIO.input(5)
          

          if buttonState1 != oldButtonState1 and buttonState1 == False:
          subprocess.call("shutdown -h now", shell=True,
          stdout=subprocess.PIPE, stderr=subprocess.PIPE)
          oldButtonState1 = buttonState1

          time.sleep(.1)
          

          ===================================

          1 Reply Last reply Reply Quote 0
          • C
            CeEeeEe4
            last edited by

            can anybody help?

            i know it is possible i just dont know the correct syntax to trigger the emulator exit in the script.

            1 Reply Last reply Reply Quote 0
            • C
              CeEeeEe4
              last edited by CeEeeEe4

              I managed to sort it out on my own.

              GPIO.IN, pull_up_down = GPIO.PUD_UP needed to be set to GPIO.IN, pull_up_down = GPIO.PUD_DOWN

              Maybe due to the wiring of the button

              1 Reply Last reply Reply Quote 0
              • CapemanC
                Capeman
                last edited by Capeman

                If you don't want to futz with code and gpio pins...

                The easiest way i've found to use buttons on an original console is to rip apart an old usb keyboard (thrift store finds are the best), jumper test the matrix until you find the escape key, and solder the 2 pins from the reset buttons to the keyboard PCB so the reset button presses ESC (which in retropile will exit ANY emulator). Then just plug keyboard PCB into a spare usb slot. No code, not hassle.

                I did this on the buttons on my atari build (though i didnt use original buttons, a momentary switch is a momentary switch regardless of the shape). See the atari link in my sig.

                Vector Artist, Designer and Maker of Stuff: Laser Cut Atari / Pixel Theme Bartop

                1 Reply Last reply Reply Quote 0
                • C
                  CeEeeEe4
                  last edited by

                  @Capeman nice idea man. that would save a lot of headaches.

                  I managed to get it working in the end. i believe i had the GPIO pull_up_down the wrong way around.

                  Thanks anyway

                  1 Reply Last reply Reply Quote 1
                  • R
                    Rum David Rum
                    last edited by Rum David Rum

                    @CeEeeEe4 Hey man any chance u could share your reset button python code? I have exactly the same prob. My shutdown code works flawlessly, just need the exit emulator button. thanks bro

                    1 Reply Last reply Reply Quote 0
                    • F
                      Flexstarr
                      last edited by Flexstarr

                      Can somegive tell me which PINs to use from the original SNES Reset button, so I can solder 2 wires and connect one to GPIO17 and the other one to GND of the Raspberry?
                      I don't know which one is which one and am unsure if the picture is correct or not.
                      0_1508519556051_snes_reset.jpg

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

                      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.