How to setup Dual Shock 4 controller with Ubuntu 13.10?

ds4drv

ds4drv is a Sony DualShock 4 userspace driver for Linux.

  • Discussions: https://groups.google.com/forum/#!forum/ds4drv
  • GitHub: https://github.com/chrippa/ds4drv
  • PyPI: https://pypi.python.org/pypi/ds4drv

Features

  • Option to emulate the Xbox 360 controller for compatibility with Steam games
  • Setting the LED color
  • Reminding you about low battery by flashing the LED
  • Using the trackpad as a mouse
  • Custom mappings, map buttons and sticks to whatever mouse, key or joystick action you want
  • Settings profiles that can be cycled through with a button binding

Installing

Dependencies

  • Python 2.7 or 3.3+ (for Debian/Ubuntu you need to install the python2.7-dev or python3.3-dev package)
  • python-setuptools
  • hcitool (usually available in the bluez-utils or equivalent package)

These packages will normally be installed automatically by the setup script, but you may want to use your distro's packages if available:

  • pyudev 0.16 or higher
  • python-evdev 0.3.0 or higher

Stable release

Installing the latest release is simple by using pip:

sudo pip install ds4drv

[…]

Using

ds4drv has two different modes to find DS4 devices, decide which one to use depending on your use case.

Raw bluetooth mode

Supported protocols: Bluetooth

Unless your system is using BlueZ 5.14 (which was released recently) or higher it is not possible to pair with the DS4. Therefore this workaround exists, which connects directly to the DS4 when it has been started in pairing mode (by holding Share + the PS button until the LED starts blinking rapidly).

This is the default mode when running without any options:

$ ds4drv

[…]

Permissions

If you want to use ds4drv as a normal user, you need to make sure ds4drv has permissions to use certain features on your system.

ds4drv uses the kernel module uinput to create input devices in user land and the module hidraw to communicate with DualShock 4 controllers (when using --hidraw), but this usually requires root permissions. You can change the permissions by copying the udev rules file to /etc/udev/rules.d/.

You may have to reload your udev rules after this with:

$ sudo udevadm control --reload-rules
$ sudo udevadm trigger

[…]

Known issues/limitations

  • Bluetooth 2.0 dongles are known to have issues, 2.1+ is recommended.
  • The controller will never be shut off, you need to do this manually by holding the PS button until the controller shuts off
  • No rumble support

[…]


Result (while playing a game through Steam):

$ ds4drv --trackpad-mouse --emulate-xpad-wireless
[info][controller 1] Created devices /dev/input/js0 (joystick) /dev/input/event20 (evdev) 
[info][bluetooth] Scanning for devices
[info][bluetooth] Found device aa:bb:cc:dd:ee:ff
[info][controller 1] Connected to Bluetooth Controller (aa:bb:cc:dd:ee:ff)
[info][bluetooth] Scanning for devices
[info][controller 1] Battery: 62%
[info][controller 1] Battery: 50%
[warning][controller 1] Signal strength is low (44 reports/s)
[info][controller 1] Battery: 37%

DS4 in Steam

The DS4 seems to have native support in Steam (client from 2016-01-01, tested on Ubuntu 14.04 with HWE kernel and 15.10) and Big Picture Mode works as intended through USB and Bluetooth.

To pair the DS4 in Ubuntu go to the Bluetooth settings and press the plus button (+) below the listing of paired devices to get to the pairing dialog, then press and hold PS+Share on the controller until the LED starts blinking and select the wireless controller to pair once it shows up.

enter image description here

ds4drv through USB

To answer Lucas' comment, the REAMDME was updated and now contains the following:

Hidraw mode

Supported protocols: Bluetooth and USB

This mode uses the Linux kernel feature hidraw to talk to already existing devices on the system.

$ ds4drv --hidraw

[…]

To use the DS4 via USB in this mode, simply connect your DS4 to your computer via a micro USB cable.

Note: Unfortunately due to a kernel bug it is currently not possible to use any LED functionality when using bluetooth devices in this mode.