Hack Your Keyboard

Hack Your Keyboard

John St. Clair

Editor’s Note: This story is actually Chapter 8 of our latest ExtremeTech book, Project Arcade: Build Your Own Arcade Machine. If you’re jonesing for the arcade machines you grew up with but don’t want to spend thousands on a single Namco or Williams box, we can help. Read this chapter and if you want to know more, pick up a copy of the book today!

To purchase Project Arcade: Build Your Own Arcade Machine online on Amazon.com, click

here.

Check out other ExtremeTech titles.

Chapter 8: Using the Keyboard Connector for Arcade Controls

You are more likely to connect your arcade controls to your computer through the keyboard port than any other way. Everyone who has a computer has a keyboard, but not everyone has a joystick or gamepad. Software developers know this, so almost every game made for the computer includes the ability to control it with a keyboard. Even my favorite driving game, Need for Speed: Porsche Unleashed, can be played with a keyboard. I don’t recommend it though.

Taking advantage of what you learned in the previous chapter, this chapter will show you how to use the keyboard port to interface your arcade controls. I’ll start by introducing you to the various methods and products available. At that point, you’ll know everything you need to know to be able to select an interface method and start connecting wires! If you’re following along and building the Project Arcade machine instead of your own design, I’ll fill you in on the method chosen for the machine at the end of the chapter. You’ve come a long way, but so far ,all you’ve got is something to look at. After this chapter, your mad-scientist creation will actually be able to do something!

In this chapter:

Hacking a Real Keyboard

Multiple Keyboard Connections

Customized Keyboard Encoders

Remember I said you might get to take something apart? I’m sure I heard someone laughing with glee when I mentioned that. Well, now’s the time! Probably the least expensive way to connect arcade controls to your computer is by hacking apart a keyboard. (Several keyboards were harmed during the creation of this book.) I’ll start by taking a look at how keyboards work and then proceed into turning one into an arcade interface.

How keyboards work

What do keyboards do? In simple terms, a keyboard allows you to press a key, which closes a circuit associated with a particular keystroke. That closed circuit is detected by a mini-computer inside the keyboard called a keyboard encoder, which recognizes which key has been pressed. The keyboard encoder takes that information, encodes it in a digital form the main computer can understand, and passes it to the computer via the keyboard port.

The actual physical makeup of a keyboard can vary quite a bit. A typical design includes either a circuit board or a flimsy material (hereafter simply flimsy) that lies underneath the buttons on the keyboard. Laid out on the flimsy is a maze of circuits. Directly beneath each keyboard button on the flimsy are two halves of a circuit. The underside of the button has a conductive material of some kind. When the button is pressed, the conductive material comes into contact with the two halves of the circuit below, completing the circuit. Variations on this design exist, but almost all are similar. Take a look at Figure 8-1 for an example.

How the keyboard operates should sound very familiar. It’s just like the arcade pushbutton coming down to press the microswitch button, completing that circuit. The only piece that the keyboard has that is missing in the arcade pushbutton circuit is the keyboard encoder. Could we use the encoder from a real keyboard for our purposes? Take a look at the keyboard encoders shown in Figure 8-2.

Notice the connectors at the edge of the keyboard encoder boards. Those stripes are the contacts that the circuits on the flimsy come back to. If you start counting, you’ll realize that there aren’t nearly enough contacts to account for all the keys on the keyboard. Even if every key’s circuit used a shared common ground, there are still not enough contacts to account for the 100 or so keys found on a typical keyboard. What’s going on?

If a keyboard was configured to use discrete contacts (one contact per key), there would be over 100 contacts required and a keyboard encoder chip with the same number of pins on it! That would be big and expensive—something manufacturers always try to avoid. Instead, keyboard makers take advantage of a design technique called a matrix. No, Keanu Reeves is not going to show up suddenly in your arcade cabinet. A matrix is a method of using a small number of contacts to account for a larger number of inputs by arranging them into a grid. Take a closer look at the keyboard encoder in Figure 8-3, to notice the contacts are separated into two groups. There are 14 contacts on the left, and 8 on the right.

If the keyboard was setup in discrete mode, there would only be 22 buttons possible on the encoder shown in Figure 8-3, because there are only 22 contacts. However, this encoder is configured in a grid of 14 x 8. This gives a total of 112 possible buttons (14 x 8 = 112) —more than enough for a standard 104-button keyboard. The way it works is that the keyboard encoder has a map of this matrix programmed in its memory. Take a look at the matrix in Figure 8-4. I’ll refer to the 14-contact side of the matrix as the x side and the 8-contact side as the y side.

The “A” button is in the first spot on the matrix (X1-Y1). When the “A” button is pressed, the encoder sees the circuit that connects the first contact on the 14-contact side (X1) and the first contact on the 8-contact side (Y1) (see Figure 8-5). The encoder looks this up in its map and generates an “A” keystroke.

Determining which keyboard button has been pressed is a simple matter of the encoder doing a lookup in its table for the X and Y value that is generated by the key press. There is no set standard for how a matrix is designed and laid out. Another keyboard manufacturer might configure its matrix to be 13 x 9, allowing for 117 buttons, with the keystrokes occupying different spots on the grid.

You may be thinking, based on the previous section’s information about how keyboards work, that it should be possible to substitute arcade controls in place of keyboard buttons. In fact, it is, and many people have done just that. With the low cost of keyboards (sometimes with rebates you can even get them for free) and the high number of inputs available, a keyboard hack sounds ideal. It is possible to successfully use a keyboard hack, but there are several obstacles to overcome first. Because of the potential drawbacks, I strongly recommend reading this section completely before beginning work. There are alternatives available if you decide a keyboard hack is not for you.

