Raspberry Pi: Connecting multiple PS3 controllers via bluetooth

Let me know if something is missing in this guide. I whipped it up pretty quickly. If all else fails, you can click on the first link in sources at the bottom and that will get you hooked up with 1 controller.

This guide assumes you already have a Raspberry Pi with RetroPie installed and starting on boot. If not, check out this guide http://supernintendopi.wordpress.com/

Turn on your pi and press ‘f4’ to exit RetroPie.

Make sure your Pi is configured to your liking. I’m playing psx games with mine, so this is how I set mine up:

sudo raspi-config
  • Expand the file system to fill the SD card.
  • If you are from the US, change keyboard to US
  • Change the memsplit to 256 (only recommended if you are using a 512mb pi and playing psx games)
  • Overclock. I’m at 950mhz, you don’t necessarily need to though. Do at your own risk!
  • Enable overscan if you have your pi hooked up to a tv and part of the command line is off the screen
  • Reboot

Again, press f4 to get to the command line. Update your sources and upgrade all applications you have installed to minimize problems down the road. Then install the bluetooth software and dependencies you will need to hook up a PS3 controller.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install bluez-utils bluez-compat bluez-hcidump libusb-dev libbluetooth-dev joystick git dialog -y

Once everything is installed, check to see if your bluetooth dongle is recognized

hciconfig

You should get something similar to this output:

hci0: Type: BR/EDR Bus: USB
BD Address: 00:02:72:BF:BC:8F ACL MTU: 1022:8 SCO MTU: 121:3
UP RUNNING PSCAN
RX bytes:16777722 acl:289271 sco:0 events:116 errors:0
TX bytes:2561 acl:53 sco:0 commands:56 errors:0

If you don’t get something like that, you may have an incompatible bluetooth dongle.

Now you want to download and install sixpair. Sixpair is the application that pairs your Pi with the PS3 controller.

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

Download and install sixad, the controller manager.

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

Run controller manager at boot

sudo update-rc.d sixad defaults

Now we are going to pair the controllers by plugging it into your USB port with a mini-usb cable. I would recommend you get 1 controller completely connected, then go back and connect the 2nd one. Reboot the computer and turn the controllers on. Turn player 1 on first and then player 2, otherwise it will kind of screw up your keymapping.

sudo ./sixpair

You’ll get something similar to the following output:

Current Bluetooth master: 00:10:60:57:15:C7
Setting master bd_addr to: 00:10:60:57:15:C7

Start controller manager now and connect for the first time.

sudo service sixad start

Unplug your controller and press the PS button. The lights will just be flashing and you won’t get a confirmation that it connected. If you want confirmation, you can run:

jstest /dev/input/js01

Create a sixad profile for the controller

sudo nano /var/lib/sixad/profiles/default

Add the following content:

enable_leds 1
enable_joystick 1
enable_input 0
enable_remote 0
enable_rumble 1
enable_timeout 0
led_n_auto 1
led_n_number 1
led_anim 1
enable_buttons 1
enable_sbuttons 1
enable_axis 1
enable_accel 0
enable_accon 0
enable_speed 0
enable_pos 0

Now reboot your Pi

sudo reboot

Exit the emulator with f4, press the PS button on your controller, wait a couple seconds and start the emulator.

emulationstation

Enter anything for default controls and then press f4 on your keyboard. You are just making the outline for the configuration file now so you can go in and edit it. If you really are planning on getting 2 controllers connected, I would recommend having this in the es_input file twice. It will not ask you to initialize again as long as an es_input.cfg file exists.

nano ./.emulationstation/es_input.cfg

<inputConfig type=”joystick” deviceName=”Sony Computer Entertainment Wireless Controller”>
<input name=”a” type=”button” id=”13″ value=”6″ />
<input name=”b” type=”button” id=”14″ value=”5″ />
<input name=”down” type=”button” id=”6″ value=”2″ />
<input name=”left” type=”button” id=”7″ value=”3″ />
<input name=”menu” type=”button” id=”16″ value=”7″ />
<input name=”pagedown” type=”button” id=”10″ value=”9″ />
<input name=”pageup” type=”button” id=”11″ value=”10″ />
<input name=”right” type=”button” id=”5″ value=”4″ />
<input name=”select” type=”button” id=”12″ value=”8″ />
<input name=”up” type=”button” id=”4″ value=”1″ />
</inputConfig>[/code]Run jstest to determine what your Pi put each controller down as. Run the code below, see if it responds when one of the controllers presses buttons. If it responds, that controller is 0 or 1 or 2 or whatever number you put after the js in the code below.

jstest /dev/input/js0

