aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2023-02-06 22:48:47 +0000
committerStefan Eßer <se@FreeBSD.org>2023-02-09 21:35:59 +0000
commitb0f694696ceb4eea47e8bbf070ff01d682f2742a (patch)
treecfd1427cd4f906b4e98b4481f490386a05b039b2
parent9b7787294c581d160304d5bc7450cf33421a3e19 (diff)
downloadsrc-b0f694696ceb4eea47e8bbf070ff01d682f2742a.tar.gz
src-b0f694696ceb4eea47e8bbf070ff01d682f2742a.zip
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)
-rw-r--r--sys/dev/adb/adb_kbd.c1
-rw-r--r--sys/dev/atkbdc/atkbd.c1
-rw-r--r--sys/dev/gpio/gpiokeys.c1
-rw-r--r--sys/dev/hid/hkbd.c1
-rw-r--r--sys/dev/hyperv/input/hv_kbd.c1
-rw-r--r--sys/dev/kbd/kbd.c52
-rw-r--r--sys/dev/kbdmux/kbdmux.c1
-rw-r--r--sys/dev/syscons/syscons.c2
-rw-r--r--sys/dev/usb/input/ukbd.c1
-rw-r--r--sys/dev/vkbd/vkbd.c1
-rw-r--r--sys/dev/vt/vt_core.c2
-rw-r--r--sys/sys/kbio.h26
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)