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] Can I pair a PS4 Dualshock controller with two Pi 4s?

    Scheduled Pinned Locked Moved Help and Support
    ps4 bluetoothmultiple system
    18 Posts 4 Posters 1.5k 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.
    • mituM
      mitu Global Moderator @Addison
      last edited by

      Remove the controller from the Bluetooth list of devices, then repeat the pairing process. You can't have the controller synced to 2 devices at once, the controller will only connect to the current paired partner.

      AddisonA 1 Reply Last reply Reply Quote 1
      • AddisonA
        Addison @mitu
        last edited by

        @mitu

        Okay.

        I thought that since the controller was always given the same MAC address, there might be another way to connect it again.

        I'll try writing a script where it deletes the registered device and adds it back again.

        Thanks for the response.

        1 Reply Last reply Reply Quote 0
        • AddisonA
          Addison
          last edited by

          Ooh! I got it! :D

          Using Putty, I SSH into the Pi 4.

          Here's the commands I type.

          bluetoothctl
          remove 40:1B:5F:BA:D5:A0
          agent on
          power on
          scan on
          

          I then hold the share and power button on the PS4 controller.

          Once it finds the device again.

          scan off
          connect 40:1B:5F:BA:D5:A0
          trust 40:1B:5F:BA:D5:A0
          

          And done!

          So how can I make all of that into an executable file?

          It will need a few seconds so it can fully scan correctly.

          Also, is there a place I can put this so it runs once I turn on the Pi?

          That way, I can put the controller into pairing mode, turn on the Pi, and by the time Emulation Station is loaded, the controller would automatically be paired. :)

          lostlessL 1 Reply Last reply Reply Quote 0
          • lostlessL
            lostless @Addison
            last edited by

            @Addison here is a quick answer. The ps4 controller only has a memory for 1 paired device. Doesn’t matter one the pis or ps4 is looking for it. The controller is only looking for the last device it was synced to.

            1 Reply Last reply Reply Quote 1
            • AddisonA
              Addison
              last edited by

              Oh. I guess it needs to be written more like this.

              bluetoothctl remove 40:1B:5F:BA:D5:A0
              bluetoothctl scan on
              sleep 5
              bluetoothctl scan off
              bluetoothctl connect 40:1B:5F:BA:D5:A0
              bluetoothctl trust 40:1B:5F:BA:D5:A0
              

              When running that as an executable in Emulation Station, it just hangs in Discovery Mode and doesn't progress any further.

              Sorry, I don't know how to code.

              Any help at all please?

              N 1 Reply Last reply Reply Quote 0
              • N
                navi87 @Addison
                last edited by navi87

                @addison

                Do you need to do the scan on/ off though? since you already know the device you want to pair with, seems unnecessary

                AddisonA 2 Replies Last reply Reply Quote 1
                • AddisonA
                  Addison @navi87
                  last edited by

                  @navi87

                  Yeah.

                  Say for example, my controller is currently paired with my PlayStation 4.

                  I'm just trying to easily switch it over to the Raspberry Pi.

                  It's not at easy as one would think. :)

                  1 Reply Last reply Reply Quote 0
                  • AddisonA
                    Addison @navi87
                    last edited by

                    @navi87 said in [Solved] Can I pair a PS4 Dualshock controller with two Pi 4s?:

                    @addison

                    Do you need to do the scan on/ off though? since you already know the device you want to pair with, seems unnecessary

                    Oh. Sorry.

                    Yeah, the controller is already a registered device on the Pi.

                    It won't connect though, with any commands that I know of, unless I delete it and rescan the controller again for some reason.

                    N 1 Reply Last reply Reply Quote 0
                    • N
                      navi87 @Addison
                      last edited by navi87

                      @addison
                      according to this article:
                      https://www.linux-magazine.com/Issues/2017/197/Command-Line-bluetoothctl

                      14. trust <DEVICE-MAC-ADDRESS>
                      Sets the device to re-pair automatically when it is turned on, which eliminates the need to pair all over again.

                      I would just try this:

                      bluetoothctl trust 40:1B:5F:BA:D5:A0

                      By itself, if that doesnt work, then maybe:

                      bluetoothctl remove 40:1B:5F:BA:D5:A0
                      sleep 5 (you might not need this, not sure, test with and without)
                      bluetoothctl connect 40:1B:5F:BA:D5:A0
                      bluetoothctl pair 40:1B:5F:BA:D5:A0

                      AddisonA 2 Replies Last reply Reply Quote 1
                      • AddisonA
                        Addison @navi87
                        last edited by

                        @navi87

                        It's already trusted.

                        So my Dualshock controller is currently paired with my Playstation 4.

                        I would now like to connect it to my Pi 4 that it already knows and remembers.

                        @mitu

                        pi@retropie:~ $ bluetoothctl paired-devices
                        Device 40:1B:5F:BA:D5:A0 Wireless Controller
                        pi@retropie:~ $ bluetoothctl pair 40:1B:5F:BA:D5:A0
                        Attempting to pair with 40:1B:5F:BA:D5:A0
                        Failed to pair: org.bluez.Error.AlreadyExists
                        pi@retropie:~ $ bluetoothctl connect 40:1B:5F:BA:D5:A0
                        Attempting to connect to 40:1B:5F:BA:D5:A0
                        [CHG] Device 40:1B:5F:BA:D5:A0 Connected: yes
                        Failed to connect: org.bluez.Error.Failed
                        

                        Would deleting the file org.bluez.Error.AlreadyExists help any before trying to pair the controller back again with the Pi 4?

                        I'm asking since I don't want to delete anything and possibly make it all worse.

                        mituM 1 Reply Last reply Reply Quote 0
                        • AddisonA
                          Addison @navi87
                          last edited by

                          @navi87 said in [Solved] Can I pair a PS4 Dualshock controller with two Pi 4s?:

                          @addison
                          according to this article:
                          https://www.linux-magazine.com/Issues/2017/197/Command-Line-bluetoothctl

                          14. trust <DEVICE-MAC-ADDRESS>
                          Sets the device to re-pair automatically when it is turned on, which eliminates the need to pair all over again.

                          I would just try this:

                          bluetoothctl trust 40:1B:5F:BA:D5:A0

                          By itself, if that doesnt work, then maybe:

                          bluetoothctl remove 40:1B:5F:BA:D5:A0
                          sleep 5 (you might not need this, not sure, test with and without)
                          bluetoothctl connect 40:1B:5F:BA:D5:A0
                          bluetoothctl pair 40:1B:5F:BA:D5:A0

                          Once that MAC address is removed, it's no longer available until you scan on again.

                          Unless there's some special command to add it back which I haven't found.

                          Nice idea though. :)

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

                            @addison said in [Solved] Can I pair a PS4 Dualshock controller with two Pi 4s?:

                            Would deleting the file org.bluez.Error.AlreadyExists help any before trying to pair the controller back again with the Pi 4?

                            I don't think that's a file - I think you should remove the device before attempting pairing it again.

                            1 Reply Last reply Reply Quote 1
                            • AddisonA
                              Addison
                              last edited by

                              Finally got it! :D

                              I have this as an executable file under Ports in Emulation Station.

                              bluetoothctl remove 40:1B:5F:BA:D5:A0
                              timeout 10 bluetoothctl scan on
                              bluetoothctl scan off
                              bluetoothctl connect 40:1B:5F:BA:D5:A0
                              bluetoothctl trust 40:1B:5F:BA:D5:A0
                              

                              Last question and I'll be all done.

                              Where can I insert these commands when Emulation Station begins to load?

                              I only need for it to run just once when the Pi is initially turned on.

                              Please and thank you.

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

                                @addison said in [Solved] Can I pair a PS4 Dualshock controller with two Pi 4s?:

                                Where can I insert these commands when Emulation Station begins to load?

                                EmulationStation is loaded fro the autostart.sh script - https://retropie.org.uk/docs/FAQ/#how-do-i-boot-to-the-desktop-or-kodi.

                                AddisonA 1 Reply Last reply Reply Quote 1
                                • AddisonA
                                  Addison @mitu
                                  last edited by

                                  @mitu

                                  Thank you so much!

                                  End result:

                                  /opt/retropie/configs/all/autostart.sh

                                  sudo bluetoothctl remove 40:1B:5F:BA:D5:A0
                                  sudo timeout 6 bluetoothctl scan on
                                  sudo bluetoothctl connect 40:1B:5F:BA:D5:A0
                                  sudo bluetoothctl trust 40:1B:5F:BA:D5:A0
                                  emulationstation #auto
                                  

                                  Now I can easily pair my controller back to the Pi on system startup without even having to plug it in using USB and navigating through all of the menu options.

                                  So happy! :)

                                  1 Reply Last reply Reply Quote 1
                                  • AddisonA Addison referenced this topic on
                                  • 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.