Re: Broken keycodes in recent kernels

From: Vojtech Pavlik
Date: Fri Jan 09 2004 - 03:25:30 EST


On Fri, Jan 09, 2004 at 01:08:40AM +0100, Andries.Brouwer@xxxxxx wrote:
>
> Just received my tenth complaint this year about the fact
> that kbd and recent kernels disagree as to what the right
> keycodes are. Since I maintain kbd it follows that recent
> kernels are broken.
>
> What is right?
> The old Linux convention is that for 1-88 keycode equals scancode.
> Above that things are a bit messy, mainly because the 128 scancodes
> xx and the 128 escaped scancodes e0 xx and the single combination
> e1 1d 45 are put into 127 keycodes, and that doesnt fit.
>
> OK. So we want at least to preserve this 1-88 range, and may worry
> about the rest later. All common keys should keep their keycode.
> See also setkeycodes(8).
>
> 2.6 does first an untranslate and then a map to keycode,
> so the fact that keycode equals (translated) scancode
> now becomes atkbd_set2_keycode[atkbd_unxlate_table[i]] == i
> for i=1,...,88.
>
> Looking at 2.6.0 we see a single mistake: scancode 84 is
> translated incorrectly. And many Japanese complained.
> Looking at 2.6.1-rc1 we see two mistakes: also scancode 85
> is now mistranslated.
>
> So, I think the change of 2.6.1-rc1 was not necessarily an
> improvement, but 2.6.0 needs a fix.
>
> I can look at the details, but perhaps Vojtech wants to comment.

I won't argue that the 2.6.1-rc situation is correct, but I'll describe
it and the difference from 2.4:

1) Keycode 84.

On 2.4, keycode 84 is the SysRq keycode, since historically AT keyboards
do emit a different keycode for SysRq than form PrintScreen, although
they're on the same key.

On 2.6, there is only one keycode for PrintScreen, in an attempt to be a
bit saner, and that is 99. And here comes my mistake - since 84 was not
used anymore, I used it for the "103rd" European key.

The 103rd key usually produces either backslash-bar or hash-tilde, or
other national combo. I believe that 2.4 did emit keycode 43 for it,
since this keyboard is treated the same as backslash by AT Set 2
keyboards, in hardware.

USB keyboards, and Set 3 keyboards, however differentiate between this
key and the real backslash, and since there also can be the real
backslash in addition to this key on the keyboard, it makes sense to
allocate a scancode to it.

Now my snafu was that I allocated a 2.4-used scancode to it, and one
that is mapped to SAK in 2.4 keymaps usually.

This bites French, British and probably Brazilian people, too.

I'm open to suggestions about how to fix it.

2) Keycode 85.

Scancode 85 (translated, set2) at the moment is not mapped to any
keycode. There are other scancodes that are not mapped at all, only
known scancodes are mapped, the rest should be changed by the user.

Keycode 85 is defined as F13 (in keymaps), and is mapped to scancode 93
(both in atkbd.c and keyboard.c), which is F13, according to Microsoft
documentation, which was used as reference, since that's what keyboard
manufacturers tend to follow nowadays.

3) Japanese and Korean keys.

2.6 has unified support for Japanese and Korean keys on both USB and
PS/2 keyboards.

The keycodes are defined as:

KEY_INTL1 181 /* Romanji */
KEY_INTL2 182 /* Hiragana / Katakana */
KEY_INTL3 183 /* Yen */
KEY_INTL4 184 /* Henkan */
KEY_INTL5 185 /* Muhenkan */
KEY_INTL6 186 /* PC9800 KP , */
KEY_LANG1 190 /* Hanguel */
KEY_LANG2 191 /* Hanja */
KEY_LANG3 192 /* Katakana */
KEY_LANG4 193 /* Hiragana */
KEY_LANG5 194 /* Zenkaku / Hankaku */

These keycodes are translated back to the PS/2 scancodes in raw mode.

The problem here lies in that that all the keycodes are above 128, and
are different from what 2.4 used for these keys on an AT keyboard.

We could go back to the 2.4 layout, where the keycodes are scattered
where there was space in the translated set2 scancode list, and not even
all fit there, but I think that way lies madness. The 2.6 layout is
based on the USB HUT definition.

--
Vojtech Pavlik
SuSE Labs, SuSE CR
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/