måndag 3 oktober 2011

Mamepanel with Linux

The Mamepanel is great when building an usb arcade controller. It's a customizable (at build time) joystick/keyboard/volume control in one AVR uC. One drawback is that my two joystick setup wasn't recognized as two 8 button joysticks but rather as one joystick with 18 buttons. This is a known problem with using AVRUSB with a Linux-machine.
The only solution i found to the problem was to recompile the Linux usbhid module and mark the Mamepanel as quirky.
This is how I did it on Debian Lenny:
as root:
Get the source
aptitude update
aptitude install linux-source
tar jxvf /usr/src/linux-source-2.6.26.tar.bz2 linux-source-2.6.26/drivers/hid
cd linux-source-2.6.26/drivers/hid
Add these lines where they fit in /usr/src/linux-source-2.6.26/drivers/hid/usbhid/hid-quirks.c. The USB_DEVICE_ID_WIKIDOT_MAMEPANEL32 device id should probably be changed to something else if an ATMEGA8 is used (can be checked with lsusb).
#define USB_VENDOR_ID_VOTI           0x16c0
#define USB_DEVICE_ID_VOTI_MAMEPANEL32       0x05df
{ USB_VENDOR_ID_VOTI, USB_DEVICE_ID_VOTI_MAMEPANEL32, HID_QUIRK_MULTI_INPUT },
Build and load the new module (It's probably a good idea to check that usbhid.ko exists before rmmodding the old one)
make -C /usr/src/linux-headers-$(uname -r) M=$(pwd) modules
cd usbhid/
rmmod usbhid && insmod usbhid.ko
hope for the best.