git: 6a26c99f827f - main - atkbd(4): Fix "hancha" and "han/yong" korean keys handling.

From: Vladimir Kondratyev <wulf_at_FreeBSD.org>
Date: Tue, 19 Jul 2022 22:08:21 UTC
The branch main has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=6a26c99f827ffa9da5e23d466eeb17131fc75238

commit 6a26c99f827ffa9da5e23d466eeb17131fc75238
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2022-07-19 21:06:22 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2022-07-19 21:36:20 +0000

    atkbd(4): Fix "hancha" and "han/yong" korean keys handling.
    
    The Korean keyboard has two keys, the Korean/Chinese and the
    Korean/English toggles, that generate scancodes 0xF1 and 0xF2
    (respectively) when pressed, and nothing when released. They do not
    repeat.
    As Hanyong/Hancha keys are generally greater than 0x80, which is
    generally considered a release key, add extra preceding press key event
    to generate press/release pair.
    Swap Hanyong/Hancha key codes to match reality.
    
    Reported by:    Warioburn <warioburn@yahoo.co.jp>
    PR:             265260
    MFC after:      1 week
---
 sys/dev/atkbdc/atkbd.c      | 10 ++++++++++
 sys/dev/evdev/evdev_utils.c |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c
index e87e5591150c..3e261115527b 100644
--- a/sys/dev/atkbdc/atkbd.c
+++ b/sys/dev/atkbdc/atkbd.c
@@ -684,6 +684,16 @@ next_code:
 #ifdef EVDEV_SUPPORT
 	/* push evdev event */
 	if (evdev_rcpt_mask & EVDEV_RCPT_HW_KBD && state->ks_evdev != NULL) {
+		/* "hancha" and "han/yong" korean keys handling */
+		if (state->ks_evdev_state == 0 &&
+		    (scancode == 0xF1 || scancode == 0xF2)) {
+			keycode = evdev_scancode2key(&state->ks_evdev_state,
+				scancode & 0x7F);
+			evdev_push_event(state->ks_evdev, EV_KEY,
+			    (uint16_t)keycode, 1);
+			evdev_sync(state->ks_evdev);
+		}
+
 		keycode = evdev_scancode2key(&state->ks_evdev_state,
 		    scancode);
 
diff --git a/sys/dev/evdev/evdev_utils.c b/sys/dev/evdev/evdev_utils.c
index 9bb58d9b7ba1..ec4a08f27016 100644
--- a/sys/dev/evdev/evdev_utils.c
+++ b/sys/dev/evdev/evdev_utils.c
@@ -147,7 +147,7 @@ static uint16_t evdev_at_set1_scancodes[] = {
 	NONE,		NONE,		NONE,		NONE,
 	NONE,		NONE,		NONE,		NONE,
 	NONE,		NONE,		NONE,		NONE,
-	KEY_KATAKANAHIRAGANA,	KEY_HANGEUL,	KEY_HANJA,	KEY_RO,
+	KEY_KATAKANAHIRAGANA,	KEY_HANJA,	KEY_HANGEUL,	KEY_RO,
 	NONE,		NONE,	KEY_ZENKAKUHANKAKU,	KEY_HIRAGANA,
 	KEY_KATAKANA,	KEY_HENKAN,	NONE,		KEY_MUHENKAN,
 	NONE,		KEY_YEN,	KEY_KPCOMMA,	NONE,