Caution

Warning! The rest of the discussion on keyboard hacking can prove hazardous to the health of your computer! There is a +5v presence on the encoder board while connected to the computer. If something goes wrong, it is possible to fry the keyboard port on the computer or the motherboard itself. With care this can be avoided. However, if you are concerned, you may wish to skip ahead to the last section in this chapter covering commercial encoders.

Mapping the matrix

Your first hurdle will be a time-consuming one. Because every keyboard is different, you will have to manually determine the matrix your keyboard uses. I’m assuming you’ve taken apart your sacrificial keyboard and disconnected the keyboard encoder board from the rest of it. The procedure is simple. First you need a program on your computer that will tell you what keystrokes are being generated. It’s easy to tell when letters and numbers are being pressed with any word processor or notepad application. However, those won’t tell you if you’re pressing the left shift key, right control key, etc. On the download section of the Build Your Own Arcade Controls Web site (www.arcadecontrols.com) there are several utilities that will do just that. Download one of them and fire it up.

On the CD-ROM

Ghostkeys 1.1 (by John Dickson) is one of the programs that will tell you what keystroke is being generated, and is included on the companion CD.

Start by laying out a grid on a piece of paper matching the X and Y contacts on your keyboard encoder. Next, take a length of wire and strip off ¼ inch from both ends. Hold (or attach with an alligator clamp) one end of the wire to the first X contact. Then, hold the other end of the wire to the first Y contact and observe the keystroke that is generated on the computer. Record it on your grid, and move on to the second Y contact. When you’re done with all the X1 combinations, move on to X2 and repeat. Continue until you have the entire matrix laid out. This can be quite time-consuming!

After mapping the matrix out, you need to decide which keystrokes you’re going to use for your control panel. You need to consider two factors. First, you need to determine what keystrokes are required by the software you decide to use. Many games are programmable—that is, they allow you to choose what keystrokes perform the in-game functions. Some, however, have hard-coded keystrokes for game control and do not allow changing them. For instance, the fire key in a particular game may be the “F” key. Even though all your other games use the left control key to fire, you have to use the “F” in this one. Second, you need to look at how your keyboard encoder’s matrix is laid out. Certain keystroke combinations will be precluded from use simply due to where they are on the matrix. The next section, Difficulties with keyboard hacks, will cover this.

After you map out your keyboard matrix and choose the keystrokes you need, you can begin to wire things up. Take another look at the keyboard encoder from our example in Figure 8-3. The contacts on the edge of the encoder cannot be soldered to, and there’s no easy other way to attach your wiring to them.

Follow the path of the circuits back a bit to see where they connect up to solder points. That is where you can solder your own wiring to. The best way to proceed is to strip a small amount off both ends of the wire, pre-tin one tip with solder, and solder it to the contact point. Next, take the other end of the wire, crimp a connector on it, and attach it to a wiring block a few inches away, as shown in Figure 8-6. Repeat with the rest of the contacts. It is easiest to solder all the wires first and then attach them to the wiring block. The advantage of doing it this way is that any modifications are done to the wiring block, and not to the wiring between the keyboard encoder and the block. This helps to ensure the wiring to the encoder is not damaged. You don’t want to have to re-solder it!

I find the physical work of soldering the wiring to the keyboard encoder challenging, mostly due to the tight quarters. However, physical challenges aside, there are other issues with keyboard hacks. I’ll cover each one of them briefly.

Ghosts in the machine

Keyboard hacks can suffer from ghosting problems. Keyboards can be haunted? In this case, I am not referring to any nether-worldly spirits. Ghosting is a potential side affect of having a matrix design. What can occur in older keyboards is when three keys are pressed, a phantom fourth keypress is detected by the encoder even though no physical key was pressed. Figure 8-7 shows why this can happen. Recall that a keyboard encoder works by detecting completed circuits. When you press “A,” circuit X1-Y1 is completed. While pressing “A,” also press “B” to complete circuits X1-Y1 and X1-Y2. Add “O” and something interesting happens. Not only have you added circuit X2-Y1, but because the three keys “A,” “B,” and “O” involve all four terminal points, there are complete circuits between all combinations including X2-Y2, even though no key was physically pressed at X2-Y2. The encoder cannot tell that circuit X2-Y2 wasn’t intended to be completed and so generates a phantom “P” keystroke.

This only occurs when three keys in the corners of a rectangular area of a matrix are pressed simultaneously. Typically this does not occur when a keyboard is used for typing. However, this can occur very easily when used for arcade controls. Ghosting could be a problem if, for example, your “up-right” (diagonal movement involving two microswitches) and “jump” keys generated a ghost “quit” key. Picture poor Mario running his heart out, about to jump over one last barrel to save the damsel in distress, only to have the whole game suddenly exit—leaving Mario and his lady in lover’s limbo forever. That would be enough to make any pixelated persona pack up his bags and go into a less stressful line of work, such as shark dentistry.

Ghostbusting with blocks, design, and diodes

Three solutions present themselves to the ghosting problem. The first is to simply purchase a new keyboard. Ghosting is a trait of old keyboards from a few years back. Newer keyboards usually have logic designed into the encoders to block ghost keys from appearing. Recognizing when two corner keystrokes of a rectangle in the matrix have been generated, the encoder will simply block the third corner keystroke from appearing. This is known as keyboard blocking, and has its own drawbacks. There may be times when you want those three keystrokes to be able to function simultaneously. I’d recommend against it, but you may not have a choice depending on the encoder matrix and requirements of your software. No ready solution is available for keyboard blocking other than to try a different keystroke combination or different keyboard encoder.

