diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1998-05-29 00:42:54 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1998-05-29 00:42:54 +0000 |
commit | 2de1e4190b510b46917c96c19d7ebd01a07b41b8 (patch) | |
tree | a4bbe176fed4759e3f83b1d28d67c19575570fbe | |
parent | b8784109249d1b00bc2c35c6721e165e0741795c (diff) |
add support for pcvt.
ugly call system(kcon) when needed to avoid code copying.
-rw-r--r-- | sbin/kbd/kbd_i386.c | 84 |
1 files changed, 54 insertions, 30 deletions
diff --git a/sbin/kbd/kbd_i386.c b/sbin/kbd/kbd_i386.c index 036f973b2a9..76cd8314b1f 100644 --- a/sbin/kbd/kbd_i386.c +++ b/sbin/kbd/kbd_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kbd_i386.c,v 1.6 1997/09/14 10:37:57 deraadt Exp $ */ +/* $OpenBSD: kbd_i386.c,v 1.7 1998/05/29 00:42:53 mickey Exp $ */ /* * Copyright (c) 1996 Juergen Hannken-Illjes @@ -34,6 +34,7 @@ #include <sys/types.h> #include <machine/pccons.h> +#include <machine/pcvt_ioctl.h> #include <paths.h> #include <unistd.h> #include <fcntl.h> @@ -72,18 +73,30 @@ struct { extern char *__progname; +int +ispcvt() +{ + struct pcvtid pcvtid; + + return ioctl(0, VGAPCVTID, &pcvtid); +} + void kbd_list() { int i, j; - printf("tables available:\n%-16s %s\n\n", "encoding", "nick names"); - for (i = 0; keymaps[i].name[0]; i++) { - printf("%-16s",keymaps[i].name[0]); - for (j = 1; j < NUM_NAMES && keymaps[i].name[j]; j++) - printf(" %s", keymaps[i].name[j]); - printf("\n"); - } + if (ispcvt() < 0) { + printf("tables available:\n%-16s %s\n\n", + "encoding", "nick names"); + for (i = 0; keymaps[i].name[0]; i++) { + printf("%-16s",keymaps[i].name[0]); + for (j = 1; j < NUM_NAMES && keymaps[i].name[j]; j++) + printf(" %s", keymaps[i].name[j]); + printf("\n"); + } + } else + printf("consult 'keycap' database for kbd mapping tables\n"); } void @@ -91,30 +104,41 @@ kbd_set(name, verbose) char *name; int verbose; { - int i, j, fd; - pccons_keymap_t *map = NULL; - - for (i = 0; keymaps[i].name[0]; i++) - for (j = 0; j < NUM_NAMES && keymaps[i].name[j]; j++) - if (strcmp(keymaps[i].name[j], name) == 0) { - name = keymaps[i].name[0]; - map = keymaps[i].map; - break; - } - - if (map == NULL) { - fprintf(stderr, "%s: no such keymap: %s\n", __progname, name); - exit(1); - } - if ((fd = open(_PATH_CONSOLE, O_RDONLY)) < 0) - err(1, "%s", _PATH_CONSOLE); + if (ispcvt() < 0) { + int i, j, fd; + pccons_keymap_t *map = NULL; + + for (i = 0; keymaps[i].name[0]; i++) + for (j = 0; j < NUM_NAMES && keymaps[i].name[j]; j++) + if (strcmp(keymaps[i].name[j], name) == 0) { + name = keymaps[i].name[0]; + map = keymaps[i].map; + break; + } - if (ioctl(fd, CONSOLE_SET_KEYMAP, map) < 0) - err(1, "CONSOLE_SET_KEYMAP"); + if (map == NULL) { + fprintf(stderr, "%s: no such keymap: %s\n", + __progname, name); + exit(1); + } - close(fd); + if ((fd = open(_PATH_CONSOLE, O_RDONLY)) < 0) + err(1, "%s", _PATH_CONSOLE); - if (verbose) - fprintf(stderr, "keyboard mapping set to %s\n", name); + if (ioctl(fd, CONSOLE_SET_KEYMAP, map) < 0) + err(1, "CONSOLE_SET_KEYMAP"); + + close(fd); + + if (verbose) + fprintf(stderr, "keyboard mapping set to %s\n", name); + } else { + char buf[32]; + + snprintf(buf, sizeof(buf), "kcon -m %s", name); + + if (system(buf)) + err(1, name); + } } |