This page provides information on connecting a Sony PS3 Sixaxis or DualShock 3 Joystick via Bluetooth and configuring Ubuntu to use it in a variety of environments.

Much of the information on this page applies to old versions (3.x) of the Bluetooth userspace stack (bluez) found in 8.04/Hardy and below, not the the current versions (4.x) found in 8.10/Intrepid and above. Approaches that are more current include:

Quick Setup Guide for 12.10

1. Add the qtsixa ppa which contains an updated version of sixad

1a. Update and install the sixad package.

2. Connect your ps3 controller to your computer via usb and run:

3. Unplug your ps3 controller from the usb cable and run:

When prompted, press the PS button on the controller. If it's detected correctly, the controller will vibrate. Then use jstest-gtk to test your controller.

Introduction

Included on this page is information to pair the Sixaxis with a bluetooth receiver, configure xserver to recognize it as an input device (mouse/keyboard support), integrate controls with MythTV, and integrate it with a number of console emulators.

Bluetooth Pairing

The pairing process is done with the controller connected via USB.

Requirements

  1. Must be using kernel version 2.6.21 or later
  2. Must have the libusb-dev and libusb-0.1-4 package installed.
    $ sudo apt-get install libusb-dev libusb-0.1-4

USB Pairing

  1. Connect the controller to a USB port.
  2. Run sixpair
    • a) Download sixpair.c (save to a directory such as /home/%user%/sixaxis) b) Compile sixpair using

      $ gcc -o sixpair sixpair.c -lusb
      c) Run sixpair
      $ sudo ./sixpair
      
      sixpair will echo
      Current Bluetooth master: xx:xx:xx:xx:xx:xx
      Setting master bd_addr to xx:xx:xx:xx:xx:xx
  3. Disconnect the USB cable

Patch HIDD from bluez-utils

  1. Download patch-hidd-3.19-pabr3 (save to a directory such as /tmp)

  2. Create a directory and download bluez-utils source and dependencies there:
    $ apt-get source bluez-utils
    $ sudo apt-get build-dep bluez-utils
  3. Go into the bluez-utils-x.xx directory and run
    $ mv <path_where_you_saved_it>patch-hidd-3.19-pabr3 .
    $ patch -p1 < patch-hidd-3.19-pabr3
  4. Rebuild the package:
    $ dpkg-buildpackage -rfakeroot
  5. Install the new package (ignore the others that were created):
    $ cd .. (to find the debs)
    $ dpkg -i bluez-utils_<version>_<architecture>.deb
  6. Optional: if you will dist-upgrade your system, the process will overwrite your modified package with newer versions. You can either choose to redo the above steps every time a new version of bluez-utils is packaged, or "hold" the package. This should work with both apt and aptitude:
    $ echo bluez-utils hold | dpkg --set-selections

Bluetooth Monitoring

  1. Stop the BlueTooth service

    $ sudo /etc/init.d/bluetooth stop
  2. Make sure all hcid processes are stopped
    $ sudo killall hcid hidd
  3. Run HIDP daemon in terminal
    $ hidd --server --nocheck -n
    • a) Press the PS button on the Sixaxis hidd should echo
      hidd[pid]: Bluetooth HID daemon
      hidd[pid]: New HID device 00:19:C1:xx:xx:xx (Sony Computer Entertainment Wireless Controller)
      b) Press Ctrl+C to end the process
  4. Start the BlueTooth service

    $ sudo /etc/init.d/bluetooth start

Using the Sixaxis as a Pointer Device

We first need to install the input-joystick drivers XServer needs, and then either configure HAL (for newer X versions) or add an InputDevice to xorg.conf (for older versions).

Driver Installation

The package xserver-xorg-input-joystick is required to use the Sixaxis as an input device without the use of a third party program. There are two installation methods for the package. The simpler method is to install via the repositories, but you may also compile your own copy of the drivers.

Note: if using Hardy Heron (8.04) you will need to compile the drivers yourself as one of the files needs to be modified.

Install from Repositories

  1. Install the package xserver-xorg-input-joystick from the Ubuntu Repositories
    $ sudo apt-get install xserver-xorg-input-joystick

