rebuilding the kernel
  • Hello everybody :)

    I recently installed pimame onto one of my Pis, and really got the hang of the old snes and ps1 games. nice stuff :)

    now in order to be able to play these games in style, i wanted to hook up some original controller hardware. I already succeeded in fitting an Arduino Leonardo as an "adapter" between an old SNES gamepad and the Pi, and it works great!

    So yesterday I wanted to extend the setup to the second controller, and here's where it becomes a bit techy. The firmware on the Arduino seems to work (I set up the HID descriptors to the best of my knowledge, and it also shows as two gamepads when i hook it up to an old WinXP machine) but the pimame detects the setup as one joystick with 4 axes and 18 buttons.

    Though I might even make this work for some emulators, I'd really like to see those pads listed as separate device (/dev/input/js0, js1 and maybe even js2 and 3... I bought 4 connectors, just don't have that many gamepads).

    Now my googling has brought me to the point where I think that this might be an issue with the linux kernel USB HID driver, more specifically: There's a quirk inside the linux kernel named "HID_QUIRK_MULTI_INPUT" which is supposed to enable exactly the desired behaviour.

    The problem with that quirk is: it needs to be enabled for my specific USB vendor id / device id in the kernel source code, which in turns brings me to the point where I need to recompile the pimame kernel in order to confirm my theory (and hopefully make things work).

    So to round things up, my simple questions would be: What's the base for the pimame kernel? Since I believe it's based on Raspbian, will the original kernel sources from https://github.com/raspberrypi/linux work? which branch was used? what patches are applied?

    I've been doing linux for some time, and compiled kernels before (I've done it on the Pi, too) so I guess I could pick it up from there again if somebody could fill in my blanks :)

    Cheers
    J
  • 15 minutes later and I stumbled across an easier solution that will work perfectly fine (and still proves the theory. now look at that ^^). I'll leave it here, just in case.

    Luckily, the kernel developers did not only include those quirks... They also set up configuration parameters, that allow us to enable them in such unforeseen cases as mine. More specifically, the "usbhid" module has a parameter named "quirks" that can be passed at module load time.

    I was not aware of that parameter since pimame does not have that module - usbhid is compiled into the kernel itself, and as such I cannot pass that parameter through modprobe and the likes.

    It is still possible however to pass that parameter - but it needs to be at boot time. and so by simply appending "usbhid.quirks=0x2341:0x8036:0x0040" to /boot/cmdline.txt, i could make it work.

    0x2341 = vendor id (Arduino SA)
    0x8036 = product id (supposedly Leonardo; shows up blank in listings though)
    0x0040 = HID_QUIRK_MULTI_INPUT (see http://lxr.free-electrons.com/source/include/linux/hid.h#L285)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!