Procedures to install driver for Dualshock 4 on Raspberry Pi 3
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md Update README.md May 1, 2017
dualshock4-l298n.py Create dualshock4-l298n.py Jul 26, 2017
joy-invert-wheel.py Create joy-invert-wheel.py May 19, 2017
joytest.py Code to control 2WD robot using Dualshock 4 May 19, 2017

README.md

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:

https://github.com/retropie/retropie-setup/wiki/PS4-Controller

https://github.com/chrippa/ds4drv

https://www.piborg.org/joyborg

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.

Commands list:

Step 0:

sudo apt-get update

Step 1:

You will now need to run the following to ensure the generic joystick drivers are installed first:

sudo apt-get -y install joystick

Step 2:

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.

Step 3:

sudo apt install python-dev python3-dev python-pip python3-pip

Step 4:

(install either one or both)

Install for Python 3: sudo pip3 install ds4drv

Install for Python 2: sudo pip install ds4drv

Step 5:

Allow non-root users to control the ds4drv joystick: Location:/etc/udev/rules.d/

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

Step 6:

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

______________________________________________________________________________________________________________________

Step 7:

[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 &

Step 8:

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.

Step 9:

ps aux | grep python