DUALSHOCK 4 + Raspberry Pi 3
This is just a simplified compilation of commands needed to get the Dualshock 4 up and running on the Raspberry Pi 3.
Credit to these links/websites for the guidance:
Procedures to install linux driver for Dualshock 4 on Raspberry Pi 3
Copy and paste all these commands to complete the installation. Make sure the Dualshock 4 controller is charged to ensure reliable bluetooth connection later on.
sudo apt-get update
You will now need to run the following to ensure the generic joystick drivers are installed first:
sudo apt-get -y install joystick
Then you will want to run jstest as follows:
Note: If you run the above command
jstest for the first time, you will get this error:
jstest: No such file or directory It is because there is no Joystick connected yet. Don't worry. Just proceed to Step 3.
sudo apt install python-dev python3-dev python-pip python3-pip
(install either one or both)
Install for Python 3:
sudo pip3 install ds4drv
Install for Python 2:
sudo pip install ds4drv
Allow non-root users to control the ds4drv joystick: Location:
sudo wget https://raw.githubusercontent.com/chrippa/ds4drv/master/udev/50-ds4drv.rules -O /etc/udev/rules.d/50-ds4drv.rules
sudo udevadm control --reload-rules
sudo udevadm trigger
By now, the driver is fully installed and you can test pairing with Dualshock 4
Make sure Bluetooth on the Pi is turned ON. Then, press and hold
PS button +
Share button on Dualshock 4
Hold until the LED on the controller blinks rapidly
On the terminal run this command to run the driver normally:
If you want to run the driver in the background (daemon), add
& at the end:
sudo ds4drv &
If everything is correct, the Pi will detect the controller. Now you can retry
Step 2 to test the Dualshock 4 input. You can open up a new Terminal session to perform the following command.
[IMPORTANT] Now configure ds4drv to run at startup by editing the rc.local file:
sudo nano /etc/rc.local
# By default this script does nothing. line, add a new line with the contents:
Now just reboot the Pi so that the driver will be started at boot.
Once rebooted, enter command in Step 9 to check if the
ds4drv driver is running in the background as root.
ps aux | grep python