[Solved] Can I pair a PS4 Dualshock controller with two Pi 4s?
-
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. :)
-
@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.
-
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?
-
Do you need to do the scan on/ off though? since you already know the device you want to pair with, seems unnecessary
-
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. :)
-
@navi87 said in [Solved] Can I pair a PS4 Dualshock controller with two Pi 4s?:
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.
-
@addison
according to this article:
https://www.linux-magazine.com/Issues/2017/197/Command-Line-bluetoothctl14. 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 -
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.
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.
-
@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-bluetoothctl14. 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:A0Once 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. :)
-
@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.
-
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.
-
@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. -
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! :)
-
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.