Sixaxis emulator in a Virtual Machine

I recently was asked about running the sixaxis emulator in a VM (Virtual Machine).

As the sixaxis emulator is not designed to work in any other OS than Linux (mainly because the bluetooth stack is not as open in other OSes), running the sixaxis emulator in a VM could be a work-around for people that can’t (or don’t want to) install Linux on their machine.

With Windows Vista running VirtualBox/Ubuntu, I tried to perform the Sixaxis emulator tutorial.

Only step 1 doesn’t work: it seems the usb connection with the sixaxis doesn’t work as expected.

This is not a big issue since step 1 can be done once and for all with a livecd on any pc.

The only thing to care about is to disconnect usb devices from the VirtualBox before unplugging them.

With VirtualBox+Ubuntu, I get too much lag with the mouse, so that it can’t be used to play. I’m going to test other VMs.

About cheap CSR dongles

I was thinking the Bluecore4-ROM dongles can’t have their bdaddrs (bluetooth device address) changed… I was wrong! Curiously, these dongles seem to have some writable non-volatile memory!

I bought 4 Bluecore4-ROM dongles on ebay – 3$ each – about a month ago, and thought at the beginning they wouldn’t work.


But some people told me that the bdaddr of their Bluecore4-ROM bluetooth dongle can be modified permanently…

I finally received them, and as expected, I got their bdaddr changed permanently 🙂

The only bad thing is that 2 of the 4 dongles I received are not, as advertised, CSR dongles with Bluetooth 2.0+EDR (i.e. Bluecore4 dongles). One seems to be an old bluecore1 dongle (its bdaddr can’t be changed), and another one seems to be a counterfeit (it has the CSR product and vendor ids, but it does not contain a CSR chip) and doesn’t work at all.

EDIT August 4: Sellers usually don’t tell which CSR chip is inside a bluetooth dongle. The key point is that bluecore4 implements bluetooth 2.0+EDR. Therefore, a dongle advertised as a CSR dongle with bluetooth 2.0+EDR should contain a bluecore4 chip (or newer). Be careful, it seems some sellers are retailing old bluecore1 dongles as CSR dongles with bluetooth 2.0+EDR. Bluecore1 chips can’t have their bdaddr changed!

Joystick support

Last sunday I went to a bric-a-brac sale. I was looking for a steering wheel to adapt to my emulator. I bought a Wingman Formula Force GP for 5€:


This wheel is quite old – it was released in 2002 – but it still has a force feedback and a usb connector (older steering wheels have a gameport connector). It is probably outdated but I bet I can’t find better for that price.

I committed some code that enables the use of this controller with the sixaxis emulator. It uses the joystick API of the SDL library. The code is not well designed and has some limitations (only one joystick plugged to the PC, mappings are hardcoded…), but it is for now a proof of concept. It can be activated by modifying the Makefile: remove the # character from the line “#CFLAGS+=-DJOYSTICK”, and perform a make clean and a make.

Note that your joystick may be wrapped by default to a mouse and/or a keyboard by your linux distro. This is annoying because it generates extra mouse/keyboard events that interfere with real mouse and keyboard events in the emulator. This behavior can be configured/removed with the xinput command line utility. For more info on that command, type “xinput –help”.

 

The ultimate sixaxis emulator

Several input devices (keyboards, mice, wheels, joysticks…), several bluetooth dongles…

Guess what?

I’m thinking to make the sixaxis emulator capable of emulating several sixaxis at the same time, and reading several input devices at the same time (several mice, several keyboards…).

The emuclient process (responsible for grabbing input events) will connect to several emu processes (responsible for connecting and sending data to the PS3).

The bad thing is that the SDL 1.2 is not designed to handle multiple mice/keyboards (unlike joysticks). For mice and keyboards, the origin of an event can’t be known.

With the coming SDL 1.3, it seems that multiple mice can be handled at the same time thanks to the merge of the ManyMouse library.

I looked closer to the source code, and it seems that multiple keyboard can be handled by the SDL 1.3 too!

EDIT 12/06: the multi-mouse / multi-keyboard support has been removed from the trunk of the SDL library. It will be re-added in a near future => the multiple sixaxis emulator is postponed.

Sixaxis emulator: coming functionalities

Yesterday, I wanted to start playing Battelfield Bad Company 2 with the sixaxis emulator.

The great thing with this game is that you can control vehicles including helicopters.

As the sixaxis controls slightly differs from COD MW2, I started to play after doing small changes to the keymap.

Note that the dead zone is 8 for that game. I had to increase – x2 – the multiplier, but this depends on the mouse – mine is a G5 set to the highest sensitivity.

But I quickly saw that the keymap for infantry does not fit to vehicles driving very well.

A great thing to add to the sixaxis emulator is the ability to alter the keymap: a press on a key can change the keymap, so that several keymaps can be used while playing a game. Example: press F9, it emulates a circle button press (=enter into the vehicle) and changes the keymap!

For helicopter driving, there is nothing better than a joystick. I own an old ST200 usb joystick that I’m going to use with the sixaxis emulator!

Sixpair-emu customizer

The final sixpair-emu firmware for the Teensy++ is available there.

I wrote a small python app that makes the customization of the sixpair-emu easier: nothing to compile, no firmware to download (except the pre-compiled initial one) to the Teensy++!

It looks like this:


Disclaimer:

  • use it at your own risk
  • the (vendor id, product id) = (0x054c, 0x0268) is the property of Sony

Instructions:

  • plug the Teensy++ to the PC
  • download the firmware to the Teensy++ with the Teensy loader
  • if the bluetooth device to be used is a dongle, then plug it to the PC (if external)
  • launch the sixpair-emu customizer
  • select the Teensy++
  • select the bluetooth device, or select and edit custom bdaddr
  • select the (vendor id – product id): sixaxis = 0x054c – 0x0268, original firmware = 0x03eb – 0x2042
  • clic apply (if there is no change, the application tells nothing was modified)
  • unplug the Teensy++
  • plug it to the PS3

=> the bluetooth device is registered as a Sixaxis by the PS3, so that it can connect to the PS3 as a sixaxis!

If a Teensy++ or a bluetooth device is plugged after the application is started, the refresh button allows to refresh the gui without restart.

Python code is available there.

Ubuntu:

It requires following packages:

  • python 2.6.5
  • python-tk
  • libusb > 1.0
  • pyusb > 1.0
  • pybluez 0.18

It has to be launched in a terminal with the following command:

sudo python sixp-emu-cust.py

Windows:

(tested in windows vista)

python 2.6.5 (includes python-tk)
libusb filter driver 1.1.14.0
pyusb 1.0.0-a0 (to be installed in cmd shell with ‘setup.py install’)
pybluez 0.18

(the bdaddrs are not read, but custom bdaddr can be set)

Sixpair-emu

[deprecated – see newer post]

The code to get a teensy++ pair a bluetooth device with a PS3 is available there.

Disclaimer:

  • use it at your own risk
  • the vendor id and the product id are the property of Sony

To get it working, the following changes have to be done:

In sixaxis_pair_emu.c, edit the following lines:

uint8_t EEMEM DeviceBdaddr[6] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
uint16_t EEMEM VendorId = 0x03EB;
uint16_t EEMEM ProductId = 0x2042;

If your bdaddr is 11:22:33:44:55:66 then replace {0x01, 0x02, 0x03, 0x04, 0x05, 0x06 } with {0x11, 0x22, 0x33, 0x44, 0x55, 0x66 }.
The vendor id of a sixaxis is 0x054c, and the product id is 0x0268.

For now, you have to compile the firmware yourself.

Enhancements that I planned to do:

  • make the PS3 bdaddr be learnt by the device (but not persistent) done
  • write the variables that have to be modified in the eeprom done
  • make a specific usb request to modify them done
  • make a definitive firmware
  • make a linux/windows gui app