| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|
| Key | scancode | Original (wrong) keycode | wrong Xkeysym | remapped "scancode" | XKB keycode | correct X keysym |
| STOP | e0 68 | 232 | Help | D6 (=214) | 222 | Cancel |
| AGAI | 5d | 101 | NoSym | D7 | 223 | Redo |
| PROP | 5e | 102 | Right | D8 | 224 | SunProps |
| FRNT | 62 | 106 | Ins | DA | 226 | SunFront |
| ... | ||||||
| INS | e0 52 | 106 | - | - | 106 | Ins |
The first column denotes the actual key on your keyboard. The second is the scancode as it can be observed on the console by showkey -s and is sent from kernel to X server.
When I first started an unpatched X server with no modifications in XKB, columns 3 and 4 show the wrong keycode/keysym pair as reported by xev. Note the conflict at keycode 106. The conflict occurs because internally not all scancodes are translated, but only some ranges (and these possibly by different offsets).
I'd guess if you see right now the same values then you've got good chances that my patch works for you. :-)
The scancode->keycode mapping is done in (xf86 src root)/xc/programs/Xserver/hw/xfree86/common/xf86Events.c in the function xf86PostKbdEvent. The first translation is being done in a big case-expression; the code calls the result still "scancode", but I refer to it by remapped scancode (column 5). I tabulated the codes and found, starting at 214, some free space to map my special keys to. So I extended the translation with my patch to resolve the conflicts.
Now, how do we get from column 5 to 6? Later on in xf86PostKbdEvent, you'll find
/* * Now map the scancodes to real X-keycodes ... */ keycode = scanCode + MIN_KEYCODE;where MIN_KEYCODE is defined as 8, so here the offset 8 comes into play (Some scancode ranges are being left untouched before, so keycode is then scancode +8. Several ranges receive different translations, so that the remapped scancodes already have an offset relative to the original scancode - like my own translation for the special Sun keys.)
If you apply the server patch, xev should report the new keycodes (col 6). In order to be able to use them, you've got to configure XKB to map these keycodes to a keysym (i.e., a character or action). This is what the XKB patch does.
Nils Ellmenreich, Apr 2001