The Bi-Weekly British Backtrack - The Keyboard Hack
by, 17-09-11 at 09:35 (2416 Views)
Well, no series of blogs about MAME would be complete without mention of the keyboard hack, and though it is a little bit dated nowadays and there really isn't that much need for them nowadays, they can still be done if you want to make a low budget Arcade Cab control panel.
First off, what is a keyboard hack? Well, if you think back to when I described configuring my control panel and getting the arcade controls to interact with my Windows PC, then there is every chance you’ll remember me mentioning the i-Pac, a neat little IC Board that you connect to the PC with either USB or PS/2 and then you wire each and every button and joystick switch to it. The i-Pac then translates button presses and joystick movements into signals that the PC can understand and pass on to M.A.M.E. or whatever emulator you happen to be running at the time.
Well, before the days of the i-Pac, when all this was nowt but fields, there were other ways to do things like that, and the main one was with a keyboard hack, which meant literally hacking into a keyboard and taking it apart, but that was just the beginning of the fun.
Would I recommend you use a keyboard hack in your modern day cab? No.
I would recommend that you use the I-Pac or a similar device, but if you don't have the budget, or simply have lots of time and keyboards then give it a go.
ADVANTAGES OF A KEYBOARD HACK
COST - If you’ve got some basic electrical tools then your total cost is that of the keyboard which can be bought for next to nothing, if you don't already have a spare one of course.
INPUTS - A keyboard hack will allow over 100 separate inputs, however only probably 16 of these can be pressed simultaneously. This is more than any other option and probably more than you would ever need.
DISADVANTAGES OF A KEYBOARD HACK
SOLDERING - Even if you know how to solder, a drip in the wrong place could mean that you fry your motherboard. That's bad. very bad.
TIME - If you have a lot of it, fine, if not just buy an I-Pac.
PROGRAMMABILITY - A keyboard hack is non-programmable. While M.A.M.E. allows reassignment of all input keys this is not a problem, but for other emulators it might be critical.
BUILD EASE AND QUALITY An I-Pac is a Printed Circuit Board with a terminal strip that the input wires attach to, and a detachable cable to connect to the PC. There is very little possibility of damage. A keyboard hack generally has the keyboard cable soldered to the PCB with a mess of wires soldered to the inputs sides. The entire assembly is much more flimsy, and should either one "die", with a dedicated encoder you just purchase a new one, unwire the old one, and wire the new one up to the same wires. If your keyboard hack dies you probably won't find the exact same model keyboard so you will have to start all over again and then re-configure M.A.M.E. to match the new inputs.
SIMULTANEOUS INPUTS - If you’re playing a multiplayer game then there may be times when you need more than the available limit of simultaneous key presses. Further to the limitations already mentioned, there is usually a hardcoded limit on the number of simultaneous key presses which reduces the amount of RAM required in the keyboard microcontroller.
Why is this such an issue? Because of Key Ghosting, Key Blocking and Key Masking.
Basically, newer keyboards work by scanning a matrix and when three keys that form the corners of any rectangle anywhere on the matrix are depressed, one of two things happen, either the keyboard will assume that the key marking the fourth corner of the rectangle is also depressed and send this key to the computer (key ghosting), or the third key will not register (key blocking). In addition, if ghosting occurs, if the fourth key of the rectangle is depressed simultaneously and one of the other keys is released, the key release will not register (key masking).
Bear in mind that even a single player game like Robotron using two joysticks with diagonals can generate four simultaneous key presses without any other buttons being pressed.
Still intent on going ahead with this outdated hack?
What you will need is a cheap keyboard. Only the Integrated Circuit card from the keyboard will actually be used so don't bother with an expensive one, however, don't use a USB keyboard or a PS/2 convertor with the USB port as the standard USB interface only supports six simultaneous key presses (plus any modifier keys such as Alt, Ctrl, Caps Lock, or Shift). Due to the limitations of the Windows keyboard driver, any attempt to press more than six keys simultaneously will result in a Blue Screen of Death and require a reboot.
What you need to do is to take the keyboard apart by removing the screws on the back, and it should then come apart easily. Some of the screws may be under labels or some keyboards use plastic retaining clips to hold the halves together. Inside you will find the buttons, a rubber sheet, a plastic matrix plate, and the main part we want to use, a small controller board. The cord should be attached to this little board.
What you do now depends on your electrical equipment and how technical you want to get, but I’m going to cover the easy way.
Right at the base of where the cord attaches to the controller there is just a plastic interlocking joint holding them together. Use the marker to mark a line down one side of the little plastic joint so that you can remove the cord while you are soldering but be sure that you put it back together the right way around.
The first step is to solder a length of wire about eight inches long to each of the little metal pins that were covered by the plastic sheath you took off of the controller board where the plastic matrix was attached. Now you should have a controller board with around thirty wires hanging off it and you will have two groups of wires, a large one and a small one.
It is a good idea to do this next part on a spreadsheet but you can use graph paper or even just make your own grid on a plain piece of paper. What you need to do is take the smaller set of wires, count how many there are then enter the numbers from to that number along one axis of your grid. Now take the large set of wires and again count how many there are then enter the numbers from to that number along the other axis of your grid.
Now plug the keyboard cord back into the controller card using the black mark you drew as a guide and boot up the computer. Run a program like Notepad and once it is open, take the first wire from the small group and touch it to the first wire in the large group. If you get a key press registered in Notepad record it in your spreadsheet in the cell A1 or wherever 1 and 1 on your two axes intersect. If you don't get a character on screen don't worry as not every connection will type a noticeable character such as the SHIFT key. Now touch the first wire in the small group to the second wire in the large group and again record any inputs you get registered. Once you have been through all of the large group, take the second wire in the small group and touch it to the second wire in the large group (you have already touched it with the first wire in the small group last time around). Continue until you have used every possible combination and record any results in your spreadsheet.
Once you have a full list of inputs you can start to build a button list, finding out what keys you need to run the emulators you want to run and create a list of which two wires will make those key presses. When that is done you can unsolder any unnecessary wires from your controller and connect the necessary ones up to one side of a junction box. To the other side of the junction box you can wire up your arcade controls buttons.
Now you have a working keyboard hack.