• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
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

{SOLVED} How to make a momentary push button that exit games and take me back to game menu ?

Scheduled Pinned Locked Moved Help and Support
push buttonretropiepsxscriptnewbie
56 Posts 3 Posters 6.9k 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.
  • M
    mitu Global Moderator @O.M.A.A
    last edited by mitu 4 Nov 2019, 19:21 11 Apr 2019, 18:20

    @O-M-A-A said in How to make a momentary push button that exit games and take me back to game menu ?:

    I hope this is what u guys meant !!

    Not really:

    Run your original script (now modified) and see if you get the desired behavior.

    You need to run shutdown.py, not the other way around.

    1 Reply Last reply Reply Quote 0
    • O
      O.M.A.A
      last edited by 11 Apr 2019, 18:25

      @mitu
      the original script's name is shutdown.py, I did modified it, or what did u mean ?

      C 1 Reply Last reply 11 Apr 2019, 18:28 Reply Quote 0
      • C
        cyperghost @O.M.A.A
        last edited by cyperghost 4 Nov 2019, 19:29 11 Apr 2019, 18:28

        @O-M-A-A How do you startup this python script? (It should be the one @mitu presented you in this posting)

        O 1 Reply Last reply 11 Apr 2019, 18:29 Reply Quote 0
        • O
          O.M.A.A @cyperghost
          last edited by O.M.A.A 4 Nov 2019, 19:30 11 Apr 2019, 18:29

          @cyperghost just copied it and paste it ;D

          1 Reply Last reply Reply Quote 0
          • M
            mitu Global Moderator
            last edited by 11 Apr 2019, 18:30

            Can you take a picture of how the buttons are wired ?

            C 1 Reply Last reply 11 Apr 2019, 18:32 Reply Quote 0
            • C
              cyperghost @mitu
              last edited by 11 Apr 2019, 18:32

              @O-M-A-A How do you start the script? How do you start the shutdown.py script?

              1 Reply Last reply Reply Quote 0
              • O
                O.M.A.A
                last edited by 11 Apr 2019, 18:42

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • O
                  O.M.A.A
                  last edited by 11 Apr 2019, 18:46

                  @cyperghost @mitu
                  sry for the delay, I was having some error when replaying to u guys.

                  I actually found a command, when I just executed it, it made the shutdown.py script and power button works immediately.

                  this is the command:
                  3333.png

                  1 Reply Last reply Reply Quote 0
                  • M
                    mitu Global Moderator
                    last edited by mitu 4 Nov 2019, 19:49 11 Apr 2019, 18:48

                    Why are you posting an image of a text, instead of posting the text ? It makes it harder to copy it and verify the URL/file. We know now how the script looks like, the issue is why the 2nd button doesn't work - can you show us how you wired the buttons to the PI ?

                    O 1 Reply Last reply 11 Apr 2019, 18:49 Reply Quote 0
                    • O
                      O.M.A.A @mitu
                      last edited by 11 Apr 2019, 18:49

                      @mitu I received error when posting it as it marked as a spam, give me seconds

                      M 1 Reply Last reply 11 Apr 2019, 18:51 Reply Quote 0
                      • M
                        mitu Global Moderator @O.M.A.A
                        last edited by 11 Apr 2019, 18:51

                        @O-M-A-A The link to the script is not so important now.

                        O 1 Reply Last reply 11 Apr 2019, 18:54 Reply Quote 0
                        • O
                          O.M.A.A @mitu
                          last edited by 11 Apr 2019, 18:54

                          @mitu fd3d39ce-9d86-4beb-ac63-38011dfbbdf4.jpg

                          O 1 Reply Last reply 11 Apr 2019, 18:56 Reply Quote 0
                          • O
                            O.M.A.A @O.M.A.A
                            last edited by 11 Apr 2019, 18:56

                            the white and grey wires are for the power button, while the brown and red are for the exit emu button

                            M 1 Reply Last reply 11 Apr 2019, 19:03 Reply Quote 0
                            • M
                              mitu Global Moderator @O.M.A.A
                              last edited by mitu 4 Nov 2019, 20:10 11 Apr 2019, 19:03

                              @O-M-A-A I don't think the brown/red are tied to GPIO 7.

                              Modify the script and change 2nd buttons's pin number from 7 to 33 and see if you get a different result:

                              #!/usr/bin/python
                              import RPi.GPIO as GPIO
                              import time
                              import subprocess
                              
                              GPIO.setmode(GPIO.BOARD)
                              
                              # we will use the pin numbering to match the pins on the Pi, instead of the
                              # GPIO pin outs (makes it easier to keep track of things)
                              # use the same pin that is used for the reset button (one button to rule them all!)
                              GPIO.setup(5, GPIO.IN)
                              GPIO.setup(33, GPIO.IN)
                              
                              oldButtonState1 = True
                              oldButtonState2 = True
                              
                              while True:
                                  #grab the current button state
                                  buttonState1 = GPIO.input(5)
                                  buttonState2 = GPIO.input(33)
                              
                                  # check to see if button has been pushed
                                  if buttonState1 != oldButtonState1 and buttonState1 == False:
                                      # shutdown
                                      subprocess.call("shutdown -h now", shell=True,
                                        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                                      oldButtonState1 = buttonState1
                                  
                                  if buttonState2 != oldButtonState2 and buttonState2 == False:
                                      # Reset emulator
                                      subprocess.call("/home/pi/scripts/multi_switch.sh --es-closeemu", shell=True,
                                        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                                      oldButtonState2 = buttonState2
                              
                              1 Reply Last reply Reply Quote 0
                              • O
                                O.M.A.A
                                last edited by 11 Apr 2019, 19:12

                                @mitu didn't work,
                                would it be fine if u get access to my computed and try it yourself as maybe the way I'm doing it is wrong.

                                M 1 Reply Last reply 11 Apr 2019, 19:14 Reply Quote 0
                                • M
                                  mitu Global Moderator @O.M.A.A
                                  last edited by 11 Apr 2019, 19:14

                                  @O-M-A-A said in How to make a momentary push button that exit games and take me back to game menu ?:

                                  would it be fine if u get access to my computed and try it yourself as maybe the way I'm doing it is wrong.

                                  Can't do that, I'm sorry.

                                  O 1 Reply Last reply 11 Apr 2019, 19:19 Reply Quote 0
                                  • O
                                    O.M.A.A @mitu
                                    last edited by 11 Apr 2019, 19:19

                                    @mitu it is okay thank you for your patient,

                                    I will just summarized what I did so u will have an idea maybe of the mistake I did, when I installed the retropie image, I basically run the link to the script (shudown.py) and this made the power button to work.

                                    Then I open it with notepad++ and I modified it to install the exit emu button.

                                    lastly, I downloaded ur file (multi_switch.sh) and executed the command u provided it me.

                                    for now pins are 3+4 for the exit emu button and 5+6 for the power button.

                                    M 1 Reply Last reply 11 Apr 2019, 19:20 Reply Quote 0
                                    • M
                                      mitu Global Moderator @O.M.A.A
                                      last edited by mitu 4 Nov 2019, 20:20 11 Apr 2019, 19:20

                                      @O-M-A-A said in How to make a momentary push button that exit games and take me back to game menu ?:

                                      for now pins are 3+4 for the exit emu button and 5+6 for the power button.

                                      I edited the post - try putting the reset pins (brown/red) on the original position and change the GPIO number from 3 to 33 (or just copy the edited script).

                                      O 1 Reply Last reply 11 Apr 2019, 19:27 Reply Quote 0
                                      • O
                                        O.M.A.A @mitu
                                        last edited by 11 Apr 2019, 19:27

                                        @mitu I put the 2 wires back to the same position and I edited the file from 3 to 33, but didn't work

                                        C O 2 Replies Last reply 11 Apr 2019, 19:32 Reply Quote 0
                                        • C
                                          cyperghost @O.M.A.A
                                          last edited by 11 Apr 2019, 19:32

                                          @O-M-A-A Please remeber to do a restart after every change!

                                          O 1 Reply Last reply 11 Apr 2019, 19:40 Reply Quote 0
                                          27 out of 56
                                          • First post
                                            27/56
                                            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.

                                            This community forum collects and processes your personal information.
                                            consent.not_received