Skip to content
matt335672 edited this page Apr 8, 2024 · 1 revision

Terminology

Term Meaning
Scancode Value representing a physical key received from the RDP client. See [MS-RDPBCGR]. Essentially a 9 bit value.
Keycode Value used by X11 to represent a physical key. This has essentially the same semantics as an RDP scancode. In the range 8-255
KeySym Encoding of a symbol engraved into a key (e.g. XK_percent for a percent sign
Keyboard mapping table A file in /etc/xrdp which maps keycodes to KeySyms and Unicode characters

Lookup process

The current process, ignoring modifiers, works as follows:-

  1. An RDP scancode is received from the client.
  2. This passes through an xrdp-specific lookup table to generate an keycode.
  3. The keycode is further processed as follows:-
    1. [Login screen] The keycode is looked up in the keyboard mapping table to get a character for the keycode
    2. [VNC backend] The keycode is looked up in the keyboard mapping table to get a KeySym. This is used to inject an X Event into Xvnc.
    3. [Xorg backend] The RDP scancode is passed to xorgxrdp which performs its own translation. The keyboard mapping table is not used.

3c will be considered in later versions of this document.

Keycode

The translation from scancode to keycode seems a bit pointless based on the above description. Why go through an intermediate value? The answer is that somehow we need to produce the keyboard mapping tables. Each keyboard mapping table is produced by running a program called genkeymap. This uses the Xlib XLookupString() call to convert all 247 keycodes into KeySyms and characters. Before the program is run, the setxkbmap program is used to set a particular keyboard model and layout.

This process works fine provided the X11 keycodes used by the X server match the table embedded into xrdp. However, there is no official standard in this area.

When xrdp was created, the predominant X server used was RealVNC. At the time that used its own particular mapping. Since then, a lot has changed:-

  1. Linux (and FreeBSD) have standardised on keycodes produced by the evdev driver.
  2. The predominant VNC server is now RealVNC, which also uses evdev keycodes.

Consequently, the X11 keycodes now used by xrdp are effectively the evdev ones.

Clone this wiki locally