Use an Xbox360 controller with Vagrant on Mac

More than one person on the internet wanted to use a wired Xbox360 controller in a Vagrant VM, but most of the instructions I found are incomplete, or they flat out don't work. I found the following instructions to work swimmingly.

Step 1 - Install VirtualBox

Install VirtualBox and the corresponding version of VirtualBox Extension Pack. Both can be found here:

Step 2 - Install controller

Install version >= 0.15 of 360Controller. It makes your wired Xbox360 controller work on Mac OS X. Find that here:

Optionally, after that install, install Controllers Lite from the app store. Plug in your controller and then open the app. The app should reflect your button presses and joystick movements. Then, unplug the controller.

Step 3 - Controller info

On the success of the previous steps, go to Apple+Option > System Information > USB > Controller and record the Product ID and Vendor ID attributes.

Step 4 - Vagrantfile

Add these lines to the appropriate position in your Vagrantfile:

vb.customize ["modifyvm", :id, "--usb", "on"]
vb.customize ["modifyvm", :id, "--usbehci", "on"]
vb.customize ["usbfilter", "add", "0",
  "--target", :id,
  "--name", "xbox360",
  "--vendorid", “<your vendor id>“,
  "--productid", “<your product id>“]

Save the file, then `vagrant reload`. After the machine reboots, `vagrant ssh` into the VM.

Step 5 - Install drivers

  • modprobe joydev
  • sudo apt-get install joystick xboxdrv
  • Plug in your controller
  • At this point, running lsusb should display your controller.
  • xboxdrv
  • After some positive stdout about finding the controller, any manual input to the controller will produce representative data in the terminal.
  • Kill xboxdrv

Step 6 - Start on boot

  • sudoedit /etc/init/xboxdrv.conf
  • Add the contents:
start on filesystem
exec xboxdrv -D
expect fork
  • echo "joydev" | sudo tee --append /etc/modules