Donnerstag, 16. August 2012

Dualshock 3 and Raspberry PI

Getting Sony Dualshock 3  gamepad to work in Raspberry Pi on Raspbian (Debian Wheezy).

First of all, I'll need a bluetooth dongle, since Raspbery Pi doesn't have built-in one, listing of compatible dongle you can find here.

So, install dependencies first

sudo apt-get install bluez-utils bluez-compat bluez-hcidump checkinstall libusb-dev  libbluetooth-dev joystick

It takes a while.

After all type "hciconfig" in console, you should see something like this.

pi@raspberrypi ~ $ hciconfig
hci0: Type: BR/EDR Bus: USB
 BD Address: 00:1F:81:00:06:20 ACL MTU: 1021:4 SCO MTU: 180:1
UP RUNNING PSCAN
RX bytes:1260 acl:0 sco:0 events:46 errors:0
TX bytes:452 acl:0 sco:0 commands:45 errors:0


if not, your dongle seems not to be recognized by system.

So now, we need to pairing the dongle with the gamepad using this tool.

download and compile it.

wget http://www.pabr.org/sixlinux/sixpair.c
gcc -o sixpair sixpair.c -lusb

After this you should have a executable file "sixpair".
Now connect your  Dualshock via a USB cable to Raspberry Pi and launch this file with sudo.

sudo ./sixpair

Current Bluetooth master: DE:AD:BE:EF:00:00
Setting master bd_addr to: 00:1F:81:00:06:20


If you see this, it was successful.

Install a Sixaxis Joystick Manager. Download a last archive and compile only important for us part.

wget http://sourceforge.net/projects/qtsixa/files/QtSixA%201.5.1/QtSixA-1.5.1-src.tar.gz
tar xfvz QtSixA-1.5.1-src.tar.gz
cd QtSixA-1.5.1/sixad
make
sudo mkdir -p /var/lib/sixad/profiles
sudo checkinstall

the last command make automatically a package for you, so you can later simple uninstall it, if you won't it or use a different system, type  "sudo make install" instead of "sudo checkinstall"

Now test it, for this launch temporary a sixad daemon.

sudo sixad --start

Then press a "PS" button on Dualshock gamepad, if you feel a vibration, it works, congratulations!

After all you can make "sixad" daemon starting at boot time.

sudo update-rc.d sixad defaults
reboot


If you have any trouble with recognition, you can debug your Dualshock controller with "jstest".

sudo jstest /dev/input/js0


P.S. Thanks goes to http://blog.onsw.net/yuta/

