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:

  • QTSixA, a dedicated SIXAXIS manager project supporting both USB and Bluetooth (PPA provided)

  • Bug 124743, a feature request for SIXAXIS Bluetooth support built into Ubuntu's own bluez

  • An Ubuntu user's custom bluez .deb for 12.04 Precise adding support for the SIXAXIS, plus details of what went into it and why

Quick Setup Guide for 12.10

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

  •  sudo apt-add-repository ppa:falk-t-j/qtsixa

1a. Update and install the sixad package.

  •  sudo apt-get update
     sudo apt-get install sixad

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

  •  sudo sixpair

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

  •  sixad --start

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):

  • Section "ServerFlags"
      Option "AllowEmptyInput" "True"
    EndSection

2. Configure HAL

  • Create the following file: /etc/hal/fdi/policy/x11-joystick.fdi (it must be of the form <name>.fdi) and paste a configuration like the example below (taken from the stock xf86-input-joystick):

    <?xml version="1.0" encoding="UTF-8"?>
    <deviceinfo version="0.2">
      <device>
        <match key="info.capabilities" contains="input">
          <!-- Match on anything you like from lshal -->
          <match key="input.product" string_outof="Sony Computer Entertainment Wireless Controller;Sony PLAYSTATION(R)3 Controller">
    
            <!-- xorg-server<1.5 will only hotplug devices where these two capatilities
                 are set. This hack can confuse other hal clients. -->
            <!--
            <append key="info.capabilities" type="strlist">input.keys</append>
            <append key="info.capabilities" type="strlist">input.mouse</append>
            -->
            
            <merge key="input.x11_driver" type="string">joystick</merge>
            
            <!-- Arbitrary options can be passed to the driver using 
                 the input.x11_options property since xorg-server-1.5. -->
    
            <!-- DEFAULT CONFIGURATION 
                 Change this to override the default settings of the input driver.
            -->
            <merge key="input.x11_options.MapButton1" type="string">button=1</merge>
            <merge key="input.x11_options.MapButton2" type="string">button=2</merge>
            <merge key="input.x11_options.MapButton3" type="string">button=3</merge>
    
            <merge key="input.x11_options.MapAxis1" type="string">mode=relative axis=+1x deadzone=5000</merge>
            <merge key="input.x11_options.MapAxis2" type="string">mode=relative axis=+1y deadzone=5000</merge>
            <merge key="input.x11_options.MapAxis3" type="string">mode=relative axis=+1zx deadzone=5000</merge>
            <merge key="input.x11_options.MapAxis4" type="string">mode=relative axis=+1zy deadzone=5000</merge>
            <merge key="input.x11_options.MapAxis5" type="string">mode=accelerated axis=+1x deadzone=5000</merge>
            <merge key="input.x11_options.MapAxis6" type="string">mode=accelerated axis=+1y deadzone=5000</merge>
    
            <!-- EXAMPLES
            <merge key="input.x11_options.DebugLevel" type="string">5</merge>
            <merge key="input.x11_options.AutoRepeat" type="string">500 4</merge>
            <merge key="input.x11_options.MapButton4" type="string">key=Alt_L+Tab</merge>
            <merge key="input.x11_options.MapButton8" type="string">amplify=0.3</merge>
            <merge key="input.x11_options.MapButton9" type="string">disable-mouse</merge>
            <merge key="input.x11_options.MapButton10" type="string">key=space</merge>
    
            <merge key="input.x11_options.MapAxis1" type="string">mode=accelerated keylow=Left keyhigh=Right</merge>
            <merge key="input.x11_options.MapAxis2" type="string">mode=accelerated keylow=Up keyhigh=Down</merge>
            -->
          </match>
        </match>
      </device>
    </deviceinfo>

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

  • $ /etc/init.d/hal restart
    $ /etc/init.d/kdm stop
    $ /etc/init.d/kdm start

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.

  • Section "InputDevice"
            Identifier      "Sixaxis"
            Driver          "joystick"
            Option          "Device"        "/dev/input/by-id/usb-Broadcom_Corp_BCM92045B3_ROM_00191567386A-event-joystick"  
    #The previous line will be system specific.  To find yours, invoke $ls /dev/input/by-id
            Option          "Path"          "/dev/input/js0"
    #The previous line will also be system specific, but you will most likely find the Sixaxis at /dev/input/js0
    # Map Button 16 - square
            Option          "MapButton16"   "button=3"
    # Map Button 15 - x
            Option          "MapButton15"   "button=1"
    # Map Button 11 - L1
            Option          "MapButton11"   "key=Alt_L,Left"
    # Map Button 12 - R1
            Option          "MapButton12"   "key=Alt_L,Right"
            Option          "MapAxis1"      "mode=relative axis=2.0x deadzone=3000"
            Option          "MapAxis2"      "mode=relative axis=2.0y deadzone=3000"
    EndSection
    • Note: a detailed explanation of the input options can be found in the xserver-xorg-input-joystick manual which can be opened with $man joystick

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

  •         InputDevice     "Sixaxis"       "SendCoreEvents"

    The ServerLayout section should now look similar to this:

    Section "ServerLayout"
            InputDevice     "Sixaxis"       "SendCoreEvents"
            Identifier      "Default Layout"
            screen          "Default Screen"
    EndSection

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.

  • $sudo xinit -server -- :1 -config /etc/X11/xorg.conf.sixaxis
    • You should see a static filled screen with a big X for a cursor. At this point you should be able to move that cursor with the left joystick on the Sixaxis. If not, go back and tweak your settings in xorg.conf.

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

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

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)