The second solution is to select the keystrokes that you are going to use from the matrix such that three corner keystrokes from a rectangle in the matrix cannot be generated. Examine your matrix map, and make sure that no three keystrokes form a rectangle with a fourth keystroke that will cause you problems. This prevents ghosting and blocking both. This can be a problem if your software requires the use of three keystrokes that violates the above rule. However, software that does not allow changing its controls is fairly rare. Another possibility is to choose keystrokes that are impossible to have occur simultaneously. For instance, the keystrokes you choose for up, left, and right could safely be chosen even if they would normally be candidates for causing ghosting, because it’s impossible to move a joystick in all three directions at the same time. With careful planning, ghosting and blocking issues are a moot point.

The final solution brings up another electrical component — the diode. A diode is a device that in simplest terms only allows electricity to flow in one direction. A diode has two ends: a cathode (-) and an anode (+). Current can only flow from the anode to the cathode, but not the other direction (see Figure 8-8).

Ghosting is an electrical issue. With proper diode placement, you can prevent electricity from flowing the wrong way on the matrix, preventing a ghosting situation. The following is paraphrased from information provided by the folks at Hagstrom Electronics, a keyboard encoder vendor whose products are introduced later in this chapter.

While scanning the keyboard matrix for activity, a keyboard encoder will normally check columns in the matrix one at a time. When it activates a column, it will check each row to see if any circuits are completed for the current active column. It then moves on to the next column. When three or more switches are pressed that share two columns and one row (or two rows and one column) then electrical ghosting occurs. In many early PC keyboards, you will find a diode in series with each button of the keyboard. On these keyboards, you may press every key on the keyboard at the same time, and the keyboard sends all that information to the PC. By placing a diode in series with each switch, ghosting is prevented. The cathode of the diode is connected to the column side of your matrix, the anode is connected to your switch, and the other contact on your switch connects to the row (see Figure 8-9). Using isolation diodes in a matrix to prevent ghosting is a technique that has been used in keyboards for many years—even preceding the personal computer. Cherry Corporation, a popular manufacturer of keyboard switches, even offers an option of built-in diodes on their switches.

Is your head spinning a bit? Don’t worry about the theory. If you’re suffering from ghosting problems, pick up some 1N4148 or equivalent diodes (a good electronics store will know what to substitute), and connect them up to the switches having problems. One of two things will happen. Either your ghosting problem will go away, or the switch will stop working entirely. If it has stopped working altogether, your diode is in backwards. Reverse it, and all is well.

Be careful about choosing a USB-based keyboard to hack. The USB keyboard interface is designed to limit the number of simultaneous possible keystrokes to six. This isn’t a problem when used for games such as Pac-Man or Donkey Kong, which are unlikely to need more than two or three keystrokes at the same time. However, modern games such as fighting games can easily require many more than six simultaneous keystrokes, particularly if you are building a four-player control panel. PS/2 keyboard encoders often have a maximum simultaneous keypress limit as well, but it’s typically between 10 to 20 or so, and unlikely to cause you issues unless you are building a four-player panel. One final drawback of USB keyboards is that DOS support for them is limited. Newer computers will probably work with USB keyboards in DOS, but older computers probably will not without finding and installing special drivers that are not guaranteed to work.

Keyboard hack recommendations

A keyboard hack is not terribly difficult, but it is fairly time-consuming. You should ask yourself what your time is worth to you. There is some sense of satisfaction for having accomplished a keyboard hack and having spent very little money on it, but with solderless commercial alternatives available starting at $34, a keyboard hack is probably not worth the effort. I do not recommend spending the time on one unless you are on an extremely tight budget. If you are going to pursue a keyboard hack, there is a good article on the Internet that I suggest consulting as an addendum to the material presented here. Marshall Brooks has created an excellent document expanding on the issues presented here, as well as providing matrix maps for several keyboard models. Keyboard hacks are recommended only for those on a tight budget building two-player panels.

Multiple Keyboard Connections

You may find there are times when you will want more than one keyboard device functional at the same time. Why would you want that? Take as an example a situation where you’ve created a keyboard hack for your arcade controls but still need to be able to operate your computer for non-gaming functions. You could simply swap plugs, but you should not do that while the computer is on, and rebooting every time you want to change programs would grow tiresome quickly. Wouldn’t it be better to have two keyboard devices plugged in at the same time? Your keyboard-hack based arcade controls would be ready to use whenever you wanted, and your un-hacked keyboard could sit inside the cabinet ready to be used as needed.

You have a few options if you want to use more than one keyboard device at the same time. All of the solutions are good ones and use different approaches to the problem.

Tip

When I refer to using more than one keyboard device at a time, I mean two keyboard encoders with whatever is connected to them. Presumably it would be a keyboard-based set of arcade controls as one device, and a keyboard as the second. It could just as easily mean two sets of keyboard-based arcade controls. Just remember that the phrase “keyboard device” doesn’t necessarily mean a keyboard.

Keyboard splitters

A keyboard splitter is not someone who has broken apart their keyboard in order to hack it. A keyboard splitter is a device that converts a single PS/2 keyboard port into two ports. You can find a circuit diagram to build your own on the Internet, if you are so inclined. If you are not electronically inclined, purchasing a splitter is a better choice. P.I. Engineering sells the Y-key key Dual Keyboard Adapter shown in Figure 8-10. This retails for around $50 and is plug-and-play. Simply plug in the adapter, plug in both keyboard devices, and turn on the computer. Both keyboard devices are fully functional and the Y-key key is daisy chainable allowing three or four keyboard devices to be connected simultaneously.

