Friday, November 15, 2013

Arcade controls for my homebrew arcade machine


Sticks and buttons

I got my stick and buttons off an online auction site (www.trademe.co.nz). They are all genuine arcade parts. I bought one Sanwa 8 way joystick, and four Streetfighter style buttons (which are concave, rather than convex). I prefer those buttons, as most arcade machines I played on had that style of button. I also bought two player 1/player 2 buttons with the intention of having a seperate (home made) coin mech for credits.








I only bought 4 buttons because I don't like fighting games, which usually require 6. There is a web page (I can't find it again) which shows stats for the number of buttons used, by far 3 or 4 buttons was the most common. I also bought only one stick, for a couple of reasons. Mostly, it was quite expensive, and I wasn't sure how successful my hack would be. Given the issues I've since had with the keyboard hack, I think if I was doing a multi-player cabinet I would get some actual joysticks. Keyboards don't seem to be designed for too many key inputs at once.

The keyboard that I used had a limited number of buttons which could be pressed at once, due to the way the key matrix is set up. I'd say that most keyboards are like that.

However, if I can modify my control panel so the buttons are removable, then I would happily set up something which would hot-swap a button/joystick panel for twinstick shooters.

Wiring a keyboard as a joystick + buttons:

I pulled apart an old ps2 keyboard. You could equally pull apart (or use) a USB joystick. I thought about buying one of -these- USB joysticks and putting it part, but ultimately decided to go with a keybaord.

Inside, there is a board which allows each key press to be interpreted as a letter.


I took 3 goes before I finally wired my keyboard correctly! I got instructions for wiring the keyboard from this instructible and soldered  it up. However, I skipped step 4 (which requires using a multimeter to get the keycodes) and hooked the keyboard up to my computer. Using a bit of wire, I simulated pressing a key by shorting the contacts for each key, and mapped out each key on a piece of paper, in a grid.



I found out the keys pressed by running testkeys from the mame-tools package. This is better than just pressing keys on the console or a text editor, as it will display non-printing characters, such as shift (and even say if its left or right shift). The reason I took so many tries to do the joystick was because some of the keys would block other keys from being pressed. Eg (use example from the keycode matrix)

This page explains how keyboard matricies work. Effectively, I had hooked up my keyboard so the key A1 and A3 could be pressed at once: A1 was
"joystick left" and Button 2 was A3. The keyboard didn't know both keys were being pressed at once, and would only send the first input. So I couldn't move when I had a button held down. So I needed to pull out all of my connections and start over.

I started out with hooks made from paperclips, but ended up soldering it in the end, as I thought it might be more robust. If I ever redo it, I'll try drilling wiring holes in the circuit board, and solder the wires through, instead of soldering it directly on. I'll also use some kind of quick release system or something so I don't waste so much heat shrink tubing. Too many of the contacts either came off when I was resoldering, or  got  pulled off by the weight of the harness (or my impatience).






I did make quick release end bits for the switch ends of the wires, so I could rewire the switches if I needed to. They worked really well, though I used a lot of heatshrink tubing to make them neat and tidy.

I'm not sure what I would do for twinsticks, but I could have it so the second stick uses the same keys as the four buttons, and have the buttons/extra stick each on their own removable baseplate.

Or I could make another cabinet, for twinstick shooters :P



No comments: