[HOW TO] Use Xbox 360 controller as mouse in Xubuntu

With the help of xboxdrv, the Userspace Xbox USB Gamepad Driver for Linux, the Xbox 360 controller can be used in Xubuntu as a mouse.

Install

Open a terminal window and run:

sudo apt-get install xboxdrv -y

Usage

Open a terminal window and run:

sudo rmmod xpad
sudo xboxdrv --mouse

Running the last command will make the Xbox 360 Controller produce the following key events:

  • LS (move): move mouse cursor
  • LS (click): backspace
  • LS (move): mouse scroll
  • RS (click): space
  • D-Pad: up/down/left/right
  • Reset: Alt+Left
  • Start: Alt+Right
  • LB: PageUp
  • LT: VolumeDown
  • RB: PageDown
  • RT: VolumeUp
  • Y: enter
  • A: mouse left-click
  • B: mouse right-click
  • X: mouse middle-click

Note: This also works for the original Xbox controller, however I didn't have the chance to test and register the event mapping.

References

Userspace Xbox/Xbox360 USB Gamepad Driver for Linux

Comments

  1. I am getting an error saying that the xpad module does not exist and cannot figure out how to fix it. Any ideas?

    ReplyDelete
    Replies
    1. If the error happens when running the first command (rmmod) don't worry. I just added this command because xboxdrv would complain if the xpad module was loaded.
      Just run the second command (xbox-controller) and it should work :)

      Delete
  2. ive tried to run command and it asks for my password but it wont let me type ive tried copy and pasting but couldnt either would appreciate any help thanx

    ReplyDelete
    Replies
    1. You could try becoming root, prior to running the commands, using: sudo -s

      Delete
    2. Linux console hides the password, you are typing but it does not show anything. <-- for future users with similar issue

      Delete
  3. I tried and it says "command not found" (xbox controller)

    ReplyDelete
    Replies
    1. I'm so sorry. Actually there was a mistake: it's xboxdrv and not xbox-controller.

      xbox-controller is a shell script that I wrote to include the two commands (rmmod and xboxdrv) and not having to type them everytime.

      Again, I apologize for the mistake.

      Delete
    2. ok i recieved the following error

      -- [ ERROR ] ------------------------------------------------------
      Error couldn't claim the USB interface: LIBUSB_ERROR_BUSY
      Try to run 'rmmod xpad' and then xboxdrv again or start xboxdrv with the option --detach-kernel-driver.

      Delete
    3. Just to be sure, confirm that you have run the command "sudo rmmod xpad" prior to running "sudo xboxdrv --mouse"

      Delete
  4. Ok i got it figured out, but is there a way i can remap?

    ReplyDelete
    Replies
    1. I don't how to remap the buttons globally, but I'll investigate on that. I did the remapping in the application where I used the controller.

      Delete
    2. Ok thanks i wold be extremely greatful:D

      Delete
    3. Here's how to remap: http://goo.gl/7rFsb

      Delete
  5. It was working but i closed the terminal and tried it again and it gave me this... "Module xpad does not exist in /proc/modules"
    Dont know how to fix this...

    ReplyDelete
    Replies
    1. You only need to run rmmod once per session. When you reboot you must run it again before xboxdrv. Then you can run xboxdrv as mamy times as you want.

      Also, if you close the terminal where xboxdrv is running, the controller will stop working as a mouse.

      Delete
  6. This comment has been removed by the author.

    ReplyDelete
  7. How to write the script to automatically start controller with system to use it as a --mouse ?

    ReplyDelete
    Replies
    1. To answer this i'll point you to this guide available at nixCraft. Please let me know if you need further assistance.

      Delete
    2. Here's the guide: http://www.cyberciti.biz/tips/linux-how-to-run-a-command-when-boots-up.html

      Delete
  8. Thanks i hope this will solve my problem while i wait for a new mouse

    ReplyDelete
  9. hi, sorry for bothering, please help

    when i write sudo rmmod xpad i ged

    root@eduardo-HP-Mini-110-1100:~# sudo rmmod xpad
    rmmod: ERROR: Module xpad is not currently loaded








    then, when I write sudo xboxdrv --mouse i get

    root@eduardo-HP-Mini-110-1100:~# sudo xboxdrv --mouse
    xboxdrv 0.8.5 - http://pingus.seul.org/~grumbel/xboxdrv/
    Copyright © 2008-2011 Ingo Ruhnke
    Licensed under GNU GPL version 3 or later
    This program comes with ABSOLUTELY NO WARRANTY.
    This is free software, and you are welcome to redistribute it under certain
    conditions; see the file COPYING for details.

    Controller: Microsoft Xbox 360 Play&Charge Kit
    Vendor/Product: 045e:028f
    USB Path: 005:008
    Controller Type: Xbox360 Play&Charge

    -- [ ERROR ] ------------------------------------------------------
    The Xbox360 Play&Charge cable is for recharging only, it does not transmit data, thus xboxdrv can't support it. You have to get a wireless receiver:

    * http://www.xbox.com/en-ca/hardware/x/xbox360wirelessgamingreceiver/
    -------

    help please, and thank you!!

    ReplyDelete
    Replies
    1. It's OK for the rmmod command to fail.
      However, it seems that the controller you're using is a wireless controller, not an usb controller, so it won't work.

      Delete
  10. helo Wilson,
    it worked well here, thank you! However, when I close the terminal, the controller stops. Is this normal?

    ReplyDelete
    Replies
    1. Yes it is. It stops because the xboxdrv is killed when the terminal is closed.
      If you want to keep xboxdrv running and close the terminal first run: sudo -s
      Now run: nohup xboxdrv --mouse &

      Close the terminal

      Delete

Post a Comment

Popular posts from this blog

[HOW TO] Create QR Codes in Xubuntu 12.04

[FIX] VLC is unable to open the MRL (smb://)

Add items to Xfce Applications Menu