Sony DualShock
This article describes the use of Sony DualShock 3 / Sixaxis, DualShock 4, and DualSense 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 lsusb command (available via the sys-apps/usbutils package).
Device | Vendor ID / Product ID | Vendor Name | Product Name | Supported | Kernel Version | Notes |
---|---|---|---|---|---|---|
DualShock 3 / Sixaxis | 054c:0268
|
Sony Corp. | Batoh Device / PlayStation 3 Controller | Yes | >=3.15[1] | |
DualShock 4 | 054c:05c4
|
Sony Corp. | DualShock 4 [CUH-ZCT1x] | Yes | >=3.15[1] | New revisions have a modified HID descriptor that require Linux 4.5+[2]. |
DualShock 4 (2nd Gen) | 054c:09cc
|
Sony Corp. | DualShock 4 [CUH-ZCT2x] | Yes | >=4.10[3] | Since kernel 6.2 hid-playstation is needed (which depends on LED Multicolor Class Support) |
DualSense | 054c:0ce6
|
Sony Corp. | Wireless Controller | Yes | >=5.12[4] |
Installation
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[1]. New revisions of the DualShock 4 have a modified HID descriptor and require Linux 4.5[2]. The 2nd generation DualShock 4 included with the PlayStation 4 Slim and Pro requires Linux 4.10[3]. The PlayStation 5 DualSense controller requires Linux 5.12[4].
Enable the following configuration options: CONFIG_BT_HIDP, CONFIG_INPUT_JOYDEV, CONFIG_INPUT_EVDEV, CONFIG_INPUT_UINPUT, CONFIG_HID_BATTERY_STRENGTH, CONFIG_UHID, CONFIG_HIDRAW, CONFIG_HID_SONY, CONFIG_SONY_FF, CONFIG_HID_GENERIC, CONFIG_USB_HID, NEW_LEDS, LEDS_CLASS:
Networking support --->
<M> Bluetooth subsystem support --->
[*] Bluetooth Classic (BR/EDR) features
<*> HIDP protocol support
Device Drivers --->
Input device support --->
-*- Generic input layer (needed for keyboard, mouse, ...)
<*> Joystick interface
<*> Event interface
[*] Miscellaneous devices --->
<*> User level driver support
HID support --->
[*] Battery level reporting for HID devices
[*] /dev/hidraw raw HID device support
<*> User-space I/O driver support for HID subsystem
<*> Generic HID driver
Special HID drivers --->
<*> Sony PS2/3/4 accessories
[*] Sony PS2/3/4 accessories force feedback support
<*> PlayStation HID Driver
[*] PlayStation force feedback support
USB HID support --->
<*> USB HID transport layer
[*] LED Support --->
<*> LED Class Support
<*> LED Multicolor Class Support
Xorg
To have the DualShock 4 touchpad behave as a mouse using the kernel driver, the Xorg input driver should be set to libinput
, and >=sys-fs/eudev-3.2.6 should be used for libinput to recognize the touchpad correctly:
Section "InputClass"
Identifier "ds4-touchpad"
Driver "libinput"
MatchProduct "Sony Interactive Entertainment Wireless Controller Touchpad"
Option "Mode" "Relative"
EndSection
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:
Section "InputClass"
Identifier "ds4-gyro"
Driver "joystick"
MatchProduct "Sony Interactive Entertainment Wireless Controller Motion Sensors"
Option "Ignore" "False" # Switch the last value in this line to "True" to disable using DS4's gyro as a joystick.
EndSection
BlueZ
To have the DualSense controller connect using Bluetooth and properly load the drivers, it is necessary to enable user-space HID support in BlueZ. This can be done by uncommenting the associated line:
# Enable HID protocol handling in userspace input profile
# Defaults to false (HIDP handled in HIDP kernel module)
UserspaceHID=true
Be sure to restart the bluetooth service so that the configuration file change is recognized and applied:
OpenRC:
root #
rc-service bluetooth restart
systemd:
root #
systemctl restart bluetooth
Usage
USB
- Connect the DualShock to the system using a USB cable and press the PlayStation button on the controller.
- Turn the DualShock off when it's no longer in use by pressing and holding the PlayStation button for 10 seconds.
- Press the PlayStation button to use the DualShock again.
Bluetooth
It is recommended to use a Bluetooth controller that supports at least Bluetooth 2.1+EDR.
The recommended minimum version of BlueZ to use is 5.14. This release adds full support for the DualShock 4[5]. This release also incorporates DualShock 3 setup and pairing support which was added in BlueZ 5.12[6].
DualShock 3
Start bluetoothctl:
user $
bluetoothctl
Enable the agent and set it as default:
[bluetooth]#
agent on
[bluetooth]#
default-agent
Power on the Bluetooth controller, and set it as discoverable and pairable:
[bluetooth]#
power on
[bluetooth]#
discoverable on
[bluetooth]#
pairable on
Connect the DualShock 3 to the system using a USB cable and press the PlayStation button.
Allow the service authorization request:
[agent]
Authorize service service_uuid (yes/no): yes
Discover the DualShock 3 MAC address:
[bluetooth]#
devices
Trust the DualShock 3:
[bluetooth]#
trust device_mac_address
Disconnect the USB cable from the DualShock 3.
The DualShock 3 is now paired:
[bluetooth]#
quit
Turn the DualShock 3 off when it's no longer in use by pressing and holding the PlayStation button for 10 seconds.
Press the PlayStation button to use the DualShock 3 again.
DualShock 4
Start bluetoothctl:
user $
bluetoothctl
Enable the agent and set it as default:
[bluetooth]#
agent on
[bluetooth]#
default-agent
Power on the Bluetooth controller, and set it as discoverable and pairable:
[bluetooth]#
power on
[bluetooth]#
discoverable on
[bluetooth]#
pairable on
Scan for devices:
[bluetooth]#
scan on
Put the DualShock 4 into pairing mode by pressing and holding the PlayStation and Share buttons until the light bar starts flashing.
Discover the DualShock 4 MAC address:
[bluetooth]#
devices
Pair with the DualShock 4:
[bluetooth]#
pair device_mac_address
Allow the service authorization request:
[agent]
Authorize service service_uuid (yes/no): yes
Trust the DualShock 4:
[bluetooth]#
trust device_mac_address
The DualShock 4 is now paired:
[bluetooth]#
quit
Turn the DualShock 4 off when it's no longer in use by pressing and holding the PlayStation button for 10 seconds, or by disconnecting it from bluetoothctl or any GUI Bluetooth device manager.
Press the PlayStation button to use the DualShock 4 again.
Battery charge level
The DualShock battery charge level can checked with sysfs:
user $
cat "/sys/class/power_supply/sony_controller_battery_04:76:6e:9a:98:fc/capacity"
25
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 sys-power/upower. First, list available devices:
user $
upower -e
/org/freedesktop/UPower/devices/battery_sony_controller_battery_04o76o6eo9ao98ofc /org/freedesktop/UPower/devices/DisplayDevice
Next, display the DualShock power information:
user $
upower -i /org/freedesktop/UPower/devices/battery_sony_controller_battery_04o76o6eo9ao98ofc
native-path: sony_controller_battery_04:76:6e:9a:98:fc power supply: no updated: Tue 01 Dec 2015 00:00:00 UTC (1 seconds ago) has history: yes has statistics: yes battery present: yes rechargeable: yes state: discharging warning-level: none energy: 0 Wh energy-empty: 0 Wh energy-full: 0 Wh energy-full-design: 0 Wh energy-rate: 0 W percentage: 25% capacity: 100% icon-name: 'battery-full-symbolic' History (charge): 1449283773 25.000 discharging 1449283773 0.000 unknown History (rate): 1449283773 0.000 unknown
Troubleshooting
Imitation DualShock 3 controllers
Imitation DualShock 3 controllers are not supported by BlueZ and will not work via Bluetooth[7]. However, Linux 4.15[8] and BlueZ 5.48[9] will have full support for imitation DualShock 3 controllers via USB and Bluetooth.
Steam doesn't detect Dualshock PS4 over bluetooth
If Steam doesn't detect Dualshock PS4 over bluetooth, the following may help:
user $
echo -e "# Valve HID devices over bluetooth hidraw\nKERNEL==\"hidraw*\", KERNELS==\"*28DE:*\", MODE=\"0666\"" | sudo tee -a /etc/udev/rules.d/99-steam-controller-perms.rules
user $
echo -e "# Dualshock 4 over bluetooth hidraw\nKERNEL==\"hidraw*\", KERNELS==\"*054C:05C4*\", MODE=\"0666\"" | sudo tee -a /etc/udev/rules.d/99-steam-controller-perms.rules
user $
echo -e "# Dualshock 4 Slim over bluetooth hidraw\nKERNEL==\"hidraw*\", KERNELS==\"*054C:09CC*\", MODE=\"0666\"" | sudo tee -a /etc/udev/rules.d/99-steam-controller-perms.rules
user $
sudo udevadm trigger
DualSense does not work in certain games
If the controller works in applications such as inside of Big Picture mode in Steam, but not inside of certain games running Wine or Proton, verify that the CONFIG_INPUT_UINPUT kernel symbol has been enabled in the running kernel:
Device Drivers --->
Input device support --->
[*] Generic input layer (needed for keyboard, mouse,...)
[*] Miscellaneous devices --->
<*> User level driver support
Dualshock PS4 not working on kernel >= 6.2
If the DS4 controller is not working with hid-sony driver, try the hid-playstation driver. It added support for DS4 controller in Kernel 6.2.
To enable the hid-playstation driver "LED Multicolor Class Support" must be selected.
See also
- Steam Controller — a game controller developed by Valve.
External resources
References
- ↑ 1.0 1.1 1.2 Jiri Kosina. [GIT] HID, LKML, April 2nd, 2014. Retrieved on October 24th, 2014.
- ↑ 2.0 2.1 Frank Praznik. HID: sony: Remove the size check for the Dualshock 4 HID Descriptor, Linux kernel stable tree, November 19th, 2015. Retrieved on July 8th, 2016.
- ↑ 3.0 3.1 Roderick Colenbrander. HID: sony: Update device ids, Linux kernel stable tree, October 10th, 2016. Retrieved on March 21st, 2017.
- ↑ 4.0 4.1 Bobby Borisov. Linux Kernel 5.12 Released With Many Essential Addons, April 26, 2021. Retrieved on November 10, 2021.
- ↑ Johan Hedberg. Release of BlueZ 5.14, BlueZ, January 21st, 2014. Retrieved on October 24th, 2014.
- ↑ Johan Hedberg. Release of BlueZ 5.12, BlueZ, December 10th, 2013. Retrieved on October 24th, 2014.
- ↑ DjMadness. Sixaxis via bluetooth, Gentoo Forums, March 4th, 2015. Retrieved on March 12th, 2015.
- ↑ Bastien Nocera. HID: sony: Fix SHANWAN pad rumbling on USB, Linux kernel stable tree, November 9th, 2017. Retrieved on December 20th, 2017.
- ↑ Bastien Nocera. plugins/sixaxis: Provide DualShock 3 SDP record while adding new device, Bluetooth protocol stack for Linux, November 9th, 2017. Retrieved on December 20th, 2017.