This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Sony DualShock

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
Resources

This article describes the use of Sony DualShock 3 / 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 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-ZCT1E] 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-ZCT2E] Yes >=4.10[3]

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].

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:

KERNEL Enabling Sony DualShock support
    Device Drivers --->
          Input device support --->
            <*>   Joystick interface
            <*>   Event interface
          HID support --->
            [*]   Battery level reporting for HID devices
            [*]   /dev/hidraw raw HID device support
            <*>   Generic HID driver
                  Special HID drivers --->
                    <*> Sony PS2/3/4 accessories
                    [*]   Sony PS2/3/4 accessories force feedback support
                USB HID support --->
                  <*> USB HID transport layer
      [*] LED Support --->
            <*>   LED 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; The gyro can be set as a joystick, but that will confuse some games:

FILE /etc/X11/xorg.conf.d/30ds4.conf
Section "InputClass"
        Identifier   "ds4-touchpad"
        Driver       "libinput"
        MatchProduct "Sony Interactive Entertainment Wireless Controller Touchpad"
        Option       "Mode" "Relative"
EndSection
Section "InputClass"
        Identifier   "ds4-gyro"
        Driver       "joystick"
        MatchProduct "Sony Interactive Entertainment Wireless Controller Motion Sensors"
        Option       "Ignore" "True" #comment out this line to use the gyro as a joystick
EndSection

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

Note
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[4]. This release also incorporates DualShock 3 setup and pairing support which was added in BlueZ 5.12[5].

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.

Discover the DualShock 3 MAC address:

[bluetooth]#devices

Disconnect the USB cable from the DualShock 3:

Allow the service authorization request:

[agent]Authorize service service_uuid (yes/no): yes

Trust the DualShock 3:

[bluetooth]#trust device_mac_address

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 are not supported by BlueZ and will not work via Bluetooth[6]. However, Linux 4.15[7] and BlueZ 5.48[8] will have full support for imitation DualShock 3 controllers via USB and Bluetooth.

External resources

References

  1. 1.0 1.1 1.2 Jiri Kosina. [GIT] HID, LKML, April 2nd, 2014. Retrieved on October 24th, 2014.
  2. 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. 3.0 3.1 Roderick Colenbrander. HID: sony: Update device ids, Linux kernel stable tree, October 10th, 2016. Retrieved on March 21st, 2017.
  4. Johan Hedberg. Release of BlueZ 5.14, BlueZ, January 21st, 2014. Retrieved on October 24th, 2014.
  5. Johan Hedberg. Release of BlueZ 5.12, BlueZ, December 10th, 2013. Retrieved on October 24th, 2014.
  6. DjMadness. Sixaxis via bluetooth, Gentoo Forums, March 4th, 2015. Retrieved on March 12th, 2015.
  7. Bastien Nocera. HID: sony: Fix SHANWAN pad rumbling on USB, Linux kernel stable tree, November 9th, 2017. Retrieved on December 20th, 2017.
  8. 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.