Difference between revisions of "EnhancedKeyboardMapping"

From TTWiki
Jump to navigationJump to search
m (Bot: Automated text replacement (--= +==))
(Reformat and update)
 
Line 1: Line 1:
 
 
=Enhanced Keyboard Mapping=
 
 
Remapping key combinations in TTD
 
 
 
TTD uses its own character set, which is a modification of the ISO-8859-1 (also known as Latin-1) character set with some less useful characters replaced with special symbols. For the most part, this set matches the Windows Western code page (Windows-1252), so e.g. accented letters may be entered directly in the Windows versions of TTD as long as your keyboard layout supports them. However, it doesn't work that well if you want to translate TTD (see [[TranslatingTTDPatch| Translating TTDPatch]]) to a language not covered by the Western set, like Czech or Polish, and you're going to modify TTD's character set to support characters that occur in those languages. Non-Western Windows code pages are, unfortunately, more or less incompatible with TTD. For instance, some letters that occur in Czech are mapped by Windows to character codes that TTD uses to change color of text.
 
TTD uses its own character set, which is a modification of the ISO-8859-1 (also known as Latin-1) character set with some less useful characters replaced with special symbols. For the most part, this set matches the Windows Western code page (Windows-1252), so e.g. accented letters may be entered directly in the Windows versions of TTD as long as your keyboard layout supports them. However, it doesn't work that well if you want to translate TTD (see [[TranslatingTTDPatch| Translating TTDPatch]]) to a language not covered by the Western set, like Czech or Polish, and you're going to modify TTD's character set to support characters that occur in those languages. Non-Western Windows code pages are, unfortunately, more or less incompatible with TTD. For instance, some letters that occur in Czech are mapped by Windows to character codes that TTD uses to change color of text.
   
Line 22: Line 16:
   
 
The enhanced keyboard mapping can work together with the morehotkeys switch (see [[MoreHotkeys| More Hotkeys]]) and the `ttdpttxt' mechanism (see [[CustomIngameTexts| Custom in-game texts]]). The keyboard remapping file defines which keys (or combinations) translate to which characters, while the `ttdpttxt' mechanism decides which characters trigger which functions if morehotkeys is turned on.
 
The enhanced keyboard mapping can work together with the morehotkeys switch (see [[MoreHotkeys| More Hotkeys]]) and the `ttdpttxt' mechanism (see [[CustomIngameTexts| Custom in-game texts]]). The keyboard remapping file defines which keys (or combinations) translate to which characters, while the `ttdpttxt' mechanism decides which characters trigger which functions if morehotkeys is turned on.
  +
[[Category:Additional Reading]][[Category:TTDPatch]][[Category:TTDPatch Manual]]

Latest revision as of 18:39, 18 June 2011

TTD uses its own character set, which is a modification of the ISO-8859-1 (also known as Latin-1) character set with some less useful characters replaced with special symbols. For the most part, this set matches the Windows Western code page (Windows-1252), so e.g. accented letters may be entered directly in the Windows versions of TTD as long as your keyboard layout supports them. However, it doesn't work that well if you want to translate TTD (see Translating TTDPatch) to a language not covered by the Western set, like Czech or Polish, and you're going to modify TTD's character set to support characters that occur in those languages. Non-Western Windows code pages are, unfortunately, more or less incompatible with TTD. For instance, some letters that occur in Czech are mapped by Windows to character codes that TTD uses to change color of text.

A similar problem occurs with the Euro character (see More Currencies and Euro), which in most Windows code pages is mapped to the code 128; but that code has special meaning in TTD, so no character may be mapped to it, and therefore TTDPatch maps the Euro glyph to the unused code 158. Unfortunately this means you have to resort to key combinations like Alt-0158 if you want to enter the Euro character into e.g. the name of a savegame, even if the Euro character is directly supported in your keyboard layout.

The problem is even more severe in the DOS versions of TTD, which have hardcoded and sometimes very restricted keyboard mappings (in particular, the French version is notorious for missing the colon (:) key mapping), and have no support for key combinations involving the right Alt key, common in many European locales.

Therefore, since version 2.0 TTDPatch supports keyboard remapping. To enable this feature, first you have to get (or create yourself) the keyboard remapping file, ttdpatch.kbd for the DOS version or ttdpatchw.kbd for the Windows version. Simply place that file in the TTD directory, and TTDPatch will load it and enable its enhanced keyboard handler.

The keyboard remapping file is a binary file; the DOS version and the Windows version use a different format. You may download a sample file from the TTDPatch website at [1], which contains a detailed description of the file formats as well.

DOS versions of TTD feature its own low-level keyboard handler, so TTDPatch's enhanced keyboard handler is more powerful in the DOS version, allowing the user to remap virtually any key or key combination. Windows versions of TTD rely on the Windows keyboard driver to map keys to characters, so the Windows version of TTDPatch offers a more simple character-based remapping.

When the enhanced keyboard handler is active, some bug fixes are activated even if the generalfixes switch is disabled (see General Fixes), and some aspects of the keyboard interface change, which is explained in detail in the sample file mentioned above.

In the DOS versions, if the enhanced keyboard handler is active, the three Lock keys (Num Lock, Caps Lock, Scroll Lock) toggle the LED indicators on the keyboard, as they normally do in DOS and Windows. This works even if ttdpatch.kbd is empty; however, TTD normally ignores the states of the Lock keys anyway, so if proper key mappings are not defined in ttdpatch.kbd, this feature is rather useless.

The enhanced keyboard mapping can work together with the morehotkeys switch (see More Hotkeys) and the `ttdpttxt' mechanism (see Custom in-game texts). The keyboard remapping file defines which keys (or combinations) translate to which characters, while the `ttdpttxt' mechanism decides which characters trigger which functions if morehotkeys is turned on.