Monday, September 07, 2015

Linux Support for Arduino Leonardo / Micro USB Game Controllers

A few months ago I posted an article that described how 3 USB game controllers could be added to the Arduino Leonardo and the Arduino Micro. Out of the box, they look like a USB serial port, keyboard, and mouse to the host computer, but with these modifications they can also look like 3 game controllers. This works great on Microsoft Windows (I have tested it on 7, 8.1, and 10), but it does not work on Linux.

If you plug the modified Arduino Leonardo or Arduino Micro into a machine running Linux and do a listing on the input devices, you will see the Arduino mouse, but not the joysticks.

Before Plugging in the Arduino Leonardo or Micro

BeforePluggingIn

After Plugging in the Arduino Leonardo

LeonardoBeforeConfigurationChange

After Plugging in the Arduino Micro

MicroBeforeConfigurationChangeCropped

To get this to work on Linux, you need to adjust a setting on the usbhid driver. This can be done by editing the /boot/cmdline.txt file. Add the following string to the end of the line of text in this file (there should only be one line of text in this file):

For the Arduino Leonardo

usbhid.quirks=0x2341:0x8036:0x040

For the Arduino Micro

usbhid.quirks=0x2341:0x8037:0x040

Explanation

0x2341 is the Vendor ID for Arduino
0x8036 is the Product ID for the Leonardo
0x8037 is the Product ID for the Micro
0x040 indicates the Multiple Input “quirk” should be used (i.e. HID_QUIRK_MULTI_INPUT)

Example

cmdline.txt_Update

After changing the /boot/cmdline.txt file the Linux machine will need to be rebooted. You will need to have root privileges to edit the /boot/cmdline.txt file. Now when the modified Arduino Leonardo or Arduino Micro is plugged in, three new joysticks will appear.

After Applying Setting – Arduino Leonardo

LeonardoAfterConfigurationChange

After Applying Setting – Arduino Micro

MicroAfterConfigurationChangeCropped

No comments: