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 --- tools/keymap-gen | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'tools') 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