The two main schools of thought for interfacing the controls to the PC are to either hack a keyboard, or buy a keyboard encoder. Since I was feeling witty, I first decided to go with the keyboard hack. I used the controller chip from a Gateway 2000 keyboard, and started to map it out with my multimeter. Unfortunately, I must have somehow crossed one of the 5V LED leads on the keyboard to one of the other leads on the keyboard PCB or something, because I ended up frying the motherboard of my PC!
The stupid thing is, I had two spare (but working) 486s sitting in the basement that I could have used while experimenting around, but noooooo...I had to use my main PC and fry the board out on that one! And this was at a time when money was pretty tight, and buying a new motherboard wasn't just an easy purchase. Man, I was pissed. I came so close to just giving up on the whole project altogether at this point, but for whatever reason (my love for failure?), I continued on.
So after getting a new motherboard, I decided to just cut my losses and go ahead and purchase a keyboard encoder from Hagstrom Electronics. If I had to do it all over again, I would still buy the LP-24. It's a great little piece of hardware.
The LP-24 has 24 distinct I/O pins on it, and it's fully programmable. You can use it one of two ways:
As with any matrix, there is always a chance of key ghosting. However, if you plan your layout right, this should never be a problem. I saw a really good matrix layout by someone named John on the BYOAC FAQ site, so I used his and modified it a little to fit my needs.
This is how I programmed the matrix on my LP24:
|B||D1||R1||D2||R2||2-1||2-2||2-3||2-4||2-5||2-6||Cfg||Sel||Quit||Frm Skip||Speed Togl|
These controls map out to these keys:
|A||Up||Left||L ctrl||L alt||Spc||L shift||Z||X||R||D||1||2||3||4||F3||P|
This is the actual layout of the control panel. By looking at the above two tables and this picture, you can see how I mapped the matrix, and where exactly those keystrokes are placed on the panel.
The only possible chance of ghosting occurs when two keys in the same column are hit simultaneously. However, with this layout, that'll pretty much never happen. Since joysticks cannot be both up and down or left and right at the same time, there is no chance of ghosting there. Any other "overlaps" of keys being in the same column are non-gameplay buttons, so it turns into a moot point. Yeah, you'll most likely get key ghosting if you do something stupid like start mashing every key on the control panel at once just to see what happens, but you're more likely to get punted out of my house before you see any key ghosting.
I wired the pins from the LP-24 to terminal blocks for ease of connecting. Word to the wise: if you go with a matrix like the one that I did, make sure that you have multiple terminals set up to accept the "A" and "B" inputs, because they sure ain't all fitting into two slots! If you look closely at the picture that shows my wiring job, you can see the LP-24 and then 3 sets of 8-wide terminal blocks to the right of it. However, after I mounted all of this and started wiring it up, I figured out that hard way that I would have to be able to fit 16 wires into one damn slot for both the "A" and "B" inputs! So, I picked up one more 8-wide terminal block, mounted it to the left of the LP-24, and connected two wires over from the original "A" and "B" slots, so that the first four terminals on the left-hand block are all for "A", and the second four are all for "B".
I used 22 AWG solid wire from Radio Shack for my wiring. I used red wire to go from the "N/O" ("normally open") prongs on the microswitchs to the "numbers" (or "columns" of the matrix) slots on the terminal blocks, and green and black wire to go from the ground prongs on the microswitches to the "letters" (or "rows" of the matrix) slots on the terminal blocks. I also painstakingly labeled every wire on both sides of the connection, just to make potential future troubleshooting easier. The wires are bare and are just screwed down on the terminal block end, but I attached .187 insulated crimp female quick-disconnects on the wires to connect to the prongs of the microswitches. This not only makes them secure, but easy to unplug and re-plug if I need to. I find solid wire much easier to work with than stranded wire, but your mileage may vary.
And of course, I tested each and every connection between the terminal blocks and their respective microswitches with a multimeter before actually plugging everything into the LP-24. I'd rather find out at THIS point that I've made a mistake in the wiring than mount the panel into the cabinet and wonder why a certain button isn't working. Amazingly, everything lit right up on my first attempt. It was time to close this baby up and mount 'er in.