Configure controller with the actual emulators themselves. P is the player number (just start at 1 and count up), and j is your controller number which you determined with jstest.

cd ~/RetroPie/emulators/RetroArch/tools

./retroarch-joyconfig -o p1.cfg -p 1 -j 0

./retroarch-joyconfig -o p2.cfg -p 2 -j 1

cat p*.cfg >> ~/RetroPie/configs/all/retroarch.cfg

sudo nano RetroPie/configs/all/retroarch.cfg

Verify that this was put at the end of your retroarch.cfg file. If it’s not the same, just edit it.

input_player1_a_btn = "13"
input_player1_b_btn = "14"
input_player1_x_btn = "12"
input_player1_y_btn = "15"
input_player1_l_btn = "10"
input_player1_r_btn = "11"
input_player1_l2_btn = "8"
input_player1_r2_btn = "9"
input_player1_l3_btn = "1"
input_player1_r3_btn = "2"
input_player1_start_btn = "3"
input_player1_select_btn = "0"
input_player1_left_btn = "7"
input_player1_up_btn = "4"
input_player1_right_btn = "5"
input_player1_down_btn = "6"
input_player1_l_x_plus_axis = "+0"
input_player1_l_y_plus_axis = "+1"
input_player1_l_x_minus_axis = "-0"
input_player1_l_y_minus_axis = "-1"
input_player1_r_x_plus_axis = "+2"
input_player1_r_y_plus_axis = "+3"
input_player1_r_x_minus_axis = "-2"
input_player1_r_x_minus_axis = "-3"

input_player2_a_btn = "13"
input_player2_b_btn = "14"
input_player2_x_btn = "12"
input_player2_y_btn = "15"
input_player2_l_btn = "10"
input_player2_r_btn = "11"
input_player2_l2_btn = "8"
input_player2_r2_btn = "9"
input_player2_l3_btn = "1"
input_player2_r3_btn = "2"
input_player2_start_btn = "3"
input_player2_select_btn = "0"
input_player2_left_btn = "7"
input_player2_up_btn = "4"
input_player2_right_btn = "5"
input_player2_down_btn = "6"
input_player2_l_x_plus_axis = "+0"
input_player2_l_y_plus_axis = "+1"
input_player2_l_x_minus_axis = "-0"
input_player2_l_y_minus_axis = "-1"
input_player2_r_x_plus_axis = "+2"
input_player2_r_y_plus_axis = "+3"
input_player2_r_x_minus_axis = "-2"
input_player2_r_x_minus_axis = "-3"

I also added this line to the bottom so you can press the PS button to exit the emulator and return to the emulationstation screen.

input_exit_emulator_btn = "16"

You should now be able to reboot, and test them out. You may need to exit emulationstation, let the controllers connect, and re-run it. Alternatively, I hear some people are putting ‘sleep 15’ in the script that starts emulationstation, which should give you time to get the controllers connected before emulationstation starts. I haven’t tried it because I don’t want to wait an additional 15 seconds for my Pi to boot.

Sources:

http://mypiandi.blogspot.com/2012/12/retropie-sixaxis-over-bluetooth.html

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=78&t=13552&start=50

http://qtsixa.sourceforge.net/manual.pdf

Advertisements

