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

    Adding a 9th button to GPIO

    Scheduled Pinned Locked Moved Help and Support
    retropiebutton mappinggpio
    49 Posts 7 Posters 11.4k 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.
    • T
      theRog05
      last edited by

      Hey everyone,

      I just set up attractmode on my retropie and I'm having an issue trying to assign a 9th button to a hotkey. Before this, I was using recalbox which allowed for a hotkey on GPIO2 (PIN 3) for joypad1 and GPIO3 (PIN 5) for joypad2. When running jstest for either of my joypads, the buttons only allow for the joystick and 0-7 buttons. When I press my 9th button, jstest doesn't show that anything is happening. Does anyone know how I can enable this 9th button?

      Thanks!

      edmaul69E 1 Reply Last reply Reply Quote 0
      • edmaul69E
        edmaul69 @theRog05
        last edited by edmaul69

        @theRog05 not sure what you are using so i dont know if this helps as far as controls go, but for the hotkey you can set up something like your select button for the hotkey.

        1 Reply Last reply Reply Quote 0
        • T
          theRog05
          last edited by

          @edmaul69 I'm using arcade buttons (2 joysticks and 18 buttons), all which are connected to the GPIO of the pie. Each "controller" is using a Joystick along with buttons A, B, X, Y, LT, RT, select, start, hk (9th controller button). If you are familiar with Recalbox, they allow that 9th button to be used as a hotkey. I understand that I could use select for the hotkey, but I already built the cabinet and have that 9th button for each controller; I don't want it to go unused. Both of my hotkey buttons are connected to GPIO2 (PIN3) and GPIO3 (PIN5) on the pie (which is the suggested configuration for RecalBox. If it's possible for RecalBox, I would think it should be possible for Retropie, I just can't figure out where I would need to make a change to allow for this.

          edmaul69E 1 Reply Last reply Reply Quote 0
          • spruce_m00seS
            spruce_m00se
            last edited by

            well if you cant figure it out just wire up two buttons to one gpio, then at least you have a working ninth button

            T 1 Reply Last reply Reply Quote 0
            • T
              theRog05 @spruce_m00se
              last edited by

              @spruce_m00se This would defeat the purpose of having another button to do something different. I would rather find out how to utilize the GPIO for another button.

              1 Reply Last reply Reply Quote 0
              • simonsterS
                simonster
                last edited by simonster

                You need to install the hotkeybtn variant of mk_arcade_joystick, this isn't installed by the RetroPie installer as it isn't part of the main branch, but can be done manually from the command line. The instructions aren't clear on their git page, but I think this is the correct order.

                git clone https://github.com/pinuct/mk_arcade_joystick_rpi/tree/customgpiohotkey
                mkdir /usr/src/mk_arcade_joystick_rpi-0.1.5/
                cd mk_arcade_joystick_rpi/
                cp -a * /usr/src/mk_arcade_joystick_rpi-0.1.5/
                dkms build -m mk_arcade_joystick_rpi -v 0.1.5
                dkms install -m mk_arcade_joystick_rpi -v 0.1.5

                Once you have done this and restarted, I think that you should be OK, as it will upgrade the version already installed.

                The reference is on the git page: https://github.com/recalbox/mk_arcade_joystick_rpi/tree/hotkeybtn

                T 2 Replies Last reply Reply Quote 0
                • T
                  theRog05 @simonster
                  last edited by theRog05

                  @simonster said in Adding a 9th button to GPIO:

                  You need to install the hotkeybtn variant of mk_arcade_joystick

                  Thanks!!! I'll give this a shot tonight or this weekend and let you know how it goes.

                  1 Reply Last reply Reply Quote 0
                  • edmaul69E
                    edmaul69 @theRog05
                    last edited by

                    @theRog05 do both controllers have a 9th key or just one controller? If only one is it actually going to controller 1?here is something you could try. Set up the controller in emulationstation and choose select as your hotkey. Now open up /opt/retropie/configs/all/retroarch/autoconfig/NAMEOFYOURCONTROLLER.cfg and find the hotkey line and change it to the correct button number. I assume that would be 8. (Since buttons start with zero)

                    simonsterS 1 Reply Last reply Reply Quote 0
                    • simonsterS
                      simonster @edmaul69
                      last edited by

                      Hi @edmaul69 , the problem is the standard GPIO driver only has 8 buttons and 4 directions per pad (equivalent of a SNES pad), you can add a 9th but it requires a fork of the standard driver that removes I2C support whilst installed, it appears that they were previously using this when using Recalbox (as GPIO 3 and 5 are the correct wirings for this in the driver) but the version included in RetroPie is the main branch and doesn't include support for the 9th button.

                      T 1 Reply Last reply Reply Quote 0
                      • T
                        theRog05 @simonster
                        last edited by

                        @edmaul69 : I actually did try just adding an 8 to the .cfg file and that didn't work. As @simonster mentioned, mk_arcade_joystick needs the update to allow the hotkeybtn. I'll be trying this when I get home after work, as long as the wife doesn't have me doing anything else -___-
                        Thanks, guys.

                        1 Reply Last reply Reply Quote 0
                        • T
                          theRog05 @simonster
                          last edited by

                          @simonster Unfortunately, the first line you mentioned above results in a "repository not found". I tried copying the files manually, but then when I run the 'dkms build' I get "Your kernel headers for kernel 4.9.35-v7+ cannot be found at /lib/modules/4.9.35-v7+/build or /lib/modules/4.9.35-v7+/source". I've tried updating the headers with "sudo apt-get install raspberrypi-kernel-headers", but that didn't work either. Any ideas what else could be wrong?

                          1 Reply Last reply Reply Quote 0
                          • simonsterS
                            simonster
                            last edited by

                            It worked for me, but this was some time ago. Try the recalbox copy of the fork

                            git clone https://github.com/recalbox/mk_arcade_joystick_rpi/tree/hotkeybtn

                            If you have updated the kernel headers, I don't know why it wont compile.

                            T 1 Reply Last reply Reply Quote 0
                            • T
                              theRog05 @simonster
                              last edited by

                              @simonster This also failed to find the repository. :/

                              1 Reply Last reply Reply Quote 0
                              • simonsterS
                                simonster
                                last edited by simonster

                                I just ran this command and it cloned successfully:

                                git clone https://github.com/recalbox/mk_arcade_joystick_rpi.git -b hotkeybtn

                                I am trying to compile it at the moment (there are a few issues with the code), there is also the matter of the missing headers, so bear with me and when I get something I will update this thread.

                                1 Reply Last reply Reply Quote 0
                                • simonsterS
                                  simonster
                                  last edited by

                                  Hi @theRog05

                                  How are you using kernel 4.9.35-v7+? I have just run an update in RetroPie-Setup and am still using kernel 4.4.50-v7+

                                  Can you fill in the detail list in https://retropie.org.uk/forum/topic/3/read-this-first

                                  T 1 Reply Last reply Reply Quote 0
                                  • T
                                    theRog05 @simonster
                                    last edited by

                                    @simonster I've been working on this all day so far and started getting some other funky errors (probably from me messing around in there). So I decided to wipe the card and start fresh. Once I get my card loaded up, I'll give this a try again. Sorry, wish I saw this message before I went and formatted the card.

                                    P.S. - Thanks for your continuous help on this!

                                    simonsterS 1 Reply Last reply Reply Quote 0
                                    • simonsterS
                                      simonster @theRog05
                                      last edited by

                                      @theRog05

                                      No problem, I can only assume you had run rpi-update at some point and ended up with a unstable beta kernel.

                                      T 1 Reply Last reply Reply Quote 0
                                      • T
                                        theRog05 @simonster
                                        last edited by

                                        @simonster I'm pretty sure I did run rpi-update at some point in the past 7 hours. haha. I do remember using kernel 4.4.50-v7+ and I was also wondering why 4.9.35-v7+ was being used. Oh well, starting fresh now. As soon as I get it loaded on the Pi, I'll follow your steps again to clone the hotkeybtn branch in the mk_arcade_joystick_rpi repo and see what I can come up with. Thanks again!

                                        1 Reply Last reply Reply Quote 0
                                        • simonsterS
                                          simonster
                                          last edited by simonster

                                          I have just tried this method and it worked for me completely:

                                          Install MK_Arcade_Joystick from the drivers in the retropie setup. Then exit Emulation Station by pressing F4

                                          rm -r mk_arcade_joystick_rpi
                                          git clone https://github.com/recalbox/mk_arcade_joystick_rpi.git -b hotkeybtn
                                          sudo mkdir /usr/src/mk_arcade_joystick_rpi-0.1.5.1/
                                          cd mk_arcade_joystick_rpi/
                                          nano dkms.conf

                                          change the line that begins PACKAGE_VERSION to read

                                          PACKAGE_VERSION="0.1.5.1"

                                          Press Ctrl+X and then Y and Enter to exit and save changes

                                          sudo cp -a * /usr/src/mk_arcade_joystick_rpi-0.1.5.1/
                                          sudo dkms build -m mk_arcade_joystick_rpi -v 0.1.5.1
                                          sudo dkms install -m mk_arcade_joystick_rpi -v 0.1.5.1 --force

                                          Once installed, restart the Pi using the following command

                                          sudo shutdown -r -t 0 now

                                          T P 2 Replies Last reply Reply Quote 1
                                          • T
                                            theRog05 @simonster
                                            last edited by

                                            @simonster Awesome. I'll give that a try when the card loads back up. And after I replace my sisters shock in her car. -____-

                                            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.