Pair and Connect the Controller
Bluetooth Pairing
With the updated package in place, you can now follow steps will get the PS3 controller paired with your Ubuntu system. This step only needs to be performed once as it will remain successfully paired with Ubuntu between uses. If you reconnect/re-pair the controller with the PS3 however, you will have to repeat this step.
If you want to setup multiple controllers, repeat this step for each one individually.
Run the following command to view the system log messages as they are generated.
$ watch -n 1 "tail /var/log/messages"
Plug in PS3 controller with USB cable. You should see output similar to the following system log in the terminal.
Apr 4 11:06:40 xps kernel: [ 9666.789711] input: Sony PLAYSTATION(R)3 Controller as /devices/pci0000:00/0000:00:1d.0/usb5/5-2/5-2:1.0/input/input23 Apr 4 11:06:40 xps kernel: [ 9666.834506] input,hiddev96,hidraw3: USB HID v1.11 Joystick [Sony PLAYSTATION(R)3 Controller] on usb-0000:00:1d.0-2
The lights will blink indicating that the controller is communicating with the system.
Press the PS button (clear button in the center of the gamepad). This will acknowledge the controller connection sequence and the controller will become activated.
Check that the /dev/input/js0 device exists at this point.
$ls /dev/input/js*
/dev/input/js0
You can test the controller by running either of the following commands. jscalibrator opens a GUI window and allows you you calibrate your buttons. jstest shows the raw output from the buttons themselves. Make sure you have pressed the PS button on the controller if you aren’t getting any response.
$ jscalibrator -d /dev/input/js0
or
$ jstest /dev/input/js0
The lights will continue to blink indefinitely as long as the controller is connected, this is normal. There is no way at this point to disable them but the controller will operate correctly over USB.
Execute the sixpair utility. This will tell the PS3 controller to look for your Ubuntu bluetooth master device and not the PS3 itself when it attempts to connect over bluetooth.
$ sudo ./sixpair
Current Bluetooth master: 00:1f:e1:e3:48:YY Setting master bd_addr to 00:1f:e1:e3:48:YY
You should now disconnect the controller from the USB cable. It will remain paired with the Ubuntu system from this point forward.
Initiate Connection
By now you should have installed the updated package and successfully paired the PS3 controller with your Ubuntu system. Until you reconnect/re-pair the controller to the PS3 you can simply repeat this step each time you want to use your controller.
For the controller to successfully connect with your Ubuntu system you will have to temporarily disable the default bluetooth service and start the hidd daemon instead.
Stop the bluetooth service.
$ sudo /etc/init.d/bluetooth stop
Run the hidd daemon. The ‘-n‘ will stop it from running in the background and you can see its output in the terminal.
$ sudo hidd --server --nocheck -n
hidd[14407]: Bluetooth HID daemon
In a separate terminal run the hcidump command below. It will show you the current bluetooth traffic as it happens.
$ sudo hcidump -t -V -x
Press the PS button (clear button in the center of the gamepad). This will cause the controller to begin its connection sequence. You should see the hidd daemon accept the connection and print something similar to the output below. Pay attention to the bold text below. This is your bluetooth PS3 controller address which you will need later to ultimately disconnect the controller.
hidd[13149]: New HID device 00:16:FE:D7:8C:XX (Sony Computer Entertainment Wireless Controller)
The system log should also show the following.
Apr 4 11:09:52 xps kernel: [ 6258.750437] input: Sony Computer Entertainment Wireless Controller as /devices/pci0000:00/0000:00:1d.2/usb7/7-2/7-2.1/7-2.1:1./bluetooth/hci0/hci0:11/input22
hcidump should start reporting a large amount of bluetooth traffic from the PS3 controller. Here’s a snippet of the sample output below.
2009-04-04 11:10:04.745725 > ACL data: handle 11 flags 0x02 dlen 54 L2CAP(d): cid 0x0041 len 50 [psm 19] HIDP: Data: Input report 01 00 00 00 00 00 86 88 78 79 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 05 14 FF C8 00 00 23 5E 77 01 81 01 FE 01 E8 01 8F 00 02 2009-04-04 11:10:04.757745 > ACL data: handle 11 flags 0x02 dlen 54 L2CAP(d): cid 0x0041 len 50 [psm 19] HIDP: Data: Input report 01 00 00 00 00 00 86 88 78 79 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 05 14 FF C8 00 00 23 5E 77 01 81 01 FE 01 E7 01 8F 00 02
Check that the /dev/input/js0 device exists once again.
$ls /dev/input/js*
/dev/input/js0
You can verify the controller is correctly working over bluetooth by once again running either jscalibrator or jstest.
$ jscalibrator -d /dev/input/js0
or
$ jstest /dev/input/js0
Congratulations! You have successfully connected your PS3 controller. As before, the lights will continue to blink as long as the controller is connected. You can operate the controller and map its buttons just like any other joystick or gamepad.
If you are wanting to connect multiple controllers that were successfully paired in the previous step, press the PS button for each one. You should see that a device (/dev/input/js*) is created for each one.
Kill the hidd daemon by pressing Ctrl+C in the terminal window. You no longer need this as the the PS3 controller is now connected.
You can now restart the bluetooth service to resume the normal operation of bluetooth devices on your system. The controller will continue to operate normally.
$ sudo /etc/init.d/bluetooth start
Terminate Connection
The PS3 controller doesn’t hibernate and power off like it does when paired with the PS3. To conserve your battery, once you are done with it you need to “unplug” the controller from the system with the following command. Use the bluetooth address you saved from initiating the connection.
$ sudo hidd --unplug 00:16:FE:D7:8C:XX
The lights on the controller will go dark once it has been successfully unplugged.
If you want to reconnect/re-pair the controller to your PS3, simply reattach the controller to the PS3 with the USB cable and press the PS button.