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

    How to Use Momentary Switch for Exit Game Button?

    Scheduled Pinned Locked Moved Help and Support
    momentary switcbuttonexit game
    7 Posts 3 Posters 988 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.
    • S
      saddlepiggy
      last edited by

      Hello! I am wanting to hook up a momentary switch to a Raspberry Pi 3b+ with RetroPie (obviously) to use as a dedicated "Exit Game" button. Is there some sort of script I could use that would just run that command whenever the button is pressed? Or is there a better way to do that? Sorry for just asking to be almost spoon fed an answer. I am willing to do some light and basic programming or mess with stuff if need be.

      Thank you, -saddlepiggy!

      1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator
        last edited by

        You can try @cyperghost's script (https://github.com/crcerror/ES-generic-shutdown) to hook it up to your button press and invoke it with the --closeemu parameter to just stop the current emulator instead of shutting down/restarting your Pi.
        The topic for the script is at https://retropie.org.uk/forum/topic/17415.

        1 Reply Last reply Reply Quote 1
        • S
          saddlepiggy
          last edited by

          Oh cool. I was already going to use that for my shutdown button. I didn't know there was a command for closing the emulator. Thank you!

          cyperghostC 1 Reply Last reply Reply Quote 0
          • cyperghostC
            cyperghost @saddlepiggy
            last edited by

            @saddlepiggy The --closeemu switch is also always used for es reset and the reboots of the system. It is essential to close any running instance of an emulator or port (Kodi and Pixel Desktop also work) BEFORE closing EmulationStation.

            Most shutdown scripts just use killall emulationstation, this works in most cases but you can't restart emulationstation anymore and even worse you can retain broken metadata.

            1 Reply Last reply Reply Quote 0
            • S
              saddlepiggy
              last edited by

              @cyperghost good to know. Thanks :)

              1 Reply Last reply Reply Quote 0
              • S
                saddlepiggy
                last edited by

                @cyperghost Sorry for bothering you again, but does the script work with 2 switches? I would have a latching for power and a momentary for closing the emulator.

                1 Reply Last reply Reply Quote 0
                • cyperghostC
                  cyperghost
                  last edited by

                  @saddlepiggy The script provides a generic power button. Just connect your latching button to pin 5 and 6 then you can power down and restart the Pie. The command switch is --generic

                  Or you can write your own script. I modified the python script for the NesPi+ to demonstrate usage
                  https://retropie.org.uk/forum/topic/17506

                  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.