Sponsored Links
Note:The use of Bluetooth authentication and encryption has not been investigated yet.

Running in non-secure mode, as described in this document, might be inappropriate for some applications, and may also make the host computer temporarily vulnerable to attacks.

Requirements:

- linux-2.6.21 or later. Earlier kernels do not support Bluetooth HID devices in "Report Protocol" mode.

- patch-hidd-3.9-pabr3 ([Register or Login to view links]) or patch-hidd-3.19-pabr3 ([Register or Login to view links]) .

This patch causes the Linux Bluetooth HIDP daemon (hidd) to send a special command to the SIXAXIS when it connects. Sony already published a similar patch for enabling reporting in USB mode.

- sixpair.c. ([Register or Login to view links])

Only required if the SIXAXIS is to be used with a non-PS3 Bluetooth master. The SIXAXIS apparently does not support the standard Bluetooth pairing procedure; instead, pairing is done over USB, which is arguably simpler and more secure. This command-line utility searches USB buses for SIXAXIS controllers and tells them to connect to a new Bluetooth master.

Alternatively, it might be possible to support the Bluetooth HID "Report Protocol" on older kernels by using bthid instead of hidd, with a similar patch.

Besides, the new "input service" (bluetoothd-service-input), which replaces hidd in recent versions of bluez-utils, should support the SIXAXIS without any patch. However, since it does not accept connections from unknown Bluetooth devices, authorizations must be set-up by another utility, such as a udev plugin, as suggested in this discussion ([Register or Login to view links]).

Note: Bluetooth experts use the word "controller" to refer to the Bluetooth network adapter inside the host or the PS3, whereas everybody else thinks "game controller" (a.k.a. joystick). This sometimes causes confusion.

Operation:

Ensure /etc/bluetooth/hcid.conf contains:


[Register or Login to view code]

Enable Bluetooth:

[Register or Login to view code]

If the host is not the PS3, pairing is required:

Connect the SIXAXIS with a USB cable. Run sixpair:

[Register or Login to view code]

Disconnect the USB cable. Run the HIDP daemon:

[Register or Login to view code]

(Note: --nocheck is only required for the first connection.)

Optionally run hcidump in another shell, for troubleshooting and comparison with this successful trace ([Register or Login to view links])

[Register or Login to view code]

Press the PS button on the SIXAXIS. hidd should report:

[Register or Login to view code]

/var/log/messages should report:

[Register or Login to view code]

Check that the SIXAXIS is recognized as a joystick:

[Register or Login to view code]

jstest should report buttons being pressed and sticks being moved. After testing, restore the security settings in /etc/bluetooth/hcid.conf:

[Register or Login to view code]

And apply them with:

[Register or Login to view code]

Using Inertial Sensors with the Hidraw Interface:
The Linux joystick interface
[Register or Login to view code]

does not report inertial measurements from the accelerometers and gyro. The hidraw interface can be used instead. It transfers raw HID input reports to user-space and works identically in USB mode and in Bluetooth mode.

Requirements:

A kernel with
[Register or Login to view code]

enabled. patch-bluetooth-hidraw-pabr1. Adds hidraw support to hidp.ko for use in Bluetooth mode. Not required in USB mode.

Operation:

Connect the device with a USB cable and press PS. dmesg should report:

[Register or Login to view code]

(or another minor number) should be created automatically.

In Bluetooth mode, a:

[Register or Login to view code]

device is created as well, but dmesg does not report its minor number.

Raw input reports can be read from /dev/hidraw1:

[Register or Login to view code]

sixhidtest.c ([Register or Login to view links]) decodes inertial measurements:

[Register or Login to view code]

xsixhidtest.c ([Register or Login to view links]) graphically displays speed, position and orientation derived from accelerometer measurements. High-pass filtering is used to control integration drift; this works well for fast periodic signals, e.g. circular motion. In this simple example, no attempt is made to track simultaneous translations and rotations, nor rotations around the vertical axis.

[Register or Login to view code]

Known Issues:

- A 2.0 Bluetooth adapter is recommended. Otherwise, incoming input reports may be truncated to 12 bytes.

- On some PS3 hosts, hcidump shows "Role Change" "Role: Master" and dmesg reports "hci_acldata_packet: hci0 ACL packet for unknown connection handle". Upgrading to linux-2.6.23 or later should solve this problem.

- The Bluetooth adapter in the PS3 supports remote wake-up. This has not been tested with Linux.

- Bluetooth authentication and encryption have not been investigated. This probably requires a key exchange procedure over USB.

- The LEDs are not supported. /dev/js0 should have the first LED turned on, and so on.

- Hand-over between USB mode and Bluetooth mode is not transparent for applications.

- Monitoring of battery status is not implemented.