2 * Copyright (c) 1994-1995 Søren Schmidt
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * in this position and unchanged.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
40 #include <sys/consio.h>
45 * HALT, PDWN, and PASTE aren't defined in 4.x, but we need them to bridge
46 * to 5.0-current so define them here as a stop gap transition measure.
49 #define HALT 0xa1 /* halt machine */
52 #define PDWN 0xa2 /* halt machine and power down */
55 #define PASTE 0xa3 /* paste from cut-paste buffer */
58 char ctrl_names[32][4] = {
59 "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
60 "bs ", "ht ", "nl ", "vt ", "ff ", "cr ", "so ", "si ",
61 "dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb",
62 "can", "em ", "sub", "esc", "fs ", "gs ", "rs ", "us "
65 char acc_names[15][5] = {
66 "dgra", "dacu", "dcir", "dtil", "dmac", "dbre", "ddot",
67 "duml", "dsla", "drin", "dced", "dapo", "ddac", "dogo",
71 char acc_names_u[15][5] = {
72 "DGRA", "DACU", "DCIR", "DTIL", "DMAC", "DBRE", "DDOT",
73 "DUML", "DSLA", "DRIN", "DCED", "DAPO", "DDAC", "DOGO",
77 char fkey_table[96][MAXFK] = {
78 /* 01-04 */ "\033[M", "\033[N", "\033[O", "\033[P",
79 /* 05-08 */ "\033[Q", "\033[R", "\033[S", "\033[T",
80 /* 09-12 */ "\033[U", "\033[V", "\033[W", "\033[X",
81 /* 13-16 */ "\033[Y", "\033[Z", "\033[a", "\033[b",
82 /* 17-20 */ "\033[c", "\033[d", "\033[e", "\033[f",
83 /* 21-24 */ "\033[g", "\033[h", "\033[i", "\033[j",
84 /* 25-28 */ "\033[k", "\033[l", "\033[m", "\033[n",
85 /* 29-32 */ "\033[o", "\033[p", "\033[q", "\033[r",
86 /* 33-36 */ "\033[s", "\033[t", "\033[u", "\033[v",
87 /* 37-40 */ "\033[w", "\033[x", "\033[y", "\033[z",
88 /* 41-44 */ "\033[@", "\033[[", "\033[\\","\033[]",
89 /* 45-48 */ "\033[^", "\033[_", "\033[`", "\033[{",
90 /* 49-52 */ "\033[H", "\033[A", "\033[I", "-" ,
91 /* 53-56 */ "\033[D", "\033[E", "\033[C", "+" ,
92 /* 57-60 */ "\033[F", "\033[B", "\033[G", "\033[L",
93 /* 61-64 */ "\177", "\033[J", "\033[~", "\033[}",
94 /* 65-68 */ "" , "" , "" , "" ,
95 /* 69-72 */ "" , "" , "" , "" ,
96 /* 73-76 */ "" , "" , "" , "" ,
97 /* 77-80 */ "" , "" , "" , "" ,
98 /* 81-84 */ "" , "" , "" , "" ,
99 /* 85-88 */ "" , "" , "" , "" ,
100 /* 89-92 */ "" , "" , "" , "" ,
101 /* 93-96 */ "" , "" , "" , "" ,
104 const int delays[] = {250, 500, 750, 1000};
105 const int repeats[] = { 34, 38, 42, 46, 50, 55, 59, 63,
106 68, 76, 84, 92, 100, 110, 118, 126,
107 136, 152, 168, 184, 200, 220, 236, 252,
108 272, 304, 336, 368, 400, 440, 472, 504};
109 const int ndelays = (sizeof(delays) / sizeof(int));
110 const int nrepeats = (sizeof(repeats) / sizeof(int));
116 void dump_accent_definition(char *name, accentmap_t *accentmap);
117 void dump_entry(int value);
118 void dump_key_definition(char *name, keymap_t *keymap);
119 int get_accent_definition_line(accentmap_t *);
121 int get_key_definition_line(keymap_t *);
122 void load_keymap(char *opt, int dumponly);
123 void load_default_functionkeys(void);
124 char * nextarg(int ac, char **av, int *indp, int oc);
125 char * mkfullname(const char *s1, const char *s2, const char *s3);
126 void print_accent_definition_line(FILE *fp, int accent,
128 void print_entry(FILE *fp, int value);
129 void print_key_definition_line(FILE *fp, int scancode,
130 struct keyent_t *key);
131 void print_keymap(void);
132 void release_keyboard(void);
133 void mux_keyboard(u_int op, char *kbd);
134 void set_bell_values(char *opt);
135 void set_functionkey(char *keynumstr, char *string);
136 void set_keyboard(char *device);
137 void set_keyrates(char *opt);
138 void show_kbd_info(void);
139 void usage(void) __dead2;
142 nextarg(int ac, char **av, int *indp, int oc)
145 return(av[(*indp)++]);
146 warnx("option requires two arguments -- %c", oc);
152 mkfullname(const char *s1, const char *s2, const char *s3)
154 static char *buf = NULL;
158 f = strlen(s1) + strlen(s2) + strlen(s3) + 1;
161 buf = (char *)realloc(buf, f);
163 buf = (char *)malloc(f);
181 switch ((token = yylex())) {
229 return LCTRA | 0x100;
231 return RCTRA | 0x100;
233 return LALTA | 0x100;
235 return RALTA | 0x100;
241 return PASTE | 0x100;
243 if (ACC(number) > L_ACC)
245 return ACC(number) | 0x100;
247 if (F(number) > L_FN)
249 return F(number) | 0x100;
251 if (S(number) > L_SCR)
253 return S(number) | 0x100;
255 return (unsigned char)letter;
257 if (number < 0 || number > 255)
266 get_definition_line(FILE *fd, keymap_t *keymap, accentmap_t *accentmap)
276 c = get_key_definition_line(keymap);
278 errx(1, "invalid key definition");
279 if (c > keymap->n_keys)
283 c = get_accent_definition_line(accentmap);
285 errx(1, "invalid accent key definition");
286 if (c > accentmap->n_accs)
287 accentmap->n_accs = c;
293 errx(1, "illegal definition line");
299 get_key_definition_line(keymap_t *map)
301 int i, def, scancode;
303 /* check scancode number */
304 if (number < 0 || number >= NUM_KEYS)
308 /* get key definitions */
309 map->key[scancode].spcl = 0;
310 for (i=0; i<NUM_STATES; i++) {
311 if ((def = get_entry()) == -1)
314 map->key[scancode].spcl |= (0x80 >> i);
315 map->key[scancode].map[i] = def & 0xFF;
317 /* get lock state key def */
318 if ((token = yylex()) != TFLAG)
320 map->key[scancode].flgs = number;
322 return (scancode + 1);
326 get_accent_definition_line(accentmap_t *map)
332 if (ACC(number) < F_ACC || ACC(number) > L_ACC)
333 /* number out of range */
336 if (map->acc[accent].accchar != 0) {
337 /* this entry has already been defined before! */
338 errx(1, "duplicated accent key definition");
341 switch ((token = yylex())) {
343 map->acc[accent].accchar = letter;
346 map->acc[accent].accchar = number;
352 for (i = 0; (token = yylex()) == '(';) {
353 switch ((token = yylex())) {
363 switch ((token = yylex())) {
373 if ((token = yylex()) != ')')
375 if (i >= NUM_ACCENTCHARS) {
376 warnx("too many accented characters, ignored");
379 map->acc[accent].map[i][0] = c1;
380 map->acc[accent].map[i][1] = c2;
387 print_entry(FILE *fp, int value)
389 int val = value & 0xFF;
393 fprintf(fp, " nop ");
396 fprintf(fp, " lshift");
399 fprintf(fp, " rshift");
402 fprintf(fp, " clock ");
405 fprintf(fp, " nlock ");
408 fprintf(fp, " slock ");
411 fprintf(fp, " btab ");
414 fprintf(fp, " lalt ");
417 fprintf(fp, " lctrl ");
420 fprintf(fp, " nscr ");
423 fprintf(fp, " pscr ");
426 fprintf(fp, " rctrl ");
429 fprintf(fp, " ralt ");
432 fprintf(fp, " alock ");
435 fprintf(fp, " ashift");
438 fprintf(fp, " meta ");
441 fprintf(fp, " boot ");
444 fprintf(fp, " debug ");
447 fprintf(fp, " susp ");
450 fprintf(fp, " saver ");
453 fprintf(fp, " panic ");
456 fprintf(fp, " lshifta");
459 fprintf(fp, " rshifta");
462 fprintf(fp, " lctrla");
465 fprintf(fp, " rctrla");
468 fprintf(fp, " lalta ");
471 fprintf(fp, " ralta ");
474 fprintf(fp, " halt ");
477 fprintf(fp, " pdwn ");
480 fprintf(fp, " paste ");
484 if (val >= F_FN && val <= L_FN)
485 fprintf(fp, " fkey%02d", val - F_FN + 1);
486 else if (val >= F_SCR && val <= L_SCR)
487 fprintf(fp, " scr%02d ", val - F_SCR + 1);
488 else if (val >= F_ACC && val <= L_ACC)
489 fprintf(fp, " %-6s", acc_names[val - F_ACC]);
491 fprintf(fp, " 0x%02x ", val);
493 fprintf(fp, " %3d ", val);
497 fprintf(fp, " %s ", ctrl_names[val]);
499 fprintf(fp, " del ");
500 else if (isascii(val) && isprint(val))
501 fprintf(fp, " '%c' ", val);
503 fprintf(fp, " 0x%02x ", val);
505 fprintf(fp, " %3d ", val);
511 print_key_definition_line(FILE *fp, int scancode, struct keyent_t *key)
515 /* print scancode number */
517 fprintf(fp, " 0x%02x ", scancode);
519 fprintf(fp, " %03d ", scancode);
521 /* print key definitions */
522 for (i=0; i<NUM_STATES; i++) {
523 if (key->spcl & (0x80 >> i))
524 print_entry(fp, key->map[i] | 0x100);
526 print_entry(fp, key->map[i]);
529 /* print lock state key def */
547 print_accent_definition_line(FILE *fp, int accent, struct acc_t *key)
552 if (key->accchar == 0)
555 /* print accent number */
556 fprintf(fp, " %-6s", acc_names[accent]);
557 if (isascii(key->accchar) && isprint(key->accchar))
558 fprintf(fp, "'%c' ", key->accchar);
560 fprintf(fp, "0x%02x ", key->accchar);
562 fprintf(fp, "%03d ", key->accchar);
564 for (i = 0; i < NUM_ACCENTCHARS; ++i) {
568 if ((i > 0) && ((i % 4) == 0))
570 if (isascii(c) && isprint(c))
571 fprintf(fp, "( '%c' ", c);
573 fprintf(fp, "(0x%02x ", c);
575 fprintf(fp, "( %03d ", c);
577 if (isascii(c) && isprint(c))
578 fprintf(fp, "'%c' ) ", c);
580 fprintf(fp, "0x%02x) ", c);
582 fprintf(fp, "%03d ) ", c);
588 dump_entry(int value)
684 if (value >= F_FN && value <= L_FN)
685 printf(" F(%2d),", value - F_FN + 1);
686 else if (value >= F_SCR && value <= L_SCR)
687 printf(" S(%2d),", value - F_SCR + 1);
688 else if (value >= F_ACC && value <= L_ACC)
689 printf(" %-4s, ", acc_names_u[value - F_ACC]);
691 printf(" 0x%02X, ", value);
694 } else if (value == '\'') {
696 } else if (value == '\\') {
698 } else if (isascii(value) && isprint(value)) {
699 printf(" '%c', ", value);
701 printf(" 0x%02X, ", value);
706 dump_key_definition(char *name, keymap_t *keymap)
710 printf("static keymap_t keymap_%s = { 0x%02x, {\n",
711 name, (unsigned)keymap->n_keys);
714 " * scan cntrl alt alt cntrl\n"
715 " * code base shift cntrl shift alt shift cntrl shift spcl flgs\n"
716 " * ---------------------------------------------------------------------------\n"
718 for (i = 0; i < keymap->n_keys; i++) {
719 printf("/*%02x*/{{", i);
720 for (j = 0; j < NUM_STATES; j++) {
721 if (keymap->key[i].spcl & (0x80 >> j))
722 dump_entry(keymap->key[i].map[j] | 0x100);
724 dump_entry(keymap->key[i].map[j]);
726 printf("}, 0x%02X,0x%02X },\n",
727 (unsigned)keymap->key[i].spcl,
728 (unsigned)keymap->key[i].flgs);
734 dump_accent_definition(char *name, accentmap_t *accentmap)
739 printf("static accentmap_t accentmap_%s = { %d",
740 name, accentmap->n_accs);
741 if (accentmap->n_accs <= 0) {
746 for (i = 0; i < NUM_DEADKEYS; i++) {
747 printf(" /* %s=%d */\n {", acc_names[i], i);
748 c = accentmap->acc[i].accchar;
752 printf(" '\\\\', {");
753 else if (isascii(c) && isprint(c))
754 printf(" '%c', {", c);
756 printf(" 0x00 }, \n");
759 printf(" 0x%02x, {", c);
760 for (j = 0; j < NUM_ACCENTCHARS; j++) {
761 c = accentmap->acc[i].map[j][0];
764 if ((j > 0) && ((j % 4) == 0))
766 if (isascii(c) && isprint(c))
767 printf(" { '%c',", c);
769 printf(" { 0x%02x,", c);
770 printf("0x%02x },", accentmap->acc[i].map[j][1]);
778 load_keymap(char *opt, int dumponly)
781 accentmap_t accentmap;
785 char blank[] = "", keymap_path[] = KEYMAP_PATH, dotkbd[] = ".kbd";
786 char *prefix[] = {blank, blank, keymap_path, NULL};
787 char *postfix[] = {blank, dotkbd, NULL};
789 cp = getenv("KEYMAP_PATH");
791 asprintf(&(prefix[0]), "%s/", cp);
794 for (i=0; prefix[i] && fd == NULL; i++) {
795 for (j=0; postfix[j] && fd == NULL; j++) {
796 name = mkfullname(prefix[i], opt, postfix[j]);
797 fd = fopen(name, "r");
801 warn("keymap file \"%s\" not found", opt);
804 memset(&keymap, 0, sizeof(keymap));
805 memset(&accentmap, 0, sizeof(accentmap));
808 if (get_definition_line(fd, &keymap, &accentmap) < 0)
812 /* fix up the filename to make it a valid C identifier */
813 for (cp = opt; *cp; cp++)
814 if (!isalpha(*cp) && !isdigit(*cp)) *cp = '_';
816 " * Automatically generated from %s.\n"
819 dump_key_definition(opt, &keymap);
820 dump_accent_definition(opt, &accentmap);
823 if ((keymap.n_keys > 0) && (ioctl(0, PIO_KEYMAP, &keymap) < 0)) {
824 warn("setting keymap");
828 if ((accentmap.n_accs > 0)
829 && (ioctl(0, PIO_DEADKEYMAP, &accentmap) < 0)) {
830 warn("setting accentmap");
840 accentmap_t accentmap;
843 if (ioctl(0, GIO_KEYMAP, &keymap) < 0)
844 err(1, "getting keymap");
845 if (ioctl(0, GIO_DEADKEYMAP, &accentmap) < 0)
846 memset(&accentmap, 0, sizeof(accentmap));
849 "# scan cntrl alt alt cntrl lock\n"
850 "# code base shift cntrl shift alt shift cntrl shift state\n"
851 "# ------------------------------------------------------------------\n"
853 for (i=0; i<keymap.n_keys; i++)
854 print_key_definition_line(stdout, i, &keymap.key[i]);
857 for (i = 0; i < NUM_DEADKEYS; i++)
858 print_accent_definition_line(stdout, i, &accentmap.acc[i]);
863 load_default_functionkeys(void)
868 for (i=0; i<NUM_FKEYS; i++) {
870 strcpy(fkey.keydef, fkey_table[i]);
871 fkey.flen = strlen(fkey_table[i]);
872 if (ioctl(0, SETFKEY, &fkey) < 0)
873 warn("setting function key");
878 set_functionkey(char *keynumstr, char *string)
882 if (!strcmp(keynumstr, "load") && !strcmp(string, "default")) {
883 load_default_functionkeys();
886 fkey.keynum = atoi(keynumstr);
887 if (fkey.keynum < 1 || fkey.keynum > NUM_FKEYS) {
888 warnx("function key number must be between 1 and %d",
892 if ((fkey.flen = strlen(string)) > MAXFK) {
893 warnx("function key string too long (%d > %d)",
897 strncpy(fkey.keydef, string, MAXFK);
899 if (ioctl(0, SETFKEY, &fkey) < 0)
900 warn("setting function key");
904 set_bell_values(char *opt)
906 int bell, duration, pitch;
909 if (!strncmp(opt, "quiet.", 6)) {
910 bell = CONS_QUIET_BELL;
913 if (!strcmp(opt, "visual"))
914 bell |= CONS_VISUAL_BELL;
915 else if (!strcmp(opt, "normal"))
916 duration = 5, pitch = 800;
917 else if (!strcmp(opt, "off"))
918 duration = 0, pitch = 0;
923 duration = strtol(opt, &v1, 0);
924 if ((duration < 0) || (*v1 != '.'))
927 pitch = strtol(opt, &v1, 0);
928 if ((pitch < 0) || (*opt == '\0') || (*v1 != '\0')) {
930 warnx("argument to -b must be duration.pitch or [quiet.]visual|normal|off");
934 pitch = 1193182 / pitch; /* in Hz */
935 duration /= 10; /* in 10 m sec */
938 ioctl(0, CONS_BELLTYPE, &bell);
939 if (!(bell & CONS_VISUAL_BELL))
940 fprintf(stderr, "
\e[=%d;%dB", pitch, duration);
944 set_keyrates(char *opt)
951 if (!strcmp(opt, "slow")) {
952 delay = 1000, repeat = 500;
954 } else if (!strcmp(opt, "normal")) {
955 delay = 500, repeat = 125;
957 } else if (!strcmp(opt, "fast")) {
964 delay = strtol(opt, &v1, 0);
965 if ((delay < 0) || (*v1 != '.'))
968 repeat = strtol(opt, &v1, 0);
969 if ((repeat < 0) || (*opt == '\0') || (*v1 != '\0')) {
971 warnx("argument to -r must be delay.repeat or slow|normal|fast");
974 for (n = 0; n < ndelays - 1; n++)
975 if (delay <= delays[n])
978 for (n = 0; n < nrepeats - 1; n++)
979 if (repeat <= repeats[n])
986 if (ioctl(0, KDSETREPEAT, arg)) {
987 if (ioctl(0, KDSETRAD, (d << 5) | r))
988 warn("setting keyboard rate");
993 get_kbd_type_name(int type)
1000 { KB_101, "AT 101/102" },
1001 { KB_OTHER, "generic" },
1005 for (i = 0; i < sizeof(name_table)/sizeof(name_table[0]); ++i) {
1006 if (type == name_table[i].type)
1007 return name_table[i].name;
1015 keyboard_info_t info;
1017 if (ioctl(0, KDGKBINFO, &info) == -1) {
1018 warn("unable to obtain keyboard information");
1021 printf("kbd%d:\n", info.kb_index);
1022 printf(" %.*s%d, type:%s (%d)\n",
1023 (int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
1024 get_kbd_type_name(info.kb_type), info.kb_type);
1028 set_keyboard(char *device)
1030 keyboard_info_t info;
1033 fd = open(device, O_RDONLY);
1035 warn("cannot open %s", device);
1038 if (ioctl(fd, KDGKBINFO, &info) == -1) {
1039 warn("unable to obtain keyboard information");
1044 * The keyboard device driver won't release the keyboard by
1045 * the following ioctl, but it automatically will, when the device
1046 * is closed. So, we don't check error here.
1048 ioctl(fd, CONS_RELKBD, 0);
1051 printf("kbd%d\n", info.kb_index);
1052 printf(" %.*s%d, type:%s (%d)\n",
1053 (int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
1054 get_kbd_type_name(info.kb_type), info.kb_type);
1057 if (ioctl(0, CONS_SETKBD, info.kb_index) == -1)
1058 warn("unable to set keyboard");
1062 release_keyboard(void)
1064 keyboard_info_t info;
1067 * If stdin is not associated with a keyboard, the following ioctl
1070 if (ioctl(0, KDGKBINFO, &info) == -1) {
1071 warn("unable to obtain keyboard information");
1075 printf("kbd%d\n", info.kb_index);
1076 printf(" %.*s%d, type:%s (%d)\n",
1077 (int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
1078 get_kbd_type_name(info.kb_type), info.kb_type);
1080 if (ioctl(0, CONS_RELKBD, 0) == -1)
1081 warn("unable to release the keyboard");
1085 mux_keyboard(u_int op, char *kbd)
1087 keyboard_info_t info;
1091 * If stdin is not associated with a keyboard, the following ioctl
1094 if (ioctl(0, KDGKBINFO, &info) == -1) {
1095 warn("unable to obtain keyboard information");
1099 printf("kbd%d\n", info.kb_index);
1100 printf(" %.*s%d, type:%s (%d)\n",
1101 (int)sizeof(info.kb_name), info.kb_name, info.kb_unit,
1102 get_kbd_type_name(info.kb_type), info.kb_type);
1105 * split kbd into name and unit. find the right most part of the
1106 * kbd string that consist of only digits.
1109 memset(&info, 0, sizeof(info));
1115 unit = strpbrk(ep + 1, "0123456789");
1117 info.kb_unit = strtol(unit, &ep, 10);
1121 } while (unit != NULL && info.kb_unit == -1);
1123 if (info.kb_unit == -1) {
1124 warnx("unable to find keyboard driver unit in '%s'", kbd);
1129 warnx("unable to find keyboard driver name in '%s'", kbd);
1132 if (unit - kbd >= (int) sizeof(info.kb_name)) {
1133 warnx("keyboard name '%s' is too long", kbd);
1137 strncpy(info.kb_name, kbd, unit - kbd);
1140 * If stdin is not associated with a kbdmux(4) keyboard, the following
1144 if (ioctl(0, op, &info) == -1)
1145 warn("unable to (un)mux the keyboard");
1151 fprintf(stderr, "%s\n%s\n%s\n",
1152 "usage: kbdcontrol [-dFKix] [-A name] [-a name] [-b duration.pitch | [quiet.]belltype]",
1153 " [-r delay.repeat | speed] [-l mapfile] [-f # string]",
1154 " [-k device] [-L mapfile]");
1160 main(int argc, char **argv)
1164 while((opt = getopt(argc, argv, "A:a:b:df:iKk:Fl:L:r:x")) != -1)
1168 mux_keyboard((opt == 'A')? KBRELKBD : KBADDKBD, optarg);
1171 set_bell_values(optarg);
1177 load_keymap(optarg, 0);
1180 load_keymap(optarg, 1);
1183 set_functionkey(optarg,
1184 nextarg(argc, argv, &optind, 'f'));
1187 load_default_functionkeys();
1196 set_keyboard(optarg);
1199 set_keyrates(optarg);
1207 if ((optind != argc) || (argc == 1))