The information below
was kindly written up for EmuAdvice by Marshall,
based on his experiences when building his arcade controls. You can also download
this document as a printer-friendly Word .doc file by clicking here
or an Adobe .pdf file by clicking here. Additionally,
Marshall provided us with a quick explanation on how to get around the "Type
"OK" Screen" when MAME starts a game if you're using your controller and
don't have any keys at hand, which is now explained on this
page. Thanks Marshall!!
HOW TO HACK A KEYBOARD FOR USE IN MAME
UPDATE (23Oct2003):
Added a graphic by
tmasman showing how to wire the switches to the keyboard hack.
UPDATE (23Sep2003):
Somehow in the
first edition of this page, I didn't see that a keyboard hack can also work for 3-player
3-button games and 4-player 2-button games as well as the standard Street Fighter
2-player, 6-button layout. Details and a brief run-through of how to make this work
are now included. Also, the first two Appendices have been revised to show 4-player
key assignments.
Also, later
versions of MAME (probably from 0.60 up) now allow use of the Windows "Flag"
keys on the keyboard, but you need some tricks to make them work. Details added.
Gamepad hacks were
left out of the alternatives section of the page. Details added. Also
completely revised the alternatives section as well.
Added a paragraph
on "build quality" to the keyboard hacks disadvantages section.
BTW, I no longer
recommend keyboard hacks. I am glad I wrote the page, I will continue to maintain
it, and I am glad it has helped people, but with products like the KeyWiz Eco offering 32 non-ghosting inputs,
Shazaaam! (shift-key) functionality, better response time, and re-programmability for
under $30, it is hard to justify. I still think a keyboard hack will do what I say,
and if you are on a limited budget, only need a few controls, and only want to play MAME
(or other apps with assignable inputs), it makes sense, but for the majority of users, a
simple encoder is more desirable in terms of cost/time involved/functionality. (Added to
Procedure also).
Added some keys to
avoid (direction arrows, among others) to the main procedure. Information initially
provided by RandyT (KeyWiz). This had
an unexpected positive in that by avoiding the arrow keys, I was able to map J1 Up and
Down to KP 8 and KP 2 and the Player 1 buttons to MAME defaults on most of the keyboards,
making them more useful for scrolling front-end menus by using the HotRod support options.
Clarified the
"Idealized, Advanced concepts" section.
Revised all
appendices for consistency and to highlight some errors.
Entire page
reformatted for readability and to add some things lost in the original Word
conversion. Way overdue. Sorry.
INTRODUCTION:
This procedure explains how to
hack apart a keyboard for use with MAME.
First, I have not completed
this myself, but I have done all except the soldering so it should work.
Second, more than one person
has fried their motherboard from a bad soldering job on a keyboard hack. If you are not
comfortable, soldering on a printed circuit board, find someone who is. Use this procedure
at your own risk and preferably test the controller on an older computer before plugging
it into your brand new Mega-GHz PC.
Third, in deciding whether to
use this method or a keyboard encoder, the most important considerations are in order:
cost, available time, soldering skill, and number of gameplay buttons required. A
typical keyboard hack will support two joysticks and between 8 and 14 total gameplay
buttons. An almost unlimited (up to 104-keys) total inputs are supported, but these may
have ghosting or blocking problems.
Finally, a keyboard hack is a very intensive solution for
very limited results. Yes, it can be virtually free. Yes, it may provide
enough inputs for most games in MAME for an arcade cab. Yes, MAME (and many other
emulators) can get past the limitation of not being able to reprogram your controller to
match it's default inputs. Having said that, I have come to the conclusion that a
dedicated encoder such as the KeyWiz, I-PAC, or MK64
will be a better solution for the vast majority of arcade control users. At the risk
of sounding like RandyT's (KeyWiz) posterboy,
I don't think I could summarize my thoughts on this better than he did in a recent BYOAC post.
"I have a hard time recommending a keyboard hack to
anyone who isn't chronically unemployed and to the point where every penny counts, or
extremely bored and looking for a personal conquest. It's a lot of work, it's easy
for a novice to ruin parts (like keyboard fuses on motherboards), and the end result is
usually pretty sub-standard. The keyboard I hacked was noticeably poorer in
performance than a dedicated encoder . . . I suggest you do a lot of reading before
attempting this and don't base your decision on the successes or failures of a couple of
individuals. This is going to require a certain amount of introspection on your
part, after educating yourself, to decide if you are "up to the job". If
you haven't soldered before, you'll need to practice. If you don't own a
multi-meter, you should get one. It'll help tremendously.
For some, the task is trivial, but time consuming.
For others, it is impossible and cost them a motherboard to find out. You should
probably try to figure out which group you'll end up in before you get too far into
it."
So now, if you're ready and still want to pursue this, let's get started.
GENERAL NOTES ON KEYBOARD CONSTRUCTION
The keyboard case is generally assembled in two halves. The halves are held
together by (usually Phillips-head) screws. In some cases, plastic retainer clips are also
used to hold the halves together. The keyboards that we are interested in will have
a circuit card that the cable plugs into and one or more Mylar overlays that connect to
this card and register keypresses. In some cases, a
metal or plastic plate is screwed to the upper half of the keyboard to hold the Mylar
against the keys.
The Mylar overlay will generally have carbon or copper
contacts in a "double C" configuration like this:

One lead of this circuit (the left trace above) goes to a row of the matrix and the
other lead goes to a column. The contacts may also be in the form of a split circle.
On some keyboards, there are three sheets of Mylar. The upper sheet has
conductive contacts on its lower surface and the lower sheet has contacts on its upper
surface. A Mylar sheet without any contacts but with holes
along the contact points is placed between the two sheets to ensure that only the selected
keypresses register.
The Mylar overlay is generally clamped to a header terminal
strip on the circuit card. On some keyboards, the Mylar overlay has terminal strips
that correspond to the terminal strips on the keyboard circuit card and screws hold the
Mylar to the card and ensure contact. This connection method
would probably be easier to solder to.
WHAT TO EXPECT:
Using this procedure, you should end up with a controller
capable of handling two joysticks and six buttons per player with no ghosting during game
play. You may have to go through the entire procedure on a couple of different
keyboards before you find a useable one, though. Once you find one that works, it
should also be able to support 3-player, 3-button games, or 4-player, 2-button games as
well.
TOOLS/MATERIALS REQUIRED:
Analog or digital multi-meter
with resistance (ohms, W) scale ($10.99 at Pep Boys).
Soldering Iron, preferably
low wattage.
Office style correction tape,
single line.
Rosin-core solder, preferably
the small-gauge electronics type.
- Some type of wiring. I recommend IDE-type ribbon cable, available at Computer Stores (or
surplus from old computer hard drive cables), Radio
Shack, or Digi-Key
(Digi-key P/N R007-5-ND Multicolor $5.09 for 5 feet, P/N R027-5-ND Gray $3.51 for 5 feet).
I used 40-conductor cable because I will also be connecting my keyboard hack to
removable control panels and to an optical controller board and 40-pin cable and 40-pin
connectors are the easiest to find. If you are just connecting the keyboard hack to
a single arcade controller, you could probably go with 24-conductor cable, which is a few
pennies cheaper and will make a cleaner installation. You also
can peel off the extra conductors if they are not required.
BTW, I wanted solid rather than stranded conductor wire for my project, because I
thought it would be easier to work with. Digi-Key does not carry this. They gave me
the 800 number to 3M. 3M only sells it in 200-foot rolls for a lot of money.
However, they said the local distributor might be able to get me a sample of it to try.
I called the distributor and he sent me a five-foot sample, Priority Mail, for
FREE. I don't know if this will work for you, but it's worth a
shot.
Cheap Keyboard - Only the Integrated Circuit card from
the keyboard will actually be used, so don't spend a lot of money on this item. The
choice of a DIN-5 or PS/2 keyboard is not important, as there are adapters to go either
way. However, do NOT buy a USB keyboard (and do not hook your PS/2 Keyboard up to
the USB port) as the standard USB interface only supports six simultaneous keypresses
(plus any modifier keys such as Alt, Ctrl, Caps Lock, or Shift). Also, the six-key
limit is not merely a keyboard manufacturers decision but a function of the Windows
keyboard driver. Any attempt to press more than six keys simultaneously will result
in the infamous "Blue Screen of Death" and require a re-boot. (This is not
a problem with the I-PAC in USB mode, because the inventor wrote special code to get
around this limitation.) The following keyboards have been evaluated (in
alphabetical order): (If you use a different keyboard, e-mail me the particulars, and I will add it to this
document.
Apricot Computers Ltd.,Mitsubishi Electric UK, FCC ID :
AQ6-MTN4XZ15, Model : RT6656TUK, P/N : 121287-002 REV.D, S/N : 31260302. Thanks to Oliver
Wells for the data on this keyboard. The matrix is included as Appendix C.
Compaq model: SK-2800c, Compaq p/n:
341162-006, Spare p/n: 387084-003 Thanks to Mr. Arcade for the information on this
keyboard. The matrix is included as Appendix D.
Digital Research Model DR-104 KEY (box art), Model
Scorpius 104 (keyboard itself), Circuit Card - Qtronix Qwin95-A.PCB 27-050-150,
Microcontroller - UMC UM6868A-0011 9903M EBNC0. This is a DIN 5 104-key
keyboard with included PS/2 adapter. Screws hold the halves together and a plastic
plate holds the Mylar to the upper half of the keyboard. The circuit card is
approximately 4.5 by 2.5 inches and the Mylar sheet is clamped to it. It uses a 16x8
matrix and key blocking. The matrix is included in Appendix A. I purchased it
for $11.99 with an $11.00 rebate from Best Buy in December 1999. Digital Research is bad about honoring their rebates, though.
Micro Innovations - model KB400i. Thanks again to
Mr. Arcade. The matrix is included as appendix E.
Mitsumi KPQEA42A - This is a DIN 5 104-key keyboard.
Screw and plastic clips hold the halves together and a metal plate covers the Mylar
sheet. The Mylar sheet appears to have three wires which each key press contacts.
I have not mapped out the matrix, but the three wires may make this keyboard
unusable, depending on function. The circuit card is approximately 1.25 by 3.25
inches and the Mylar sheet is held against it with two screws. It uses key blocking.
I purchased it with a computer system from a local computer store in June 1998.
Non-Branded Keyboard, chicony ver a 105-06868-010
6868A-0017 9947M FADD3 keyboard encoder. Thanks Pete Clements for the info.
Matrix included as Appendix F.
PC Concepts PC104 Keyboard Model Number KWD-203, Item
Number 61595, Circuit Card - P/N 001-00200-001, Microcontroller - Chicony C34451BE Ver L
105-08049-250 9807 CT1. This is a DIN 5 104-key keyboard with included PS/2 adapter.
Screws hold the halves together. This keyboard uses the two Mylar sheets with
a Mylar separator. The circuit card is approximately 4.5 by 2.5 inches. The
column inputs are on one edge of the card and the row inputs are on the other edge.
It uses a 16x9 matrix which casts serious doubts on my later comments about a 24-terminal
matrix being "almost an industry standard" and it uses key blocking. The
matrix is included in Appendix B. I purchased it at
Office Depot in November 1998 for $14.99 with a $15.00 rebate.
Silitek SK-1500. This is a 107-key PS/2 only
keyboard. Screws hold the halves together. The circuit card is approximately
1.25 by 3.25 inches and the Mylar sheet is held against it with two screws. I have
not mapped out the matrix yet, but this keyboard looks like it would be very easy to hack.
It uses key blocking. I purchased it with a computer system from a local
computer store in May 2000.
Terminal Blocks or Headers - Optional but highly
recommended. For removable control panels, such as mine I plan to use a Digi-Key
MPL40K-ND Plug Connector ($8.05). This attaches to the IDE-ribbon cable without
soldering and allows quick connection/disconnection of panels. For permanently
installed panels, I recommend small PCB terminal blocks Digi-key
P/N ED2236-ND ($2.07 for 12-pin). I like these because they are compact and
reasonably priced. The twelve-pin TB is 2.25 inches long by 9 mm wide by 12 mm high.
Using terminal blocks will make it much easier if you
decide to change button layouts later, or for example, if MAME changes coin input keys
from 3 to 5, as it did a few revisions ago.
Secondary keyboard - If the
keyboard to be hacked is your primary keyboard, a second keyboard or a working different
computer system is required, to allow the use of Word or EXCEL, etc.
Keyboard Testing Software - (Freeware) - This allows you to see what keys are really
going to the computer when you press the keyboard keys. Go to Saint's BYOAC site and follow the links
to downloads and utilities. The advantages of each
program will be explained in the testing section of these instructions.
ALTERNATIVES (AND THEIR PROS AND CONS):
Okay, if you read through this procedure and have decided that hacking a keyboard is
not for you there are two other options: a gamepad hack, or a pre-built encoder.
Detailed information on either option is available here. Also, I will
include some brief comments below.
Gamepad hack - Physically a gamepad hack requires about
the same amount of work as a keyboard hack, i.e., you still have to tear the pad apart and
solder wires to the circuit contacts. You don't not have to map out the matrix and
you don't have to worry about ghosting. Another advantage is that if you hack a
Playstation gamepad, you can use it with adapters with any type of console or PC games.
The biggest drawback to a gamepad hack is that you are limited to a usual maximum
of 14 inputs. You could hack multiple USB gamepads to get more inputs, but many
people have reported problems with them "swapping" positions when the computer
is powered off and back on.
Dedicated Encoder - The reference
page provides much more detail, but the main three encoders I will recommend
(alphabetically) are the I-PAC, KeyWiz, and MK64. I will not recommend one of these over
another, because they all have different features and it depends on the combination of
price and features that are important to you. However, all of them feature
common-ground rather than matrix-mode connections, more inputs than a keyboard hack, no
possibility of ghosting, better response time, and full programmability.
KEYBOARD HACK ADVANTAGES:
Cost - Forget about wire and terminal blocks because you
would have to buy these either way (Well okay, no TB's if you use a dedicated encoder and
don't have removable control panels). If you have basic electrical tools, your total
cost is the keyboard, which you can often find for less than $5.00 with a rebate or for
free (if the keys, case, etc. is broken) at computer surplus stores. In a worst
case, at $15.00 for a keyboard, $10.00 for a multimeter, and $10.00 for a soldering iron,
the total cost of $35.00 is still less than any other option, and the cost of doing a
second one is only $5 or free. However, if you are only building one project,
haven't soldered, and don't own a multimeter, you are probably much better off buying a
dedicated encoder.
Number of total inputs - As previously stated, a keyboard
hack will allow a total of 101 (or 104) separate inputs, however only probably 16 of these
can be pressed simultaneously. This is more total inputs than
any other option (and more than you would ever need).
Cost - This is the cheapest
way possible to connect arcade controls to your PC.
Feeling of Accomplishment - It's pretty fun knowing that
you created something yourself and it does what it was intended to and works better than
anyone says it should. Especially when most everyone you ask for advice says
"Save yourself the headaches. Buy a dedicated encoder."
Cost - Did I mention it is really cheap? If not, see items 1 and 3 above.
- Size - In some cases, the circuit cards on newer keyboards measure approximately 1.25 by
3 inches. This is about half the size of most dedicated encoders and is smaller than
any of them. This may be an important consideration for
a desktop controller with many buttons.
KEYBOARD HACK DISADVANTAGES (REAL AND PERCEIVED):
- Soldering - Be sure to read the warning at the beginning of this page about frying your
motherboard. Actually, all soldering is done to the input side of the integrated
circuit, so I think you would be more likely to end up with stuck keys or non-working keys
from a bad soldering job. Of course, if the solder drips onto the IC circuit board
and shorts out a couple of pins. . . Well let's just say that could be bad. Basically, if you don't know how to solder well, and I don't, you
are probably better off letting someone else solder this, as I plan to do.
Tip: if a keyboard hack goes wrong, i.e., the 5 volt supply is grounded, the
motherboard keyboard port will appear to have died instantly. This is because most
motherboards supply the 5 volts through a tiny fuse which blows rather easily. While
expensive to professionally replace, the fuse can pretty safely be wired across, saving an
apparently useless board. Keep in mind that this now leaves the other areas of the
motherboard vulnerable, so if the original problem is not corrected or another faulty
keyboard hack is connected, more extensive damage may occur. Also, many A-Open brand
motherboards use a resettable circuit breaker in lieu of a fuse on the keyboard and USB
ports. While A-Open typically offers a good selection of features per dollar and
their boards have been well-rated in most reviews, I would not recommend buying a
motherboard solely because of this feature. However, if you
like their products, this is something to consider and maybe something to look for in
other manufacturers boards.
Time - For me, I would rather spend time on a project
than money. Those that disagree, should buy one of the alternative products shown above.
I would estimate the time required for this project as follows: disassembly - 0.2
hours, mapping out the matrix - 2.0 hours, reassembly - 0.1 hours, planning the input keys
- 1.0 hours, testing the proposed input keys - 0.5 hours, second disassembly - 0.1 hours,
soldering (rough guess, from here on I have not accomplished this) 1.5 hours, mounting -
0.5 hours, miscellaneous and sundry distractions - 1.1 hours. Total time: 7.0 hours (if my
calculator is correct). If you happen to find or
purchase one of the keyboards mapped here, you can shave most of the key mapping and
planning stages, so the total time should be about 3.0 hours.
- Number of Independent Inputs As explained elsewhere a keyboard hack will support
from 12 to 18 independent inputs. This is sufficient for two joysticks and between eight
and 14 total buttons. The Player Start, Coin Input, and other maintenance keys are
not included and may in fact have blocking problems. Normally the likelihood of this
happening is rare as most games do not allow the 1P or 2P Start keys to be depressed
during gameplay. (It can be made even more rare by assigning
the Coin 1, 1P Start, and 2P start keys to keys not in the same matrix column as any of
the joystick direction keys or the B1 or B2 buttons for each player, but this added
complexity is probably not required, unless you cannot EVER tolerate
ghosting/blocking problems.) If you require additional buttons for gameplay (highly
unlikely) or if you cannot tolerate even the possibility of ghosting with the coin
or start keys, you should not use a keyboard hack.
Also, Andy Warne ( I-PAC)
pointed out and Randy T (KeyWiz)
confirmed that most current keyboards employ two blocking methods. There is the key
blocking routine mentioned below, but there is usually a pressed key maximum hard-coded as
well which varies but is usually eight. This is done to reduce the amount of RAM
required in the keyboard microcontroller. I have no doubts that this exists, but
both the keyboards that I have mapped have been able to register at least 15 simultaneous
keypresses (I ran out of fingers on the PC Concepts verification). Unfortunately,
there is no easy way to tell and no easy solution if your keyboard has this limitation.
You basically have to map the matrix, test the keys,
and if keys stop registering either limit yourself to that many keys, or start over with a
different keyboard.
Ghosting, Masking, and Key Blocking - This is probably
the single, strongest reason why people avoid the keyboard hack. There is also a lot
of outdated or plain wrong information about this on the web. It is so important
that I will spend most of the next section (Common Misconceptions) covering the technical
aspects of it in detail. A short summary of the problem and
solutions is included here:
What happens - In a nutshell, newer keyboards work by
scanning a matrix. See Appendix A for example keyboard matrices. 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).
How serious is this, really - That is a tough question.
Keep in mind that this condition only occurs when three or more keys are pressed simultaneously.
I played Asteroids for about six months before I read a review of the Stick-It on
Saint's BYOAC site saying that
Windows popped up when he pressed alt (thrust) and space (hyperspace) at the same time.
I tried it at home and it instantly did the same thing, although I had never
noticed it before. Also, consider that a two-joystick game with both joysticks on
the diagonals generates four simultaneous keypresses without any other buttons being
depressed. The trick is to pick your keys carefully and avoid the problem
altogether. BTW, the asteroids problem was a windows shortcut problem and not key masking,
and was easily solved.
Why is there so much confusion: Basically, and I am
guessing here, about 1989, keyboard chip manufacturers became aware of the ghosting
problem, decided that having uncommanded keys show up was a bad idea for word processing
and went to the blocking route. At about the same time, MAME took off and people
using older keyboards discovered that having uncommanded keys show up for emulators was a
bad idea. They recommended the use of diodes to solve the problem, which worked for
some of the key ghosting keyboards. Other older key ghosting keyboards used very low
voltages for the switch scanning and thus were unaffected by diodes. Later, people
bought newer keyboards and found that diodes didn't make any difference and they were
still having (now blocking) problems. A huge debate ensued and is still raging about
whether diodes make a difference, and when or if they should be used. Hopefully, I will not respark that here.
- What are the solutions: Ironically, the solutions end up being identical, at least as
far as I am concerned. If you have one of the older keyboards that actually
demonstrates ghosting instead of key-mapping (and I don't think you will find a new
keyboard which does), you could (theoretically) attach diodes to each input line and be
able to use all 101-keys without ghosting (assuming the keyboard does not limit
simultaneous inputs in firmware). However, this doubles the amount of soldering
required, and increases the possibilities of a solder connection coming loose and messing
up your computer. Additionally, if this works, I would expect Hagstrom to be aware
of this solution and incorporate diodes in their encoders, and the fact that many people
are posting suggested key assignments to use with Hagstrom encoders in matrix mode tells
me that they still have ghosting/masking. If your keyboard uses key blocking, diodes
will not help and may actually hurt things. However, in either
case, if you choose your keys strategically, you will not have any problems with ghosting
or masking, regardless of keyboard type.
Lack of a keyboard when using the controller (no keyboard
pass-thru support). Some people mention this as a problem with keyboard hacks.
Actually there are several solutions. Before I
get to them, consider the following:
If you are using your controller in a MAME arcade
cabinet, you shouldnt need a keyboard at all except for set-up and configuration
changes, or for adding new games or new MAME releases. By designing the cabinet for
this, it should be fairly easy to shut down the computer, unplug the keyboard hack, plug
in the standard keyboard, make the updates, and plug the keyboard hack back in. Or
you could use a wireless keyboard for maintenance.
Now, in order of my personal preference, here are the solutions to the no-real keyboard problem:
USB - if your computer
supports USB, purchase a USB keyboard for general use and plug the keyboard hack into the
regular keyboard port. You should be able to find a USB keyboard for around $15.00 or
less. Under NO circumstances should you use a standard keyboard for general use and hack a
USB keyboard for MAME, because the USB specification does not allow more than six
simultaneous key presses (plus modifier keys). This does not apply to the I-PAC in USB
mode. (Thanks to Andy Warne for this tip.)
Keyboard splitter circuit: Saint's BYOAC site has links to two
keyboard splitter circuits: Stephan Hans, and one from everyday practical electronics.
Either one could be built for under $10.00. The
following information regarding these circuits was provided by Bill Lash in response to
questions I posted on the BYOAC message board and should be helpful for someone
considering these options:
What are the differences - Stephan's circuit is set-up so
that one keyboard is primary and the other is secondary. The LED's on the primary
circuit will always work and on the secondary one they never will. If you are building a
MAME Cabinet with LED's on the panel, plug your keyboard hack into the primary port and
the computer keyboard into the secondary. If you are building the controller for a
general use computer that also plays MAME, plug you computer keyboard into the primary
port and your keyboard hack into the secondary one. The other circuit is easier to
build and costs a few dollars less to build. It will activate the LED's on the
keyboard or hack which last sent an input to the computer. Thus,
your LED's in MAME will not work until you press a button and your LED's on the computer
keyboard will then be off until you press a key on it.
In both circuits, the keyboard port pins are numbered
looking at the cable side in on the receptacle (looking at it the way the cable would be
inserted). Also notice that the simpler circuit shows a plug
rather than a receptacle for the computer connection.
Integrated circuits (IC's) are numbered as follows:
Pin 1 is indicated by a dimple or U-shaped indentation on the side of the chip that
contains Pin 1 (or by markings on the IC). Looking down on the
chip, Pin 1 would be on the upper left corner and pin numbering continues CCW down the
edges and around the chip, so that the highest pin number ends up at the upper right
corner opposite Pin 1.
The simpler circuit shows a 4093 IC in two different
places on the circuit schematic. Actually, only one 4093 IC is
required.
- The simpler circuit implies that +5V and ground are coming in on a external wire into
the circuit. In fact, these inputs are supplied through the
keyboard port.
Keyboard switch: Lew's wheels includes a circuit using a SPDT (single pole dual throw) switch and three sockets
to switch between two keyboards.
The simplest solution is to hot-swap between your
computer keyboard and your keyboard hack. I asked Andy Warne about this and he said
that theoretically there is a danger in this, but he had done it at least a hundred times
setting up the I-PAC and never had any problems. I also had tried it several times
with no problems before I asked him. Digi-Key
(among others) sells an M-F keyboard extension cable which
will allow you to do this without crawling around behind the computer.
Y-Key-Key : Also on Saint's BYOAC site, PI Engineering sells
this adapter for about $50.00 which will allow you to have two keyboards connected to your
computer. However, as far as I can tell, the device
operates identically to Stephan Hans circuit and the price will eat up any of your savings
by going the keyboard hack route.
- Micro-center (among others) sells a cable
splitter (for $7.95) for laptop computers which allows a keyboard and mouse to be hooked
up to the same port. The cable has three connectors, a female PS/2 and two male PS/2
's which are labeled keyboard and mouse. There were no instructions as to whether it
was intended to plug into the PC keyboard port or the PC mouse port. I tried it in
various configurations with two keyboards, couldn't get it to work, and returned it.
There might be a way to get this to work, though. If someone finds one, let me know and I will include the information
here. This
is a similar device which is designed for connecting two keyboards, but I have not tried
it and don't know if it works or not.
Wiring complexity - Dedicated Keyboard encoders in
non-matrix mode and also the standard arcade machine JAMMA harness reference all keys to
one common input. Thus, you can string one wire to the second terminal of all of
your arcade controls. In matrix mode or with a keyboard hack, each button connects
two of the input contacts to the circuit card. This
really doesn't make any difference, but it does require a different way of thinking about
wiring.
Lack of programmability - A keyboard hack is
non-programmable. On the DR-104 keyboard (for example), there are only 16 keys that
can be pressed simultaneously. And only certain keys may be selected for those
sixteen keys. There is definitely, however, more than one choice of key assignments
for any particular key. For example, looking at Appendix A, in Row 12, I have
assigned the Space bar to P1 B3. I could just as easily have assigned this to
another button, say P1 B2 and changed the P1 B3 assignment to a key in a different row.
I also could leave all the other keys the same and assign Keypad (KP) 7, KP4, KP1,
Num Lock, Down Arrow, or Delete to P1 B3 instead of Space and the hack would work just as
well. However, I cannot assign space to one button say P1 B3 and another Row 12 key,
say Down arrow to P1 Down without the possibility of ghosting/blocking. Different
keyboards will have different acceptable key assignments, but the concept is the same.
Since MAME allows reassignment of all input keys, this
is not a problem (except for some awkwardness in the game setup) but with other emulators,
it might be critical.
Available key assignments - Similar to the above problem,
you will have some problems with key assignments in MAME. I would be highly
surprised, and it would be only blind coincidence, if you found any keyboard hack which
will support two joysticks and 12 game buttons and map the joystick to the direction
arrows. On the other hand, of the default Player 1 Buttons 1 through 6, I would
expect at least four of the six to be available, regardless of the type of keyboard.
The DR-104 key (for example) supports all six buttons.
Build Quality - I mean here the quality compared to a
dedicated encoder. Consider the following two items:
A dedicated encoder is
mounted to a PCB 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. Granted
this shouldn't matter in an arcade cab where the hack will not be moved much, especially
if you use terminal blocks after the input cables, but it's still a consideration.
Let's say either option
"dies" for whatever reason. With a dedicated encoder, you just purchase a
new one, unwire the old one, and wire the new one up to the same wires and you're
finished. Even if the original dedicated encoder is no longer available, (assuming
you recorded your settings), you could buy a different model, wire it up, and re-program
it to match you old settings in under 45 minutes. If your hack dies, you probably
won't find the exact same model keyboard, so you have to start over at square one -
disassemble, re-map the matrix, re-test, assign different inputs keys, solder new wires,
re-connect new wires, and re-configure MAME to match the new inputs.
Lack of shift key support - The I-PAC,
KeyWiz, and MK64 encoders include several special "shift
key" functions which are designed to reduce the number of buttons required on the
control panel. For example, on the I-PAC, pressing the 1 key and the 2 key together
simulates ESC and exits MAME. Since R36B13, MAME allows key combinations and
multiple assignments to be made to each input. Therefore, from the MAME Input
(General) menu, selecting UI CANCEL = "1 2 or ESC" accomplishes the same thing.
Caveat One: The dedicated encoders include this functionality in the controller
code, so this feature will also work using it on emulators which do not support key
remapping. Caveat Two: Key remapping in MAME does not exactly mimic the I-PAC and
MK64 shift functions. The differences and the results
are as follows:
On the I-PAC or MK64, if you press the shift key nothing happens until you release it.
Then it either sends its own code (1) or (if you have pressed another key) the
shift code. If you map the same combinations in MAME, you will always get the first
key send followed by the combination key send. The
effect of this for each shift key function is as follows:
Coin Input: The I-PAC uses 1 and P1B1 keys to mimic coin
input. In MAME, from the attract screen, if you map this combination, the first coin
input will register. If you try to input a second coin, the game will start a
1-player game, because MAME reads the 1 key first. Therefore, you will never be able
to start a two player game. For this reason, I recommend having a dedicated coin
input key on your panel if using a keyboard hack. (You
CAN get around this from the attract screen for most games by pressing the P1B1 key FIRST,
followed by the 1 key; but a dedicated key is the easier solution).
ESC: The I-PAC uses the 1 and 2 player start keys to
mimic ESC. In MAME, the game will either quit immediately or will start a one or two
player game and then immediately quit. This is perfectly acceptable and I recommend
mapping these keys if you dont want a dedicated escape key. However, a
drawback to both of these methods is that you might exit your game if both players press
the start buttons at the same time.
Pause: The I-PAC uses the 1 and J1 Down key to mimic
Pause. In MAME, if you are on the attract screen with credits already input, MAME
will start a new game before pausing the game (assuming you press the 1 key first).
If you are in one of the game playing screens MAME will pause properly unless you press
the J1 Down key first, in which case the player position will move down slightly before
the game pauses. This is acceptable, although I personally
prefer a dedicated Pause key so that I dont have to remember key combinations when I
need to stop gameplay at a critical point.
Tilde and Tab: The I-PAC uses the 1 and J1 Up or J1 Right
keys, respectively, to map these functions. These keys will function the same way as
the Pause key above. See the section on assigning keys
for my personal key mapping recommendations on these keys.
- Enter: The I-PAC uses 1 and J1 LEFT to mimic this key. This will work in MAME.
This key is only used in MAME for items on the Configuration or On Screen Display
Menus. The only difference between using this key in MAME is that if you enter these
menus without pausing the game, the player may move left while you are hitting
enter! You are not likely to do this, though. Again,
see the key mapping section for my personal recommendations on this key.
LITTLE KNOWN FACTS AND
COMMON MISCONCEPTIONS:
Matrix Mode:
Most keyboards use some kind of matrix to interface with
the keyboard IC. This keeps the manufacturer from having to run 105 inputs (104 keys
+ common) to the controller. Instead, only 25-30 inputs are used, by assigning the
inputs to rows and columns and assigning keys to each combination on the matrix, all of
the keys are supported. For some reason, 24 input matrices are almost the industry
standard. For example, the DR-104 keyboard has 26 terminals connected to the IC.
However, terminals 17 and 18 are used to support the Windows 95 menu keys only.
Since these keys are not recognized by early versions of MAME and most all other
programs, this results in an effective matrix of 16 x 8 = (you
guessed it) 24 keys.
Ideally, one would like to find a matrix with 22 x 2 (rows
by columns). However, this is impossible since such a matrix would only support 44
total keys. The best keyboard we could hope to find would be an 18 x 6 matrix (108
keys theoretically supported). This keyboard would support two joysticks and 7
buttons per player (or two joysticks, six buttons per player and the player 1 and 2 start
keys), with no chance of ghosting. If someone finds a keyboard with this
configuration, let me know and I will add
the information to this document. The worst option would be a 12 x 12 matrix.
This will only support two joysticks and 4 buttons per player (or one joystick, six
buttons, the 1P, Coin Input, Pause, and ESC keys) with no chance of ghosting. As you
can see, even this is not a bad option, unless you really like the Mortal Kombat / Street
Fighter style of games.
Ghosting, Masking, and
Blocking:
Dave Dribin
does a much better job of explaining the technical side of key ghosting and masking than I
could ever hope to. Stephan
Hans also has some excellent info on his site. Follow the links to SuperDuperArcadeConsole
(using Cherry Core). Stephan's page doesn't provide much detail on how you pick
the keys to avoid ghosting (that's my job), but he uses the same concept that I am and his
site was the first place I ever saw this mentioned. I think his information about
diodes is incorrect, though :-((. Thanks to Saint for the links. I will try to
cover the practical side of the problem here:
- Key Ghosting - Most keyboards use a matrix to determine key
presses. The DR-104 uses a 16 by 8 matrix. To show a random real example configuration:
Ghosting may occur when you press any three keys that form
a rectangle (any number of rows and columns apart) in the matrix. In the example
above, pressing E, Q, and C, simultaneously will generate X. This is rarely a problem as
the X key, for example is not usually used by another game input and all keys need to be
pressed simultaneously.
Key masking - Since the keyboard doesn't know whether C
or X should be pressed and generates both keystrokes, it also doesn't know when the key is
released, and will keep registering the keystroke even after the key is released. This is
called key masking and will result in an apparent stuck key during gameplay, which is a
problem.
Key Blocking - On the DR-104 keyboard, and I believe
virtually all newer keyboards (from about 1993-up), a technique called key blocking is
used. In this method, the IC scans the matrix and blocks any keys which could create
ghosting or masking. Thus when any three keys which would form a square if a fourth
key is pressed are depressed, the third key will not register. Using the example above, when E, and Q are both depressed and C is then pressed,
the C key will not register.
Also, any keys pressed after
the three conflicting keys are pressed will not register until one of the three keys are
released, releasing the blocking condition.
The following message from the BYOAC message board,
from Bill Lash to Malberg, documents this and is preserved here for historical purposes:
<Malberg wrote> I noticed while I was laying out my matrix for my keyboard hack
that it was a 16x8 matrix. Just for the sake of testing the matrix for ghosting, with my
second identical keyboard from Compaq, I picked any 3 points on the matrix that form a
rectangle or square and pressed them. I was using the Ghostkey program which I downloaded
from this site to test for ghosting. As I was pressing the keys one at a time and holding
the previous key down, I was only able to get 2 keys of the rectangle to only show. And I
tried many combinations and different rectangles, anything I tried I only got 2 keystokes
to show. But If I pressed down any keys that didn't form a rectangle then I was able to
hold down 8 to 10 keys and all would show in the Ghostkey program.
Can anybody give me any
suggestions why this is so???
I thought that if you hold down 3 keys in a rectangle the
forth key would automatically be triggered which is called ghosting!!! I can't give get 3
to show in a rectangle, can someone please explain!!!
: Regards -
<Bill Lash replied> This
sounds like they are using a software workaround for the ghosting problem. The keyboard
chip is basically a little processor that scans the matrix and sends the data to the PC.
Someone got clever several years ago, and decided that you don't need diodes in the matrix
(the classic way of solving the n-key rollover or "ghosting" problem), if you
detect that 2 keys of the rectangle have been pressed, you can have the software ignore
any new corners of the rectangle that get connected until you drop back to only one or
zero corners being detected. I see this method mentioned in an application note from
National Semiconductor from 1989 for using one of their COP microcontrollers as a keyboard
encoder. It seems that a lot of newer keyboards use this method, which makes diodes
useless. I think there are some older keyboards that don't do this, and they are probably
better to use for a hack.
You may have found a good way to determine if a keyboard
encoder could benefit from diodes. If you actually see ghosting, and not the 2 key only
behavior you see now, the ghosting can be taken care of with proper use of diodes. If you
see the 2 key behavior, diodes won't help. You may be able to come up with a clever
map for your controls to get enough free inputs though. Good luck.
BTW, the entire national semiconductor paper referenced above can be found by searching
the archives at BYOAC
message board for "national semiconductor" and opening this thread by Bill Lash entitled "Re: Diod Method A Myth?"
- Diodes
There has been much heated debate on the use of diodes in a
keyboard hack. It has been very ugly at times. I don't want to rehash that
here. Diodes may or may not work on older keyboards which show key ghosting.
They won't work on keyboards that use key blocking. They are not required on either
if you pick your input keys carefully. See the FAQ section for
more info on diodes.
HOW GOOD ARE THE RESULTS:
Since the DR-104 keyboard uses an 18x8 matrix, I should
theoretically have eighteen keys available with no blocking. In fact, this and many
other keyboards put the right and left Windows Menu keys all alone on two rows and since
earlier versions of MAME do not recognize these keys, only 16 keys are available.
However, since a joystick cannot be both up and down or both right and left at the same
time, these keys can be allowed to block and only two inputs per joystick are
required. Thus, my method allows two joysticks and six buttons per player to operate
with no chance of key blocking. I still will get blocking if I press the 1P, 2P,
coin, or pause keys with certain other keys depressed, but this should rarely create any
problems. I was even able to use the MAME default keys for the Player 1 inputs,
although the joystick and Player 2 inputs are nothing like the MAME defaults. Later,
I was able to expand
this concept, and the keyboard now also supports 3-player 3-button games and 4-player
2-button games.
HOW TO DO IT:
SECTION A - USING ANY TYPE
OF KEYBOARD.
If you have one of the example keyboards for which the
matrix has already been mapped, you can skip most of these steps. See SECTION B for the procedures to follow: During these procedures, I will use the
DR-104 keyboard in developing the examples, however, the general procedures should apply
to any keyboard.
- Tearing it down:
Place the unplugged keyboard to be hacked face down on
the desktop and remove the screws holding the keyboard halves together. (Generally,
eight to ten philips-head screws. Some of the screws may be under labels or some
keyboards use plastic retaining clips to hold the halves together. If the halves
don't separate easily, look for this). Do not lose the screws
as you will need them again later.
Carefully, remove the back cover from the keyboard.
Depending on the design, this may leave all of the little key buttons and rubber
pads which go under them loose. Do not lose these either. You will see one of the following three things:
There may be a bunch of metal plates inside the keyboard.
On older keyboards these were used for magnetic shielding. I have never run
across one of these, but one of the example websites said that they cannot be hacked.
However, the Mitsumi keyboard uses a metal plate to cover the Mylar membrane, so
you might try removing the metal plates and seeing if you see a Mylar sheet. Otherwise, trash the keyboard, buy another one, and start over.
The keyboard may have a huge circuit board which
covers all of the keys and little mechanical switches below each key. These were
typically used on the old IBM-type "clickety-click" keyboards. Many people
have reported that these keyboards did not use a matrix and all keys could be pressed
simultaneously. Andy Warne reported that these keyboards do use a matrix and therefore, I
would expect some type of ghosting/masking behavior. All I can recommend is that
before you start, you check for the presence of ghosting/blocking using one of the
keyscanning programs as shown in Step 5. If ghosting/blocking is not present,
you connect the keyboard by just soldering two wires to the back of the circuit board
opposite the mechanical switches for the keys you want your buttons to use and running
these wires to the appropriate switches. In some cases, people have reassembled the
keyboard after they finished and still been able to use it as a regular keyboard and as an
arcade control!
- The keyboard may have a circuit card in one of the upper corners (follow the input
cable) which connects to a Mylar sheet(s) which records the key presses. The Mylar
sheet may be retained under a plastic or metal cover plate. Remove
the plate so that the Mylar sheet and circuit board are exposed.
- Mapping the Matrix:
An alternative method which many people recommend involves disassembling the keyboard
and plugging the circuit card into the keyboard port and shorting between the terminals
and recording the generated keystrokes to map the matrix. I recommend my method over this
one for the following reasons: 1) In my method, the keyboard is unplugged so there
is no possibility of damage to the computer system during testing. 2) It's not
always easy to tell where the connection points are and which ones are rows and
columns. I'm not sure what happens if you connect two row inputs together, but it
might not be good. 3) Many inputs (L Alt, Windows Key, etc.) won't display on
a screen like NotePad. (I realize GhostKey or some of the other utilities will work;
however, even some of the utilities can't pick up the NumPad keys, or the difference
between R Alt and L Alt. And if it doesn't detect these keys, they will be left out
of the final matrix. With my method, you are using the physical locations on the
keyboard, so every key gets picked up, and no effort is wasted). 4) A
16x8 matrix is 128 inputs, but MAME can only use 104, so you have 24 unused and unusable
inputs that you still need to map out. (Add another 36 to that for an 18x8 matrix).
5) If the keyboard ends up being a poor choice to hack, with my method you can
reassemble it and either use it as a regular keyboard or yard sale it. With the
other method, you have spent a couple of hours soldering wires to a keyboard encoder that
you will never use.
I recommend using either a spreadsheet program or a word
processing program to map out the matrix, but it can be done on graph paper as well.
Pick one terminal of the circuit card to be terminal one.
Label the first line of your spreadsheet or word processing file as "Terminal
one is right edge of card (connector side of board) looking at component side of
board." or similar wording. You may also use correction tape to label terminal
1 on the Mylar sheet so that you don't get confused as you start mapping out the matrix.
This ensures that you will still know how to wire everything up when your joysticks
and buttons arrive in three weeks later.
Select the top row and the first column of your table or
spreadsheet to bold. This will make it easy to distinguish between row 5 and an
input for key 5 on the keyboard.
On many keyboards, the Mylar sheet(s) will have more
contacts than the actual number of keyswitches on the keyboard. This usually occurs
around the shift or bottom row keys, or around the enter key. I think it occurs so
that the keyboard manufacturer may use the same Mylar with L-shaped or straight Enter
keys, etc. These contacts are not required for the keyboard being tested and might
be confusing. Cover the contacts with correction tape on the conductive side of the Mylar to ensure they are not mapped.
Lay the Mylar sheet (and
possibly the circuit card also) flat on the desktop as follows:
If the Mylar sheet(s) and
circuit card are connected (clamped) together, remove them as an assembly and lay them
flat on the desktop with the conductive side up. (The same orientation they would normally
be in when you actually use the keyboard.)
If the Mylar sheet is held down by the screws holding the
circuit card to the keyboard, remove and retain the screws and place only the Mylar sheet
on the desktop with the conductive side up. (The same orientation they would normally be
in when you actually use the keyboard.) In this configuration, (looking at the
disassembled upside-down keyboard), the circuit card is usually mounted with the component
side and the contacts pointing up and the Mylar sheet is placed on top of the terminals
with its contacts face down. Thus if you label the
circuit card terminals from 1-26 starting at the left, you must label the Mylar sheet from
1-26 starting at the RIGHT when the sheet is flipped over.
- You will now have a Mylar sheet with contact points corresponding to the key positions
on the keyboard under test. These should be similar to your standard keyboard so you may
use it to determine the key associated with each contact point. The contacts will look
similar to the following

"double-C" configuration, or possibly a split circle configuration. You will
want to check for continuity between each leg of the C and the traces leading to the
circuit card as follows:
Turn the Ohmmeter (multimeter) to the highest resistance
scale.
Touch the positive and negative ohmmeter leads together.
You should see full scale deflection of the needle reading. (A digital Ohmmeter should
read 0.0).
- Touch one lead to each side of one leg of the double-C trace as shown by the red dots
below. You should see full scale deflection. This will ensure that you are testing
on the conductive side of the Mylar.

Keep one lead on one leg of the Mylar contact and touch the other lead to the traces
leading to the circuit card, in order, until you see full-scale deflection. Repeat
for the other leg of the contact. For example (on the DR-104 keyboard), for L CTRL, you
would see full scale deflection on pins 4 and 25.
- Test all keys and complete the matrix as follows: Place the lower number terminal on the
row and the higher on the column. Insert rows and columns in order as necessary. (I
usually just work left to right and up the keyboard, but it doesn't really matter. These
examples are from the DR-104 Key keyboard).
- For the Left Ctrl key (contacts 4 and 25):
- For the L Win95 key (contacts 17 and 20):
- For the L Alt Key (contacts 10 and 22):
| |
20 |
22 |
25 |
4 |
|
|
L Ctrl |
10 |
|
L Alt |
|
17 |
L Win |
|
|
- For the Space Bar (contacts 12 and 22):
| |
20 |
22 |
25 |
4 |
|
|
L Ctrl |
10 |
|
L Alt |
|
12 |
|
Space |
|
17 |
L Win |
|
|
- For the R Alt Key (contacts 10 and 24):
| |
20 |
22 |
24 |
25 |
4 |
|
|
|
L Ctrl |
10 |
|
L Alt |
R Alt |
|
12 |
|
Space |
|
|
17 |
L Win |
|
|
|
- And so forth. . . Continue this process until all of the keys are mapped. When complete,
add rows or columns for any unused circuit traces. Usually there won't be any.
- You should now have a table similar to the matrix in Appendix A. The only other
possibility is that if you chose the wrong end of the card for terminal 1, your table may
have more columns than rows. In that case, you can either use the transpose function of
your spreadsheet or word processor (save and print the current configuration first), or
you can leave it as it is and just substitute column for row in the rest of this document.
- Sizing things up:
At this point, you can determine how successful a
keyboard hack will be for you. Look at the Matrix and eliminate any rows which only
contain keys not used by MAME (the Win95 and Win98 Powerkeys (later versions of MAME
support these, but I don't recommend using them)). Count the remaining rows.
The total will between 12 and 18 rows. In our example,
the result is 16 rows.
The total number of rows (16) corresponds to the maximum
number of non-ghosting keypresses which the keyboard controller allows. Since a
joystick cannot be both up and down or left and right at the same time, these keys may be
placed on the same row and allowed to block each other at the same time. Thus, a
typical joystick requires 2 independent buttons and a two-way
joystick requires one button.
Subtract the number of joystick inputs from the number of
rows. 16 rows minus 2 joysticks x 2 inputs = 16 - 4 = 12 remaining inputs. These are
available for buttons. Thus, our example will support 2 joysticks and 6 buttons per
player. This is perfect for the Street Fighter / Mortal Kombat and almost all MAME games.
Also, 16 - 3 joysticks x 2 inputs = 16 - 6 = 10 remaining inputs, so our keyboard
will also support 3 joysticks and 3 buttons per player. And 16 - 4 joysticks x 2
inputs = 16 - 8 = 8 remaining inputs, so our keyboard will also support 4 joysticks and 2
buttons per player.
What if your results don't
match up, e.g., you have more or less rows than the number of desired inputs? I will use
some extreme examples to show your options:
I want 2 joysticks with 6
buttons each, but my keyboard uses a 12x12 matrix. What can I do?
If you play games that actually require 2 joysticks and 6 buttons per player (SF2), this will not work for you,
regardless. Don't even try it! Start over with a different keyboard. The good news is that
keyboards using a 16x8 matrix are common and inexpensive.
If you mainly play classic
games, it would still be a good idea to try a different keyboard, but you have other
options. A 12x12 matrix will support 2 joysticks and 4 buttons per player. Therefore, you
could assign buttons 5 and 6 for Player One to the same matrix row as the Joystick 2
movement keys and buttons 5 and 6 for Player Two to the same matrix row as the Joystick 1
movement keys. You would have blocking, but only when button 5 or 6 was pressed at the
same time as someone was moving the opposite joystick. This would still work acceptably
for the majority of MAME games.
I have a simple arcade
control panel (say, 2 joysticks and 6 buttons total) and my keyboard uses a 16x8 matrix.
What do I do with the additional rows?
In this case, your panel
requires 10 inputs so you have six inputs remaining. I would assign keys to the six open
rows in the following order: 1P Start, Coin Input 1, 2P Start, Pause, Coin Input 2,
Escape, and so forth. If 1 (1P Start) and 5 (Coin Input 1) are on the same matrix row, I
would pick a key on another row for Coin Input 1 and configure MAME to recognize the
change.
Quick Verification - At this point, before we get too far
into things it is a good idea to verify that your keyboard does not have a pressed-key
maximum imposed in the firmware. To do this, perform the following Steps:
Re-assemble and connect the
keyboard to the computer.
Load one of the keyboard
testing programs (Keyscan, Ghostkey) listed in the Verification
section.
Examine the matrix and select
one key from each row. Do NOT select two keys from the same row. Try to select keys
that are physically near each other (so you can press them with one hand). Using the
DR-104 Keyboard Example, I would select the following keys:
D, S, A, L Ctrl, F (mostly in one row on the physical keyboard)
J, K, L, R Alt, Enter (again mostly in one row on the physical keyboard)
KP1, KP2, KP3, KP Enter, (again in a neat row)
Either L Shift or R Shift, and (optionally) L Win and R Win.
Extra hands are useful here: Depress and hold each
of the keys selected in Step 3. You should see all the keys display. If no
more keys register after you get to eight (or six or five or ten?), then your keyboard has
a pressed key maximum and will not be able to use all the inputs. You now have the
following options.
If you are building a four player panel, you probably
will need to start over again with a different keyboard. (If the limit was eight,
then four players activating the diagonals is eight inputs, without any buttons being
pressed.)
If you are building a two-player panel, you will probably
also want to start over with a different keyboard, but it is not nearly as critical.
(If the limit was eight, two players could each activate the diagonals and up to
two buttons simultaneously, but no more. This is not acceptable for fighting games,
but probably acceptable for most classics.) NOTE: If you choose to use the
keyboard anyway, you still want to map out the keys to use as shown below to ensure you
don't encounter ghosting/blocking problems.
- Choosing the keys:
You can now assign keys to your MAME inputs. The critical point here is not to
put any keys that you don't want to have blocking problems with on the same ROW of the
matrix. Keys may be in any column as long as they are not in
the same row. Joystick left and right or up and down keys may be in the same row, since
they will never be pressed at the same time. As long as these guidelines are followed, any
key choice will work and the following steps are just suggestions.
I recommend highlighting the keys as shown below so you can see which keys have already
been used or can't be used. Colors are only suggestions and to help you follow along
with the appendix A and B examples.
It may be useful to print the matrix out or this section of the instructions to select these keys.
There are certain keys which send extra commands to the
keyboard buffer and should be avoided. Highlight
these non-recommended keys in Gray
(for example) as follows: Direction Arrows (note that both HotRod and X-Arcade avoid these), Windows Menu Key, L Windows GUI,
R Windows GUI, R Ctrl, R Alt, Insert, Home, Page Up, Delete, End, Page Down,
PrntScrn, Pause, Keypad Slash, and Keypad Enter. Details of how I came up with this
list are available here.
Most keys send three characters to the keyboard buffer. These all send five or more.
There are a couple of other points to consider below:
The Power, Wake, Sleep, and Windows Multi-Media keys all fall in
the category above, but MAME can't use them, so there is not much point even mapping them.
While I recommend avoiding these keys even for dedicated encoders,
the problem is orders of magnitude worse with a keyboard hack. Dedicated encoders
have been optimized for speed and throughput, because they expect to be used with arcade
games. Keyboards are designed for typing in a word processor.
There is a catch-22 with the arrow keys. While MAME itself
can be easily programmed to get around using them, many Windows programs and probably even
some front-ends for MAME cannot. However, the HotRod is non-programmable, and it
does not use them. Furthermore, the odds of a keyboard having the Up and Down arrows
on one row and also having the Left and Right arrows on the same row but different from
the Up and Down row is pretty slim, so you most likely can't use them even if you wanted
to.
- In some cases, you may have no option other than to use these keys. (For example, a matrix row does not contain any
keys that arent on the Avoid list.)
This is acceptable, the keys will still work, they just slow down the processing,
so their use should be minimized.
- The windows GUI keys deserve special consideration. These were not useable in
older versions of MAME and are on the "Avoid" list above. I did not use
them in my example, because when I wrote this up, MAME could not use them. I did not
add them in when I revised the page because the 16x8 matrix without them was
representative of most keyboards. However, MAME from version 0.60 up will recognize
them and I would gain two additional inputs by using them with the DR-104 keyboard.
OTOH, you can't just use the Windows Key in MAME because if you just set the FIRE button
to L WIN (for example), MAME will fire a shot and freeze as the Start menu pops up,
fire a shot and continue as the Start menu disappears, fire a shot and freeze . . .
etc. You can avoid this by installing either WinKey Killer 1.7 (homepage/download) or LogoLess. Here is a
comparison of the two programs (either one of which I can recommend):
WinKey Killer 1.7 - Very simple (double-click to run, double-click again to
exit). Transparent. Can be loaded at startup by placing in a shortcut and
adding to the Windows Start folder. Kills Windows key instantly in all apps.
Has several advanced set-up options like Disable Ctrl+Esc, Disable WinKey+E to launch
Internet Explorer, Disable Ctrl-Alt-Del, Hide from Ctrl-Alt-Del, Display message on
shutdown, etc.
LogoLess - Runs with an Icon in the Systray. This is the better program if you ever
use the Windows key because it only eliminates it in windows beginning with
"MAME" (user-specified), or in full-screen applications.
Map the non-gameplay
keys. These keys will be allowed to block or mask each other so any matrix position is
acceptable (unless you have additional rows available and can make them non-ghosting.)
Find the keys you want to use on the matrix and change the shading to yellow (for example) to
highlight them. (This prevents you from selecting these keys for gameplay and then
finding out you need them for MAME functions). (It's not a bad idea to highlight ALL
the keys listed below, even if you don't plan to use them on your panel. This will
remind you to change their function in MAME if you decide to use them for action keys when
you start assigning the action keys). The following is a list of maintenance keys
that I have seen on people's cabinets and my personal suggestions:
1 - For 1P Start (recommended)
5 - For Coin 1 (recommended)
2 - For 2P Start (recommended, unless you never play
2-player games)
6 - For Coin 2 (or map another button such as P1B6 to
Coin 2 in MAME. Coin 1 will work for either player except for a few games (Gauntlet,
etc)).
3, 4 - For 3P and 4P Start (not recommended unless doing
a four player panel)
7, 8 - For Coin 3 and Coin 4 (same as above)
P - For Pause (recommended)
Esc - For Quit (acceptable or recommend mapping UI CANCEL
= 1 AND 2 in MAME.)
Tilde - MAME On Screen Display Menu (recommend using a
keyboard to adjust this during setup)
Tab - MAME Configuration Menu (same as above, however
this key is required to bring up the joystick calibration menu. Many MAME games will not
play correctly with an out-of-calibration gameport joystick, even though the game may not
require it. I recommend having access to this key on any MAME computer which will have a
device connected to the gameport. Personally, I recommend mapping CONFIG MENU = 1 AND 5 to
provide access to this menu. Then pressing the 1P Start and Coin Input buttons will access
this menu.)
Enter - Used for accepting menu changes or for
calibrating analog joysticks/pedals. (Recommend including this under the same circumstance
as above. Many people have recommended setting one of the less used buttons (say P2B6) to
Enter. This is acceptable or you can simply configure UI SELECT to use the same key as
P2B6 is assigned to. The only drawback to either method is that if you are playing a game
that requires P2B6 and you do not pause the game before entering the menu, the game may
continue to carry out the P2B6 action while you calibrate, etc.!!).
F12 - Snapshot (not recommended)
F11 - Toggle speed display (not recommended)
F10 - Toggle Speed throttling (not recommended)
F9 - Adjust frameskip (not recommended)
F8 - Adjust frameskip (not recommended)
F7 - Load Save State (not recommended)
F3 - Reset Game (not recommended)
O and K - To get past "Press OK to continue."
See this
page for better ways around this. (Not Recommended)
If desired (not recommended), try to assign the joystick
keys to the arrow keys. This will only be possible if LEFT and RIGHT are on the same
matrix row, and UP and DOWN are on the same row, but a different row from LEFT and
RIGHT. If this is the case, change the shading for these key to a contrasting color,
say teal. Most likely, this will not
be possible.
If this is not possible try to assign the Joystick 1 keys to the numeric keypad arrow keys
(2, 4, 6, and 8, especially 2 and 8 which are the down and up keys). These are the HotRod and X-Arcade defaults. If any of these keys can work,
shade them in teal. If you can
select KP 2 and KP 8, then you can tell EmuLoader
(or any frontend with HotRod or X-Arcade support) that you are using these controllers and
use the P1 Joystick to scroll the games list. Interestingly, 4 of the 5 keyboards
tested allow this and the 5th one doesn't have either key even listed on the matrix.
Try to assign the default Player 1 Keys to buttons as
follows:
Locate the L CTRL key, if no key on this row is shaded teal, change the shading to aqua. If L Ctrl
is on the same row as a teal key, decide whether you would rather have the joystick keys
remain or be able to use L Ctrl, and change the shading accordingly. Do NOT leave
both L Ctrl and the joystick keys shaded in the same row.
Repeat for L Alt, Space, L Shift, Z, and X.
However, if a row already has a key selected, skip it and move on.
You should have most of the Player 1 keys available and
highlighted. If any keys were skipped, select replacement keys from any remaining
open rows. At this point, you should have six rows with one aqua key in each one
highlighted.
Assign the joystick inputs as follows: Look through
all of the rows with no teal or aqua shading.
Either look for logical assignments like Up = U, Down = D, Left = L, Right = R or look for
keys which are in the same row and physically oriented like up and down or side by side,
or don't worry about it and just pick two keys on each row. Shade the P1 Joystick
keys in teal and the P2 Joystick
keys in green. When you finish,
you should have six rows with one aqua key in each one
highlighted, two rows with two teal
keys in each highlighted, and two rows with two green keys in each highlighted (ten rows
used). The teal and green keys will represent:
J1 UP and
J1 DOWN
J1 LEFT
and J1 RIGHT
J2 UP and J2
DOWN
J2 LEFT and
J2 RIGHT
Assign the remaining rows to P2 button inputs as follows:
In any row that does not have any teal or aqua or green shaded keys, pick one key and shade it
lime for six of the
rows. It is better to pick letter keys than commas or periods (which will be hard to
see on the MAME configuration menu), but it really doesn't matter.
Double-check your work. At this point, (for a dual
joystick panel) you should have six rows with one aqua key in each one
highlighted, two rows with two teal
keys in each highlighted, two rows with two green
keys in each highlighted, and six rows with one lime key in each one
highlighted (16 total rows used). If this is not the case, make corrections. At this point, you now know which of the keys you will be using in
MAME.
You still need to decide
which keys will be assigned to which joystick motion or button, but this is basically
personal preference as MAME will accept any choice.
Advanced Concepts in Key Assignments (Optional)
The following information is for the advanced user and is not necessary for general
keyboard hacking. If you want the simple approach, proceed to the Verification Paragraph. I felt that I should include this
for those that happen to discover it or that want to know the details. While testing the PC Concepts keyboard, I discovered that the "one key per
row except the joystick keys" method that I recommend is actually a very useful
oversimplification. It is possible to have two (or more) gameplay keys on the same row
with no ghosting/blocking provided that no other gameplay keys are in the same column
as these keys. The following idealized example (which would never work with a real
keyboard) will illustrate how this works:
Let's say that you have an 18x6 keyboard matrix and all 14 action keys are mapped to
column one and the four joystick keys are mapped between columns one and two so your matrix looks like this:
| |
19 |
20 |
21 |
22 |
23 |
24 |
1 |
1U |
1D |
|
|
|
|
2 |
1L |
1R |
|
|
|
|
3 |
2U |
2D |
|
|
|
|
4 |
2L |
2R |
|
|
|
|
5 |
X |
|
|
|
|
|
6 |
X |
|
|
|
|
|
|
X |
|
|
|
|
|
18 |
X |
|
|
|
|
|
It is possible to move the keys on two of the rows to
unused columns and not have ghosting as follows:
| |
19 |
20 |
21 |
22 |
23 |
24 |
1 |
1U |
1D |
|
|
|
|
2 |
1L |
1R |
|
|
|
|
3 |
2U |
2D |
|
|
|
|
4 |
2L |
2R |
|
|
|
|
5 |
|
|
X |
X |
|
|
6 |
|
|
|
|
X |
X |
|
X |
|
|
|
|
|
18 |
X |
|
|
|
|
|
What is the effect of this? The biggest thing is that if there are two keys that you
absolutely must have for gameplay that are positioned on the same row, you probably can
rearrange your matrix to use these keys. A second advantage is that you may be able
to pick up additional available keys using this method. However, in the idealized
method above, we only gained two keys. In point of fact, most keyboards will have
too many "open spaces" in the matrix to allow keys to be added. In the
"real world", you are probably better planning things out using the "one
key per row except joysticks" method and only using this method to tweak the matrix
if you absolutely want to have some keys on the same row available for gameplay. For
example, using this method with the PC Concepts keyboard matrix (see the Appendix), it
would be possible to leave the joystick mapped to left and right and also add the L Alt
key which is the MAME default for P1B2. However, to do
this, you would no longer be able to use the R, Z, X, C, Up, or Page Down keys for
gameplay. Each of these keys would have to be moved to a different key on the same row,
resulting in a lot of less desirable keys, such as the numeric keypad or function keys.
Here is an even more extreme example of this provided by RandyT (KeyWiz).

(Click
image to enlarge) |