Configure USB Gamepad on GNU/Linux

Kernel Configuration

First and foremost we need to configure our kernel. To do that, I have used a kernel version 2.6.21, although any 2.6 kernel would be all right. Basically, the USB gamepads and joysticks work using the uhid (USB Human Interface Device) in Linux, which contains support for keyboards, mouse and other USB input devices. Apart from this, to make Xmame or Dgen detect the device, we'll have to use another driver called Joystick Interface.

To let Xmame and Dgen work correctly, we need to enable the driver Joystick Interface 1.x. Any 2.6 kernel will have a 1.x or higher version of Joystick Interface driver; moreover, in the 2.6.21 kernel, actually, there's a Joystick driver 2.0. So we just need now to enable the following options in our menuconfig:

  • Device Drivers --->
    • Input device support --->
      • <*> Joystick interface
      • <*> Event interface
    • [*] USB support --->
      • <*> USB Human Interface Device (full HID) support

With this, basically, that's all. Now we recompile the kernel and reboot the system to use the new code. Needless to say, the fanatics of modules can build everything separately in modules and then load them without any problem. I do it this way because I like to include everything in kernel since I do an intensive use of everything.

Software Installation

Once we have our new kernel up and running, we have to install the package joystick, which will provide the userland support for gamepads and joysticks. In Debian, just do as it follows:

~$ sudo apt-get install joystick

Alternatively, you can use a software named jscalibrator to calibrate the joysticks and gamepads. However, many modern games (such as TORCS) have a built-in gamepad calibrator.

Using the Gamepad

I only use it with xmame and dgen emulators. To use it with other programs you'd need to read the manual or surf a bit on Internet. I'll explain how to use the gamepad with the two emulators mentioned above.

~$ xmame -jt 1 -jdev /dev/input/js0 [our_options] romfile
Launching Xmame with Joystick/Gamepad support

Just that. To use it with the dgen emulator you'll need to do:

~$ dgen -j [our_options] romfile
Launching Dgen with Joystick/Gamepad support

Notice that you will have to manually edit your ~/.dgenrc in order to set up the keymap for other users.

www.claudiocamacho.org
Updated on Friday, 19 September 2008 21:03