Setting up PS3 controllers on Retropie (Gasia/ Shanwan clones)

Step 1:
Download the source-code of bluez (version 5.39 at the time of writing). Extract the archive and create a subfolder named ‘patches‘ within the bluez directory.

Step 2:
Change into the ‘patches‘ directory and download all bluez patches found at:

https://github.com/OpenELEC/OpenELEC.tv/tree/openelec-7.0/packages/network/bluez/patches

Please note that you have to download these files in ‘raw mode’, otherwise HTML tags will remain and patch will complain about the garbage within the files.

While being in the bluez folder apply all patches with:

patch -p 1 < patches/bluez-01_add-obexd-policy.patch
patch -p 1 < patches/bluez-02_obexd-use-system-bus.patchpatch -p1 < patches/bluez-03_storagedir.patch
...

Step 3:
Navigate to the bluez/src subdirectory and edit the file ‘bluetooth.ver’. Add this line into the ‘global:’ block:

sdp_*;

Alternatively, download the already patched bluez source code from my github repo:

 git clone https://github.com/luetzel/bluez

I will try to keep my repo in sync with future releases of bluez and patches to support other PS3 clones than Gasia/Shanwan. Current version of patched blueZ is 5.43.

Step 4:
Change into the bluez folder, then, configure, compile and install bluez:

./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-sixaxis

 make -j3

 sudo make install

Be aware that this will overwrite your distribution’s bluetooth/bluez package. It is highly recommended to purge/uninstall your distributions bluez package prior to the installation of patched bluez in order  to avoid version conflicts.

Now, restart the bluetooth daemon with:

sudo systemctl daemon-reload
sudo systemctl start bluetooth

On distributions without systemd, you have to use:

sudo service bluetooth restart

If this doesn’t work or if you are unable to pair your controller in the following steps,  reboot your Pi after installation of patched bluez!

Subscribe
Notify of
117 Comments
Inline Feedbacks
View all comments
ryan groth
8 years ago

For the sake of google searchers everywhere. I picked up a “FiveStar” PS3 clone controller pair for $20 on Amazon. They recognize as gaisa controllers on an RP3. I could not get the native bluetooth stack to recognize the controller OR the retropie default sixaxis driver to recognize the controller. A combination of luetzel’s bluetooth build and supertypo’s qtsixa github repo were the trick. A couple of notes though– I removed bluez native which removes bluetooth-pi3, you have to install THIS bluez package from “make install”, then reinstall package bluetooth-pi3. Remove any old sixaxis and install sypertypo’s version sixaxis and… Read more »

Daniele
8 years ago

Hi Martin,
Thank you really much, at the end I finally got my ps3 controller paired with internal RPI 3 bluetooth!
After the installation of sixpair I always got:
pi@retropie:~/QtSixA-1.5.1/utils/bins $ sudo ./sixpair
Current Bluetooth master: aa:aa:aa:aa:aa:aa
Setting master bd_addr to aa:aa:aa:aa:aa:aa

Rebooting rpi everything worked at the first try!
Thank you again
Daniele

8 years ago
Reply to  Daniele

Would you kindly explain how you managed to overcome the invalid MAC issue?

With Jessie running fresh on an Rpi3, I installed RetroPie and Kodi, dropped to a shell, pulled the patched BlueZ and QtSixA sources, and compiled. My Gasia controller paired just fine and passed a jstest with flying colors, but my integrated Bluetooth started spitting out a MAC of AA:AA:AA:AA:AA:AA following a reboot D=

8 years ago
Reply to  Daniele

Would you kindly explain how you managed to overcome the invalid MAC issue?

With Jessie running fresh on an Rpi3, I installed RetroPie and Kodi, dropped to a shell, pulled the patched BlueZ and QtSixA sources, and compiled. My Gasia controller paired just fine and passed a jstest with flying colors, but my integrated Bluetooth started spitting out a MAC of AA:AA:AA:AA:AA:AA following a reboot and won’t snap out of it D=

Crescendo
8 years ago

I refine my approach.
Using Luetzels’ patched Bluez, the sixad can share control with Bluez (tested using bt mouse while PS3 Shanwan connected, in Raspbian desktop).

No more need of sixad –boot-no or –stop after using retropie, just install this patched Bluez, then Shanwan sixad, reboot, then its working like a boss..

Yes, without this patched Bluez, it can’t share control with sixad.

Thanks so much Luetzels….

Crescendo
8 years ago
Reply to  luetzel

You’re welcome…
If you use non-patched bluez, the bluetooth adapter is not even recognizable by bluetoothctl if you got sixad installed (you can’t even type anything into bluetoothctl prompt).

However, if you install patched bluez (overwriting default raspbian bluez – do not uninstall it first, just overwrite), then sixad. All is normal, no timeout, no problem whatsoever. It just like there’s no sixad installed but controller now can pair normally (patched bluez without sixad won’t do).

daniele
8 years ago

