Now Working with Mame!

A project log for USB Crank-Stick

wheel based game controller

PixJuanPixJuan 07/29/2020 at 04:500 Comments

To test my device, I was just using a text editor on my Linux box to see if some characters are printed when I turn the crank. As it was working well enough I started Mame to test it with a game and... Segfault :-(
  I tried it on my Debian, on a Linux Mint, with the latest version of Mame and it still segfaults!
  What's wrong? I played Sabotage many times on Mame, why is Mame segfaulting now? It segfaults on startup when I start Mame with my device plugged in, while without it is working fine. If I am plugging my joystick after I launch Mame, it doesn't always segfault... but i doesn't work very well.

I had 2 distinct problems :

My code was based on the examples included in the Arduino so I suppose it I didn't make any mistakes. The code is pretty basic I just used Keyboard.write()
In Mame my device seems to be working just a bit, like a one in twenty pulse. So I though I could just increase the length of the key presses... and that's when I noticed I was using the wrong function! Keyboard.write() is designed to spit chars as fast as possible. This is perfect if you want to make a rubber ducky style device, not if you want to make a game controller. So the functions I am supposed to use are and Keyboard.release(). It's working much better now!

  Concerning Mame, I opened a ticket and waited for the developers to fix it. I suppose it is not a high priority problem and quite a difficult one to reproduce if you don't have a Teensy. I finally found the cause of the bug was that the Teensy USB "stack" declares itself as a joystick with 33 axes and 143 buttons !
I did a quickfix by myself but it didn't get accepted, which is ok because I can not guarantee it doesn't break something else. After that, one of the dev provided a fix that works for me.