USB keyboards

A very easy way to have a second keyboard available on your arcade cabinet is to use a USB keyboard. Your computer has to have a USB port, of course, but almost every computer made in the last few years has them. Some of the first computers with USB ports had problems running a USB keyboard until the operating system loaded, making configuring the BIOS settings in your computer a problem. However, this is also an unlikely scenario today. Just make sure if you use a USB keyboard that it is your actual keyboard and not used for a hack, because of the six keystroke and operating system limitations discussed in the USB keyboard limitations section.

Keyboard pass-thru

Probably the most elegant solution to the multiple keyboard question is available with many of the commercial keyboard encoders in the next section. They include a keyboard pass-thru connector which allows a keyboard to be plugged into the back of the keyboard encoder device. Not every commercial encoder comes with a pass-thru, so you need to read the details on the ones you might be considering.

You have many excellent alternatives to a keyboard hack available to you today. When I first became interested in this hobby five years ago, keyboard hacks were the only way I knew of to use the keyboard port for arcade controls. In fact, there were other possible solutions, but no one had put them and arcade controls together at that time. Since then, not only have vendors with suitable products been discovered, but several cottage industries have sprung up solely to serve the home arcade cabinet industry! In the rest of this chapter there are many keyboard-port based interfaces you can choose from. There’s even one you can build yourself!

All of the following interfaces are custom keyboard encoders suitable for interfacing arcade controls via the keyboard port. Each has a set of features addressing some or all of the problems associated with keyboard hacks. They appear to the computer to be a regular keyboard, and are available in prices ranging from $27 up to $140, with the higher priced models supporting extra features. The next few sections cover the highlights of each model.

Pouring over the next several sections covering 13 different keyboard encoders may prove a bit daunting. I suggest reviewing the comparison chart in Table 8-1 first, and then reading the full details on those encoders that catch your eye. It’s difficult to put all the important details into a single chart, however, so I encourage you to at least skim the introduction to each encoder.

Tip

The chart and encoder descriptions that follow refer to matrix mode and direct mode inputs. Matrix mode refers to a keyboard matrix as described in earlier sections. Direct mode indicates the encoder is using a single pin for each input with no matrix involved, and hence no ghosting possibilities.

Table 8-1: Keyboard Encoder Comparison Chart

Name

Cost

Number of Inputs

Programmable

Extra Features

ButtonBox

$35-$50

Direct: 27

Matrix: 128

Yes

No

Hagstrom KE18/

KE18 MAME

$45

Direct: 18

Matrix: 81

No

No

Hagstrom LP24

$80

Direct: 23

Matrix: 144

Yes

No

Hagstrom KE24

$100

Direct: 24

Matrix: 144

Yes

Mixing direct and matrix modes

Hagstrom KE72/KE72T

$120-$140

Direct: 72

Yes

Trackball interface add-on

KeyWiz Eco/Max

$27-$35

Direct: 32

Yes

Shazaaam! key (shift key)

MAMI 24/48

$53-90

Direct: 24/48

No

No

MK64

$63-108

Direct: 24

Yes

Rotary joystick support; shift key

Ultimarc I-PAC2/I-PAC4/

Mini-PAC

$39-$69

Direct: 28/56/28-36

Yes

Built-in programming; shift key

The ButtonBox

The ButtonBox is a build-it-yourself keyboard encoder project designed specifically for interfacing arcade controls. It was designed and made available online by an arcade cabinet enthusiast. It supports both direct mode and matrix mode configurations. It handles up to 27 inputs in direct mode and 128 inputs in matrix mode. Assuming you have the tools, building the ButtonBox will cost you between $35 and $50 depending on how you build it. It consists of two separate components: the main CPU card, and the direct or matrix-mode daughter card.

You will have to determine in advance how you want to configure the matrix or direct mode, as you will physically construct the daughter card to match your needs. There is no one-size-fits-all daughter card in the design specifications. For instance, if you create an 8 x 8 matrix for 64 inputs, and decide later you want an 8 x 16 matrix for 128 inputs, you will have to build a new daughter card. The design is a well thought out one, however. As far as wiring goes, follow the plans for the boards in order to end up with screw-down terminals that are easy to connect to.

Programming the ButtonBox requires constructing a special parallel cable to connect to it, and then running the programming software. Programming cannot be loaded or saved from disk, and must be done interactively with the encoder. The programming software can be run within DOS or Windows.

The ButtonBox is an interesting home-brew device and has appeal to those who are building an arcade cabinet for the challenge of it. It is included here for those of you who fall into that category. However, the complexity of construction and the costs involved in gathering all the needed components make this impractical for most people.

Hagstrom Electronics has an entire suite of keyboard encoders suitable for use in arcade cabinet projects. Prices start at $45 for their entry-level model and range up to $140 for their top of the line models. Hagstrom was in the keyboard encoder business when the home arcade cabinet hobby started taking off and was quick to embrace the community with both product customizations and excellent user support. As an example, with a majority of the arcade cabinet community using MAME (see Chapter 14, “Choosing and Loading Software”), Hagstrom modified one of their encoders to better support MAME at no extra cost. All of the Hagstrom encoders referred to in this book have been used by the arcade cabinet community with good results reported. I’ll introduce you to the four models they offer for keyboard port connection in this section (Hagstrom appears in the next two chapters as well).