49 thoughts on “Raspberry Pi: Connecting multiple PS3 controllers via bluetooth

  1. Hi there. Thank you for this excellent tutorial.

    I am having an issue getting the second controller working, I hope you can steer me in the right direction.

    I have a file for js0, however I can’t seem to get a file for the second controller. I’ve tried using sixpair with both controllers, no luck.

    Any ideas what I need to do?!

    • Hey josh,
      Unfortunately, I am out doing annual training for the army and won’t be back until the end of the month. My internet here consists of 2g cell phone internet, and I haven’t been able to load up the blog for the last 2 days. Make sure you have the config for js0 and js1 in the same file though. Its probably a syntax issue you’re having. Controller number 0 is actually player 1, and controller 1 is player 2. Not sure if that helps but I can be more useful when I get home.

  2. Pingback: Retro Gaming on the Raspberry Pi: Everything You Need to Know ← SIMPLYGRAY

  3. As soon as I unplug the controler from the USB I can go no farther. The remote and the pi have no communication. In /dev/input/ there is no joysticks. No matter how I play with it or what guide I use. I have reformatted 4 times now. Tried retropie and plain raspbian. Any help you can give me?

    • At that point, they shouldn’t be showing up as a joystick in /dev/input. When you type ‘lsusb’, does your bluetooth dongle show up?

      When the controller is plugged in, are you running ‘sudo ./sixpair’? The way the PS3 controllers work with the pi, you are actually pairing the controllers via the USB cable.

  4. Yes sudo ./sixpair
    It does the Mac adress change and I have verified it many times. The BT dongle is verified and I can play with my wii remote so I know it’s working properly with the pi. Lsusb shows my BT dongle as well.

    • Ok, so you would want to unplug your controller and make sure all the lights are turned off. Type ‘sudo sixad -stop’ and then ‘sudo sixad -s’. Press the ps button on the controller you paired and it should say something like connection established with Playstation 3 controller. Can’t remember exactly what it says because I’m doing something else on my Pi right now.

  5. Ok I did that. It says unable to connect to the smb it sda or some 3 letter word like that… It never works tho.

      • Mine never connects. It attempted for like 30 mins yesterday and nothing. Tried 2 different Ps3 controllers. 1 thing that puzzles me is not being able to get them to work via USB…

  6. Are you use a ssh application like Putty to get into the Pi? I ask because I can get everything set up fine using Putty, but by default the Pi boots into emulationstation and I need a keyboard to exit emulation station, connect the controller, and re-run emulationstation otherwise it won’t connect the controller.

    Also, after it connects, you can type ‘ls /dev/input’
    Look for anything that says js[number]. Mine is showing up as js0. So then, type ‘jstest /dev/input/js[number]’. So in my case, it would say ‘jstest /dev/input/js0’. Then it should pop up with a screen with white letters that looks like a non-moving matrix screen. when you start pressing buttons on the controller, it should start looking like a white version of the matrix.

  7. No I’m connected directly to the pi. Nothing remote. When I do the ls /dev/input I get no jsxx. Only when it’s USB. When I do jtest it shows all these numbers but they never change. When I get home today, first thing ill do is hook up the controllers to the pc and make sure they work! They were brand new in package from amazon… Lets rule that out I guess? Hate to make all these comments on your site, would you rather take this to the forums or private email?

      • I have this same problem, with Sony controllers. Bluetooth is recognized fine. I can use the controllers when plugged in via USB, but just no joy getting beyond the sudo ./sixpair step.

      • OK, just figured this out via Michael’s post below. Search for: “SOLVED! Here’s the forum post that saved my life:”

        Now I get pairing and jstest works! Now to try a second control and within ES.

    • One adapter can handle at least 2 controllers at full speed. Any more and it starts lagging. Not sure how you would go about running 2 adapters. I would mess with it but I dont have another adapter or a 3rd controller.

  8. Ps3 controllers NO LONGER WORK WITH THE PIE!

    I have searched high and low! Hours and hours if time wasted in forums and irc chat. No more does the PS3 remote work.

    If someone figures out how to make it work please let me know!

  9. Hi everyone. I up was really late and then dreaming Linux code however I manage to set it up. I setup my PS3 controller via bluetooth with my RetroPie over the weekend. I used the instructions and settings contained in this blog post. I only setup one controller though because I only have one. I used the Asus USB-BT211 Mini Bluetooth Dongle.

    It is a work in progress though. I was able to setup the SNES and NES config files. For now I am only able to play NES and SNES games. I need to figure out the configs for Genesis and Sega Master System.

    Here is a YouTube video demonstration I made: http://youtu.be/nZBLEYisdfk

    • I’m very interested in knowing how you managed to get it to pair. No one I know can get it to work. Is it some file or something you can share? What was the issue?

      Details please!

      • I am a Linux n00b, so please forgive my ignorance. I had paired my PS3 controller with my Raspberry Pi. I assume you are following the steps outlined in this blog post. You know it was paired because. Type the following in the command line:

        jstest /dev/input/js0

        You should see a screen full of characters. You can test the controller by pressing various buttons. When you press a button you should see the characters on the screen shift. The characters on the screen responding to your button presses is a way to confirm the PS3 controller is paired.

        Also type in the command line:

        hciconfig

        (You should see this)
        hci0: Type: BR/EDR Bus: USB
        BD Address: 00:02:72:BF:BC:8F ACL MTU: 1022:8 SCO MTU: 121:3
        UP RUNNING PSCAN
        RX bytes:16777722 acl:289271 sco:0 events:116 errors:0
        TX bytes:2561 acl:53 sco:0 commands:56 errors:0

        If you get *UP RUNNING* you should be connected. With the latest build of RetroPie the PS3 Controller does NOT rumble when it pairs. The four red lights flash until it pairs at which point they simply stop flashing.

        I was frustrated because up to this point everything seemed on track. I still could not control the Emulation Station because my configs were not programmed properly. So I found this site and used the settings contained in this post for my:

        RetroPie/configs/all/retroarch.cfg
        ./.emulationstation/es_input.cfg
        /var/lib/sixad/profiles/default

        When I boot Emulation Station I have to hold the PS button on the PS3 Controller for it to pair. It takes anywhere from 30 seconds to 2 minutes to pair. The lights flash and when they stop flashing I know the controller is paired.

        I hope this helps you along. I was so close for a long time until it all came together.

  10. . I just spent some time getting it to work, and found some steps that need fixing:

    When you configure the controller with the actual emulators, the commands should be:

    cd ~/RetroPie/emulators/RetroArch/installdir/bin

    ./retroarch-joyconfig -o p1.cfg -p 1 -j 0

    ./retroarch-joyconfig -o p2.cfg -p 2 -j 1

    cat p*.cfg >> ~/RetroPie/configs/all/retroarch.cfg

    sudo nano ~/RetroPie/configs/all/retroarch.cfg

    There is also a typo, so when you check the retroarch.cfg file, make sure the last lines for P1 and P2 are:

    input_player1_r_y_minus_axis = “-3”

    and

    input_player2_r_y_minus_axis = “-3”

    Okay, hope that helps some people who may be confused, and if I’m wrong on any of these points (I very well could be) just respond below or message me.

  11. Hi!
    I’m having trouble to get my ps3 controller (2 controllers) to work in emulationstation….
    both controllers are paired with rpi and i see the response of the keys in jstest.
    i followed this tutorial step by step but still it won’t work in emulationstation….

    es_input.cfg (i posted the congig twice for 2 controllers) and retroarch.cfg (should this line: input_exit_emulator_btn = “16” also be posted twice??) look exactaly like above.
    (i also respected the fixed steps)

    could anyone please help me to get this to work….

    thx

  12. I’ve followed all these steps twice now, and I simply cannot get the second controller to work. They both pair, but only one will connect (by pressing th PS button) at a time. I only ever get one joystick device (/dev/input/js0). I would expect to also get js1 when I connect the second controller, but it just won’t happen. It’s alright to use the same USB port to pair both controllers, right? I’m forced to pair them one at a time, due to a lack of available USB ports on the Pi. I’m thoroughly stumped. Any ideas?

    • Yes pairing individually on the same USB port is alright. I haven’t used this setup in quite a while, but if I remember right, you have to exit emulation station. Turn the controllers on 1 at a time, then restart emulation station. Don’t forget you have to set up both controllers individually to work within emulationstation (input_player1 and input_player2)

      • Yeah, I don’t think it’s emulation station that’s the problem. The OS itself doesn’t seem to be creating a device binding for the second controller. Either will work on its own, but not both.

      • SOLVED! Here’s the forum post that saved my life:

        The error message “unable to connect to sdp session” is because the newer version of bluetoothd is not running the sdp socket in udev mode. Running the bluetoothd daemon without ‘–udev’ will not allow the PS3 controller to connect. I believe it has to do with the protocol Sony is using. The sdp session is used by sixad to determine which controller type is connected over bluetooth. If anyone wants to research how to get the sdp running in udev mode please do.

        For myself I modified the source code to ignore the controller type. Since I’m only using a PS3 controller I don’t care about the others. Here is how to modify the code. Assuming you already have the source code installed.

        In directory ‘QtSixA-1.5.1/sixad’ edit the file ‘bluetooth.cpp’. Change line #218 in the ‘l2cap_accept’ function.

        OLD:
        if (!legacy && req.vendor == 0x054c && req.product == 0x0268) {
        NEW:
        if (!legacy) {

        Next run the ‘make’ command. Followed by the ‘sudo make install’ command.

        Remember to restart the service or reboot the RPi.

  13. I tried:

    In directory ‘QtSixA-1.5.1/sixad’ edit the file ‘bluetooth.cpp’. Change line #218 in the ‘l2cap_accept’ function.

    OLD:
    if (!legacy && req.vendor == 0x054c && req.product == 0×0268) {
    NEW:
    if (!legacy) {

    and when i reboot both controllers rumble then disconnect soon after …

    if i check sixad it says this:

    sixad-sixaxis[15784]: Connected ‘PLAYSTATION(R)3 Controller (60:38:0E:C4:A0:15)’ [Battery 00]
    sixad-sixaxis[15784]: Bad Sixaxis buffer (out of battery?), disconneting now…

    any idea what im doing wrong?

  14. I am having the same issue as Sam and Steve. The controller appears to pair, player 1 indicator light is solid, and jstest works no problem. However, the controller does not work with emulationstation after configuring and reinstalling everything multiple times.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s