In the Microsoft retail keyboard driver, several of the translation tables are associative tables that map a virtual-key code or a combination of a virtual-key code and some other value (for example, shift state) into an ANSI character. All such tables in these drivers are assembled using special macros that arrange the tables so that the first column of the table is a single vector, which may be searched with a single-string scan instruction.
Table | Description |
keyTrTab | Maps scan codes to Windows virtual-key codes. Some entries in this table in TABS.ASM may be overlaid when a language-specific library is loaded. |
USTransPatch | Maps selected scan codes to virtual-key codes. This table contains that part of the default keyTrTab table that can be overlaid by language-specific libraries. The driver uses this table to restore the default keyTrTab if an error occurs while changing translation tables. |
Most of the remaining tables are either in a discardable segment in the driver or in a language-specific library. If they are in the driver, functions such as ToAscii that use the tables ensure that the table segment is loaded by calling the GetTableSeg function.
The tables in the driver are for the U.S. keyboard. Several of the following tables are blank for the U.S. keyboard since it has no dead keys or CTRL+ALT keys.
In the language-specific versions of these tables, there is often padding (with zeros) at the end of a table to allow for overlaying the tables.
Associative Table | Description |
AscControlVK, AscControl | This table translates the virtual-key code + CTRL to a control character, when the virtual-key code is not one for a letter. For letters, the table is not used. |
AscCtlAltVK, AscCtlAlt | This table translates the virtual-key code + CTRL + ALT to an ANSI character. This is empty for the U.S. keyboard. |
AscShCtlAltVK, AscShCtlAlt | This table translates the virtual-key code + CTRL + ALT + SHIFT to an ANSI character. This table is empty for the U.S. keyboard. |
AscTranVK, AscTran | This table translates the virtual-key codes to ANSI for unshifted and shifted key combinations. AscTranVK is a byte array of virtual-key codes; AscTran is a WORD array of their translations. In each WORD, the low byte is the unshifted translation, and the high byte is the shifted translation. If the virtual-key code is one for a letter (A..Z), this table is bypassed. |
CapitalTable | This table is a list of the virtual keys for which the CAPSLOCK key is effective, in addition to the letter keys (VK_A .. VK_Z). This table is empty for the U.S. keyboard. |
DeadKeyCode, DeadChar | This table translates a combination of a dead key and a letter into an accented letter. This table is accessed when the key after a dead key is pressed. If a translation is not found in this table, ToAscii will return two characters in its output buffer: the dead key plus the second character. This table is empty for the U.S. keyboard. |
Morto, MortoCode | This table is searched to check if a particular virtual-key code and shift combination is for a dead key. If it is, the dead-key value is returned by ToAscii, with a negative-character count. This table is empty for the U.S. keyboard. |
SGCapsVK, SGTrans | This table has entries only in the DLL for Swiss-German keyboards. It handles a special case where keys with SHIFT LOCK are translated differently from shifted keys. |