Thank you very much for your great job! I’m following your steps on raspberry pi3 with a fresh RetroPie 4 and shanwan ps3 controllers. I get stuck in step 4: after compile and installation of bluez from your repo, when I try to restart bluetooth service I get the messagge: pi@retropie:~ $ sudo service bluetooth restart Failed to restart bluetooth.service: Unit bluetooth.service is masked. To be sure I’ve reboot my raspberry. Going on with your step, whit hciconfig I don’t get any result (internal rpi3 bluetooth is not showed). So I disable the internal rpi3 bluetooth (adding the line “dtoverlay=pi3-disable-bt”… Read more »

daniele
8 years ago
Reply to  daniele

just noticied:
pi@retropie:~ $ sudo hciconfig hci0 up pscan iscan
pi@retropie:~ $ hciconfig
hci0: Type: Primary Bus: USB
BD Address: 00:02:72:CF:9E:29 ACL MTU: 1022:8 SCO MTU: 121:3
UP RUNNING ISCAN
RX bytes:1052 acl:0 sco:0 events:51 errors:0
TX bytes:698 acl:0 sco:0 commands:51 errors:0

but I’m still missing pscan…

Thank you
Daniele

Daniele
8 years ago
Reply to  luetzel

Hi Martin,

thank you very much for your answer, I will try this evening!
Just another question for you about “It is highly recommended to purge/uninstall your distributions bluez package prior to the installation of patched bluez in order to avoid version conflicts.”
I did “sudo apt-get remove bluez”, but this commands also remove bluetooth and pi-bluetooth package (they depend on bluez). Is it ok to remove also bluetooth and pi-bluetooth?

Crescendo
8 years ago

I paste the terminal output to pastebin for easier reading….

http://pastebin.com/WjbmtphX

Crescendo
8 years ago
Reply to  luetzel

Hi, yes I already trust it in bluetoothctl.

I use Shanwan controller & your Bluez.

I’ll post the dmesg tomorrow morning as I’m trying with clean RetroPie image now.

Thank you so much for helping.

Crescendo
8 years ago
Reply to  Crescendo

I tried something different that completely solved the issue.
1. Did all your steps above.
2. Install sixad for shanwan via retropie-setup.
3. Disable sidxad on boot using cmd: sixad –boot-no.
4. Create script: sixad –start; emulationstation; sixad –stop;.
5. That solved the issue, bluetooth still OK in Raspbian desktop coz its only activated when using RetroPie.

Strangely, if I didn’t use your patched bluez, the installation of sixad disables the bluez even though its stopped.

Crescendo
8 years ago

After doing everything exactly described in this post, I still can’t make the controller to connect to RPi3, not even on clean Raspbian install (latest + rpi-update). Could you please shed some light to my problem? This is the terminal output of mine: pi@CF-RPi3:~ $ sudo bluetoothctl [NEW] Controller B8:27:EB:E3:D4:48 CF-RPi3 [default] [NEW] Device 03:81:98:A1:63:25 PLAYSTATION(R)3 Controller [NEW] Device 03:8C:85:9D:63:25 PLAYSTATION(R)3 Controller [bluetooth]# agent on Agent registered [bluetooth]# default-agent Default agent request successful [bluetooth]# pairable on Changing pairable on succeeded [bluetooth]# discoverable on Changing discoverable on succeeded [CHG] Device 03:81:98:A1:63:25 Connected: yes [CHG] Device 03:81:98:A1:63:25 Connected: no [bluetooth]# exit Agent… Read more »

Thomas Messmer
8 years ago

I had also a lot of problems to get Gasia and Shanwan Controllers to work.
No solution I found worked. But now I found a realy simple way to get them working.

Have a look at this page where I described the very simple solution which was the only one which worked for me!!
http://thomas-messmer.com/index.php/howtos/67-retropie-controller-pairing-problems

Hopefully It will work for others too.

subs
8 years ago

Hey just to say on a fresh 4.0.2 retropie, i had to :

sudo apt-get install libreadline-gplv2-dev libical-dev libjack-dev libusb-dev

+ it ain’t working for my GAsia controller. No wonder, the sixaxis plugin patches just handle shanwans

Nicky
8 years ago

Hi Martin, I can’t seem to get my controller connected. Connected to USB it says “SHANWAN”, connected over bluetooth it says “PLAYSTATION(R)3Conteroller-PANHAI” It seems like the bluetooth authentication process is not being handled correctly. I’m not familiar enough with bluetooth to know, but could the misspelled name do any wrong? Or could it be something with the “PANHAI’ type bluetooth controller is sending bytes in a different order than expected (cfr : https://github.com/nefarius/ScpToolkit/issues/241) When I try to pair the device with my PS3, it seems to work fine. Log of trying to connect : pi@retropie:~/qtsixa-1.5.0/utils/bins $ sudo bluetoothctl [NEW] Controller… Read more »

Nicky
8 years ago
Reply to  luetzel

Hi Martin, Thanks for the quick reply. I’m using the Retropie 4.0 (Raspbian Jessie). I thought I disabled Sixad, but apparently it was still starting as a service and taking over control over the bluetooth ( I think even if the Sixad is setup to not startup at boot, I think Retropie is starting it when it was installed with the Retropie setup script) Anyhow the first times I tried to connect, I had Sixad disabled for sure (stopped the service manually) and checked the bluetooth status like described in your guide. Maybe it was because I didn’t do a… Read more »

Hjalte
8 years ago

Hi again, purged bluez* and had a rerun with the 5.41 version – successfully connected to both controllers simultaneously in the first try, mapped beautifully to /dev/input/js0 & js1. However, after a short while the connection is lost, and I think bluetoothctl is getting confused as to what is connected and what is not, and I can’t reconnect. (btw had to force ISCAN with $hciconfig hci0 piscan). Will give it a go on the raspberry as soon as possible.