diff options
Diffstat (limited to 'sbin/wsconsctl')
-rw-r--r-- | sbin/wsconsctl/keyboard.c | 5 | ||||
-rw-r--r-- | sbin/wsconsctl/keysym.c | 67 | ||||
-rw-r--r-- | sbin/wsconsctl/mkkeysym.sh | 19 | ||||
-rw-r--r-- | sbin/wsconsctl/util.c | 3 | ||||
-rw-r--r-- | sbin/wsconsctl/wsconsctl.h | 3 |
5 files changed, 85 insertions, 12 deletions
diff --git a/sbin/wsconsctl/keyboard.c b/sbin/wsconsctl/keyboard.c index 2539e565bd5..8c11077450a 100644 --- a/sbin/wsconsctl/keyboard.c +++ b/sbin/wsconsctl/keyboard.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keyboard.c,v 1.7 2009/07/15 20:32:28 martynas Exp $ */ +/* $OpenBSD: keyboard.c,v 1.8 2010/06/28 20:40:39 maja Exp $ */ /* $NetBSD: keyboard.c 1.1 1998/12/28 14:01:17 hannken Exp $ */ /*- @@ -98,6 +98,9 @@ keyboard_get_values(const char *pre, int fd) kbmap.maplen = KS_NUMKEYCODES; if (ioctl(fd, WSKBDIO_GETMAP, &kbmap) < 0) warn("WSKBDIO_GETMAP"); + if (ioctl(fd, WSKBDIO_GETENCODING, &kbdencoding) < 0) + warn("WSKBDIO_GETENCODING"); + ksymenc(kbdencoding); } repeat.which = 0; diff --git a/sbin/wsconsctl/keysym.c b/sbin/wsconsctl/keysym.c index df55cf12916..10bb5d56a45 100644 --- a/sbin/wsconsctl/keysym.c +++ b/sbin/wsconsctl/keysym.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keysym.c,v 1.5 2008/06/26 05:42:06 ray Exp $ */ +/* $OpenBSD: keysym.c,v 1.6 2010/06/28 20:40:39 maja Exp $ */ /* $NetBSD: keysym.c,v 1.3 1999/02/08 11:08:23 hannken Exp $ */ /*- @@ -42,6 +42,7 @@ static int first_time = 1; static struct ksym ksym_tab_by_ksym[NUMKSYMS]; +static int encoding = KEYSYM_ENC_ISO; /* copied from dev/wscons/wskbdutil.c ... */ @@ -85,6 +86,7 @@ static int qcmp_name(const void *, const void *); static int qcmp_ksym(const void *, const void *); static int bcmp_name(const void *, const void *); static int bcmp_ksym(const void *, const void *); +static int bcmp_ksym_enc(const void *, const void *); static void sort_ksym_tab(void); @@ -97,7 +99,13 @@ qcmp_name(const void *a, const void *b) static int qcmp_ksym(const void *a, const void *b) { - return(((struct ksym *) b)->value - ((struct ksym *) a)->value); + int i; + + i=((struct ksym *) b)->value - ((struct ksym *) a)->value; + if (i == 0) { + i=((struct ksym *) a)->enc - ((struct ksym *) b)->enc; + } + return(i); } static int @@ -109,7 +117,25 @@ bcmp_name(const void *a, const void *b) static int bcmp_ksym(const void *a, const void *b) { - return(((struct ksym *) b)->value - *((int *) a)); + int i; + + i=((struct ksym *) b)->value - *((int *) a); + if (i == 0) { + i=KEYSYM_ENC_ISO - ((struct ksym *) b)->enc; + } + return(i); +} + +static int +bcmp_ksym_enc(const void *a, const void *b) +{ + int i; + + i=((struct ksym *) b)->value - *((int *) a); + if (i == 0) { + i=encoding - ((struct ksym *) b)->enc; + } + return(i); } static void @@ -134,9 +160,14 @@ ksym2name(int k) if (first_time) sort_ksym_tab(); - + r = bsearch(&k, ksym_tab_by_ksym, - NUMKSYMS, sizeof(struct ksym), bcmp_ksym); + NUMKSYMS, sizeof(struct ksym), bcmp_ksym_enc); + + if (r == NULL) { + r = bsearch(&k, ksym_tab_by_ksym, + NUMKSYMS, sizeof(struct ksym), bcmp_ksym); + } if (r != NULL) return(r->name); @@ -166,6 +197,32 @@ name2ksym(char *n) return(-1); } +void +ksymenc(int enc) +{ + switch(KB_ENCODING(enc)) { + case KB_HU: + case KB_PL: + case KB_SI: + encoding=KEYSYM_ENC_L2; + break; + case KB_TR: + encoding=KEYSYM_ENC_L5; + break; + case KB_LT: + case KB_LV: + encoding=KEYSYM_ENC_L7; + break; + case KB_RU: + case KB_UA: + encoding=KEYSYM_ENC_KOI; + break; + default: + encoding=KEYSYM_ENC_ISO; + break; + } +} + keysym_t ksym_upcase(keysym_t ksym) { diff --git a/sbin/wsconsctl/mkkeysym.sh b/sbin/wsconsctl/mkkeysym.sh index 00246e7c90b..c4a15480a3b 100644 --- a/sbin/wsconsctl/mkkeysym.sh +++ b/sbin/wsconsctl/mkkeysym.sh @@ -1,6 +1,6 @@ #! /bin/sh # -# $OpenBSD: mkkeysym.sh,v 1.1 2000/07/01 23:52:45 mickey Exp $ +# $OpenBSD: mkkeysym.sh,v 1.2 2010/06/28 20:40:39 maja Exp $ # $NetBSD: mkkeysym.sh 1.1 1998/12/28 14:01:17 hannken Exp $ # # Build a table of keysyms from a file describing keysyms as: @@ -17,7 +17,12 @@ ${AWK} ' BEGIN { in_decl = 0; printf("/* DO NOT EDIT: AUTOMATICALLY GENERATED FROM '$1' */\n\n"); - printf("struct ksym {\n\tchar *name;\n\tint value;\n};\n\n"); + printf("#define\tKEYSYM_ENC_ISO\t0\n"); + printf("#define\tKEYSYM_ENC_L2\t1\n"); + printf("#define\tKEYSYM_ENC_L5\t2\n"); + printf("#define\tKEYSYM_ENC_L7\t3\n"); + printf("#define\tKEYSYM_ENC_KOI\t4\n\n"); + printf("struct ksym {\n\tchar *name;\n\tint value;\n\tint enc;\n};\n\n"); printf("struct ksym ksym_tab_by_name[] = {\n"); } @@ -34,6 +39,12 @@ $1 == "/*ENDKEYSYMDECL*/" { } $1 ~ /^#[ ]*define/ && $2 ~ /^KS_/ && $3 ~ /^0x[0-9a-f]*/ { - if (in_decl) - printf("\t{ \"%s\", %s },\n", substr($2, 4), $3); + if (in_decl) { + enc="KEYSYM_ENC_ISO" + if ($2 ~ /^KS_L2_/) { enc="KEYSYM_ENC_L2" } + if ($2 ~ /^KS_L5_/) { enc="KEYSYM_ENC_L5" } + if ($2 ~ /^KS_L7_/) { enc="KEYSYM_ENC_L7" } + if ($2 ~ /^KS_Cyrillic_/) { enc="KEYSYM_ENC_KOI" } + printf("\t{ \"%s\", %s, %s },\n", substr($2, 4), $3, enc); + } }' $1 diff --git a/sbin/wsconsctl/util.c b/sbin/wsconsctl/util.c index 7ce30ffb77c..8bf7d0669ff 100644 --- a/sbin/wsconsctl/util.c +++ b/sbin/wsconsctl/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.49 2010/03/07 21:26:24 miod Exp $ */ +/* $OpenBSD: util.c,v 1.50 2010/06/28 20:40:39 maja Exp $ */ /* $NetBSD: util.c,v 1.8 2000/03/14 08:11:53 sato Exp $ */ /*- @@ -474,4 +474,5 @@ print_kmap(struct wskbd_map_data *map) } } } + ksymenc(0); } diff --git a/sbin/wsconsctl/wsconsctl.h b/sbin/wsconsctl/wsconsctl.h index 5319bc1f6db..30c70e081b2 100644 --- a/sbin/wsconsctl/wsconsctl.h +++ b/sbin/wsconsctl/wsconsctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsconsctl.h,v 1.9 2009/07/15 20:32:28 martynas Exp $ */ +/* $OpenBSD: wsconsctl.h,v 1.10 2010/06/28 20:40:39 maja Exp $ */ /* $NetBSD: wsconsctl.h 1.1 1998/12/28 14:01:17 hannken Exp $ */ /*- @@ -67,6 +67,7 @@ void pr_field(const char *, struct field *, const char *); void rd_field(struct field *, char *, int); int name2ksym(char *); char *ksym2name(int); +void ksymenc(int); keysym_t ksym_upcase(keysym_t); void keyboard_get_values(const char *,int); int keyboard_put_values(const char *,int); |