Use a PS3 Controller on Linux (USB)

With Steam recently coming to Linux, and all the great humble bundles, it’s becoming more and more important to have a good gamepad to use on your Linux PC. If you’re a console gamer, you probably already have an XBox 360 or a PS3 controller. In fact, plug in your controller via USB and it probably already works. Unfortunately, many games (Hotline Miami, Super Meat Boy, etc.) assume you have a 360 controller and the button mappings of a PS3 dualshock controller will be horribly skewed (the PS3 select button is 360′s A button). In some games, like Cave Story+, this is not a problem because they allow custom key mappings within the program. A few, like Steam Big Picture, correctly detect the PS3 controller. However, many games just assume a 360 controller, so it simplifies things if you make the dualshock pretend to be a 360 controller. Luckily, there’s a program that does just this: xboxdrv.

Setup

  1. Install the xboxdrv package. Or get it from the source.
    sudo apt-get install xboxdrv
  2. Plug in your PS3 DualShock controller via USB. The LEDs will flash. You should see relevant lines in your /var/log/syslog file (or equivalent, depending on your distribution – I’m using Ubuntu 13.04).
    usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
    usb 4-2: Product: PLAYSTATION(R)3 Controller
    usb 4-2: Manufacturer: Sony
    sony 0003:054C:0268.0008: Fixing up Sony Sixaxis report descriptor
    input: Sony PLAYSTATION(R)3 Controller as /devices/pci0000:00/0000:00:13.2/usb4/4-2/4-2:1.0/input/input18
    sony 0003:054C:0268.0008: input,hiddev0,hidraw0: USB HID v1.11 Joystick [Sony PLAYSTATION(R)3 Controller] on usb-0000:00:13.2-2/input0
  3. Press the PlayStation button to enable it. The LEDs will continue to flash, but input will now register.
  4. Run xboxdrv.
    sudo xboxdrv --detach-kernel-driver

    You may require one or both of “sudo” and “–detach-kernel-driver” above. If you get a LIBUSB_ERROR_ACCESS error, you’ll have to use sudo. If you get a LIBUSB_ERROR_ACCESS error, you can try the –detach-kernel-driver option.

  5. Play a game!

Other References

11 thoughts on “Use a PS3 Controller on Linux (USB)

  1. I’ve been unsuccessfully messing around with jscal to try to get this working, but your method works perfectly – thanks!!

    For Fedora 18 or 19, just replace step 1 with:
    yum install kernel-modules-extra (this gets you the required joydev kernel module)
    yum –enablerepo=updates-testing install xboxdrv (currently in the Fedora 18 and 19 testing repos, but should be in main soon)
    Reboot to use the new kernel module

    Link the the Fedora package listing: https://admin.fedoraproject.org/updates/xboxdrv

    • Glad it was useful! I went down a similar path as you and wondered why I didn’t encounter this solution before… hence this article. :)

      Thanks for the extra info!

  2. Pingback: LinuxGameCast Weekly EP66 — Right Is Left | Linux Game Cast

    • Hi Damian,
      Just type the following in the terminal: sudo xboxdrv --detach-kernel-driver, and press Enter. Modified the step a little to make that more clear. :)

  3. I can’t seem to get this running in steamOS…

    I get “xboxdrv has no instalation candidate”

    Then when i try to install the PPA i get “add-apt-repository: command not found”

    Then when i try to install “python-software-propertoes” i get “E: Invalid operation python-software-properties. please help

    • Hi Michael,

      If it said invalid operation, maybe you forgot the “install” before the package name?

      I’m not running SteamOS, but it looks like it’s based on Debian Wheezy (stable 7.1), so that might help when looking for information. It looks like you first have to add Debian’s repository to your apt sources. Take a look here for more information, and let me know how it goes.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>