From 22b8996dba9041874845c7446ce89ec4ae2b713d Mon Sep 17 00:00:00 2001 From: Ross Lagerwall Date: Mon, 27 Feb 2023 17:20:58 +0000 Subject: Fix Hangeul/Hanja scancodes Invert the Xfree86 scancodes for these keys. They were swapped due to a Linux bug which has since been fixed [1]. Fix the scancodes for the AT set 1 to be correct - they include bit 0x80 which requires some special handling to avoid triggering asserts. Also ensure that the QNum scancodes remain as 0x71/0x72 to avoid the wire protocol changing. Finally, add the scancodes for AT set 2 since this is what Windows uses. [1] Linux commit 0ae051a19092 ("Input: atkbd - fix HANGEUL/HANJA keys") Signed-off-by: Ross Lagerwall --- data/keymaps.csv | 8 ++++---- tools/keymap-gen | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/data/keymaps.csv b/data/keymaps.csv index 0fefcef..dd7f555 100644 --- a/data/keymaps.csv +++ b/data/keymaps.csv @@ -192,10 +192,10 @@ KEY_PAUSE,119,,,0xe046,0xe077,0x62,72,VK_PAUSE,0x013,0x66,0x66,XK_Pause,0xff13,P KEY_SCALE,120,,,0xe00b,,,,,,,,,,,I128,,, KEY_KPCOMMA,121,,,0x7e,0x6d,,133,VK_SEPARATOR??,0x6c,,,,,NumpadComma,KPCO,kp_comma,, KEY_KPCOMMA,121,,,0x7e,0x6d,,133,VK_SEPARATOR??,0x6c,,,,,NumpadComma,I129,,, -KEY_HANGEUL,122,JIS_Kana,0x68,0x72,,,144,VK_HANGEUL,0x15,,0x71,,,Lang1,HNGL,lang1,, -KEY_HANGEUL,122,JIS_Kana,0x68,0x72,,,144,VK_IME_ON,0x16,,0x71,,,Lang1,HNGL,lang1,, -KEY_HANJA,123,JIS_Eisu,0x66,0x71,,,145,VK_HANJA,0x19,,0x72,,,Lang2,HJCV,lang2,, -KEY_HANJA,123,JIS_Eisu,0x66,0x71,,,145,VK_IME_OFF,0x1A,,0x72,,,Lang2,HJCV,lang2,, +KEY_HANGEUL,122,JIS_Kana,0x68,0xf2,0xf2,,144,VK_HANGEUL,0x15,,0x72,,,Lang1,HNGL,lang1,, +KEY_HANGEUL,122,JIS_Kana,0x68,0xf2,0xf2,,144,VK_IME_ON,0x16,,0x72,,,Lang1,HNGL,lang1,, +KEY_HANJA,123,JIS_Eisu,0x66,0xf1,0xf1,,145,VK_HANJA,0x19,,0x71,,,Lang2,HJCV,lang2,, +KEY_HANJA,123,JIS_Eisu,0x66,0xf1,0xf1,,145,VK_IME_OFF,0x1A,,0x71,,,Lang2,HJCV,lang2,, KEY_YEN,124,JIS_Yen,0x5d,0x7d,0x6a,0x5d,137,VK_OEM_5,0xdc,0x7d,0x7d,,,IntlYen,AE13,yen,, KEY_LEFTMETA,125,Command,0x37,0xe05b,0xe01f,0x8b,227,VK_LWIN,0x5b,0x6b,0x6b,XK_Meta_L,0xffe7,MetaLeft,LMTA,meta_l,0x78,0x37 KEY_LEFTMETA,125,Command,0x37,0xe05b,0xe01f,0x8b,227,VK_LWIN,0x5b,0x6b,0x6b,XK_Meta_L,0xffe7,MetaLeft,LWIN,meta_l,0x78,0x37 diff --git a/tools/keymap-gen b/tools/keymap-gen index d05e945..4ac4800 100755 --- a/tools/keymap-gen +++ b/tools/keymap-gen @@ -151,6 +151,11 @@ class Database: MAP_QCODE: "Q_KEY_CODE__MAX", } + # These keys need special handling since the key press scan code overlaps + # the 0x80 bit commonly used to indicate key release. + # It also needs handling to ensure that the QNum matches its historical value. + HANJA_HANGEUL_KEYS = (0xf1, 0xf2) + def __init__(self): self.mapto = {} @@ -252,7 +257,7 @@ class Database: # 0xe0 scan codes if linux in self.mapto[self.MAP_ATSET1]: at1 = self.mapto[self.MAP_ATSET1][linux] - if at1 > 0x7f: + if at1 > 0x7f and at1 not in self.HANJA_HANGEUL_KEYS: assert((at1 & ~0x7f) == 0xe000) xtkbd = 0x100 | (at1 & 0x7f) else: @@ -286,7 +291,9 @@ class Database: # different encoding of 0xe0 scan codes if linux in self.mapto[self.MAP_ATSET1]: at1 = self.mapto[self.MAP_ATSET1][linux] - if at1 > 0x7f: + if at1 in self.HANJA_HANGEUL_KEYS: + qnum = at1 & 0x7f + elif at1 > 0x7f: assert((at1 & ~0x7f) == 0xe000) qnum = 0x80 | (at1 & 0x7f) else: -- cgit v1.1