Kommentare:

  1. I was searching the net for sixaxis on pi, and there is only your article ;)
    the only thing you forgot (maybe you got it installed previously) is that you have to install pkg-config, otherwise the make fails.

    Anyway, thanks for your help

    AntwortenLöschen
  2. Antworten
    1. Hi, unfortunately I don't know, I don't have rpi anymore.

      Löschen
  3. http://forum.stmlabs.com/showthread.php?tid=5123

    AntwortenLöschen
  4. This worked great for me! I had to run "sudo apt-get update" first for everything to install correctly.

    AntwortenLöschen
  5. How can I run qtsixa ??? Please answer me

    AntwortenLöschen
    Antworten
    1. Sorry, I don't really know what you mean.

      Löschen
  6. I dont knot the terminal command to start the qtsixa gui
    how can i start qtsixa ???

    AntwortenLöschen
    Antworten
    1. you need compile it first, the instruction is in INSTALL file, inside of archive, but I think you need install "python-qt4-dev" using apt-get for dependency first. After install just type qtsixa in terminal.

      Löschen
    2. Thanks you helped me very very thanks again

      Löschen
  7. Hmm, can I somehow use this without the bluetooth dongle, that is via USB?

    AntwortenLöschen
    Antworten
    1. You can't... PS3 controllers only speak Bluetooth. The USB port is only for charging and pairing the controller.

      Löschen
    2. yes you can, plug usb and linux (or windows or mac) simply recognize the controller as a game controller.

      usb work normally.

      Löschen
  8. how to disable accelerometers?.. the profile on MAC address of the SIXAXIS controller doesn't disable it.. worked before on XBMCbuntu. But on the Raspberry Pi I can't get it to work.

    AntwortenLöschen
    Antworten
    1. Starting daemon in "Legacy" mode should disable accelerometers, check sixad manual for more info: http://qtsixa.sourceforge.net/manual.pdf

      Löschen
  9. Hi, after get bluetooth working and sixpair compiled, I execute and i get that error message:

    sudo ./sixpair
    No controller found on USB busses.

    Any idea?


    Thanks!

    AntwortenLöschen
  10. Just as a note, there is a space after the / in the jstest command, and it caused an error. Just for anybody who was confused like me.

    AntwortenLöschen
  11. Dieser Kommentar wurde vom Autor entfernt.

    AntwortenLöschen
  12. having trouble connecting 2 ps3 controlers.. any help?

    AntwortenLöschen
  13. can somebody help me please?

    desktop@steamos:~/QtSixA-1.5.1/sixad$ make
    mkdir -p bins
    g++ -O2 -Wall -Wl,-Bsymbolic-functions sixad-bin.cpp bluetooth.cpp shared.cpp textfile.cpp -o bins/sixad-bin `pkg-config --cflags --libs bluez` -lpthread -fpermissive
    /bin/sh: 1: pkg-config: not found
    sixad-bin.cpp: In function 'int main(int, char**)':
    sixad-bin.cpp:84:20: warning: taking address of temporary [-fpermissive]
    sixad-bin.cpp:89:18: error: 'close' was not declared in this scope
    sixad-bin.cpp:100:20: error: 'sleep' was not declared in this scope
    sixad-bin.cpp:109:22: error: 'close' was not declared in this scope
    sixad-bin.cpp:117:22: error: 'close' was not declared in this scope
    sixad-bin.cpp:140:18: error: 'close' was not declared in this scope
    sixad-bin.cpp:144:14: error: 'close' was not declared in this scope
    bluetooth.cpp: In function 'void do_connect(int, bdaddr_t*, bdaddr_t*, int)':
    bluetooth.cpp:104:30: error: 'close' was not declared in this scope
    bluetooth.cpp:110:24: error: 'dup2' was not declared in this scope
    bluetooth.cpp:111:22: error: 'close' was not declared in this scope
    bluetooth.cpp: In function 'int l2cap_listen(const bdaddr_t*, short unsigned int, int, int)':
    bluetooth.cpp:148:17: error: 'close' was not declared in this scope
    bluetooth.cpp:162:17: error: 'close' was not declared in this scope
    bluetooth.cpp: In function 'void l2cap_accept(int, int, int, int, int)':
    bluetooth.cpp:195:26: error: 'close' was not declared in this scope
    bluetooth.cpp:201:26: error: 'close' was not declared in this scope
    bluetooth.cpp:221:26: error: 'fork' was not declared in this scope
    bluetooth.cpp:228:32: error: 'dup2' was not declared in this scope
    bluetooth.cpp:229:30: error: 'close' was not declared in this scope
    bluetooth.cpp:242:57: error: 'execve' was not declared in this scope
    bluetooth.cpp:254:26: error: 'close' was not declared in this scope
    bluetooth.cpp: In function 'int l2cap_connect(bdaddr_t*, bdaddr_t*, short unsigned int)':
    bluetooth.cpp:274:25: error: 'close' was not declared in this scope
    bluetooth.cpp:291:25: error: 'close' was not declared in this scope
    make: *** [sixad_bins] Error 1

    AntwortenLöschen
    Antworten
    1. try install pkg-config.

      sudo apt-get install pkg-config

      Löschen
    2. well, as I understand steamos doesn't have some dependencies for compiling sixad. Try this guide instead http://www.reddit.com/r/SteamOS/comments/1svnfx/ps3_controller_

      Löschen
    3. that don't work also because he work with debian on a virtualmachine

      Löschen
    4. i can connect my contreoller but don't have interface for controlls

      Löschen
  14. when i put

    wget http://www.pabr.org/sixlinux/sixpair.c
    gcc -o sixpair sixpair.c -lusb

    it says wget: --level: invalid number 'usb'.

    AntwortenLöschen
  15. i fixed thde first one but sixpair is a text file and it wont run

    AntwortenLöschen
    Antworten
    1. You need to make the text file into an executable file (the line starting gcc below) :

      wget http://www.pabr.org/sixlinux/sixpair.c
      gcc -o sixpair sixpair.c -lusb
      this is from here
      http://kearnesrpi.blogspot.co.uk/2013/06/mame-and-ps3-dualshock-controller.html

      I hope this helps! I'm new to this and have been trying to mak my os3 work for 3 days now ...and still haven't had any success!

      Löschen