by "Cajun" David Richard, David Artur-Daix, and Matt Burch
With the release of Escape Velocity, there has been a lot of enthusiasm about the
game and about creating plug-ins for it. Through plug-ins, folks can create new
universes, systems, planets, ships, weapons, and more to give players a wider variety
in the game.
Plug-ins can also be useful to make smaller changes to the game as well. We have found a small
problem with the way Matt is reading input from the keyboard and it's relationship with international keyboard layouts. David Artur-Daix, a gentleman in France, was using a different
keyboard layout than we do here in the US. David and Matt collaborated to make it possible for
plug-ins to be created to accomodate these different keyboard layouts.
They both gathered their respective information and send it to me for this article. The following is a detailed description of how to create a plug-in for your different keyboard layout.
• The Keyboard Layout Package, available from the Add Ons section of our Web site.
• A Macintosh computer
• Version 1.0.2 or later of Escape Velocity.
The procedure is rather simple, but it does take a little organization. I will begin with a little
background on how EV reads the keyboard.
When you press a key on your keyboard, it sends a numerical code to the system. EV then reads
this code, determines which key you have pressed, and takes the appropriate action. EV bypasses
certain Macintosh toolbox routines that would normally handle these conversions in the interest of speed and playability.
The problem with international keyboard layouts arrises because the letters of each key are moved around, but the key codes remain the same. For instance, the "A" key on a US keyboard sends a key code of "8" to the system. If the "Y" key is in the "A" key's place on another layout, the key code sent by the "Y" will be "8". In effect, the keys are the same even though the letters on the keys are different. EV doesn't know the difference. What happens is that the Preferences dialog in EV will say you need to hit "A" but in actuality you need to hit "Y" for that function.
When you create a keyboard plug-in, you change the letters that appear in the Preferences dialog
box so that they correspond to your keyboard layout. You effectively change the keyboard map to
the correct letters.
The Keyboard Layout Package from the Web site contains two items. One is a plug-in that can be
used to build your own. It contains one resource (a 'STR#') that matches the letters to the respective key codes. The STR#'s are listed between 1 and 128.
Also in the Keyboard Layout Package is a program called KeyTest that Matt threw together to
determine what the key code of a pressed key is. This program will display the key code of a key
when you press it on your keyboard. When you are done, you can click the mouse to exit the
program. The key codes range from 0 to 127, so you need to make sure you do the proper shift.
For example: the "A" key has the key code "8", but if you want to change it, You will have to make the change in STR# resource 9.
Now that we understand how EV is reading the keyboard, we need to make the changes. The
plug-in included in the Keyboard Layout Package is what is used for the US keyboards. What you need to do is to determine which keys are different in your keyboard layout. The easiest way to do this is to record all of the keys on a piece of paper. Then, by using the KeyTest program, record all of the key codes for each key. You should have a list that includes all of the keys and their respective codes.
All that is left is to make the changes. First, you will want to make a copy of the plug-in just to be safe. Then, open the plug-in in ResEdit and open the 'STR#' resource. You will see a list of all 128 STR's. Some will have letters, some will not. What needs to be done at this point is to match what is on your list to what is in the resource. Remember the ID# shift. The numbers in the resource will be one higher than the key code. Also, make sure you use capital letters in the resource.
Once this is done, save the changes you made in ResEdit and move your newly created plug-in to the Plug-Ins folder for EV. Then, run EV and check the Preferences dialog box to see if what you have done is correct. You may also want to play EV a little to make sure everything works properly.
Now you have successfully created a plug-in for EV. Name it appropriately and send it to us. We will place it on the Add Ons page for EV so that others can make use of your creation.