Friday, 22 May 2009

Sixaxis support in BlueZ

Getting the Sixaxis PlayStation 3 joypad to work with Linux (in Bluetooth mode) is a bit of a pain. There were my various attempts at cleaning up the code lying around on the Internet, and hacks involving hidd.

The way to set the pad up in Bluetooth mode is fairly straight forward:
  • Open the USB device
  • Get the device's Bluetooth address through magic USB commands
  • Write your Bluetooth adapter's address in the pad (magic USB commands again), and then give the device back to the USB HID driver, so that it works as a pad through USB.
  • Set up the internals of bluetoothd so it recognises the device, and allows it to connect to your computer
  • When the device connects through Bluetooth, poke at it with magic commands again to enable its HID mode (code is already in bluetoothd's input plugin)
Yesterday I refactored my code as a bluetoothd plugin.

First up, detecting the device being plugged in. I wanted to use DeviceKit's GObject helper library, but it uses the D-Bus DeviceKit daemon which will be going away (note, this is just the DeviceKit daemon itself, not the -power, or -disks "sub"-daemons), in favour of libudev usage.

So I ported devkit-gobject to use libudev directly. Patch is currently being reviewed (it's in DavidZ's inbox), and it should show up soon in udev-extras under a different namespace.

After a bit of work, I had a bluetoothd plugin that detected PS3 pads being plugged in, and did the necessary work to make bluetoothd recognise it on plug.


Next, finishing up the libudev GObject helper library, and getting the bluetoothd plugin reviewed. And it would be nice to finally get the extra functionality merged into a hid driver in the kernel.

PS: Any info on the PS3 Headset or the keypad?

14 comments:

Malcolm Parsons said...

Any chance of Wiimote support?

Bastien Nocera said...

The Wiimote shows up as a normal Bluetooth device and can be paired. The support for it is already in the latest gnome-bluetooth.

Malcolm Parsons said...

Does that make it usable as a HID?

Is a joystick device node created?

Anonymous said...

Just wanted to thank you for your work on this. Pairing PS3 joypads is one of the most wanted features of the crazy people installing Ubuntu on their PS3.

Please make other posts about it when it gets accepted upstream (kernel, bluez) so that we can cherry pick the commits and help test it asap.

Thanks again

Bastien Nocera said...

Pepsiman: Seriously, why don't you just try it?

ajeans: given that we get about a person a day showing up with those questions on the #bluez channel, I'm pretty certain it's helping :)

Malcolm Parsons said...

hadess:

I'm using gnome-bluetooth 0.11.0-0ubuntu4.

I get "Pairing with Nintendo RVL-CNT-01 failed".

Bastien Nocera said...

Pepsiman: gnome-bluetooth 0.11? You're using bluez-gnome to do the pairing then. Upgrade to gnome-bluetooth 2.27.x

Malcolm Parsons said...

hadess: I've installed gnome-bluetooth 2.27.4-0ubuntu5 from https://launchpad.net/~bmillemathias/+archive/ppa

The dialog is slightly different, but pairing fails in the same way.

Bastien Nocera said...

Pepsiman: Try 2.27.5. And this is the last comment I'll reply to, this isn't a forum, and there's a mailing-list and a bug tracker...

Malcolm Parsons said...

gnome-bluetooth 2.27.5 can pair with a Wiimote.
Nothing useful happens while it is paired.

Anonymous said...

hi there.
I am developing an app that connects Sixaxis to PC through bluetooth.
I never liked to have a patched hidd just to connect it.
But having Sixaxis support out-of-the-box will be just awesome!
I also posted an idea on the Ubuntu Brainstorm about this (still using for aproval)

Mikael said...

You sir, rock

Anonymous said...

Next up, the Guitar Hero drums? :D

Bastien Nocera said...

Anon: If somebody buys me the gear :)

Bluetooth gear wishlist lives here: http://www.amazon.co.uk/registry/wishlist/TKL85H14LHFU/ref=cm_wl_rlist_go