Specifications
CHAPTER 8 Configuring Devices
311
the keyboard. Most keys have one-byte scan codes, but some keys have two-byte
scan codes with prefix 0xe0.
Internally, GSX Server uses a simplified version of the PC scan code that is a single
nine-bit numeric value, called a v-scan code. A v-scan code is written as a three-digit
hexadecimal number. The first digit is 0 or 1. For example, the left-hand Ctrl key has a
one-byte scan code (0x1d); its v-scan code is 0x01d. The right-hand Ctrl key scan
code is two bytes (0xe0, 0x1d); its v-scan code is 0x11d.
An X server uses a two-level encoding of keys. An X key code is a one-byte value. The
assignment of key codes to keys depends on the X server implementation and the
physical keyboard. As a result, an X application normally cannot use key codes directly.
Instead, the key codes are mapped into keysyms that have names like space, escape, x
and 2. The mapping can be controlled by an X application via the function
XChangeKeyboardMapping() or by the program xmodmap. To explore
keyboard mappings, you can use xev, which shows the key codes and keysyms for
keys typed into its window.
To recap, a key code corresponds roughly to a physical key, while a keysym
corresponds to the symbol on the key top. For example, with an XFree86 server
running on a PC, the Z key on the German keyboard has the same key code as the Y
key on an English keyboard. The German Z keysym, however, is the same as the
English Z keysym, and different from the English Y keysym.
For an XFree86 server on a PC, there is a one-to-one mapping from X key codes to PC
scan codes (or v-scan codes, which is what GSX Server really uses). GSX Server takes
advantage of this fact. When it is using an XFree86 server on the local host, it uses the
built-in mapping from X key codes to v-scan codes. This mapping is keyboard
independent and should be correct for most, if not all, languages. In other cases (not
an XFree86 server or not a local server), GSX Server must map keysyms to v-scan
codes, using a set of keyboard-specific tables.
Key code mapping is simple, automatic and foolproof. (Keysym mapping is more
complex and described later.) However, because the program cannot tell whether a
remote server is running on a PC or on some other kind of computer, it errs on the safe
side and uses key code mapping only with local X servers. This is often too
conservative and has undesirable effects. Luckily, this and other behavior related to
key code-mapping can be controlled by powering off the virtual machine and closing
the console, then using a text editor to add configuration settings to the virtual
machine’s configuration file.
• xkeymap.usekeycodeMapIfXFree86 = true
Use key code mapping if you are using an XFree86 server, even if it is remote.