From nobody Thu Feb 9 21:36:15 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PCVYD0dVwz3nmd7; Thu, 9 Feb 2023 21:36:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PCVYD04HTz4FgM; Thu, 9 Feb 2023 21:36:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675978576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=N6mU+9Tw9fA9gFgZppR1WjgJGWbXhdwcebZoPxdrSbs=; b=arKijcg84+cstHVfBNiEJeGUVuInDTdvdwunCDMn1PrI9Fyju2oJviFU6nBA0jInUCvSoA sWIU7Jybk7iTo2/wtpLfAHfLIEMkz5DlZrTTk8PG+4TGMztLKQMP73JLcbfKe0FzfQEOMG DOkB4//ChGsWNdRIu3A8tiBWU1t/EE4AX0M2G8LxxewhyupzeCNmwQCNhbFKcIRvuFg9/V AqjGvocHYWsXScJRbWWIjYMRihk2Qev5y4H6YZyJRkIcs5T7Z07kZYnLcdAMEBWcozzkyw mwpIBUFHXToNNd/3jRU25HP0/LqkznwiaLmXFxqqz84MAhHyIFtMuWWSWpYFHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675978576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=N6mU+9Tw9fA9gFgZppR1WjgJGWbXhdwcebZoPxdrSbs=; b=b1DUZUDIuJ/qepEwtnUjZz/fMPc0KJhH3q5xZoOhrxRxcfzuow9TyDtdcbCMhAfJi+MIPq iPxrjS1agK0/znNI3SoqDxSB6Azg2Qjb/EueabB2nMPWp0KtgQzb6h9PkCpKpWZOagcvPi gPhTt2vatPGEU6lKBKHkPCA3ImETD9is+ZIuVDCqxE2t82SukvITxLvZWxpyOgoTZ6NfLb nfyIrRVQTHa/CDumODi9J2SY7I/h4Kf2fe0NiuN0976+d6xzn9agfIrlqDOKN0a2iynFob ZWxTVAy9iDM0QiFyWuVaJsPNTI06ajim3lcwVRg4EfxTkNbpWIb9+1Lih9lezg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675978576; a=rsa-sha256; cv=none; b=b8NdncdP+fiyX0Gs++Ufj0xBXEP2zdYJ5hDLTzIflWvk2UPuCUQaVXefroFpQCosikq6n7 vNWLue1Nf7KQyKPLJS3yydK1WB2IAdnDZ6Bx0eWvBglZdxhD+SwDiqPQ4v8ft7VzRTyXco Vpf3Qt3l3LGAZczhl7/uhE4GPXLOMg3m93g7DIc5C+AC9/Ju66OmdDp0KUYyTKJrl6Wh73 AVxtnMr/GhYNBy0xLUmsKgdxyj5lms0L3JBdbc7+t9BNisrRdH/g5N200xTV0SfzRFrqv8 VnLfe86R9HdL16X/wPzGdrYIpSJ6OTyYmSSlSoIDlULQMho/+NT4HgwuRPuH0A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PCVYC6CR8zsjy; Thu, 9 Feb 2023 21:36:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 319LaFu1072525; Thu, 9 Feb 2023 21:36:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 319LaFNd072524; Thu, 9 Feb 2023 21:36:15 GMT (envelope-from git) Date: Thu, 9 Feb 2023 21:36:15 GMT Message-Id: <202302092136.319LaFNd072524@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Stefan=20E=C3=9Fer?= Subject: git: b0f694696ceb - stable/13 - Support Unicode characters in keymap dead key tables List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b0f694696ceb4eea47e8bbf070ff01d682f2742a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=b0f694696ceb4eea47e8bbf070ff01d682f2742a commit b0f694696ceb4eea47e8bbf070ff01d682f2742a Author: Stefan Eßer AuthorDate: 2023-02-06 22:48:47 +0000 Commit: Stefan Eßer CommitDate: 2023-02-09 21:35:59 +0000 Support Unicode characters in keymap dead key tables Support for Unicode characters had been added to the keyboard code, but there are keymaps that have accented characters accessed via dead key combinations, and those were still restricted to 8 bit codes. This update to kbd.c adds support for Unicode characters and compatibility code that allows a kbdcontrol command built from kbio.h without these patches to work on a new kernel. Compatibility code that allows a new kbdcontrol binary running on an old kernel to load and display the dead key map will be committed in a separate commit. Reviewed by: imp, brooks Approved by: brooks MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D38381 (cherry picked from commit 4972fb9276389fb87a790b415b1161cff395884c) --- sys/dev/adb/adb_kbd.c | 1 + sys/dev/atkbdc/atkbd.c | 1 + sys/dev/gpio/gpiokeys.c | 1 + sys/dev/hid/hkbd.c | 1 + sys/dev/hyperv/input/hv_kbd.c | 1 + sys/dev/kbd/kbd.c | 52 +++++++++++++++++++++++++++++++++++++++---- sys/dev/kbdmux/kbdmux.c | 1 + sys/dev/syscons/syscons.c | 2 ++ sys/dev/usb/input/ukbd.c | 1 + sys/dev/vkbd/vkbd.c | 1 + sys/dev/vt/vt_core.c | 2 ++ sys/sys/kbio.h | 26 ++++++++++++++++++---- 12 files changed, 82 insertions(+), 8 deletions(-) diff --git a/sys/dev/adb/adb_kbd.c b/sys/dev/adb/adb_kbd.c index d765e73ed351..69ef6271bfa2 100644 --- a/sys/dev/adb/adb_kbd.c +++ b/sys/dev/adb/adb_kbd.c @@ -800,6 +800,7 @@ static int akbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t data) case OPIO_KEYMAP: case PIO_KEYMAPENT: case PIO_DEADKEYMAP: + case OPIO_DEADKEYMAP: default: return (genkbd_commonioctl(kbd, cmd, data)); } diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c index 2e4c8e8e940f..cfaf7749a64c 100644 --- a/sys/dev/atkbdc/atkbd.c +++ b/sys/dev/atkbdc/atkbd.c @@ -1091,6 +1091,7 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) case OPIO_KEYMAP: /* set keyboard translation table (compat) */ case PIO_KEYMAPENT: /* set keyboard translation table entry */ case PIO_DEADKEYMAP: /* set accent key translation table */ + case OPIO_DEADKEYMAP: /* set accent key translation table (compat) */ state->ks_accents = 0; /* FALLTHROUGH */ default: diff --git a/sys/dev/gpio/gpiokeys.c b/sys/dev/gpio/gpiokeys.c index 652a828b63ba..56adb94ba091 100644 --- a/sys/dev/gpio/gpiokeys.c +++ b/sys/dev/gpio/gpiokeys.c @@ -899,6 +899,7 @@ gpiokeys_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg) case PIO_KEYMAPENT: /* set keyboard translation table * entry */ case PIO_DEADKEYMAP: /* set accent key translation table */ + case OPIO_DEADKEYMAP: /* set accent key translation table (compat) */ sc->sc_accents = 0; /* FALLTHROUGH */ default: diff --git a/sys/dev/hid/hkbd.c b/sys/dev/hid/hkbd.c index 7515c1e426dd..b0d82299e487 100644 --- a/sys/dev/hid/hkbd.c +++ b/sys/dev/hid/hkbd.c @@ -1640,6 +1640,7 @@ hkbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg) case PIO_KEYMAPENT: /* set keyboard translation table * entry */ case PIO_DEADKEYMAP: /* set accent key translation table */ + case OPIO_DEADKEYMAP: /* set accent key translation table (compat) */ sc->sc_accents = 0; /* FALLTHROUGH */ default: diff --git a/sys/dev/hyperv/input/hv_kbd.c b/sys/dev/hyperv/input/hv_kbd.c index 291dfe64a803..c6bf5cbbbf14 100644 --- a/sys/dev/hyperv/input/hv_kbd.c +++ b/sys/dev/hyperv/input/hv_kbd.c @@ -667,6 +667,7 @@ hvkbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg) case OPIO_KEYMAP: /* set keyboard translation table (compat) */ case PIO_KEYMAPENT: /* set keyboard translation table entry */ case PIO_DEADKEYMAP: /* set accent key translation table */ + case OPIO_DEADKEYMAP: /* set accent key translation table (compat) */ sc->sc_accents = 0; /* FALLTHROUGH */ default: diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c index deb7672de7fa..41d6fd5666d8 100644 --- a/sys/dev/kbd/kbd.c +++ b/sys/dev/kbd/kbd.c @@ -790,6 +790,8 @@ genkbd_commonioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) { keymap_t *mapp; okeymap_t *omapp; + accentmap_t *accentmapp; + oaccentmap_t *oaccentmapp; keyarg_t *keyp; fkeyarg_t *fkeyp; int i, j; @@ -898,16 +900,58 @@ genkbd_commonioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) #endif case GIO_DEADKEYMAP: /* get accent key translation table */ - bcopy(kbd->kb_accentmap, arg, sizeof(*kbd->kb_accentmap)); + error = copyout(kbd->kb_accentmap, *(void **)arg, + sizeof(accentmap_t)); + return (error); + break; + case OGIO_DEADKEYMAP: /* get accent key translation table (compat) */ + accentmapp = kbd->kb_accentmap; + oaccentmapp = (oaccentmap_t *)arg; + oaccentmapp->n_accs = accentmapp->n_accs; + for (i = 0; i < NUM_DEADKEYS; i++) { + oaccentmapp->acc[i].accchar = + accentmapp->acc[i].accchar; + for (j = 0; j < NUM_ACCENTCHARS; j++) { + oaccentmapp->acc[i].map[j][0] = + accentmapp->acc[i].map[j][0]; + oaccentmapp->acc[i].map[j][1] = + accentmapp->acc[i].map[j][1]; + } + } break; + case PIO_DEADKEYMAP: /* set accent key translation table */ + case OPIO_DEADKEYMAP: /* set accent key translation table (compat) */ #ifndef KBD_DISABLE_KEYMAP_LOAD - error = accent_change_ok(kbd->kb_accentmap, - (accentmap_t *)arg, curthread); + accentmapp = malloc(sizeof(*accentmapp), M_TEMP, M_WAITOK); + if (cmd == OPIO_DEADKEYMAP) { + oaccentmapp = (oaccentmap_t *)arg; + accentmapp->n_accs = oaccentmapp->n_accs; + for (i = 0; i < NUM_DEADKEYS; i++) { + for (j = 0; j < NUM_ACCENTCHARS; j++) { + accentmapp->acc[i].map[j][0] = + oaccentmapp->acc[i].map[j][0]; + accentmapp->acc[i].map[j][1] = + oaccentmapp->acc[i].map[j][1]; + accentmapp->acc[i].accchar = + oaccentmapp->acc[i].accchar; + } + } + } else { + error = copyin(*(void **)arg, accentmapp, sizeof(*accentmapp)); + if (error != 0) { + free(accentmapp, M_TEMP); + return (error); + } + } + + error = accent_change_ok(kbd->kb_accentmap, accentmapp, curthread); if (error != 0) { + free(accentmapp, M_TEMP); return (error); } - bcopy(arg, kbd->kb_accentmap, sizeof(*kbd->kb_accentmap)); + bcopy(accentmapp, kbd->kb_accentmap, sizeof(*kbd->kb_accentmap)); + free(accentmapp, M_TEMP); break; #else return (ENODEV); diff --git a/sys/dev/kbdmux/kbdmux.c b/sys/dev/kbdmux/kbdmux.c index b70e956830e5..1545022bec2a 100644 --- a/sys/dev/kbdmux/kbdmux.c +++ b/sys/dev/kbdmux/kbdmux.c @@ -1243,6 +1243,7 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) case OPIO_KEYMAP: /* set keyboard translation table (compat) */ case PIO_KEYMAPENT: /* set keyboard translation table entry */ case PIO_DEADKEYMAP: /* set accent key translation table */ + case OPIO_DEADKEYMAP: /* set accent key translation table (compat) */ KBDMUX_LOCK(state); state->ks_accents = 0; diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 6c349668410d..c456be43d8a4 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -1598,6 +1598,8 @@ sctty_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) case OPIO_KEYMAP: /* set keyboard translation table (compat) */ case GIO_DEADKEYMAP: /* get accent key translation table */ case PIO_DEADKEYMAP: /* set accent key translation table */ + case OGIO_DEADKEYMAP: /* get accent key translation table (compat) */ + case OPIO_DEADKEYMAP: /* set accent key translation table (compat) */ case GETFKEY: /* get function key string */ case SETFKEY: /* set function key string */ error = kbdd_ioctl(sc->kbd, cmd, data); diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index 48bac46ab088..ab42f0ea1283 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -1862,6 +1862,7 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg) case PIO_KEYMAPENT: /* set keyboard translation table * entry */ case PIO_DEADKEYMAP: /* set accent key translation table */ + case OPIO_DEADKEYMAP: /* set accent key translation table (compat) */ sc->sc_accents = 0; /* FALLTHROUGH */ default: diff --git a/sys/dev/vkbd/vkbd.c b/sys/dev/vkbd/vkbd.c index fdd244ec2525..27cf4549f3db 100644 --- a/sys/dev/vkbd/vkbd.c +++ b/sys/dev/vkbd/vkbd.c @@ -1207,6 +1207,7 @@ vkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) case OPIO_KEYMAP: /* set keyboard translation table (compat) */ case PIO_KEYMAPENT: /* set keyboard translation table entry */ case PIO_DEADKEYMAP: /* set accent key translation table */ + case OPIO_DEADKEYMAP: /* set accent key translation table (compat) */ state->ks_accents = 0; /* FALLTHROUGH */ diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index c5347db94c86..e148fa4f8d7d 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -2403,7 +2403,9 @@ skip_thunk: case GIO_KEYMAP: case PIO_KEYMAP: case GIO_DEADKEYMAP: + case OGIO_DEADKEYMAP: case PIO_DEADKEYMAP: + case OPIO_DEADKEYMAP: case GETFKEY: case SETFKEY: case KDGKBINFO: diff --git a/sys/sys/kbio.h b/sys/sys/kbio.h index 7f17bda76c51..daef8e474816 100644 --- a/sys/sys/kbio.h +++ b/sys/sys/kbio.h @@ -199,8 +199,8 @@ typedef struct okeymap okeymap_t; #define ACC(x) ((x)+F_ACC) struct acc_t { - u_char accchar; - u_char map[NUM_ACCENTCHARS][2]; + u_int accchar; + u_int map[NUM_ACCENTCHARS][2]; }; struct accentmap { @@ -209,6 +209,19 @@ struct accentmap { }; typedef struct accentmap accentmap_t; +#ifdef _KERNEL +struct oacc_t { + u_char accchar; + u_char map[NUM_ACCENTCHARS][2]; +}; + +struct oaccentmap { + u_short n_accs; + struct oacc_t acc[NUM_DEADKEYS]; +}; +typedef struct oaccentmap oaccentmap_t; +#endif /* _KERNEL */ + struct keyarg { u_short keynum; struct keyent_t key; @@ -241,8 +254,13 @@ typedef struct fkeyarg fkeyarg_t; #define OGIO_KEYMAP _IOR('k', 6, okeymap_t) #define OPIO_KEYMAP _IOW('k', 7, okeymap_t) #endif /* _KERNEL */ -#define GIO_DEADKEYMAP _IOR('k', 8, accentmap_t) -#define PIO_DEADKEYMAP _IOW('k', 9, accentmap_t) +/* XXX: Should have accentmap_t as an argument, but that's too big for ioctl()! */ +#define GIO_DEADKEYMAP _IO('k', 8) +#define PIO_DEADKEYMAP _IO('k', 9) +#ifdef _KERNEL +#define OGIO_DEADKEYMAP _IOR('k', 8, oaccentmap_t) +#define OPIO_DEADKEYMAP _IOW('k', 9, oaccentmap_t) +#endif /* _KERNEL */ #define GIO_KEYMAPENT _IOWR('k', 10, keyarg_t) #define PIO_KEYMAPENT _IOW('k', 11, keyarg_t)