From: Alexey Gladkov Date: Mon, 20 May 2013 13:31:55 +0000 (+0400) Subject: Remove static arrays for keymaps and keys X-Git-Tag: 2.0.2~41^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dad237f0b167991e2d2909265d04668d45d86ffa;p=platform%2Fupstream%2Fkbd.git Remove static arrays for keymaps and keys Signed-off-by: Alexey Gladkov --- diff --git a/src/libkeymap/Makefile.am b/src/libkeymap/Makefile.am index ad3699f..9ed8238 100644 --- a/src/libkeymap/Makefile.am +++ b/src/libkeymap/Makefile.am @@ -36,6 +36,7 @@ ksyms_headers = \ libkeymap_la_SOURCES = \ $(headers) \ + array.c \ findfile.c common.c kernel.c dump.c kmap.c summary.c loadkeys.c \ parser.y parser.h analyze.l analyze.h \ modifiers.c modifiers.h \ diff --git a/src/libkeymap/array.c b/src/libkeymap/array.c new file mode 100644 index 0000000..659f91a --- /dev/null +++ b/src/libkeymap/array.c @@ -0,0 +1,122 @@ +#include +#include +#include +#include +#include + +#include + +int +lk_array_init(struct lk_array *a, size_t memb, size_t size) +{ + if (!a) + return -EINVAL; + + memset(a, 0, sizeof(struct lk_array)); + + a->array = calloc(size, memb); + a->memb = memb; + a->total = size; + + if (size && !a->array) + return -ENOMEM; + + return 0; +} + +int +lk_array_free(struct lk_array *a) +{ + if (!a) + return -EINVAL; + free(a->array); + memset(a, 0, sizeof(struct lk_array)); + return 0; +} + +int +lk_array_exist(struct lk_array *a, unsigned int i) +{ + char *s; + size_t k; + + if (!a || i >= a->total) { + return 0; + } + + s = (char *) (a->array + (a->memb * i)); + + for (k = 0; k < a->memb; k++) { + if (s[k] != 0) + return 1; + } + + return 0; +} + +void * +lk_array_get(struct lk_array *a, unsigned int i) +{ + if (!a || i >= a->total) { + return NULL; + } + return a->array + (a->memb * i); +} + +void * +lk_array_get_ptr(struct lk_array *a, unsigned int i) +{ + void **ptr; + if (!a || i >= a->total) { + return NULL; + } + ptr = a->array; + return *(ptr + i); +} + +static int +array_resize(struct lk_array *a, unsigned int i) +{ + if (!a) + return -EINVAL; + + if (i >= a->total) { + void *tmp = realloc(a->array, a->memb * (i + 1)); + if (!tmp) + return -ENOMEM; + + memset(tmp + (a->memb * a->total), 0, a->memb * (i + 1 - a->total)); + + a->array = tmp; + a->total = i + 1; + } + return 0; +} + +int +lk_array_set(struct lk_array *a, unsigned int i, const void *e) +{ + int ret = array_resize(a, i); + + if (ret < 0) + return ret; + + memcpy(a->array + (a->memb * i), e, a->memb); + a->count++; + + return 0; +} + +int +lk_array_unset(struct lk_array *a, unsigned int i) +{ + if (!a || i >= a->total) + return -EINVAL; + + if (lk_array_exist(a, i)) { + memset(a->array + (a->memb * i), 0, a->memb); + a->count--; + } + + return 0; +} diff --git a/src/libkeymap/common.c b/src/libkeymap/common.c index 455ff29..be0ffdf 100644 --- a/src/libkeymap/common.c +++ b/src/libkeymap/common.c @@ -24,7 +24,7 @@ lk_log(struct keymap *kmap, int priority, # define log_unused #endif -static void +static void __attribute__ ((format(printf, 6, 0))) log_file(void *data, int priority log_unused, const char *file log_unused, @@ -104,6 +104,17 @@ lk_init(struct keymap *kmap) lk_set_log_fn(kmap, log_file, stderr); lk_set_log_priority(kmap, LOG_ERR); + kmap->keymap = malloc(sizeof(struct lk_array)); + if (!(kmap->keymap)) { + ERR(kmap, "out of memory"); + return -1; + } + + if (lk_array_init(kmap->keymap, sizeof(void *), 0) < 0) { + ERR(kmap, "out of memory"); + return -1; + } + return 0; } @@ -111,22 +122,32 @@ lk_init(struct keymap *kmap) int lk_free(struct keymap *kmap) { - int i; + unsigned int i;//, j; if (!kmap) return -1; - for (i = 0; i < MAX_NR_KEYMAPS; i++) { - if (kmap->keymap_was_set[i] != NULL) - free(kmap->keymap_was_set[i]); - if (kmap->key_map[i] != NULL) - free(kmap->key_map[i]); - } - for (i = 0; i < MAX_NR_FUNC; i++) { if (kmap->func_table[i] != NULL) free(kmap->func_table[i]); } + if (kmap->keymap) { + for (i = 0; i < kmap->keymap->total; i++) { + struct lk_array *map; + + map = lk_array_get_ptr(kmap->keymap, i); + if (!map) + continue; + + lk_array_free(map); + free(map); + } + lk_array_free(kmap->keymap); + free(kmap->keymap); + + kmap->keymap = NULL; + } + return 0; } diff --git a/src/libkeymap/dump.c b/src/libkeymap/dump.c index de8066e..5e616e1 100644 --- a/src/libkeymap/dump.c +++ b/src/libkeymap/dump.c @@ -48,9 +48,8 @@ lk_dump_bkeymap(struct keymap *kmap) { int i, j; - //u_char *p; char flag, magic[] = "bkeymap"; - unsigned short v; + u_short v; if (lk_add_constants(kmap) < 0) return -1; @@ -58,17 +57,17 @@ lk_dump_bkeymap(struct keymap *kmap) if (write(1, magic, 7) == -1) goto fail; for (i = 0; i < MAX_NR_KEYMAPS; i++) { - flag = kmap->key_map[i] ? 1 : 0; + flag = lk_map_exist(kmap, i); if (write(1, &flag, 1) == -1) goto fail; } for (i = 0; i < MAX_NR_KEYMAPS; i++) { - if (kmap->key_map[i]) { - for (j = 0; j < NR_KEYS / 2; j++) { - v = lk_get_key(kmap, i, j); - if (write(1, &v, 2) == -1) - goto fail; - } + if (!lk_map_exist(kmap, i)) + continue; + for (j = 0; j < NR_KEYS / 2; j++) { + v = lk_get_key(kmap, i, j); + if (write(1, &v, 2) == -1) + goto fail; } } return 0; @@ -106,7 +105,6 @@ lk_dump_ctable(struct keymap *kmap, FILE *fd) char *ptr; unsigned int maxfunc; - unsigned int keymap_count = 0; unsigned int func_table_offs[MAX_NR_FUNC]; unsigned int func_buf_offset = 0; @@ -122,8 +120,7 @@ lk_dump_ctable(struct keymap *kmap, FILE *fd) fprintf(fd, "#include \n\n"); for (i = 0; i < MAX_NR_KEYMAPS; i++) - if (kmap->key_map[i]) { - keymap_count++; + if (lk_map_exist(kmap, i)) { if (i) fprintf(fd, "static "); fprintf(fd, "u_short %s_map[NR_KEYS] = {", mk_mapname(i)); @@ -136,19 +133,19 @@ lk_dump_ctable(struct keymap *kmap, FILE *fd) } for (imax = MAX_NR_KEYMAPS - 1; imax > 0; imax--) - if (kmap->key_map[imax]) + if (lk_map_exist(kmap, imax)) break; fprintf(fd, "ushort *key_maps[MAX_NR_KEYMAPS] = {"); for (i = 0; i <= imax; i++) { fprintf(fd, (i % 4) ? " " : "\n\t"); - if (kmap->key_map[i]) + if (lk_map_exist(kmap, i)) fprintf(fd, "%s_map,", mk_mapname(i)); else fprintf(fd, "0,"); } if (imax < MAX_NR_KEYMAPS - 1) fprintf(fd, "\t0"); - fprintf(fd, "\n};\n\nunsigned int keymap_count = %d;\n\n", keymap_count); + fprintf(fd, "\n};\n\nunsigned int keymap_count = %u;\n\n", (unsigned int) kmap->keymap->count); /* uglified just for xgettext - it complains about nonterminated strings */ fprintf(fd, @@ -295,22 +292,39 @@ lk_dump_diacs(struct keymap *kmap, FILE *fd) void lk_dump_keymaps(struct keymap *kmap, FILE *fd) { - int i, m0, m; - char c = ' '; + unsigned int i; + int n, m, s; + i = n = m = s = 0; fprintf(fd, "keymaps"); - for (i = 0; i < kmap->max_keymap; i++) { - if (i) - c = ','; - m0 = m = kmap->defining[i]; - while (i+1 < kmap->max_keymap && kmap->defining[i+1] == m+1) - i++, m++; - if (!m0) + + for (i = 0; i < kmap->keymap->total; i++) { + if (kmap->keywords & LK_KEYWORD_ALTISMETA && i == (i | M_ALT)) continue; - (m0 == m) - ? fprintf(fd, "%c%d" , c, m0-1) - : fprintf(fd, "%c%d-%d", c, m0-1, m-1); + + if (!lk_map_exist(kmap, i)) { + if (!m) + continue; + n--, m--; + (n == m) + ? fprintf(fd, "%c%d" , (s ? ',' : ' '), n) + : fprintf(fd, "%c%d-%d", (s ? ',' : ' '), n, m); + n = m = 0; + s = 1; + } else { + if (!n) + n = i+1; + m = i+1; + } } + + if (m) { + n--, m--; + (n == m) + ? fprintf(fd, "%c%d" , (s ? ',' : ' '), n) + : fprintf(fd, "%c%d-%d", (s ? ',' : ' '), n, m); + } + fprintf(fd, "\n"); } @@ -377,14 +391,14 @@ print_bind(struct keymap *kmap, FILE *fd, int bufj, int i, int j, char numeric) void lk_dump_keys(struct keymap *kmap, FILE *fd, char table_shape, char numeric) { - int i, j, k; + unsigned int i, j; int buf[MAX_NR_KEYMAPS]; int isletter, islatin, isasexpected; int typ, val; int alt_is_meta = 0; int all_holes; int zapped[MAX_NR_KEYMAPS]; - int keymapnr = kmap->max_keymap; + unsigned int keymapnr = kmap->keymap->total; if (!keymapnr) return; @@ -393,10 +407,10 @@ lk_dump_keys(struct keymap *kmap, FILE *fd, char table_shape, char numeric) goto no_shorthands; /* first pass: determine whether to set alt_is_meta */ - for (j = 0; j < MAX_NR_KEYMAPS; j++) { - int ja = (j | M_ALT); + for (j = 0; j < kmap->keymap->total; j++) { + unsigned int ja = (j | M_ALT); - if (!(j != ja && kmap->defining[j] && kmap->defining[ja])) + if (!(j != ja && lk_map_exist(kmap, j) && lk_map_exist(kmap, ja))) continue; for (i = 1; i < NR_KEYS; i++) { @@ -410,7 +424,7 @@ lk_dump_keys(struct keymap *kmap, FILE *fd, char table_shape, char numeric) type = KTYP(buf0); if ((type == KT_LATIN || type == KT_LETTER) && KVAL(buf0) < 128) { - buf1 = (kmap->defining[ja]) + buf1 = lk_map_exist(kmap, ja) ? lk_get_key(kmap, ja, i) : -1; @@ -429,9 +443,10 @@ no_shorthands: all_holes = 1; for (j = 0; j < keymapnr; j++) { - buf[j] = (kmap->defining[j]) - ? lk_get_key(kmap, kmap->defining[j]-1, i) - : K_HOLE; + buf[j] = K_HOLE; + + if (lk_map_exist(kmap, j)) + buf[j] = lk_get_key(kmap, j, i); if (buf[j] != K_HOLE) all_holes = 0; @@ -453,7 +468,7 @@ no_shorthands: if (table_shape == SEPARATE_LINES) { for (j = 0; j < keymapnr; j++) { //if (buf[j] != K_HOLE) - print_bind(kmap, fd, buf[j], i, kmap->defining[j]-1, numeric); + print_bind(kmap, fd, buf[j], i, j, numeric); } fprintf(fd, "\n"); @@ -482,9 +497,7 @@ no_shorthands: defs[j] = K(KT_META, KVAL(defs[j-8])); for (j = 0; j < keymapnr; j++) { - k = kmap->defining[j] - 1; - - if ((k >= 16 && buf[j] != K_HOLE) || (k < 16 && buf[j] != defs[k])) + if ((j >= 16 && buf[j] != K_HOLE) || (j < 16 && buf[j] != defs[j])) goto unexpected; } @@ -498,13 +511,10 @@ unexpected: if (alt_is_meta) { for(j = 0; j < keymapnr; j++) { - int ka, ja, ktyp; - - k = kmap->defining[j] - 1; - ka = (k | M_ALT); - ja = kmap->defining[ka] - 1; + unsigned int ja, ktyp; + ja = (j | M_ALT); - if (k != ka && ja >= 0 + if (j != ja && lk_map_exist(kmap, ja) && ((ktyp=KTYP(buf[j])) == KT_LATIN || ktyp == KT_LETTER) && KVAL(buf[j]) < 128) { if (buf[ja] != K(KT_META, KVAL(buf[j]))) @@ -525,8 +535,8 @@ unexpected: } else { /* choose between single entry line followed by exceptions, and long line followed by exceptions; avoid VoidSymbol */ - int bad = 0; - int count = 0; + unsigned int bad, count; + bad = count = 0; for (j = 1; j < keymapnr; j++) { if (zapped[j]) @@ -547,24 +557,22 @@ unexpected: for (j = 1; j < keymapnr; j++) { if (buf[j] != buf[0] && !zapped[j]) { - print_bind(kmap, fd, buf[j], i, kmap->defining[j]-1, numeric); + print_bind(kmap, fd, buf[j], i, j, numeric); } } } else { for (j = 0; j < keymapnr && buf[j] != K_HOLE && - (j == 0 || table_shape != UNTIL_HOLE || - kmap->defining[j]-1 == kmap->defining[j-1]-1+1); + (table_shape != UNTIL_HOLE || lk_map_exist(kmap, j)); j++) { - //print_bind(kmap, fd, buf[j], i, kmap->defining[j]-1, numeric); + //print_bind(kmap, fd, buf[j], i, j, numeric); print_keysym(kmap, fd, buf[j], numeric); } - fprintf(fd, "\n"); for (; j < keymapnr; j++) { if (buf[j] != K_HOLE) { - print_bind(kmap, fd, buf[j], i, kmap->defining[j]-1, numeric); + print_bind(kmap, fd, buf[j], i, j, numeric); } } } diff --git a/src/libkeymap/keymap/array.h b/src/libkeymap/keymap/array.h new file mode 100644 index 0000000..ee6144a --- /dev/null +++ b/src/libkeymap/keymap/array.h @@ -0,0 +1,21 @@ +#ifndef LK_ARRAY_H +#define LK_ARRAY_H + +struct lk_array { + void *array; + size_t memb; + size_t count; + size_t total; +}; + +int lk_array_init(struct lk_array *a, size_t memb, size_t size); +int lk_array_free(struct lk_array *a); + +int lk_array_set(struct lk_array *a, unsigned int i, const void *e); +void *lk_array_get(struct lk_array *a, unsigned int i); +void *lk_array_get_ptr(struct lk_array *a, unsigned int i); + +int lk_array_unset(struct lk_array *a, unsigned int i); +int lk_array_exist(struct lk_array *a, unsigned int i); + +#endif /* LK_ARRAY_H */ diff --git a/src/libkeymap/keymap/data.h b/src/libkeymap/keymap/data.h index bf73f8b..cc435cb 100644 --- a/src/libkeymap/keymap/data.h +++ b/src/libkeymap/keymap/data.h @@ -4,6 +4,7 @@ #include #include #include +#include #ifdef KDSKBDIACRUC typedef struct kbdiacruc accent_entry; @@ -34,19 +35,15 @@ struct keymap { /* Keymap keywords (keymaps, alt-is-meta, charset, ...) */ lk_keywords keywords; - /* What keymaps are we defining? */ - u_short defining[MAX_NR_KEYMAPS]; - int max_keymap; /* from here on, defining[] is false */ + struct lk_array *keymap; /* the kernel structures we want to set or print */ - u_short *key_map[MAX_NR_KEYMAPS]; char *func_table[MAX_NR_FUNC]; accent_entry accent_table[MAX_DIACR]; unsigned int accent_table_size; char key_is_constant[NR_KEYS]; - char *keymap_was_set[MAX_NR_KEYMAPS]; int mod; /* Line by line modifiers */ int key_buf[MAX_NR_KEYMAPS]; /* Key definitions on one line */ diff --git a/src/libkeymap/keymap/kmap.h b/src/libkeymap/keymap/kmap.h index e1b365e..eceeebf 100644 --- a/src/libkeymap/keymap/kmap.h +++ b/src/libkeymap/keymap/kmap.h @@ -4,12 +4,13 @@ #include #include -int lk_add_map(struct keymap *kmap, int i); - -int lk_add_key(struct keymap *kmap, int k_table, int k_index, int keycode); -int lk_del_key(struct keymap *kmap, int k_table, int k_index); -int lk_get_key(struct keymap *kmap, int k_table, int k_index); +int lk_add_map(struct keymap *kmap, unsigned int k_table); +int lk_map_exist(struct keymap *kmap, unsigned int k_table); +int lk_add_key(struct keymap *kmap, unsigned int k_table, unsigned int k_index, int keycode); +int lk_del_key(struct keymap *kmap, unsigned int k_table, unsigned int k_index); +int lk_get_key(struct keymap *kmap, unsigned int k_table, unsigned int k_index); +int lk_key_exist(struct keymap *kmap, unsigned int k_table, unsigned int k_index); int lk_get_func(struct keymap *kmap, struct kbsentry *kbs); int lk_add_func(struct keymap *kmap, struct kbsentry kbs); diff --git a/src/libkeymap/kmap.c b/src/libkeymap/kmap.c index dea57f8..8dfa683 100644 --- a/src/libkeymap/kmap.c +++ b/src/libkeymap/kmap.c @@ -10,71 +10,104 @@ #include "modifiers.h" int -lk_add_map(struct keymap *kmap, int i) +lk_map_exist(struct keymap *kmap, unsigned int k_table) { - if (i < 0 || i >= MAX_NR_KEYMAPS) { - ERR(kmap, _("lk_add_map called with bad index %d"), i); - return -1; - } + return (lk_array_get_ptr(kmap->keymap, k_table) != NULL); +} - if (kmap->defining[i]) - return 0; +int +lk_key_exist(struct keymap *kmap, unsigned int k_table, unsigned int k_index) +{ + struct lk_array *map; + u_short *key; - kmap->defining[i] = i + 1; + map = lk_array_get_ptr(kmap->keymap, k_table); + if (!map) { + return 0; + } - if (kmap->max_keymap <= i) - kmap->max_keymap = i + 1; + key = lk_array_get(map, k_index); + if (!key) { + return 0; + } - return 0; + return (*key > 0); } int -lk_get_key(struct keymap *kmap, int k_table, int k_index) +lk_add_map(struct keymap *kmap, unsigned int k_table) { - if (k_index < 0 || k_index >= NR_KEYS) { - ERR(kmap, _("lk_get_key called with bad index %d"), k_index); - return -1; + struct lk_array *keys; + + if (lk_map_exist(kmap, k_table)) { + return 0; } - if (k_table < 0 || k_table >= MAX_NR_KEYMAPS) { - ERR(kmap, _("lk_get_key called with bad table %d"), k_table); + keys = malloc(sizeof(struct lk_array)); + if (!keys) { + ERR(kmap, _("out of memory")); return -1; } - if (!(kmap->keymap_was_set[k_table])) + lk_array_init(keys, sizeof(unsigned int), 0); + + if (lk_array_set(kmap->keymap, k_table, &keys) < 0) { + free(keys); + ERR(kmap, _("out of memory")); return -1; + } - return (kmap->key_map[k_table])[k_index]; + return 0; } int -lk_del_key(struct keymap *kmap, int k_table, int k_index) +lk_get_key(struct keymap *kmap, unsigned int k_table, unsigned int k_index) { - /* roughly: addkey(k_index, k_table, K_HOLE); */ + struct lk_array *map; + unsigned int *key; - if (k_index < 0 || k_index >= NR_KEYS) { - ERR(kmap, _("lk_del_key called with bad index %d"), k_index); + map = lk_array_get_ptr(kmap->keymap, k_table); + if (!map) { + ERR(kmap, _("unable to keymap %d"), k_table); return -1; } - if (k_table < 0 || k_table >= MAX_NR_KEYMAPS) { - ERR(kmap, _("lk_del_key called with bad table %d"), k_table); + key = lk_array_get(map, k_index); + if (!key || *key == 0) { + return K_HOLE; + } + + return (*key)-1; +} + +int +lk_del_key(struct keymap *kmap, unsigned int k_table, unsigned int k_index) +{ + struct lk_array *map; + + map = lk_array_get_ptr(kmap->keymap, k_table); + if (!map) { + ERR(kmap, _("unable to get keymap %d"), k_table); return -1; } - if (kmap->key_map[k_table]) - (kmap->key_map[k_table])[k_index] = K_HOLE; + if (!lk_array_exist(map, k_index)) + return 0; - if (kmap->keymap_was_set[k_table]) - (kmap->keymap_was_set[k_table])[k_index] = 0; + if (lk_array_unset(map, k_index) < 0) { + ERR(kmap, _("unable to unset key %d for table %d"), + k_index, k_table); + return -1; + } return 0; } int -lk_add_key(struct keymap *kmap, int k_table, int k_index, int keycode) +lk_add_key(struct keymap *kmap, unsigned int k_table, unsigned int k_index, int keycode) { - int i; + struct lk_array *map; + unsigned int code = keycode + 1; if (keycode == CODE_FOR_UNKNOWN_KSYM) { /* is safer not to be silent in this case, @@ -83,20 +116,11 @@ lk_add_key(struct keymap *kmap, int k_table, int k_index, int keycode) return -1; } - if (k_index < 0 || k_index >= NR_KEYS) { - ERR(kmap, _("lk_add_key called with bad index %d"), k_index); - return -1; - } - - if (k_table < 0 || k_table >= MAX_NR_KEYMAPS) { - ERR(kmap, _("lk_add_key called with bad table %d"), k_table); - return -1; - } - if (!k_index && keycode == K_NOSUCHMAP) return 0; - if (!kmap->defining[k_table]) { + map = lk_array_get_ptr(kmap->keymap, k_table); + if (!map) { if (kmap->keywords & LK_KEYWORD_KEYMAPS) { ERR(kmap, _("adding map %d violates explicit keymaps line"), k_table); @@ -107,51 +131,32 @@ lk_add_key(struct keymap *kmap, int k_table, int k_index, int keycode) return -1; } - if (!kmap->key_map[k_table]) { - kmap->key_map[k_table] = (u_short *)malloc(NR_KEYS * sizeof(u_short)); - - if (!kmap->key_map[k_table]) { - ERR(kmap, _("out of memory")); - return -1; - } - - for (i = 0; i < NR_KEYS; i++) - (kmap->key_map[k_table])[i] = K_HOLE; - } - - if (!kmap->keymap_was_set[k_table]) { - kmap->keymap_was_set[k_table] = (char *)malloc(NR_KEYS); + if ((kmap->keywords & LK_KEYWORD_ALTISMETA) && keycode == K_HOLE && + lk_key_exist(kmap, k_table, k_index)) + return 0; - if (!kmap->key_map[k_table]) { - ERR(kmap, _("out of memory")); - return -1; - } + map = lk_array_get_ptr(kmap->keymap, k_table); - for (i = 0; i < NR_KEYS; i++) - (kmap->keymap_was_set[k_table])[i] = 0; + if (lk_array_set(map, k_index, &code) < 0) { + ERR(kmap, _("unable to set key %d for table %d"), + k_index, k_table); + return -1; } - if ((kmap->keywords & LK_KEYWORD_ALTISMETA) && - keycode == K_HOLE - && (kmap->keymap_was_set[k_table])[k_index]) - return 0; - - (kmap->key_map[k_table])[k_index] = keycode; - (kmap->keymap_was_set[k_table])[k_index] = 1; - if (kmap->keywords & LK_KEYWORD_ALTISMETA) { - int alttable = k_table | M_ALT; + unsigned int alttable = k_table | M_ALT; int type = KTYP(keycode); int val = KVAL(keycode); - if (alttable != k_table && kmap->defining[alttable] && - (!kmap->keymap_was_set[alttable] || - !(kmap->keymap_was_set[alttable])[k_index]) && + if (alttable != k_table && !lk_key_exist(kmap, alttable, k_index) && (type == KT_LATIN || type == KT_LETTER) && val < 128) { + if (lk_add_map(kmap, alttable) < 0) + return -1; if (lk_add_key(kmap, alttable, k_index, K(KT_META, val)) < 0) return -1; } } + return 0; } @@ -245,7 +250,8 @@ lk_add_compose(struct keymap *kmap, static int do_constant_key(struct keymap *kmap, int i, u_short key) { - int typ, val, j; + int typ, val; + unsigned int j; typ = KTYP(key); val = KVAL(key); @@ -264,12 +270,11 @@ do_constant_key(struct keymap *kmap, int i, u_short key) for (j = 8; j < 16; j++) defs[j] = K(KT_META, KVAL(defs[j - 8])); - for (j = 0; j < kmap->max_keymap; j++) { - if (!kmap->defining[j]) + for (j = 0; j < kmap->keymap->total; j++) { + if (!lk_map_exist(kmap, j)) continue; - if (j > 0 && - kmap->keymap_was_set[j] && (kmap->keymap_was_set[j])[i]) + if (j > 0 && lk_key_exist(kmap, j, i)) continue; if (lk_add_key(kmap, j, i, defs[j % 16]) < 0) @@ -279,11 +284,11 @@ do_constant_key(struct keymap *kmap, int i, u_short key) } else { /* do this also for keys like Escape, as promised in the man page */ - for (j = 1; j < kmap->max_keymap; j++) { - if (!kmap->defining[j]) + for (j = 1; j < kmap->keymap->total; j++) { + if (!lk_map_exist(kmap, j)) continue; - if (kmap->keymap_was_set[j] && (kmap->keymap_was_set[j])[i]) + if (lk_key_exist(kmap, j, i)) continue; if (lk_add_key(kmap, j, i, key) < 0) @@ -296,10 +301,10 @@ do_constant_key(struct keymap *kmap, int i, u_short key) int lk_add_constants(struct keymap *kmap) { - int i, r0 = 0; + unsigned int i, r0 = 0; if (kmap->keywords & LK_KEYWORD_KEYMAPS) { - while (r0 < kmap->max_keymap && !kmap->defining[r0]) + while (r0 < kmap->keymap->total && !lk_map_exist(kmap, r0)) r0++; } @@ -309,7 +314,7 @@ lk_add_constants(struct keymap *kmap) if (!kmap->key_is_constant[i]) continue; - if (!kmap->key_map[r0]) { + if (!lk_map_exist(kmap, r0)) { ERR(kmap, _("impossible error in lk_add_constants")); return -1; } diff --git a/src/libkeymap/loadkeys.c b/src/libkeymap/loadkeys.c index e6cf8bc..0358765 100644 --- a/src/libkeymap/loadkeys.c +++ b/src/libkeymap/loadkeys.c @@ -28,9 +28,11 @@ defkeys(struct keymap *kmap, int fd, int kbd_mode) } for (i = 0; i < MAX_NR_KEYMAPS; i++) { - if (kmap->key_map[i]) { + unsigned int exist = lk_map_exist(kmap, i); + + if (exist) { for (j = 0; j < NR_KEYS; j++) { - if (!((kmap->keymap_was_set[i])[j])) + if (!lk_key_exist(kmap, i, j)) continue; ke.kb_index = j; @@ -57,8 +59,7 @@ defkeys(struct keymap *kmap, int fd, int kbd_mode) j, lk_get_key(kmap, i, j)); } - } else if ((kmap->keywords & LK_KEYWORD_KEYMAPS) && - !kmap->defining[i]) { + } else if ((kmap->keywords & LK_KEYWORD_KEYMAPS) && !exist) { /* deallocate keymap */ ke.kb_index = 0; ke.kb_table = i; diff --git a/src/libkeymap/parser.y b/src/libkeymap/parser.y index 10624d0..d77c7b8 100644 --- a/src/libkeymap/parser.y +++ b/src/libkeymap/parser.y @@ -309,7 +309,8 @@ modifier : SHIFT { kmap->mod |= M_SHIFT; } ; fullline : KEYCODE NUMBER EQUALS rvalue0 EOL { - int i, j, keycode; + unsigned int j; + int i, keycode; if (kmap->rvalct == 1) { /* Some files do not have a keymaps line, and @@ -320,11 +321,11 @@ fullline : KEYCODE NUMBER EQUALS rvalue0 EOL /* On the other hand, we now have include files, * and it should be possible to override lines * from an include file. So, kill old defs. */ - for (j = 0; j < kmap->max_keymap; j++) { - if (!(kmap->defining[j])) + for (j = 0; j < kmap->keymap->total; j++) { + if (!lk_map_exist(kmap, j)) continue; - if (lk_del_key(kmap, j, $2) == -1) + if (lk_del_key(kmap, j, $2) < 0) YYERROR; } } @@ -332,8 +333,8 @@ fullline : KEYCODE NUMBER EQUALS rvalue0 EOL if (kmap->keywords & LK_KEYWORD_KEYMAPS) { i = 0; - for (j = 0; j < kmap->max_keymap; j++) { - if (!(kmap->defining[j])) + for (j = 0; j < kmap->keymap->total; j++) { + if (!lk_map_exist(kmap, j)) continue; if (kmap->rvalct != 1 || i == 0) { diff --git a/src/libkeymap/summary.c b/src/libkeymap/summary.c index 47f4236..933b7b8 100644 --- a/src/libkeymap/summary.c +++ b/src/libkeymap/summary.c @@ -69,8 +69,8 @@ lk_dump_summary(struct keymap *kmap, FILE *fd, int console) NR_KEYS - 1); fprintf(fd, _("max number of actions bindable to a key: %d\n"), MAX_NR_KEYMAPS); - fprintf(fd, _("number of keymaps in actual use: %d\n"), - kmap->max_keymap); + fprintf(fd, _("number of keymaps in actual use: %u\n"), + (unsigned int) kmap->keymap->count); if (allocct) fprintf(fd, _("of which %d dynamically allocated\n"), allocct); diff --git a/tests/Makefile.am b/tests/Makefile.am index 689d51c..412f690 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,6 +8,7 @@ LDADD = $(top_builddir)/src/libkeymap/libkeymap.la $(CHECK_LIBS) EXTRA_DIST = \ dumpkeys-fulltable.in \ + dumpkeys-mktable.in \ \ charset-keymap0.map \ dumpkeys.full.ruwin_cplk-UTF-8.map \ @@ -17,12 +18,14 @@ EXTRA_DIST = \ keymap0.map keymap1.map keymap2.map keymap3.map keymap4.map keymap5.map keymap6.map \ VoidSymbol.map -noinst_PROGRAMS = libkeymap-dumpkeys - -check_SCRIPTS = dumpkeys-fulltable +check_SCRIPTS = dumpkeys-fulltable dumpkeys-mktable dumpkeys-bkeymap check_PROGRAMS = libkeymap-init libkeymap-kmap libkeymap-keys libkeymap-parse \ libkeymap-charset +noinst_PROGRAMS = \ + libkeymap-dumpkeys libkeymap-mktable libkeymap-bkeymap \ + $(check_PROGRAMS) + TESTS = $(check_PROGRAMS) $(check_SCRIPTS) CLEANFILES = $(check_SCRIPTS) @@ -32,6 +35,8 @@ libkeymap_keys_SOURCES = libkeymap-keys.c libkeymap_parse_SOURCES = libkeymap-parse.c libkeymap_charset_SOURCES = libkeymap-charset.c libkeymap_dumpkeys_SOURCES = libkeymap-dumpkeys.c +libkeymap_mktable_SOURCES = libkeymap-mktable.c +libkeymap_bkeymap_SOURCES = libkeymap-bkeymap.c %: %.in sed \ diff --git a/tests/dumpkeys-bkeymap.in b/tests/dumpkeys-bkeymap.in new file mode 100755 index 0000000..7be046b --- /dev/null +++ b/tests/dumpkeys-bkeymap.in @@ -0,0 +1,19 @@ +#!/bin/sh -efu + +cwd="$(readlink -ev "${0%/*}")" + +cd "$cwd" + +rc=0 +temp="$(mktemp "@BUILDDIR@/temp.XXXXXXXXX")" + +./libkeymap-bkeymap ../data/keymaps/i386/qwerty/defkeymap.map > "$temp" || rc=$? +cmp -s "@DATADIR@/dumpkeys.bkeymap.bin" "$temp" || rc=$? + +if [ "$rc" != 0 ]; then + printf 'failed\n' +else + rm -f -- "$temp" +fi + +exit $rc diff --git a/tests/dumpkeys-mktable.in b/tests/dumpkeys-mktable.in new file mode 100755 index 0000000..18e7c39 --- /dev/null +++ b/tests/dumpkeys-mktable.in @@ -0,0 +1,19 @@ +#!/bin/sh -efu + +cwd="$(readlink -ev "${0%/*}")" + +cd "$cwd" + +rc=0 +temp="$(mktemp "@BUILDDIR@/temp.XXXXXXXXX")" + +./libkeymap-mktable ../data/keymaps/i386/qwerty/defkeymap.map > "$temp" || rc=$? +cmp -s "@DATADIR@/dumpkeys.defkeymap.c" "$temp" || rc=$? + +if [ "$rc" != 0 ]; then + printf 'failed\n' +else + rm -f -- "$temp" +fi + +exit $rc diff --git a/tests/dumpkeys.bkeymap.bin b/tests/dumpkeys.bkeymap.bin new file mode 100644 index 0000000..92cb663 Binary files /dev/null and b/tests/dumpkeys.bkeymap.bin differ diff --git a/tests/dumpkeys.defkeymap.c b/tests/dumpkeys.defkeymap.c new file mode 100644 index 0000000..58b340f --- /dev/null +++ b/tests/dumpkeys.defkeymap.c @@ -0,0 +1,689 @@ +/* Do not edit this file! It was automatically generated by */ +/* loadkeys --mktable defkeymap.map > defkeymap.c */ + +#include +#include +#include + +u_short plain_map[NR_KEYS] = { + 0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, + 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, + 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, + 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73, + 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, + 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, + 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c, + 0xf703, 0xf020, 0xf207, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, + 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a, + 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf210, 0xf211, 0xf20e, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short shift_map[NR_KEYS] = { + 0xf200, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, + 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf809, + 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, + 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53, + 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, + 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, + 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, + 0xf703, 0xf020, 0xf207, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, + 0xf111, 0xf112, 0xf113, 0xf11e, 0xf11f, 0xf208, 0xf203, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf120, + 0xf121, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf206, 0xf206, 0xf210, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short altgr_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf040, 0xf200, 0xf024, 0xf200, 0xf200, + 0xf07b, 0xf05b, 0xf05d, 0xf07d, 0xf05c, 0xf200, 0xf200, 0xf200, + 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, + 0xfb6f, 0xfb70, 0xf200, 0xf07e, 0xf201, 0xf702, 0xfb61, 0xfb73, + 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf200, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, + 0xfb62, 0xfb6e, 0xfb6d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, + 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf202, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, + 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf211, 0xf210, 0xf211, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short shift_altgr_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, + 0xfb4f, 0xfb50, 0xf200, 0xf200, 0xf201, 0xf702, 0xfb41, 0xfb53, + 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf200, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, + 0xfb42, 0xfb4e, 0xfb4d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf20e, 0xf20e, 0xf206, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short ctrl_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf000, 0xf01b, 0xf01c, 0xf01d, 0xf01e, + 0xf01f, 0xf07f, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf200, + 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, + 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf201, 0xf702, 0xf001, 0xf013, + 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, + 0xf007, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, + 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, + 0xf703, 0xf000, 0xf207, 0xf122, 0xf123, 0xf124, 0xf125, 0xf126, + 0xf127, 0xf128, 0xf129, 0xf12a, 0xf12b, 0xf208, 0xf204, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf12c, + 0xf12d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short shift_ctrl_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf200, 0xf200, + 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, + 0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013, + 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016, + 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf07f, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf12e, 0xf12f, 0xf130, 0xf131, 0xf132, + 0xf133, 0xf134, 0xf135, 0xf136, 0xf137, 0xf208, 0xf200, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf138, + 0xf139, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short altgr_ctrl_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, + 0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013, + 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016, + 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short shift_altgr_ctrl_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, + 0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013, + 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016, + 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short alt_map[NR_KEYS] = { + 0xf200, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, + 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, + 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, + 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, + 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, + 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, + 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, + 0xf703, 0xf820, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, + 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf907, + 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901, + 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a, + 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short shift_alt_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, + 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf201, 0xf702, 0xf841, 0xf853, + 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, + 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf200, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short altgr_alt_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, + 0xf86f, 0xf870, 0xf200, 0xf200, 0xf201, 0xf702, 0xf861, 0xf873, + 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf200, 0xf87a, 0xf878, 0xf863, 0xf876, + 0xf862, 0xf86e, 0xf86d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short shift_altgr_alt_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, + 0xf84f, 0xf850, 0xf200, 0xf200, 0xf201, 0xf702, 0xf841, 0xf853, + 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf200, 0xf85a, 0xf858, 0xf843, 0xf856, + 0xf842, 0xf84e, 0xf84d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short ctrl_alt_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, + 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, + 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, + 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, + 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf200, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf200, 0xf50a, + 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short shift_ctrl_alt_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, + 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, + 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, + 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short altgr_ctrl_alt_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, + 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, + 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, + 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +static u_short shift_altgr_ctrl_alt_map[NR_KEYS] = { + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, + 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, + 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, + 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, + 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, + 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, + 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, + 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, + 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, + 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, +}; + +ushort *key_maps[MAX_NR_KEYMAPS] = { + plain_map, shift_map, altgr_map, shift_altgr_map, + ctrl_map, shift_ctrl_map, altgr_ctrl_map, shift_altgr_ctrl_map, + alt_map, shift_alt_map, altgr_alt_map, shift_altgr_alt_map, + ctrl_alt_map, shift_ctrl_alt_map, altgr_ctrl_alt_map, shift_altgr_ctrl_alt_map, 0 +}; + +unsigned int keymap_count = 16; + +/* + * Philosophy: most people do not define more strings, but they who do + * often want quite a lot of string space. So, we statically allocate + * the default and allocate dynamically in chunks of 512 bytes. + */ + +char func_buf[] = { + '\033', '[', '[', 'A', 0, + '\033', '[', '[', 'B', 0, + '\033', '[', '[', 'C', 0, + '\033', '[', '[', 'D', 0, + '\033', '[', '[', 'E', 0, + '\033', '[', '1', '7', '~', 0, + '\033', '[', '1', '8', '~', 0, + '\033', '[', '1', '9', '~', 0, + '\033', '[', '2', '0', '~', 0, + '\033', '[', '2', '1', '~', 0, + '\033', '[', '2', '3', '~', 0, + '\033', '[', '2', '4', '~', 0, + '\033', '[', '2', '5', '~', 0, + '\033', '[', '2', '6', '~', 0, + '\033', '[', '2', '8', '~', 0, + '\033', '[', '2', '9', '~', 0, + '\033', '[', '3', '1', '~', 0, + '\033', '[', '3', '2', '~', 0, + '\033', '[', '3', '3', '~', 0, + '\033', '[', '3', '4', '~', 0, + '\033', '[', '1', '~', 0, + '\033', '[', '2', '~', 0, + '\033', '[', '3', '~', 0, + '\033', '[', '4', '~', 0, + '\033', '[', '5', '~', 0, + '\033', '[', '6', '~', 0, + '\033', '[', 'M', 0, + '\033', '[', 'P', 0, +}; + +char *funcbufptr = func_buf; +int funcbufsize = sizeof(func_buf); +int funcbufleft = 0; /* space left */ + +char *func_table[MAX_NR_FUNC] = { + func_buf + 0, + func_buf + 5, + func_buf + 10, + func_buf + 15, + func_buf + 20, + func_buf + 25, + func_buf + 31, + func_buf + 37, + func_buf + 43, + func_buf + 49, + func_buf + 55, + func_buf + 61, + func_buf + 67, + func_buf + 73, + func_buf + 79, + func_buf + 85, + func_buf + 91, + func_buf + 97, + func_buf + 103, + func_buf + 109, + func_buf + 115, + func_buf + 120, + func_buf + 125, + func_buf + 130, + func_buf + 135, + func_buf + 140, + func_buf + 145, + 0, + 0, + func_buf + 149, + 0, +}; + +struct kbdiacr accent_table[MAX_DIACR] = { + {'`', 'A', '\300'}, {'`', 'a', '\340'}, + {'\'', 'A', '\301'}, {'\'', 'a', '\341'}, + {'^', 'A', '\302'}, {'^', 'a', '\342'}, + {'~', 'A', '\303'}, {'~', 'a', '\343'}, + {'"', 'A', '\304'}, {'"', 'a', '\344'}, + {'O', 'A', '\305'}, {'o', 'a', '\345'}, + {'0', 'A', '\305'}, {'0', 'a', '\345'}, + {'A', 'A', '\305'}, {'a', 'a', '\345'}, + {'A', 'E', '\306'}, {'a', 'e', '\346'}, + {',', 'C', '\307'}, {',', 'c', '\347'}, + {'`', 'E', '\310'}, {'`', 'e', '\350'}, + {'\'', 'E', '\311'}, {'\'', 'e', '\351'}, + {'^', 'E', '\312'}, {'^', 'e', '\352'}, + {'"', 'E', '\313'}, {'"', 'e', '\353'}, + {'`', 'I', '\314'}, {'`', 'i', '\354'}, + {'\'', 'I', '\315'}, {'\'', 'i', '\355'}, + {'^', 'I', '\316'}, {'^', 'i', '\356'}, + {'"', 'I', '\317'}, {'"', 'i', '\357'}, + {'-', 'D', '\320'}, {'-', 'd', '\360'}, + {'~', 'N', '\321'}, {'~', 'n', '\361'}, + {'`', 'O', '\322'}, {'`', 'o', '\362'}, + {'\'', 'O', '\323'}, {'\'', 'o', '\363'}, + {'^', 'O', '\324'}, {'^', 'o', '\364'}, + {'~', 'O', '\325'}, {'~', 'o', '\365'}, + {'"', 'O', '\326'}, {'"', 'o', '\366'}, + {'/', 'O', '\330'}, {'/', 'o', '\370'}, + {'`', 'U', '\331'}, {'`', 'u', '\371'}, + {'\'', 'U', '\332'}, {'\'', 'u', '\372'}, + {'^', 'U', '\333'}, {'^', 'u', '\373'}, + {'"', 'U', '\334'}, {'"', 'u', '\374'}, + {'\'', 'Y', '\335'}, {'\'', 'y', '\375'}, + {'T', 'H', '\336'}, {'t', 'h', '\376'}, + {'s', 's', '\337'}, {'"', 'y', '\377'}, + {'s', 'z', '\337'}, {'i', 'j', '\377'}, +}; + +unsigned int accent_table_size = 68; diff --git a/tests/libkeymap-bkeymap.c b/tests/libkeymap-bkeymap.c new file mode 100644 index 0000000..9939a00 --- /dev/null +++ b/tests/libkeymap-bkeymap.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + struct keymap kmap; + lkfile_t f; + + lk_init(&kmap); + + f.pipe = 0; + strcpy(f.pathname, argv[1]); + f.fd = fopen( argv[1], "r"); + + lk_parse_keymap(&kmap, &f); + lk_dump_bkeymap(&kmap); + + lk_free(&kmap); + return 0; +} diff --git a/tests/libkeymap-init.c b/tests/libkeymap-init.c index 2d514bb..1d2a836 100644 --- a/tests/libkeymap-init.c +++ b/tests/libkeymap-init.c @@ -23,11 +23,12 @@ START_TEST(test_free_0) { struct keymap kmap; - if (lk_init(&kmap) != 0) - fail("Unable to initialize structure by valid pointer"); + fail_unless(lk_init(&kmap) == 0, + "Unable to initialize structure by valid pointer"); fail_unless(lk_free(&kmap) == 0, "Unable to free by valid pointer"); + lk_free(&kmap); } END_TEST diff --git a/tests/libkeymap-keys.c b/tests/libkeymap-keys.c index 01b99a2..c401841 100644 --- a/tests/libkeymap-keys.c +++ b/tests/libkeymap-keys.c @@ -10,20 +10,11 @@ START_TEST(test_add_key_0) lk_init(&kmap); kmap.log_fn = NULL; - fail_if(lk_add_key(&kmap, 0, -1, 0) == 0, - "Possible to use index < 0"); + fail_if(lk_add_key(&kmap, 0, NR_KEYS + 1, 0) != 0, + "Unable to use index > NR_KEYS"); - fail_if(lk_add_key(&kmap, 0, NR_KEYS + 1, 0) == 0, - "Possible to use index > NR_KEYS"); - - fail_if(lk_add_key(&kmap, -1, 0, 0) == 0, - "Possible to use table < 0"); - - fail_if(lk_add_key(&kmap, MAX_NR_KEYMAPS + 1, 0, 0) == 0, - "Possible to use table > MAX_NR_KEYMAPS"); - - fail_if(lk_add_key(&kmap, 0, 0, -1) == 0, - "Possible to add key a -1 keycode"); + fail_if(lk_add_key(&kmap, MAX_NR_KEYMAPS + 1, 0, 0) != 0, + "Unable to use table > MAX_NR_KEYMAPS"); lk_free(&kmap); } diff --git a/tests/libkeymap-kmap.c b/tests/libkeymap-kmap.c index e8e8f23..e948b89 100644 --- a/tests/libkeymap-kmap.c +++ b/tests/libkeymap-kmap.c @@ -11,11 +11,11 @@ START_TEST(test_add_map_border) lk_init(&kmap); kmap.log_fn = NULL; - fail_if(lk_add_map(&kmap, -1) == 0, - "Possible to define the map with index -1"); + fail_unless(lk_add_map(&kmap, MAX_NR_KEYMAPS) == 0, + "Unable to define map == MAX_NR_KEYMAPS"); - fail_if(lk_add_map(&kmap, MAX_NR_KEYMAPS) == 0, - "Possible to define the map with index -1"); + fail_unless(lk_add_map(&kmap, MAX_NR_KEYMAPS*2) == 0, + "Unable to define map == MAX_NR_KEYMAPS*2"); fail_unless(lk_add_map(&kmap, 0) == 0, "Unable to define map"); @@ -35,16 +35,16 @@ START_TEST(test_add_map_0) kmap.log_fn = NULL; fail_if(lk_add_map(&kmap, 0) != 0, "Unable to define map"); - fail_if(kmap.max_keymap != 1, "Wrong max_keymap number"); + fail_if(kmap.keymap->count != 1, "Wrong keymap number"); fail_if(lk_add_map(&kmap, 0) != 0, "Unable to define map"); - fail_if(kmap.max_keymap != 1, "Wrong max_keymap number"); + fail_if(kmap.keymap->count != 1, "Wrong keymap number"); fail_if(lk_add_map(&kmap, 1) != 0, "Unable to define map"); - fail_if(kmap.max_keymap != 2, "Wrong max_keymap number"); + fail_if(kmap.keymap->count != 2, "Wrong keymap number"); fail_if(lk_add_map(&kmap, 2) != 0, "Unable to define map"); - fail_if(kmap.max_keymap != 3, "Wrong max_keymap number"); + fail_if(kmap.keymap->count != 3, "Wrong keymap number"); lk_free(&kmap); } diff --git a/tests/libkeymap-mktable.c b/tests/libkeymap-mktable.c new file mode 100644 index 0000000..afadc9e --- /dev/null +++ b/tests/libkeymap-mktable.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + struct keymap kmap; + lkfile_t f; + + lk_init(&kmap); + + f.pipe = 0; + strcpy(f.pathname, argv[1]); + f.fd = fopen( argv[1], "r"); + + lk_parse_keymap(&kmap, &f); + lk_dump_ctable(&kmap, stdout); + + lk_free(&kmap); + return 0; +}