KE18 / KE18 MAME

The KE18 is Hagstrom’s entry-level keyboard encoder product (see Figure 8-11) starting at $45.

It supports 18 direct inputs, or a 9 x 9 matrix mode of 81 inputs. This unit is not programmable, which means that your software will have to be configurable to work with the keystrokes available to the encoder. However, Hagstrom sells an arcade cabinet-friendly, customized version of the KE18 dubbed the KE18 MAME. The key mappings are the same in matrix mode, but are different in direct mode. Both sets of keystroke mappings are shown in Figure 8-12.

The KE18 can suffer from ghosting problems in matrix mode, so you need to plan your keystroke combinations carefully if you decide to use it in that mode. Obviously, there is no such problem in direct mode. The encoder includes a keyboard pass-thru port, which is a nice feature on an entry-level model. It also includes the ability to enable/disable keyboard repeat (a held down button can generate just one keystroke, or repeat keystrokes). The wiring connector on the KE18 is of the standard IDE flat ribbon cable variety. You can either use your own IDE ribbon cable, or add the optional screw-terminal board and cable header similar to that pictured in Figure 8-13. With that board, you connect the encoder to the terminal board with the cable, and then connect your wiring to the screw terminals.

The KE18 is an entry-level keyboard encoder, suitable for one- or two-player control panels. Its lack of programmability may limit its appeal to some users, but its cost and support of the native MAME command set make it a good alternative for someone considering a keyboard hack.

LP24

The LP24 is Hagstrom’s next step up in the keyboard encoder field (see Figure 8-14), selling for $80. It is a 24-pin, programmable encoder module capable of up to 144 inputs in matrix mode, or 23 inputs in pseudo-direct mode (see the following paragraph). Because it is programmable, you can determine exactly what keystroke is generated by any spot on the matrix. Technically, the encoder has 50 pins total in two rows of 25 pins each. Each pair of 25 pins is connected and functions like a single pin. The 25th pair is a ground pin used to erase the LP24’s programming, should programming errors render it unusable. Therefore, if you take into account the paired pins and discount the mostly unused 25th pair, you end up with 24 usable input pins. Hence the name of the unit being LP24 and my reference to it having 24 pins instead of 50.

Programming the LP24 requires an operating system capable of booting into true DOS mode. A DOS window will not work. This means you cannot program this encoder on a Windows XP machine, for instance, but Windows 98 will work. If you’re interested in this encoder but have Windows XP, you could use another computer to program it and then bring it to your XP machine to use. Programming is accomplished via an interactive program through the keyboard cable. Once you’ve booted up in DOS mode and run the programming application you’re presented with a basic menu. First you select the size of your matrix. To use it in direct mode, simply assign it to use a 1 x 23 sized matrix, effectively making it a 23-input direct mode encoder. The size of the matrix cannot exceed the number of pins available on the LP24, so the maximum matrix size is 12 x 12, or 144 possible inputs. Then you fill in the keystrokes desired in the on-screen matrix grid, save the configuration to the encoder (and a backup to disk), and exit the program. Although you can save and load the configurations from disk, the programming application does not support a batch mode of operation, so you cannot automate the process. Like the KE18, the LP24 can suffer from ghosting, so you need to design your matrix carefully to avoid that.

Wiring the LP24 is similar to the KE18. However, because the LP24 has a total of 50 pins versus the KE18’s 40, it will not work with an off-the-shelf IDE ribbon cable. Although the IDE ribbon cable is smaller and the pin spacing matches, the edges of the IDE ribbon cable connector will bend some of the unused pins on the LP24 if you try to use it. You can purchase a 12-inch wiring harness connector from Hagstrom to use with the LP24, or make your own with parts available at electronics stores. The encoder includes a keyboard pass-thru, and supports enabling/disabling keyboard repeat.

The added ability of the LP24 to program key configurations make this well suited for a two-player control panel. It will also work for a four-player control panel, but will need to be in matrix mode with proper attention paid to the matrix configuration to avoid ghosting issues.

The KE24 is Hagstrom’s distant cousin to the LP24 (see Figure 8-15), retailing for $100. It has a 52-pin header on it, with 24 pairs of input pins and 2 pairs of ground pins. Programmable like the LP24, the KE24 distinguishes itself by allowing any combination of matrix and direct mode configuration of the 24 available input pins, including true direct mode functionality. This means you could configure the encoder to have 24 direct inputs, or up to a 12 x 12 matrix for 144 inputs. You could also elect to have a combination, such as a 10 x 10 matrix with four pins in direct mode. This would present you with 100 keystrokes possibly susceptible to ghosting, and four keystrokes guaranteed not to have ghosting issues. This gives you a tremendous amount of flexibility as you design your keystroke inputs.

You may have noticed the extra serial port connecter on the KE24. This has two functions. The KE24 is a multi-function device capable of sending input and output through the serial port as well as the keyboard ports. You could use a custom keyboard device to control a serial port-based robot, for instance, without having a PC involved at all. This is very flexible, but not particularly useful for our purposes. For arcade cabinet builders, the serial port on the KE24 will be used to program the encoder. Programming the encoder is similar to the LP24, except the KE24 can be programmed both in DOS and Windows. Once you load the programming application, you assign the various pins to be in matrix or direct mode, and fill out the matrix map according to your preferences. The KE24 also supports the programming of macros (up to 16 key sequences) in the matrix, so you could generate a series of moves with one button push. Save the configuration to the encoder (and a backup to disk) and you’re ready to go. Like the LP24, you can save and load configurations for the KE24 from disk, but it cannot be automated.

