Friday, November 19, 2010

Emulate PS3 controllers

I had a play around in the past few days on how to emulate the ps3 controller from a PC with a bluetooth dongle. There are a few things one might want to emulate:

1. Six-axis
2. BD remote control
3. HID Keyboard & Mouse (for faster typing)

All the keys from the six-axis can be used from either the BD remote or the keyboard. The HID protocol doesn't seem to be able to transmit the stick movements, so it is useless for playing. There is a work around (as in, a properly reversed engineered six-axis protocol implementation) at diy-machine, which supports up to 7 controllers and it's being developed actively.

I was mainly interested to emulate the remote/keyboards in order to be able to play/pause etc a DVD from my iPod/phone through a web page. I will not post the details of the web server (yet) as it is too messy, but if google picks this up it might useful to other people to know where the resources are.

Useful python code can be found in bluemaemo (for Nokia phones) and remoko for the openmoko phone. At the heart of the implementation there is a HID server that pretends to be a HID device. There are quite a few lying around, for example hidserv.c (in bluemaemo), hidclient.c, xkbdbthid. This server opens a Bluetooth (L2CAP) socket and writes to it according to the HID protocol .

To establish a connection with Bluez4 one needs to load the SDP record of the device (specifications of the SDP protocol can be found on the Bluetooth v3 specifications (volume 3 part C)). One such service record can be found in bluemaemo (for a keyboard + mouse HID device). The record will contain the HID descriptor (according to the HID specifications, on the USB website).

The HID descriptor for the PS3 BD remote can be found here and here. On these websites there is also a SDP service record of the remote, that can easily be converted to xml.

That's all for now, I might post the code at some point if it turns out to be readable.
Post a Comment