How To Connect PS3 Or PS4 Controller To Raspberry Pi
WARNING - This guide may or may not be incomplete and may or may not need to be updated.
bluetooth built in or external
PS3 Controller Instructions
USB mini cable
Sixad
Get the latest repo info, upgrade your system, and install libusb-dev.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libusb-dev
Pull down and compile Sixpair:
mkdir ~/sixpair
cd ~/sixpair
wget http://www.pabr.org/sixlinux/sixpair.c
gcc -o sixpair sixpair.c -lusb
Plugin the controller.
Run Sixpair to re-configure the controller. This will ensure that the controller is able to talk to our Raspberry Pi over bluetooth.
sudo ~/sixpair/sixpair
You should see output that looks somewhat like this:
Current Bluetooth master: b8:27:eb:a4:59:08
Setting master bd_addr to b8:27:eb:a4:59:08
You can either use SIXAD or bluetoothctl to actually pair the controller. We cover pairing with both but bluetoothctl is recommended because it works well with other devices. SIXAD is more straight forward even considering that you compile it. SIXAD causes problems with PS4 controller pairing so if you plan to also use a PS4 controller you might not want to use SIXAD.
Pairing With bluetoothctl
Start the bluetooth config tool:
sudo bluetoothctl
Turn on the agent and tell it to use the default agent:
agent on
default-agent
Start scanning:
scan on
Press the PlayStation button on the controller.
You will see some output like this:
[NEW] Device B8:27:EB:A4:59:08 B8-27-EB-A4-59-08
[CHG] Device B8:27:EB:A4:59:08 Connected: no
[DEL] Device B8:27:EB:A4:59:08 B8-27-EB-A4-59-08
Copy the MAC address. It should look like this: “B8:27:EB:A4:59:08“. Don’t use this exact address here, copy the address you see in your output. It will be different.
Run this command. Replace the MAC address with your own address. You might need to run this command a few times before it works. Also, if the PS3 controller stops trying to connect, just press the button again.
connect B8:27:EB:A4:59:08
When you see output like this containing UUIDs, it has connected.
Attempting to connect to B8:27:EB:A4:59:08
[CHG] Device B8:27:EB:A4:59:08 Modalias: usb:v054Cp0268d0100
[CHG] Device B8:27:EB:A4:59:08 UUIDs:
00001124-0000-1000-8000-00805f9b34fb
00001200-0000-1000-8000-00805f9b34fb
Now type this, replacing the MAC address with yours:
trust B8:27:EB:A4:59:08
You should see something like this:
[CHG] Device B8:27:EB:A4:59:08 Trusted: yes
Changing B8:27:EB:A4:59:08 trust succeeded
Type ‘quit’ to exit the tool.
Reboot to make sure that it still works.
sudo reboot
Anytime you want to connect the controller you should just have to press the PlayStation button on the controller while the Raspberry Pi is turned on.
Pairing With SIXAD
Install some packages we need:
sudo apt-get install git libbluetooth-dev checkinstall libusb-dev
sudo apt-get install joystick pkg-config
Pulldown and build SIXAD. On the last command just press [enter] anytime you are prompted:
cd ~
git clone https://github.com/RetroPie/sixad.git
cd ~/sixad
make
sudo mkdir -p /var/lib/sixad/profiles
sudo checkinstall
Run SIXAD:
sudo sixad --start
Just press the PS button on the controller when it asks you to.
Make sure SIXAD starts on boot:
sudo update-rc.d sixad defaults