Subscribe via RSS
5Mar/1113

Creating your own MAME Arcade Controllers

Right, now for something completely different... The following article goes out to all those 80s kids who remember that familiar clicking sound of real mechanical microswitches. We all spent our pocketmoney on Bubble Bobble, Snow Bros, Rampage, Street Fighter; but now you don't have to. Just install MAME and build the following controllers...

Here's the photo album of the construction of the controllers...

Note, before starting this, you should really just skip the keyboard hacking and buy one of these.
Also, for a LOT of information on doing this, visit Arcade Controls.

Initial thinking...

All peripherals for a computer need to connect via an I/O port. Although there are quite a few available on most modern machines, the one we will use is USB. I've chosen this port because they will be around for decades and the old style Serial, LPT and Gameports have pretty much already been phased out.

Now, there are many options once we choose USB:

From the above, the cheapest method is to rip open a keyboard. Officeworks here in Australia was selling the Microsoft Wired Keyboard 600 for AUD$11.97 and I couldn't resist.

MS USB Keyboard

One big question here was cabling. Once I'd hacked a keyboard apart and wired up one controller.. would I then use other keys from that first keyboard and run a cable to the second controller? I looked at the price of data cabling and realised it was cheaper to buy another USB keyboard than it was to rig up a sophisticated central box that both controllers ran to.

I therefore bought 2 USB keyboards.

Now, there is an issue here... I will be 'emulating' keyboard buttons presses when the joystick buttons are pressed. Since once computer can accept multiple different keypresses at once, this will work, but it cannot distinguish multiple presses of the same letter/key from different keyboards (i.e. if the 'A' key is pressed from two different devices.) This means that the second controller will have to be mapped to a different set of keys... pretty obvious, yes?

Update/Note that buttons 5 and 6 for Player 2 aren't set by default... I've set these to I and K as they were free... for some reasons I didn't check Player 3 and 4 controls first and this is a direct conflict with Player 3 directional keys! So, you can use the below but be careful... in my this blog post I've remapped them to U and O respectively.

Button Keymapping 1 Pins Keymapping 2 Pins
Joy UP UP 12, 24 R 11, 22
Joy LEFT LEFT 12, 26 D 16, 21
Joy DOWN DOWN 4, 26 F 11, 21
Joy RIGHT RIGHT 8, 26 G 11, 24
Button 1 L-CTRL 13, 25 A 18, 21
Button 2 L-ALT 9, 24 S 17, 24
Button 3 SPACE 1, 26 Q 18, 22
Button 4 L-SHIFT 10, 23 W 17, 23
Button 5 Z 18, 20 I 6, 22
Button 6 X 17, 20 K 6, 21
Player Button 1 18, 19 2 17, 19
Insert Coin 5 11, 25 6 7, 25

Hardware

So, from the above, you'll need 2 USB keyboards for the PC interface. You'll then need the actual arcade joysticks and controls. Below is the kit I found recently on eBay for around AUD$50. I'm sure you could get it cheaper; my purchase was on a very large impulse and I had a few regrets afterwards as there were better joysticks on offer for the same price.

Arcade Controller Kit Player 1 and Player 2 Joysticks!

The buttons themselves are exactly what you'd find in real arcade machines... the microswitches make their motion feel perfect as well.

Arcade Button

Arcade Button + Microswitch

So, with all the components, it's now time to get it connected together. Start by ripping open the keyboard...

Decoding a USB Keyboard

Keyboards are built on a matrix. Just like the LED project previously with the Arduino, each button on a keyboard is connected to one row and one column of the circuit board inside. The circuit board will scan each row and column hundreds of times a second to check which buttons are pressed and then report this back to the computer.

Dismantling MS USB Keyboard

Opened USB Keyboard Button layering Controller + Keyboard Matrix

Splitting Matrix

As you can see above, the controller inside the keyboard is not soldered to the matrix. This is great news as I was expecting to have had to solder to fiddly little wires instead of the nice connection pads that you can see.

Firstly I pulled out the multimeter and started decoding the keys I'd need to use. To do this I put one probe on the pad circle of the key and I then ran the other probe across the connection to see which wire it connected to... I then recorded all of my findings:

Multimeter

Deciphered key codes

The data I gathered is in the table above. Each key has two pins and these map from left to right on the controller connection seen above. I have only decoded the keys that I need, but it's easy enough to work out the rest when you have an opened keyboard in front of you.

I then began to wire up the controllers. One the first attempt, I thought I would solder short wires to the controller and then use these for connection points. This worked OK until I was up to the final wires. It seems that constant moving around of the controller puts pressure on the soldered joints and I ripped many of the tracks off. I then had to get my tiny copper wire and re-solder the tracks as the pads were gone. This became quite tedious, but I learnt my lesson very quickly.

Soldering to controller Broke a track... Copper to the rescue Player 1 controller wired

I got enough of the wires connected for the first joystick and then quickly connected it to test. I then managed to play a quick game of Bubble Bobble. Impressive! You can see below my initial prototype housing for the controls. The washing basket was the worst idea on earth... but it was a cheap mistake.

Mounted on cardboard for test Failed washing basket prototype Playing Bubble Bobble

Building real housing

I ended up at Bunnings looking for ideas for a box to house the controls. There was nothing off-the-shelf, so I opted for enough wood to make a deep enough box for the controls. This was a pretty simple and ugly construction... but it did the job.

Construction of actual housing Marking out control spacing Construction of actual housing
Building Player 2 Power drill + Hole saw So much quicker than manual drill
Wiring up the controls Completely wired up Player 1 controller ready

Finished products

After testing, I put backing panels on both of the controllers.

Controller done

Each controller can only ever be used as Player 1 and Player 2 respectively as they are mapped to specific keys on the keyboard.

Player 2 finished

Of course, you could change the configuration of MAME, but that would be tedious... Although sometimes on games it'd be nice to be able to play as one of the other 2 players (3 or 4) ... but I'll create two more controllers for that.

Future plans

I want to build two more of these (actualy, I did, here's the link!)... 'The Simpsons' arcade and 'Teenage Mutant Ninja Turtles' require 4 players for the most amount of fun, and 'Rampage' needs all three creatures bashing up buildings.