Board index FlightGear Support Hardware

PS3 controller motion sensor (under linux)

Joysticks, pedals, monitors.

PS3 controller motion sensor (under linux)

Postby KoviRobi-HU » Sun Sep 05, 2010 10:25 pm

Hi!

Somebody http://www.pabr.org/sixlinux/sixlinux.en.html has managed to get the ps3 motion sensor working on linux!
Thanks to the user Jester and AndersG on IRC, I have managed to make the motion sensor work! Here is a small how to:

1) Attach the controller, and press the PS button.

2) Determine the number identifying your controllers motion sensor output, by typing
Code: Select all
dmesg

My output is ( the important part is in bold on the bottom ):
usb 5-3: USB disconnect, address 3
usb 5-3: new full speed USB device using ohci_hcd and address 5
usb 5-3: New USB device found, idVendor=054c, idProduct=0268
usb 5-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 5-3: Product: PLAYSTATION(R)3 Controller
usb 5-3: Manufacturer: Sony
usb 5-3: configuration #1 chosen from 1 choice
input: Sony PLAYSTATION(R)3 Controller as /devices/pci0000:00/0000:00:13.0/usb5/5-3/5-3:1.0/input/input14
sony 0003:054C:0268.0005: input,hiddev0,hidraw1: USB HID v1.11 Joystick [Sony PLAYSTATION(R)3 Controller] on usb-0000:00:13.0-3/input0

Now, everywhere you see hidrawX, replace X with the number at the end, in my case hidrawX will become hidraw1.

3) Create an udev rule.
Open a terminal and switch to root mode.
Code: Select all
cd /etc/udev/rules.d/
echo SUBSYSTEM=="hidraw", ATTRS{product}=="PLAYSTATION(R)3 Controller", MODE="664" >> 10-sony-sixaxis.rules


4) Now add the following line to the file IOrules in data/Nasal
READ ALLOW /dev/hidrawX

and create a new file called sixaxis.nas in data/Nasal with the following content:
var device = io.open("/dev/hidrawX");
var buf = bits.buf(50);
var update = func {
io.read(device, buf, 50);
var ax = ( buf[42] * 256 + buf[43] - 512 ) / 128;
var ay = ( buf[44] * 256 + buf[45] - 512 ) / 128;
var az = ( buf[46] * 256 + buf[47] - 512 ) / 128;
setprop ( "/controls/flight/aileron", ax * -1 );
setprop ( "/controls/flight/elevator", ay * -1 );
settimer(update, 0);
}

settimer(update, 0);


Now the motion sensor function should work! If not, just reply and we will resolve the problem

Thanks to everyone on IRC who helped

TODO:
ask permission from user anewb to modify his PS3 controller config
edit the nasal code so it fits all linux kernels
KoviRobi-HU
 
Posts: 12
Joined: Wed Jun 02, 2010 11:26 pm

Return to Hardware

Who is online

Users browsing this forum: No registered users and 4 guests