diff options
author | Mats O Jansson <maja@cvs.openbsd.org> | 1999-07-23 09:03:18 +0000 |
---|---|---|
committer | Mats O Jansson <maja@cvs.openbsd.org> | 1999-07-23 09:03:18 +0000 |
commit | 7404d1b805572739854469252282a4bba4c9ac58 (patch) | |
tree | 387688fe1b0aebbf58a7b8096777dff63ac61fcd /sbin | |
parent | 9c822bddba0129c65dc27afa710792426c1a18e6 (diff) |
default map is now selected by the keyboard id. If current keyboard id don't
have a map, use the first keyboard map as default (us). -moj
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/kbd/kbd_sparc.c | 54 | ||||
-rw-r--r-- | sbin/kbd/tables/sparc/us | 4 |
2 files changed, 50 insertions, 8 deletions
diff --git a/sbin/kbd/kbd_sparc.c b/sbin/kbd/kbd_sparc.c index 8ee71e51472..136a9082299 100644 --- a/sbin/kbd/kbd_sparc.c +++ b/sbin/kbd/kbd_sparc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kbd_sparc.c,v 1.3 1999/07/20 21:02:25 maja Exp $ */ +/* $OpenBSD: kbd_sparc.c,v 1.4 1999/07/23 09:03:16 maja Exp $ */ /* * Copyright (c) 1999 Mats O Jansson. All rights reserved. @@ -38,6 +38,8 @@ #define NUM_KEYS 128 /* Number of scan codes */ #define NUM_NAMES 10 /* Number of names for a map */ +#define PATH_KBD "/dev/kbd" + #define ALL(s) (s), (s), (s), (s), #define BB(s) (FUNNY+(s)) #define LF(s) (0x600+(s)-1) @@ -149,10 +151,47 @@ struct { extern char *__progname; +char * +kbd_find_default() +{ + int i, j, fd, r, ok; + int t = KB_SUN4; + int l = 0; + char defaultmap[30]; + char *ret; + + /* Generate the default map name */ + + fd = open(PATH_KBD, O_RDONLY); + if (fd != -1) { + r = ioctl(fd, KIOCTYPE, &t); + r = ioctl(fd, KIOCLAYOUT, &l); + close(fd); + } + snprintf(defaultmap,sizeof(defaultmap),"type_%d_layout_%02x\0",t,l); + + /* Check if it exist, if not use "type_4_layout_00" */ + + ret = keymaps[0].name[0]; + + for (i = 0; keymaps[i].name[0]; i++) { + ok = 0; + for (j = 1; j < NUM_NAMES && keymaps[i].name[j]; j++) + ok |= (strcmp(keymaps[i].name[j],defaultmap) == 0); + if (ok) ret = keymaps[i].name[0]; + } + + return(ret); + +} + void kbd_list() { int i, j; + char *defmap; + + defmap = kbd_find_default(); printf("tables available:\n%-16s %s\n\n", "encoding", "nick names"); @@ -160,6 +199,7 @@ kbd_list() printf("%-16s",keymaps[i].name[0]); for (j = 1; j < NUM_NAMES && keymaps[i].name[j]; j++) printf(" %s", keymaps[i].name[j]); + if (keymaps[i].name[0] == defmap) printf(" default"); printf("\n"); } } @@ -169,11 +209,15 @@ kbd_set(name, verbose) char *name; int verbose; { - int i, j, fd, t, l, r; + int i, j, fd, r; keymap_t *map = NULL; int x[] = { KIOC_NOMASK, KIOC_SHIFTMASK, KIOC_ALTGMASK, KIOC_CTRLMASK }; struct kiockey k; + + if(strcmp(name,"default") == 0) { + name = kbd_find_default(); + } for (i = 0; keymaps[i].name[0]; i++) for (j = 0; j < NUM_NAMES && keymaps[i].name[j]; j++) @@ -189,14 +233,12 @@ kbd_set(name, verbose) exit(1); } - fd = open("/dev/kbd", O_RDWR); + fd = open(PATH_KBD, O_RDWR); if (fd == -1) { - perror("/dev/kbd"); + perror(PATH_KBD); exit(1); } - r = ioctl(fd, KIOCTYPE, &t); - r = ioctl(fd, KIOCLAYOUT, &l); for (i = 0; i < 128; i++) { for (j = 0; j < 4; j++) { k.kio_tablemask = x[j]; diff --git a/sbin/kbd/tables/sparc/us b/sbin/kbd/tables/sparc/us index 06873d76e0a..8d9366ac14e 100644 --- a/sbin/kbd/tables/sparc/us +++ b/sbin/kbd/tables/sparc/us @@ -1,4 +1,4 @@ -/* $OpenBSD: us,v 1.1 1999/07/18 17:21:13 maja Exp $ */ +/* $OpenBSD: us,v 1.2 1999/07/23 09:03:17 maja Exp $ */ /* * Copyright (c) 1999 Mats O Jansson @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ - { "us", "default", "reset", "type_4_layout_00", "type_4_layout_01" }, + { "us", "reset", "type_4_layout_00", "type_4_layout_01" }, /* unshift shift alt gr control */ ALL(HOLE) /* 0 */ ALL(BB(SYSTEMBIT)) /* 1 */ |