Wiring the KE24 will require a home-made wiring harness, as Hagstrom does not list one as an available accessory. These are not difficult to make with parts from an electronics store. A standard IDE flat ribbon cable will fit over some of the pins but will bend others at the ends unless modified. The KE24 includes a keyboard pass-thru, and the ability to not only enable/disable keyboard repeat, but also to configure the delay and speed of the repeat.

The unique flexibility of the programmable KE24 to have both matrix and direct mode configurations make this an intriguing candidate for an arcade cabinet. It is well-suited for either a two- or four-player control panel.

KE72/KE72T

The KE72/KE72T (see Figure 8-16) is the flagship of the Hagstrom keyboard encoder line. This model was designed specifically to be suitable for arcade cabinet builders after consultation with many members of the gaming community. The unit retails between $120 and $140 depending on configuration. It is more than a keyboard encoder, adding support for industry-standard trackballs or spinners (KE72T model) as well.

The KE72 supports the highest number of direct inputs of any encoder currently available at 72 programmable inputs. It does not support a matrix mode. Programming the KE72 can be done through the keyboard cable or serial cable for Windows 98/95, and serial cable only for Windows 2000/XP. Hagstrom truly listened to the needs of the gaming community as the encoder can be programmed automatically through batch files. Programming is accomplished by running a command line programming utility that reads a configuration file and applies it to the encoder. If you need multiple configurations for different games, simply create a unique configuration file for each game and load it before running the game. Through the use of batch files, you can automate the entire process to load the proper configuration and run the game with a single click!

Because the encoder runs in direct mode only, ghosting is not an issue, and all 72 keystrokes can be generated simultaneously without key blocking occurring. The keystrokes generated can include any found on a standard keyboard, and also can include macros of up to 32 keystrokes with a single button press. Other features tailored to the gaming community include the trackball interface, which not only supports trackballs and spinners, but also has three mouse buttons as well. This requires using the PS/2 mouse port as well as the keyboard port. The KE72 includes a keyboard port pass-thru. It also has soldering points for attaching Num-Lock, Caps-Lock, and Scroll-Lock LEDs to your control panel. Some games, mostly a few emulated by MAME, will light up the LEDs to correspond to coin inserts or in-game action. Upon request, Hagstrom will solder in a connector and include an appropriate cable for the LEDs so that you only need to purchase the LEDs themselves. They will charge a nominal fee for this service.

Wiring the KE72 can be done with two IDE flat ribbon cables, as the two wiring headers were designed specifically to fit the IDE standard. Combine this with the optional wiring break-out board shown earlier in Figure 8-13 for an easy wiring job. Although the KE72 physically looks like a PCI card, it is designed that way solely for mounting purposes. There are no electrical connections on the PCI-style mounting. You can either elect to mount the KE72 in a PCI slot or screw it to a spot on your control panel as with any other encoder.

Of all the encoders available from Hagstrom, the KE72T is the most ideal candidate to run a four-player control panel. The added ability to run a trackball or two spinners (but not both) along with 72 direct inputs, make it almost a one-size-fits-all solution!

KeyWiz Eco/Max

The KeyWiz line of products (www.groovygamegear.com) is a recent arrival to the arcade controls community that has come on strong with an aggressive feature set. Two models are available (see Figure 8-17) sporting the same core features. Pricing starts at $27 for the economy model (Eco), and $35 for the maximized model (max).

The KeyWiz supports 32 direct inputs and does not have a matrix mode. It includes a shift key dubbed the Shazaaam! key that allows 24 inputs to have a secondary function, for a total of 56 possible inputs. The KeyWiz has a few unique features that help it stand out. Normally the purpose of a shift key is to provide for specific functions that you don’t want available during normal play. However, you have to press two buttons to activate that function. The folks at KeyWiz offer a simple but elegant alternative to this, providing an adapter cable that will let any single button generate a shifted keystroke. It’s a simple concept, but KeyWiz thought of it and makes it available to you.

The KeyWiz shines when it comes to programming, with a full-featured programming utility. One unique feature is the ability to associate configuration profiles with certain games. You can create and store up to 15 different configurations in the programming software. When you press the button corresponding to a particular configuration, it not only loads the configuration, it can also optionally launch the application! You can also assign a profile to a Windows icon and run it all with a single click. The KeyWiz is programmable in both DOS and Windows.

Another unique feature is to have two configurations resident in the KeyWiz while in use. One is the default MAME-compatible key set, and the other is your customized configuration. Change back and forth on the fly by activating the Shazaaam! key and pressing left on your joystick for MAME, right for the custom configuration. The KeyWiz ships with the MAME-compatible configuration as a default. Custom configurations are not stored when powered off and must be loaded at boot-up (which can be automated easily).

Wiring the KeyWiz ranges from difficult to easy depending on which model you purchase. The economy model comes with solder points for the inputs. If you are skilled at soldering, this may be a good consideration to save a few dollars. The max model comes with standard screw-terminals that make wiring easy. The max model also adds a switchable keyboard pass-thru port. Either the KeyWiz or the keyboard is active at one time, but not both.

The KeyWiz is a full featured line of products and represents serious competition to the other encoder manufacturers. Because of the relative newness of the product line, they do not have as big of an installed user base as some of the other encoder lines. Their feature set, pricing, and user support are all excellent, so expect that to have changed by the time the first update to this book comes out.

The Multiple Arcade Machine Interface (MAMI) line of products is the creation of 3Tronics Technical Services, another relative newcomer to the arcade cabinet community. They have two products available with 24 and 48 direct input models available, respectively. The 24-input model ranges in price from $53 to $60, and the 48-input model ranges from $86 to $90, both depending on which variation of the model you purchase. You can purchase three different variations of each model: one with solder points to connect to, one with ribbon-cable connectors similar to traditional IDE ribbon cables (but of a different size), or standard screw-terminals. With the small price difference between the low end and high end of each model, it is probably worth purchasing the screw-terminal variations.

The MAMI products are not programmable, but can be ordered with customized key mappings. By default, they ship with a fairly standard MAME-compatible configuration. They are designed to support one joystick and up to eight buttons per player, with the MAMI 24 geared for two players and the MAMI 48 meant for four-player panels.

Wiring the MAMI encoder will depend on which variation you purchase. Either the ribbon cable or screw-terminal models will be easy to wire with material available from any electronics store. Wiring to the entry-level models will require some skill with soldering. All versions of the MAMI come with a keyboard pass-thru standard.

The MAMI is a relatively recent line of products in the arcade cabinet community, and their impact on the community remains to be seen. The developer behind the MAMI has 15 years of experience developing miniature electronics devices. You may wish to visit their Web site to determine the latest pricing and feature sets of their products, as these may have changed from the time this book was written.

MK64

The MK64 is another vendor who came from the arcade cabinet-building community. The encoder (see Figure 8-18) is priced between $63 and $108, depending on the accessories (various cable kits) purchased with it. As you may gather from the name, it supports 64 direct mode inputs.

The MK64 has a couple of interesting features. Similar to a few of the other encoder options, it includes a shift key function that allows seven keystrokes to serve dual purposes. It also supports assigning up to 16 macros to different keystrokes, with up to 63 steps per macro. Perhaps its most unique feature is built-in support for rotary joysticks. You may recall that rotary joysticks have handles that rotate to 12 different positions, designed for aiming in certain games. The MK64 is the only keyboard encoder product with native support for the rotary joysticks, although a separate stand-alone device is available as an after-market add-on for other encoders. The MK64 also supports enabling/disabling keyboard repeat.

Programming the MK64 is a manual process involving script files. Although they are a bit involved to create initially, doing so is not difficult, and sample scripts are included with the encoder to get you started. Because the programming is performed via command line reading of the script files, the MK64 can be reprogrammed on the fly with batch files. Thus, while more involved to configure initially, it allows for automatic reprogramming based on the needs of any particular game you might play. The MK64 can be programmed in both DOS and Windows.

One very unique feature is the ability of the MK64 to identify which control panel is connected if you have swappable control panels. You accomplish this by dedicating one or more of the input pins as ID pins. Each panel you build gets a unique ID. Through use of a batch file, by recognizing that a new panel has been installed, you can configure the encoder to take any number of actions, such as reprogramming the encoder to match the panel or listing only games that work with that particular panel.

Wiring the MK64 is straight forward. The ribbon cable connectors can be used with cabling kits available from the vendor, or with standard IDE and floppy cables or parts available from electronics stores. The encoder includes pins for hooking up LEDs, but you will have to add the required resistors (see Chapter 15, “Buttoning Up the Odds and Ends,” for details) yourself.

The MK64 is a solid encoder for the price. By adding support for rotary joysticks, the MK64 has distinguished itself in the market. The high number of inputs makes the unit suitable for both two-and four-player panels, and the extra features of the encoder are an added bonus.

Ultimate Arcade Controls

Ultimate Arcade Controls (hereafter Ultimarc) is probably the first of the cottage industries to spring up over the past few years in response to the needs of the arcade cabinet building community. Ultimarc is extremely well regarded, providing top notch customer support, and has probably sold more encoders to the community than any other vendor. Following are two of their keyboard encoder products. A few of their other products appear in the next few chapters.

The I-PAC2 (see Figure 8-19) is Ultimarc’s entry-level product, offering 28 programmable direct mode inputs with shift-key functionality. This allows one of the keys to double as a shift key similar to a shift key on a keyboard. When pressed by itself, the key simply generates what it has been programmed for. When pressed in conjunction with one of the other 27 buttons, it generates an alternate keystroke for that button, affectively doubling your total inputs to 55. The I-PAC2 is available for $39 for the PS/2 keyboard-port model, and $43 for the USB model. Through some sophisticated programming, Ultimarc has designed their product not to suffer from the six-simultaneous-keystroke limit that native USB keyboards have.

You’ll be pleasantly surprised by some of the sophisticated features available with the I-PAC2 for the low costs involved. The encoder includes a keyboard pass-thru, a jumper to toggle between a pre-programmed MAME configuration and your own configuration, and several programming options. With the pre-programmed MAME configuration, most users will be able to plug the encoder in and use it without having to program it at all.

Ultimarc has provided four different methods to program the I-PAC2. First you need to set the jumper on the encoder to allow for programming (as compared to using the default MAME configuration). This needs to be done only once and can be left in that mode to allow reprogramming whenever needed. The first two methods involve running the I-PAC configuration application. Both a DOS mode and Windows mode are included on the encoder’s CD. The Windows version is pictured in Figure 8-20.

