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
This commit is contained in:
parent
a527c18cd7
commit
4972fb9276
@ -798,6 +798,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));
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -666,6 +666,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:
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -2403,7 +2403,9 @@ vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data,
|
||||
case GIO_KEYMAP:
|
||||
case PIO_KEYMAP:
|
||||
case GIO_DEADKEYMAP:
|
||||
case OGIO_DEADKEYMAP:
|
||||
case PIO_DEADKEYMAP:
|
||||
case OPIO_DEADKEYMAP:
|
||||
case GETFKEY:
|
||||
case SETFKEY:
|
||||
case KDGKBINFO:
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user