Sony DualShock

This article Sixaxis and DualShock 4 PlayStation controllers via USB and Bluetooth.]]

Prerequisites
This article presumes the system has been configured to use USB and Bluetooth. If these communication buses have not been configured, please take time to do so now.

Hardware
The following devices can be queried when connected via USB with the command (available via the  package).

Kernel
The recommended minimum version of Linux to use is 3.15. This release adds full support for the DualShock 4. This release also fixes the DualShock 3 blinking LED issue when connected via Bluetooth. New revisions of the DualShock 4 have a modified HID descriptor and require Linux 4.5. The 2nd generation DualShock 4 included with the PlayStation 4 Slim and Pro requires Linux 4.10.

Enable the following configuration options: CONFIG_INPUT_JOYDEV, CONFIG_INPUT_EVDEV , CONFIG_HID_BATTERY_STRENGTH , CONFIG_HIDRAW , CONFIG_HID_SONY , CONFIG_SONY_FF , CONFIG_HID_GENERIC , CONFIG_USB_HID , NEW_LEDS , LEDS_CLASS :

Xorg
To have the DualShock 4 touchpad behave as a mouse using the kernel driver, the Xorg input driver should be set to, and >=-3.2.6 should be used for libinput to recognize the touchpad correctly:

The built-in gyro can be set as a joystick, but users should note that some games will not work properly with this functionality enabled:

USB

 * Connect the DualShock to the system using a USB cable and press the button on the controller.


 * Turn the DualShock off when it's no longer in use by pressing and holding the button for 10 seconds.


 * Press the button to use the DualShock again.

Bluetooth
The recommended minimum version of BlueZ to use is 5.14. This release adds full support for the DualShock 4. This release also incorporates DualShock 3 setup and pairing support which was added in BlueZ 5.12.

DualShock 3
Start :

Enable the agent and set it as default:

Power on the Bluetooth controller, and set it as discoverable and pairable:

Connect the DualShock 3 to the system using a USB cable and press the button.

Allow the service authorization request:

Discover the DualShock 3 MAC address:

Trust the DualShock 3:

Disconnect the USB cable from the DualShock 3.

The DualShock 3 is now paired:

Turn the DualShock 3 off when it's no longer in use by pressing and holding the button for 10 seconds.

Press the button to use the DualShock 3 again.

DualShock 4
Start :

Enable the agent and set it as default:

Power on the Bluetooth controller, and set it as discoverable and pairable:

Scan for devices:

Put the DualShock 4 into pairing mode by pressing and holding the and  buttons until the light bar starts flashing.

Discover the DualShock 4 MAC address:

Pair with the DualShock 4:

Allow the service authorization request:

Trust the DualShock 4:

The DualShock 4 is now paired:

Turn the DualShock 4 off when it's no longer in use by pressing and holding the button for 10 seconds, or by disconnecting it from  or any GUI Bluetooth device manager.

Press the button to use the DualShock 4 again.

Battery charge level
The DualShock battery charge level can checked with sysfs:

The battery charge level for the DualShock 3 will reported as either 100%, 75%, 50% or 25% remaining. These values correspond to 3, 2, 1, and 0 bars respectively when checked with the PlayStation 3. The battery charge level for the DualShock 4 will be reported in the range of 100% to 0% remaining, at intervals of 10%.

The battery charge level can also be checked with. First, list available devices:

Next, display the DualShock power information:

Troubleshooting

 * Imitation DualShock 3 controllers are not supported by BlueZ and will not work via Bluetooth . However, Linux 4.15 and BlueZ 5.48 will have full support for imitation DualShock 3 controllers via USB and Bluetooth.

External resources

 * Sixaxis via bluetooth