Bluetooth latency issues

As the PS4 only supports bluetooth controls, I decided to work on the latency issues that occur when controlling a PS3 over bluetooth with GIMX:

  • Latency when using a slim/superslim PS3 and GIMX in Ubuntu 12.04+.
  • Latency when using a bluetooth headset or several controllers at the same time.

As I only had a fat PS3, I had to get a slim PS3. I bought one with a defective blu-ray lens for 60€ (about 80$).

I discovered several problems:

  • A change in the Linux 3.1 kernel: the bluetooth transmitter was forced to go into the active mode instead of remaining in the sniff mode.
  • Bluetooth packets not properly synced: the IN report has to be sent immediately after receiving the OUT report.

These problems are both related to the bluetooth sniff mode, which is used to reduce the power consumption.
To simplify, each device in the piconet is active during a fixed window:

X+0 - the master sends a packet to slave 1
X+1 - slave 1 sends a packet to the master and reduces its power till its Tsniff period is over (11250µs)
X+2 - the master sends a packet to slave 2
X+3 - slave 2 sends a packet to the master and reduces its power till its Tsniff period is over (11250µs)
...
X+18 - the master sends a packet to slave 1
...

The master sends OUT reports, and the slaves IN reports.
If an IN report is not sent at the right time, it gets retransmitted later.
If the IN report period is slightly lower than the OUT report period, the IN reports will be gradually buffered, thus generating a latency that slowly increases.

The current GIMX design can’t guarantee that the IN reports are sent in the right slot, because the OS can interrupt the program and schedule another task.

The following improvements could be made:

  • Merge emu and emuclient: this would prevent the kernel from interrupting emu to run emuclient (this can happen just after receiving an OUT report and before sending the IN report…). This would improve GIMX performances especially on single core CPUs (like the Raspberry Pi). This would still not ensure a 100% perfect sync, but I believe this is the only possible improvement without adding extra hardware.
  • Handle the Bluetooth protocol with a DIY adapter: PC —USB— AVR USB —UART— BT module —BT— PS3.

Moving to Linux Mint

I am very disappointed by Ubuntu 12.10 for the following reasons:
– it does not run smoothly on my nettop (Atom N330 + ION)
– it does not install on my old laptop, which runs a non pae CPU (Pentium M 1.6Ghz).
It’s now clear that Ubuntu only targets recent hardware…

I decided to move to a Ubuntu-based Linux Mint. I chose the Xfce version because it’s light and customizable. I am using the mintMenu applet as I am used to type with my keyboard to open files and launch applications (rather than click/unfold menus).

GIMX packages should work fine in both Ubuntu 12.10 and Linux Mint 13.

Installation of GIMX 0.25 in Ubuntu 11.10

Synaptic has been dropped from Ubuntu 11.10, and is kind of replaced by the Ubuntu Software Center. GIMX tutorials tell to use Synaptic to add ‘universe’ to the software sources, that’s why they need to be updated. It’s possible to add ‘universe’ to the software sources with the Ubuntu Software Center, but it appears that there is a bug that prevents software sources to be refreshed in case a Live CD/USB is used. A work-around is to type “sudo apt-get update” in a terminal.

GIMX 0.25 installation in Ubuntu 11.10

Ubuntu 11.04

Ubuntu 11.04 is out! Some important changes for the sixaxis emulator:

  • the bluez version is now 4.91

The Ubuntu 10.10 bluez version (4.69) seems to cause some connection problems in some undefined cases.

  • the middle mouse button emulation is now off by default

This “feature” can cause a 50ms lag for left and right mouse buttons.

Download link.

Connection errors

This post is for people getting connection errors.

Some people reported connection issues that were fixed by upgrading the linux bluetooth stack (default one in Ubuntu 10.10 is version 4.69).

Instructions if you want to do upgrade to the latest version (4.91):

System > Administration > Synaptic Package Manager
Settings > Repositories > Other Software

Add
Apt Line: ppa:blueman/ppa
Close

Reload
Mark all upgrades
Apply

I just upgraded to this version and it seems not to cause any issue on my setup. Do it at your own risk!

Note: bluez version 4.91 is now in Ubuntu 11.04.