Compile and Install from source

  1. The package xorg-dev is required to compile the drivers. To install the package...
    $ sudo apt-get install xorg-dev
  2. Uninstall the package xserver-xorg-input-joystick if it's already intalled
    $ sudo apt-get remove xserver-xorg-input-joystick
  3. Make a directory to download and compile the source in (such as /home/%user%/input-joystick)
  4. In the terminal...
    $ cd /home/%user%/input-joystick
    $ wget http://archive.ubuntu.com/ubuntu/pool/universe/x/xserver-xorg-input-joystick/xserver-xorg-input-joystick_1.3.1.orig.tar.gz
    $ tar -xzvf xserver-xorg-input-joystick_1.3.1.orig.tar.gz
    $ cd xf86-input-joystick-1.3.1
  5. Edit the source. (This step can be skipped if using an Ubuntu version prior to 8.04)
    $ gedit src/jstk.c
    • Now we must comment out lines 252-254. After doing so those lines in jstk.c should look like this:
    /*            if (priv->axis[number].valuator != -1)
                    xf86PostMotionEvent(local->dev, 1, priv->axis[number].valuator, 
                                        1, priv->axis[number].value);
    */
  6. At this point we are ready to compile and install. Here are the commands you will need:
    $ ./configure --libdir=/usr/lib
    $ make
    $ sudo make install

Configuring newer versions of X.Org (XServer >= 1.5) with HAL and automatic hot-plugging

With this configuration X will automatically detect and hotplug the Sixaxis when needed, and switching betweem USB and Bluetooth happens transparently.

1. Edit /etc/X11/xorg.conf and add the following line in the ServerFlags section (if it does not exist, create it):

2. Configure HAL

3. Restart HAL and X.Org by dropping into console (Ctrl-Alt-F1), then:

Note: Older versions of X.Org (XServer 1.4.x) will support the above configuration and will correctly plug/unplug the joystick, however they don't support the "input.x11_options.xxx" tags so you cannot customize the controls.

Disable Joystick From Controlling Mouse

If you want to play games with your controller, you might want to disable gamepad control over mouse cursor. To do this, edit /etc/X11/xorg.conf and add those lines:

Section "InputClass"
        Identifier "joystick catchall"
        MatchIsJoystick "on"
        MatchDevicePath "/dev/input/event*"
        Driver "joystick"
        Option "StartKeysEnabled" "False"       #Disable mouse
        Option "StartMouseEnabled" "False"      #support
EndSection

Configuring older versions of X.Org (non hotplug)

1. First make two copies of xorg.conf. One will be a backup and the other will be the version we edit.

  • $ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak
    $ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.sixaxis

2. Now open xorg.conf in a text editor. To open with gedit:

  • $ gksudo gedit /etc/X11/xorg.conf.sixaxis

3. Add the new InputDevice section to xorg.conf. It can be added anywhere in xorg.conf. Here is an example.

4. Add the new InputDevice to the ServerLayout section of xorg.conf. The line you need to add is as follows.

5. Now we should test xserver with our new config file. First turn on the ps3 controller, and then try out the following command. You can restart X by logging out and back in, or typing sudo /etc/init.d/gdm restart.

6. To make our settings permanent, replace xorg.conf with xorg.conf.sixaxis.

Known Issues

  1. The accelerometer and gyro axis do not work but can be used by reading the raw device -- see http://www.pabr.org/sixlinux/sixlinux.en.html for more information.

  2. The rumble feature is not supported.
  3. The leds keep blinking and do not report the chosen input device.
  4. Multiple gamepads on the same system have not been tested.
  5. When using the static X.Org configuration, the Sixaxis will not be hot pluggable -- if turning on the Sixaxis after Ubuntu is already running it will not work.

To Do

  1. Add sections for using the Sixaxis in variety of emulators
  2. Add section for using the Sixaxis in MythTV


CategoryBluetooth CategoryHardware

Sixaxis (last edited 2014-12-20 20:53:04 by lns-bzn-03-83-158-81-118)