Programming is straightforward. Click on the control you want to change, and then press the button you want assigned to it. The labels on the programming menu correspond to the labels on the wiring blocks on the I-PAC2. Save the configuration to the encoder (and a backup to disk) and you’re done. You can also program the unit on-the-fly by pressing a special keystroke combination (requires a second keyboard plugged into the pass-thru) that brings up a built-in configuration menu. It has all the functionality of the two programming applications except for loading and saving to disk. Finally, demonstrating an understanding of the needs of arcade cabinet builders, the programming applications can be used in command line mode to read in a configuration file, allowing for automated programming of the encoder. Also, at least one front-end application (Chapter 13, “Installing the Computer”) has built-in support for the I-PAC, enabling programming to be changed within the game environment.

Some of the other features include the ability to be used with a Macintosh computer along with a native Macintosh programming application, a third-party developed Linux programming application, and the ability to daisy chain the encoders for even more inputs. Also, there is an optional 32-inch LED harness that attaches to the encoder’s board, emulating a keyboard’s Num-Lock, Scroll-Lock, and Caps-Lock LEDs. The long harness and design of the LED mounting allow you to mount them to your control panel, adding colorful red, yellow, and green lights that will correspond to certain MAME functions.

Wiring the I-PAC2 is straightforward. The inputs are attached to by screw-down terminal blocks and include two ground terminals. By daisy chaining your grounds on your controls, all your wiring can come directly to the encoder board without requiring extra wiring blocks.

The I-PAC2 is tailor-made by Ultimarc to suit a two-player control panel. The impressive list of features and high quality of design have made it a favorite of arcade cabinet builders. The low cost of the encoder makes it an attractive alternative to a keyboard hack.

I-PAC4

The I-PAC4 is Ultimarc’s follow-up to the successful I-PAC2. It is the big brother to its predecessor, having double the number of inputs. Essentially, it is two I-PAC2 units installed on one board. The I-PAC4 retails for $65 in the PS/2 keyboard configuration, and $69 in the USB port configuration. See Figure 8-21.

Everything written about the I-PAC2 holds true for the I-PAC4 as well, except for the number of inputs. The I-PAC4 has 56 inputs broken into two groups, each with a separate shift key. This allows for a total of 110 inputs. The rest of the feature set is the same, including the programmability, LED harness, and multi-operating system support.

The I-PAC4 is effectively the same as purchasing two I-PAC2 units, with a slight cost savings and the convenience of programming all inputs with one interface. Custom designed by Ultimarc for people building four-player control panels, it has quickly become a favorite among the arcade cabinet building community.

Mini-PAC

Ultimarc’s Mini-PAC is the latest encoder to join their line-up. This unit works identically to the I-PAC2 and supports 28 inputs using either a PS/2 or USB connection. The 2-1/4-inch Mini-PAC can be seen in Figure 8-22.

The Mini-PAC adds trackball and spinner support to the I-PAC2 functionality, requiring that the encoder be used in USB mode. The Mini-PAC is primarily targeted at OEM and frequent cabinet builders, with the available wiring harness, 28 encoder inputs, and trackball/spinner functionality designed to allow for quick hookup. Prices for the Mini-PAC range from $29 for the encoder and PS/2 cable only up to $69 for the encoder, USB cable, trackball cable and full wiring harness.

You are likely to be satisfied with any of the encoder choices presented in the previous sections. The economy models make excellent alternatives to keyboard hacks, providing the functionality of a keyboard hack with less effort involved. The higher priced encoder models justify their increased costs with extra features such as programmability, keyboard pass-thrus, and other miscellaneous features. Most of the vendors have been supportive of the arcade cabinet building community for quite some time, and will be happy to answer any questions about their products that you might have. My best advice to you when determining which model to choose is to analyze your current needs and thoughts for the future. Purchasing a budget model might help the bottom line now, but will limit your expansion possibilities. If you’re constructing a limited purpose system, such as a Pac-Man clone for instance, a low end encoder will work fine. I would recommend looking at the high-end models if you’re planning a multi-purpose arcade cabinet, however. With the difference between the bottom and top of the lines being approximately $100, you’re better off buying the encoder with the best feature set to match your needs and not to economize on this point.

The Project Arcade control panel design uses 32 keyboard port based inputs. That includes all controls except the trackball, spinner, and three mouse buttons. With their excellent customer support, feature set, and number of supported inputs, I decided to use the Ultimarc I-Pac4 for the Project Arcade cabinet. The 56 inputs will give me ample room to grow in the simplest manner possible should I decide to remodel. I could just as easily have chosen one of the other high-end encoders with 32 or more direct inputs. With the prices being so close, I did not feel it was worth the extra work involved to use a matrix.

Summary

The keyboard port is your best choice for interfacing arcade controls to your computer. Almost every game playable on a personal computer allows for keyboard control. Keyboard hacks can be an extremely low-cost way to go, and can either be fun or infuriating to build depending on your temperament and soldering skill. Personally, if the luckless Mario depends on my soldering skills, then he’ll never escape the barrels and rescue the princess! Most people will be happier with a commercial keyboard encoder.

Keyboard ports are a great way to connect your arcade controls, but they’re not the only way. Put your mad-scientist coat back on, because in the next chapter you’ll be dissecting some mice!

Editor’s Note: This story is actually Chapter 8 of our latest ExtremeTech book, Project Arcade: Build Your Own Arcade Machine. If you’re jonesing for the arcade machines you grew up with but don’t want to spend thousands on a single Namco or Williams box, we can help. Read this chapter and If you want to know more, pick up a copy of the book today!

To purchase Project Arcade: Build Your Own Arcade Machine online on Amazon.com, click here.

Check out other ExtremeTech titles.

Copyright © 2004 Ziff Davis Media Inc. All Rights Reserved. Originally appearing in eWEEK.