kbdcontrol.c revision 5994
12088Ssos/*-
25536Ssos * Copyright (c) 1994-1995 S�ren Schmidt
32088Ssos * All rights reserved.
42088Ssos *
52088Ssos * Redistribution and use in source and binary forms, with or without
62088Ssos * modification, are permitted provided that the following conditions
72088Ssos * are met:
82088Ssos * 1. Redistributions of source code must retain the above copyright
95994Ssos *    notice, this list of conditions and the following disclaimer,
105994Ssos *    in this position and unchanged.
112088Ssos * 2. Redistributions in binary form must reproduce the above copyright
122088Ssos *    notice, this list of conditions and the following disclaimer in the
132088Ssos *    documentation and/or other materials provided with the distribution.
142088Ssos * 3. The name of the author may not be used to endorse or promote products
152088Ssos *    derived from this software withough specific prior written permission
162088Ssos *
172088Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
182088Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
192088Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
202088Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
212088Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
222088Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232088Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242088Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252088Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
262088Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272088Ssos *
285994Ssos *	$Id: kbdcontrol.c,v 1.3 1995/01/12 11:44:42 sos Exp $
292088Ssos */
302088Ssos
312088Ssos#include <ctype.h>
322088Ssos#include <stdio.h>
333864Sswallace#include <string.h>
342088Ssos#include <machine/console.h>
352088Ssos#include "path.h"
362088Ssos#include "lex.h"
372088Ssos
382088Ssoschar ctrl_names[32][4] = {
392088Ssos	"nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
402088Ssos	"bs ", "ht ", "nl ", "vt ", "ff ", "cr ", "so ", "si ",
412088Ssos	"dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb",
422088Ssos	"can", "em ", "sub", "esc", "fs ", "gs ", "rs ", "ns "
432088Ssos	};
442088Ssos
455994Ssoschar fkey_table[96][MAXFK] = {
465994Ssos/* 01-04 */	"\033[M", "\033[N", "\033[O", "\033[P",
475994Ssos/* 05-08 */	"\033[Q", "\033[R", "\033[S", "\033[T",
485994Ssos/* 09-12 */	"\033[U", "\033[V", "\033[W", "\033[X",
495994Ssos/* 13-16 */	"\033[Y", "\033[Z", "\033[a", "\033[b",
505994Ssos/* 17-20 */	"\033[c", "\033[d", "\033[e", "\033[f",
515994Ssos/* 21-24 */	"\033[g", "\033[h", "\033[i", "\033[j",
525994Ssos/* 25-28 */	"\033[k", "\033[l", "\033[m", "\033[n",
535994Ssos/* 29-32 */	"\033[o", "\033[p", "\033[q", "\033[r",
545994Ssos/* 33-36 */	"\033[s", "\033[t", "\033[u", "\033[v",
555994Ssos/* 37-40 */	"\033[w", "\033[x", "\033[y", "\033[z",
565994Ssos/* 41-44 */	"\033[@", "\033[[", "\033[\\","\033[]",
575994Ssos/* 45-48 */     "\033[^", "\033[_", "\033[`", "\033[",
585994Ssos/* 49-52 */	"\033[H", "\033[A", "\033[I", "-"     ,
595994Ssos/* 53-56 */	"\033[D", "\033[E", "\033[C", "+"     ,
605994Ssos/* 57-60 */	"\033[F", "\033[B", "\033[G", "\033[L",
615994Ssos/* 61-64 */	"\033[J", "\033[K", "\033[}", ""      ,
625994Ssos/* 65-68 */	""      , ""      , ""      , ""      ,
635994Ssos/* 69-72 */	""      , ""      , ""      , ""      ,
645994Ssos/* 73-76 */	""      , ""      , ""      , ""      ,
655994Ssos/* 77-80 */	""      , ""      , ""      , ""      ,
665994Ssos/* 81-84 */	""      , ""      , ""      , ""      ,
675994Ssos/* 85-88 */	""      , ""      , ""      , ""      ,
685994Ssos/* 89-92 */	""      , ""      , ""      , ""      ,
695994Ssos/* 93-96 */	""      , ""      , ""      , ""      ,
702088Ssos	};
712088Ssos
722088Ssosconst int	delays[]  = {250, 500, 750, 1000};
732088Ssosconst int	repeats[] = { 34,  38,  42,  46,  50,  55,  59,  63,
742088Ssos			      68,  76,  84,  92, 100, 110, 118, 126,
752088Ssos			     136, 152, 168, 184, 200, 220, 236, 252,
762088Ssos			     272, 304, 336, 368, 400, 440, 472, 504};
772088Ssosconst int	ndelays = (sizeof(delays) / sizeof(int));
782088Ssosconst int	nrepeats = (sizeof(repeats) / sizeof(int));
792088Ssosint 		hex = 0;
802088Ssosint 		number, verbose = 0;
812088Ssoschar 		letter;
822088Ssos
832088Ssos
842088Ssoschar *
852088Ssosnextarg(int ac, char **av, int *indp, int oc)
862088Ssos{
872088Ssos	if (*indp < ac)
882088Ssos		return(av[(*indp)++]);
892088Ssos	fprintf(stderr, "%s: option requires two arguments -- %c\n", av[0], oc);
902088Ssos	usage();
912088Ssos	exit(1);
922088Ssos	return("");
932088Ssos}
942088Ssos
952088Ssos
962088Ssoschar *
972088Ssosmkfullname(const char *s1, const char *s2, const char *s3)
982088Ssos{
995536Ssos	static char	*buf = NULL;
1005536Ssos	static int	bufl = 0;
1015536Ssos	int		f;
1022088Ssos
1032088Ssos	f = strlen(s1) + strlen(s2) + strlen(s3) + 1;
1042088Ssos	if (f > bufl)
1052088Ssos		if (buf)
1062088Ssos			buf = (char *)realloc(buf, f);
1072088Ssos		else
1082088Ssos			buf = (char *)malloc(f);
1092088Ssos	if (!buf) {
1102088Ssos		bufl = 0;
1112088Ssos		return(NULL);
1122088Ssos	}
1132088Ssos
1142088Ssos	bufl = f;
1152088Ssos	strcpy(buf, s1);
1162088Ssos	strcat(buf, s2);
1172088Ssos	strcat(buf, s3);
1182088Ssos	return(buf);
1192088Ssos}
1202088Ssos
1212088Ssos
1222088Ssosint
1232088Ssosget_entry()
1242088Ssos{
1252088Ssos	switch (yylex()) {
1262088Ssos	case TNOP:
1272088Ssos		return NOP | 0x100;
1282088Ssos	case TLSH:
1292088Ssos		return LSH | 0x100;
1302088Ssos	case TRSH:
1312088Ssos		return RSH | 0x100;
1322088Ssos	case TCLK:
1332088Ssos		return CLK | 0x100;
1342088Ssos	case TNLK:
1352088Ssos		return NLK | 0x100;
1362088Ssos	case TSLK:
1372088Ssos		return SLK | 0x100;
1382088Ssos	case TBTAB:
1392088Ssos		return BTAB | 0x100;
1402088Ssos	case TLALT:
1412088Ssos		return LALT | 0x100;
1422088Ssos	case TLCTR:
1432088Ssos		return LCTR | 0x100;
1442088Ssos	case TNEXT:
1452088Ssos		return NEXT | 0x100;
1462088Ssos	case TRCTR:
1472088Ssos		return RCTR | 0x100;
1482088Ssos	case TRALT:
1492088Ssos		return RALT | 0x100;
1502088Ssos	case TALK:
1512088Ssos		return ALK | 0x100;
1522088Ssos	case TASH:
1532088Ssos		return ASH | 0x100;
1542088Ssos	case TMETA:
1552088Ssos		return META | 0x100;
1562088Ssos	case TRBT:
1572088Ssos		return RBT | 0x100;
1582088Ssos	case TDBG:
1592088Ssos		return DBG | 0x100;
1605994Ssos	case TSUSP:
1615994Ssos		return SUSP | 0x100;
1622088Ssos	case TFUNC:
1632088Ssos		if (F(number) > L_FN)
1642088Ssos			return -1;
1652088Ssos		return F(number) | 0x100;
1662088Ssos	case TSCRN:
1672088Ssos		if (S(number) > L_SCR)
1682088Ssos			return -1;
1692088Ssos		return S(number) | 0x100;
1702088Ssos	case TLET:
1712088Ssos		return (unsigned char)letter;
1722088Ssos	case TNUM:
1732088Ssos		if (number < 0 || number > 255)
1742088Ssos			return -1;
1752088Ssos		return number;
1762088Ssos	default:
1772088Ssos		return -1;
1782088Ssos	}
1792088Ssos}
1802088Ssos
1812088Ssos
1822088Ssosint
1832088Ssosget_key_definition_line(FILE* fd, keymap_t *map)
1842088Ssos{
1852088Ssos	int i, def, scancode;
1862088Ssos
1872088Ssos	yyin = fd;
1882088Ssos
1892088Ssos	/* get scancode number */
1902088Ssos	if (yylex() != TNUM)
1912088Ssos		return -1;
1922088Ssos	if (number < 0 || number >= NUM_KEYS)
1932088Ssos		return -1;
1942088Ssos	scancode = number;
1952088Ssos
1962088Ssos	/* get key definitions */
1972088Ssos	map->key[scancode].spcl = 0;
1982088Ssos	for (i=0; i<NUM_STATES; i++) {
1992088Ssos		if ((def = get_entry()) == -1)
2002088Ssos			return -1;
2012088Ssos		if (def & 0x100)
2022088Ssos			map->key[scancode].spcl |= (0x80 >> i);
2032088Ssos		map->key[scancode].map[i] = def & 0xFF;
2042088Ssos	}
2052088Ssos	/* get lock state key def */
2062088Ssos	if (yylex() != TFLAG)
2072088Ssos		return -1;
2082088Ssos	map->key[scancode].flgs = number;
2092088Ssos		return scancode;
2102088Ssos}
2112088Ssos
2122088Ssos
2132088Ssosint
2142088Ssosprint_entry(FILE *fp, int value)
2152088Ssos{
2162088Ssos	int val = value & 0xFF;
2172088Ssos
2182088Ssos	switch (value) {
2192088Ssos	case NOP | 0x100:
2202088Ssos		fprintf(fp, " nop   ");
2212088Ssos		break;
2222088Ssos	case LSH | 0x100:
2232088Ssos		fprintf(fp, " lshift");
2242088Ssos		break;
2252088Ssos	case RSH | 0x100:
2262088Ssos		fprintf(fp, " rshift");
2272088Ssos		break;
2282088Ssos	case CLK | 0x100:
2292088Ssos		fprintf(fp, " clock ");
2302088Ssos		break;
2312088Ssos	case NLK | 0x100:
2322088Ssos		fprintf(fp, " nlock ");
2332088Ssos		break;
2342088Ssos	case SLK | 0x100:
2352088Ssos		fprintf(fp, " slock ");
2362088Ssos		break;
2372088Ssos	case BTAB | 0x100:
2382088Ssos		fprintf(fp, " btab  ");
2392088Ssos		break;
2402088Ssos	case LALT | 0x100:
2412088Ssos		fprintf(fp, " lalt  ");
2422088Ssos		break;
2432088Ssos	case LCTR | 0x100:
2442088Ssos		fprintf(fp, " lctrl ");
2452088Ssos		break;
2462088Ssos	case NEXT | 0x100:
2472088Ssos		fprintf(fp, " nscr  ");
2482088Ssos		break;
2492088Ssos	case RCTR | 0x100:
2502088Ssos		fprintf(fp, " rctrl ");
2512088Ssos		break;
2522088Ssos	case RALT | 0x100:
2532088Ssos		fprintf(fp, " ralt  ");
2542088Ssos		break;
2552088Ssos	case ALK | 0x100:
2562088Ssos		fprintf(fp, " alock ");
2572088Ssos		break;
2582088Ssos	case ASH | 0x100:
2592088Ssos		fprintf(fp, " ashift");
2602088Ssos		break;
2612088Ssos	case META | 0x100:
2622088Ssos		fprintf(fp, " meta  ");
2632088Ssos		break;
2642088Ssos	case RBT | 0x100:
2652088Ssos		fprintf(fp, " boot  ");
2662088Ssos		break;
2672088Ssos	case DBG | 0x100:
2682088Ssos		fprintf(fp, " debug ");
2692088Ssos		break;
2702088Ssos	default:
2712088Ssos		if (value & 0x100) {
2722088Ssos		 	if (val >= F_FN && val <= L_FN)
2732088Ssos				fprintf(fp, " fkey%02d", val - F_FN + 1);
2742088Ssos		 	else if (val >= F_SCR && val <= L_SCR)
2752088Ssos				fprintf(fp, " scr%02d ", val - F_SCR + 1);
2762088Ssos			else if (hex)
2772088Ssos				fprintf(fp, " 0x%02x  ", val);
2782088Ssos			else
2792088Ssos				fprintf(fp, "  %3d  ", val);
2802088Ssos		}
2812088Ssos		else {
2822088Ssos			if (val < ' ')
2832088Ssos				fprintf(fp, " %s   ", ctrl_names[val]);
2842088Ssos			else if (val == 127)
2852088Ssos				fprintf(fp, " del   ");
2862088Ssos			else if (isprint(val))
2872088Ssos				fprintf(fp, " '%c'   ", val);
2882088Ssos			else if (hex)
2892088Ssos				fprintf(fp, " 0x%02x  ", val);
2902088Ssos			else
2912088Ssos				fprintf(fp, " %3d   ", val);
2922088Ssos		}
2932088Ssos	}
2942088Ssos}
2952088Ssos
2962088Ssos
2972088Ssosvoid
2982088Ssosprint_key_definition_line(FILE *fp, int scancode, struct key_t *key)
2992088Ssos{
3002088Ssos	int i, value;
3012088Ssos
3022088Ssos	/* print scancode number */
3032088Ssos	if (hex)
3042088Ssos		fprintf(fp, " 0x%02x  ", scancode);
3052088Ssos	else
3062088Ssos		fprintf(fp, "  %03d  ", scancode);
3072088Ssos
3082088Ssos	/* print key definitions */
3092088Ssos	for (i=0; i<NUM_STATES; i++) {
3102088Ssos		if (key->spcl & (0x80 >> i))
3112088Ssos			print_entry(fp, key->map[i] | 0x100);
3122088Ssos		else
3132088Ssos			print_entry(fp, key->map[i]);
3142088Ssos	}
3152088Ssos
3162088Ssos	/* print lock state key def */
3172088Ssos	switch (key->flgs) {
3182088Ssos	case 0:
3192088Ssos		fprintf(fp, "  O\n");
3202088Ssos		break;
3212088Ssos	case 1:
3222088Ssos		fprintf(fp, "  C\n");
3232088Ssos		break;
3242088Ssos	case 2:
3252088Ssos		fprintf(fp, "  N\n");
3262088Ssos		break;
3272088Ssos	}
3282088Ssos}
3292088Ssos
3302088Ssos
3312088Ssosvoid
3322088Ssosload_keymap(char *opt)
3332088Ssos{
3342088Ssos	keymap_t map;
3352088Ssos	FILE	*fd;
3362088Ssos	int	scancode, i;
3372088Ssos	char	*name;
3382088Ssos	char	*prefix[]  = {"", "", KEYMAP_PATH, NULL};
3392088Ssos	char	*postfix[] = {"", ".kbd", ".kbd"};
3402088Ssos
3412088Ssos	for (i=0; prefix[i]; i++) {
3422088Ssos		name = mkfullname(prefix[i], opt, postfix[i]);
3432088Ssos		if (fd = fopen(name, "r"))
3442088Ssos			break;
3452088Ssos	}
3462088Ssos	if (fd == NULL) {
3472088Ssos		perror("keymap file not found");
3482088Ssos		return;
3492088Ssos	}
3503864Sswallace	memset(&map, 0, sizeof(map));
3512088Ssos	while (1) {
3522088Ssos		if ((scancode = get_key_definition_line(fd, &map)) < 0)
3532088Ssos			break;
3542088Ssos		if (scancode > map.n_keys) map.n_keys = scancode;
3552088Ssos    	}
3562088Ssos	if (ioctl(0, PIO_KEYMAP, &map) < 0) {
3572088Ssos		perror("setting keymap");
3582088Ssos		fclose(fd);
3592088Ssos		return;
3602088Ssos	}
3612088Ssos}
3622088Ssos
3632088Ssos
3642088Ssosvoid
3652088Ssosprint_keymap()
3662088Ssos{
3672088Ssos	keymap_t map;
3682088Ssos	int i;
3692088Ssos
3702088Ssos	if (ioctl(0, GIO_KEYMAP, &map) < 0) {
3712088Ssos		perror("getting keymap");
3722088Ssos		exit(1);
3732088Ssos	}
3742088Ssos    	printf(
3752088Ssos"#                                                         alt\n"
3762088Ssos"# scan                       cntrl          alt    alt   cntrl lock\n"
3772088Ssos"# code  base   shift  cntrl  shift  alt    shift  cntrl  shift state\n"
3782088Ssos"# ------------------------------------------------------------------\n"
3792088Ssos    	);
3802088Ssos	for (i=0; i<map.n_keys; i++)
3812088Ssos		print_key_definition_line(stdout, i, &map.key[i]);
3822088Ssos}
3832088Ssos
3842088Ssos
3852088Ssosvoid
3862088Ssosload_default_functionkeys()
3872088Ssos{
3882088Ssos	fkeyarg_t fkey;
3892088Ssos	int i;
3902088Ssos
3912088Ssos	for (i=0; i<NUM_FKEYS; i++) {
3922088Ssos		fkey.keynum = i;
3932088Ssos		strcpy(fkey.keydef, fkey_table[i]);
3942088Ssos		fkey.flen = strlen(fkey_table[i]);
3952088Ssos		if (ioctl(0, SETFKEY, &fkey) < 0)
3962088Ssos			perror("setting function key");
3972088Ssos	}
3982088Ssos}
3992088Ssos
4002088Ssosvoid
4012088Ssosset_functionkey(char *keynumstr, char *string)
4022088Ssos{
4032088Ssos	fkeyarg_t fkey;
4042088Ssos	int keynum;
4052088Ssos
4062088Ssos	if (!strcmp(keynumstr, "load") && !strcmp(string, "default")) {
4072088Ssos		load_default_functionkeys();
4082088Ssos		return;
4092088Ssos	}
4102088Ssos	fkey.keynum = atoi(keynumstr);
4112088Ssos	if (fkey.keynum < 1 || fkey.keynum > NUM_FKEYS) {
4122088Ssos		fprintf(stderr,
4132088Ssos			"function key number must be between 1 and %d\n",
4142088Ssos			NUM_FKEYS);
4152088Ssos		return;
4162088Ssos	}
4172088Ssos	if ((fkey.flen = strlen(string)) > MAXFK) {
4182088Ssos		fprintf(stderr, "function key string too long (%d > %d)\n",
4192088Ssos			fkey.flen, MAXFK);
4202088Ssos		return;
4212088Ssos	}
4222088Ssos	strcpy(fkey.keydef, string);
4232088Ssos	if (verbose)
4242088Ssos		fprintf(stderr, "setting function key %d to <%s>\n",
4252088Ssos			fkey.keynum, fkey.keydef);
4262088Ssos	fkey.keynum -= 1;
4272088Ssos	if (ioctl(0, SETFKEY, &fkey) < 0)
4282088Ssos		perror("setting function key");
4292088Ssos}
4302088Ssos
4312088Ssos
4322088Ssosvoid
4332088Ssosset_bell_values(char *opt)
4342088Ssos{
4355536Ssos	int bell, duration, pitch;
4362088Ssos
4375536Ssos	if (!strcmp(opt, "visual"))
4385536Ssos		bell = 1, duration = 1, pitch = 800;
4395536Ssos	else if (!strcmp(opt, "normal"))
4405536Ssos		bell = 0, duration = 1, pitch = 800;
4412088Ssos	else {
4422088Ssos		int		n;
4432088Ssos		char		*v1;
4445536Ssos
4455536Ssos		bell = 0;
4462088Ssos		duration = strtol(opt, &v1, 0);
4472088Ssos		if ((duration < 0) || (*v1 != '.'))
4482088Ssos			goto badopt;
4492088Ssos		opt = ++v1;
4502088Ssos		pitch = strtol(opt, &v1, 0);
4512088Ssos		if ((pitch < 0) || (*opt == '\0') || (*v1 != '\0')) {
4522088Ssosbadopt:
4532088Ssos			fprintf(stderr,
4542088Ssos				"argument to -b must be DURATION.PITCH\n");
4552088Ssos			return;
4562088Ssos		}
4572088Ssos	}
4582088Ssos
4592088Ssos	if (verbose)
4605536Ssos		if (bell)
4615536Ssos			fprintf(stderr, "setting visual bell\n");
4625536Ssos		else
4635536Ssos			fprintf(stderr, "setting bell values to %d.%d\n",
4645536Ssos				duration, pitch);
4655536Ssos	ioctl(0, CONS_BELLTYPE, &bell);
4665536Ssos	if (!bell)
4675536Ssos		fprintf(stderr, "[=%d;%dB", pitch, duration);
4682088Ssos}
4692088Ssos
4702088Ssos
4712088Ssosvoid
4722088Ssosset_keyrates(char *opt)
4732088Ssos{
4742088Ssosstruct	{
4752088Ssos	int	rep:5;
4762088Ssos	int	del:2;
4772088Ssos	int	pad:1;
4782088Ssos	}rate;
4792088Ssos
4802088Ssos	if (!strcmp(opt, "slow"))
4812088Ssos		rate.del = 3, rate.rep = 31;
4822088Ssos	else if (!strcmp(opt, "normal"))
4832088Ssos		rate.del = 1, rate.rep = 15;
4842088Ssos	else if (!strcmp(opt, "fast"))
4852088Ssos		rate.del = rate.rep = 0;
4862088Ssos	else {
4872088Ssos		int		n;
4882088Ssos		int		delay, repeat;
4892088Ssos		char		*v1;
4902088Ssos
4912088Ssos		delay = strtol(opt, &v1, 0);
4922088Ssos		if ((delay < 0) || (*v1 != '.'))
4932088Ssos			goto badopt;
4942088Ssos		opt = ++v1;
4952088Ssos		repeat = strtol(opt, &v1, 0);
4962088Ssos		if ((repeat < 0) || (*opt == '\0') || (*v1 != '\0')) {
4972088Ssosbadopt:
4982088Ssos			fprintf(stderr,
4992088Ssos				"argument to -r must be delay.repeat\n");
5002088Ssos			return;
5012088Ssos		}
5022088Ssos		for (n = 0; n < ndelays - 1; n++)
5032088Ssos			if (delay <= delays[n])
5042088Ssos				break;
5052088Ssos		rate.del = n;
5062088Ssos		for (n = 0; n < nrepeats - 1; n++)
5072088Ssos			if (repeat <= repeats[n])
5082088Ssos				break;
5092088Ssos		rate.rep = n;
5102088Ssos	}
5112088Ssos
5122088Ssos	if (verbose)
5132088Ssos		fprintf(stderr, "setting keyboard rate to %d.%d\n",
5142088Ssos			delays[rate.del], repeats[rate.rep]);
5152088Ssos	if (ioctl(0, KDSETRAD, rate) < 0)
5162088Ssos		perror("setting keyboard rate");
5172088Ssos}
5182088Ssos
5192088Ssos
5202088Ssosusage()
5212088Ssos{
5222088Ssos	fprintf(stderr,
5235536Ssos"Usage: kbdcontrol -b duration.pitch   (set bell duration & pitch)\n"
5245536Ssos"                  -b normal | visual  (set bell to visual type)\n"
5255536Ssos"                  -d                  (dump keyboard map to stdout)\n"
5265536Ssos"                  -l filename         (load keyboard map file)\n"
5275536Ssos"                  -f <N> string       (set function key N to send <string>)\n"
5285536Ssos"                  -F                  (set function keys back to default)\n"
5295536Ssos"                  -r delay.repeat     (set keyboard delay & repeat rate)\n"
5305536Ssos"                  -r slow             (set keyboard delay & repeat to slow)\n"
5315536Ssos"                  -r normal           (set keyboard delay & repeat to normal)\n"
5325536Ssos"                  -r fast             (set keyboard delay & repeat to fast)\n"
5335536Ssos"                  -v                  (verbose)\n"
5342088Ssos	);
5352088Ssos}
5362088Ssos
5372088Ssos
5382088Ssosvoid
5392088Ssosmain(int argc, char **argv)
5402088Ssos{
5412088Ssos	extern char	*optarg;
5422088Ssos	extern int	optind;
5432088Ssos	int		opt;
5442088Ssos
5452088Ssos	/*
5462088Ssos	if (!is_syscons(0))
5472088Ssos		exit(1);
5482088Ssos	*/
5492088Ssos	while((opt = getopt(argc, argv, "b:df:Fl:r:vx")) != -1)
5502088Ssos		switch(opt) {
5512088Ssos			case 'b':
5522088Ssos				set_bell_values(optarg);
5532088Ssos				break;
5542088Ssos			case 'd':
5552088Ssos				print_keymap();
5562088Ssos				break;
5572088Ssos			case 'l':
5582088Ssos				load_keymap(optarg);
5592088Ssos				break;
5602088Ssos			case 'f':
5612088Ssos				set_functionkey(optarg,
5622088Ssos					nextarg(argc, argv, &optind, 'f'));
5632088Ssos				break;
5642088Ssos			case 'F':
5652088Ssos				load_default_functionkeys();
5662088Ssos				break;
5672088Ssos			case 'r':
5682088Ssos				set_keyrates(optarg);
5692088Ssos				break;
5702088Ssos			case 'v':
5712088Ssos				verbose = 1;
5722088Ssos				break;
5732088Ssos			case 'x':
5742088Ssos				hex = 1;
5752088Ssos				break;
5762088Ssos			default:
5772088Ssos				usage();
5782088Ssos				exit(1);
5792088Ssos		}
5802088Ssos	if ((optind != argc) || (argc == 1)) {
5812088Ssos		usage();
5822088Ssos		exit(1);
5832088Ssos	}
5842088Ssos	exit(0);
5852088Ssos}
5862088Ssos
5872088Ssos
588