CentiPied: Centipede Arcade Restoration and Raspberry Pi Conversion


Human Inputs (AKA, Buttons and Trackball)

There were a few options here. Like was stated previously, GPIO was out because of the trackball. I had seen something online for like $20 that was a Atari Trackball to PS/2 (Here). That might work, but might not - it said Happ or Atari, and I wasn't sure if this was too old to work with it, since I know there were a few versions. Then I had a better idea - I had remembered the Teensy 2.0 board that I had bought, and actually bought it with something like this in mind. I was thinking about using it like a mini replacement for the I-Pac and Opti-Pac in my Sarkade cabinet (which take care of button and trackball/spinner inputs, respectively). I knew it could be used like a USB joystick, mouse, or keyboard, so it would be perfect, as long as it was fast enough to poll the keys as well as the trackball rotary encoders. After a quick search, sure enough, there was code out there for using it for rotary encoders, so I hoped it would work in my case with minimal modification.

With my work cut out for me, I set ahead to try and get the 'easy' part working: the buttons. I needed to be able to control the current game, yet have a way to exit the game to the front end, and have the same inputs control and select the game from the front end.

So instead of 1K I put in 10K and it worked on the PC just fine. So, hooked it back up to the Raspberry Pi, powered it up and...nothing. What the heck. Tried to check the voltage on the IR receivers when rotating the spinners, and the signal seemed to stay too high. At this point I figured it had to be a resistors being the wrong value, being in the circuit of the arcade acting differently for various reason, so I put in a couple of trim pots in place of the resistors so I could try different values in real time until I found the right range. After some trial and error it seemed that 2.2K seemed to be the right value for the four resistors.

With that figured out, I could finally control Centipede with the trackball. Or so I thought. I had the trackball working great, I installed gpm and could see the trackball moving the cursor from the console just fine. However when I fired up the game, no input. Well, had to be some mame configuration issue I was missing. I went through all the docs, changed config settings for the mouse, joystick, etc., over and over, different values set on and off. It was seriously frustrating. Nothing worked.

After exhaustive searches which would usually end up with me sifting through forum posts, I finally found something interesting: apparently mame4all will use whatever device it finds first, be it a joystick, mouse, etc. So my guess was that maybe it was seeing the joystick USB device since the Teensy USB driver uses the keyboard and mouse also includes the joystick as well. So within /dev/input, I saw 'js0', and I removed it. (Looking back though the notes I removed 'event3' as well, I can't remember how I came to the conclusion that one was associated with the joystick.) Fired up Centipede, and after all this work, I finally could see light at the end of the tunnel - it worked! The analog values in MAME needed to be set a bit higher, but other than that, it was working. However, I noticed if I spun the ball a bit too fast, it wouldn't register the movement. Luckily there was a fix I found after searching. From playermissle.com:

Mouse Polling

For trackball and spinner emulation, the default polling rate is apparently slow enough that fast movements can cause emulators to see movement in the opposite direction. The solution is to decrease the polling interval by changing a boot parameter by editing /boot/cmdline.txt and adding usbhid.mousepoll=(number in ms) where the number to add is:

1000 hz = 1 ms
500 hz = 2 ms
250 hz = 4 ms
125 hz = 8 ms
100 hz = 10 ms

This comes at the price of CPU processing of course. I set mine to usbhid.mousepoll=2 and works great.