From owner-freebsd-arch Tue May 29 22: 3:44 2001 Delivered-To: freebsd-arch@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id E7DB637B423 for ; Tue, 29 May 2001 22:03:19 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from hornet.unixfreak.org (hornet [63.198.170.140]) by bazooka.unixfreak.org (Postfix) with ESMTP id 9506F3E28; Tue, 29 May 2001 22:03:19 -0700 (PDT) To: Dag-Erling Smorgrav Cc: arch@freebsd.org Subject: Re: {kbd,vid}control insanity patch In-Reply-To: ; from des@ofug.org on "29 May 2001 12:45:47 +0200" Date: Tue, 29 May 2001 22:03:19 -0700 From: Dima Dorfman Message-Id: <20010530050319.9506F3E28@bazooka.unixfreak.org> Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Dag-Erling Smorgrav writes: > Dima Dorfman writes: > > Dag-Erling Smorgrav writes: > > > Damn, yet another kbdcontrol bug. This - like every other vty- > > > specific knob - should be in vidcontrol. > > Are keymaps vty-specific? > > No, they're global. Okay, then that leaves -f, -F, -b, and -r in kbdcontrol. The patch attached below moves those to vidcontrol as -F, -G, -B, and -R, respectively. If this ends up getting committed I'll gladly nuke allscreens_kbdflags. Comments? Thanks, Dima Dorfman dima@unixfreak.org Index: kbdcontrol/kbdcontrol.1 =================================================================== RCS file: /home/ncvs/src/usr.sbin/kbdcontrol/kbdcontrol.1,v retrieving revision 1.30 diff -u -r1.30 kbdcontrol.1 --- kbdcontrol/kbdcontrol.1 2001/05/28 11:05:26 1.30 +++ kbdcontrol/kbdcontrol.1 2001/05/30 04:59:43 @@ -13,7 +13,7 @@ .\" @(#)kbdcontrol.1 .\" $FreeBSD: src/usr.sbin/kbdcontrol/kbdcontrol.1,v 1.30 2001/05/28 11:05:26 des Exp $ .\" -.Dd May 27, 2001 +.Dd May 29, 2001 .Dt KBDCONTROL 1 .Os .Sh NAME @@ -21,17 +21,8 @@ .Nd keyboard control and configuration utility .Sh SYNOPSIS .Nm -.Op Fl dFKix -.Oo -.Fl b -.Ar duration . Ns Ar pitch | Ar belltype -.Oc -.Oo -.Fl r -.Ar delay . Ns Ar repeat | Ar speed -.Oc +.Op Fl dKix .Op Fl l Ar keymap_file -.Op Fl f Ar # Ar string .Op Fl k Ar keyboard_device .Op Fl L Ar keymap_file .Sh DESCRIPTION @@ -52,45 +43,6 @@ .Pp The following command line options are supported: .Bl -tag -width indent -.It Fl b Xo -.Ar duration . Ns Ar pitch | Ar belltype -.Xc -Set the bell duration in milliseconds and pitch in hertz. -If a -.Ar belltype -argument is specified, it may be one of -.Cm normal -which sets sound parameters back to normal values, -.Cm off -which disables the bell entirely, or -.Cm visual -which sets the bell to visual mode, i.e. flashes the screen instead. -If -.Ar belltype -is preceded by the word -.Cm quiet. , -the bell will not be rung when the ringing process is in the background vty. -.It Fl r Xo -.Ar delay . Ns Ar repeat | Ar speed -.Xc -Set keyboard -.Ar delay -(250, 500, 750, 1000) -and -.Ar repeat -(34, 38, 42, 46, 50, 55, 59, 63, 68, 76, 84, 92, 100, 110, 118, 126, -136, 152, 168, 184, 200, 220, 236, 252, 272, 304, 336, 368, 400, 440, -472, 504) -rates, or if a -.Ar speed -argument is specified, it may be one of -.Cm slow -(1000.504), -.Cm fast -(250.34) -or -.Cm normal -(500.126). .It Fl l Ar keymap_file Install keyboard map file from .Ar keymap_file . @@ -102,16 +54,6 @@ back to the kernel later by the .Fl l option above. -.It Fl f Ar # Ar string -Set function key number -.Ar # -to send -.Ar string . -Refer to the man page for the keyboard driver -.Pq e.g. Xr atkbd 4 -for available function keys and their numbers. -.It Fl F -Set function keys back to the standard definitions. .It Fl x Use hexadecimal numbers in keyboard map dump. .It Fl i Index: kbdcontrol/kbdcontrol.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/kbdcontrol/kbdcontrol.c,v retrieving revision 1.41 diff -u -r1.41 kbdcontrol.c --- kbdcontrol/kbdcontrol.c 2001/05/29 13:59:02 1.41 +++ kbdcontrol/kbdcontrol.c 2001/05/30 04:59:44 @@ -70,40 +70,6 @@ "DCAR", }; -char fkey_table[96][MAXFK] = { -/* 01-04 */ "\033[M", "\033[N", "\033[O", "\033[P", -/* 05-08 */ "\033[Q", "\033[R", "\033[S", "\033[T", -/* 09-12 */ "\033[U", "\033[V", "\033[W", "\033[X", -/* 13-16 */ "\033[Y", "\033[Z", "\033[a", "\033[b", -/* 17-20 */ "\033[c", "\033[d", "\033[e", "\033[f", -/* 21-24 */ "\033[g", "\033[h", "\033[i", "\033[j", -/* 25-28 */ "\033[k", "\033[l", "\033[m", "\033[n", -/* 29-32 */ "\033[o", "\033[p", "\033[q", "\033[r", -/* 33-36 */ "\033[s", "\033[t", "\033[u", "\033[v", -/* 37-40 */ "\033[w", "\033[x", "\033[y", "\033[z", -/* 41-44 */ "\033[@", "\033[[", "\033[\\","\033[]", -/* 45-48 */ "\033[^", "\033[_", "\033[`", "\033[{", -/* 49-52 */ "\033[H", "\033[A", "\033[I", "-" , -/* 53-56 */ "\033[D", "\033[E", "\033[C", "+" , -/* 57-60 */ "\033[F", "\033[B", "\033[G", "\033[L", -/* 61-64 */ "\177", "\033[J", "\033[~", "\033[}", -/* 65-68 */ "" , "" , "" , "" , -/* 69-72 */ "" , "" , "" , "" , -/* 73-76 */ "" , "" , "" , "" , -/* 77-80 */ "" , "" , "" , "" , -/* 81-84 */ "" , "" , "" , "" , -/* 85-88 */ "" , "" , "" , "" , -/* 89-92 */ "" , "" , "" , "" , -/* 93-96 */ "" , "" , "" , "" , - }; - -const int delays[] = {250, 500, 750, 1000}; -const int repeats[] = { 34, 38, 42, 46, 50, 55, 59, 63, - 68, 76, 84, 92, 100, 110, 118, 126, - 136, 152, 168, 184, 200, 220, 236, 252, - 272, 304, 336, 368, 400, 440, 472, 504}; -const int ndelays = (sizeof(delays) / sizeof(int)); -const int nrepeats = (sizeof(repeats) / sizeof(int)); int hex = 0; int number; char letter; @@ -835,139 +801,6 @@ } - -void -load_default_functionkeys() -{ - fkeyarg_t fkey; - int i; - - for (i=0; i NUM_FKEYS) { - warnx("function key number must be between 1 and %d", - NUM_FKEYS); - return; - } - if ((fkey.flen = strlen(string)) > MAXFK) { - warnx("function key string too long (%d > %d)", - fkey.flen, MAXFK); - return; - } - strcpy(fkey.keydef, string); - fkey.keynum -= 1; - if (ioctl(0, SETFKEY, &fkey) < 0) - warn("setting function key"); -} - - -void -set_bell_values(char *opt) -{ - int bell, duration, pitch; - - bell = 0; - if (!strncmp(opt, "quiet.", 6)) { - bell = 2; - opt += 6; - } - if (!strcmp(opt, "visual")) - bell |= 1; - else if (!strcmp(opt, "normal")) - duration = 5, pitch = 800; - else if (!strcmp(opt, "off")) - duration = 0, pitch = 0; - else { - char *v1; - - bell = 0; - duration = strtol(opt, &v1, 0); - if ((duration < 0) || (*v1 != '.')) - goto badopt; - opt = ++v1; - pitch = strtol(opt, &v1, 0); - if ((pitch < 0) || (*opt == '\0') || (*v1 != '\0')) { -badopt: - warnx("argument to -b must be duration.pitch or [quiet.]visual|normal|off"); - return; - } - if (pitch != 0) - pitch = 1193182 / pitch; /* in Hz */ - duration /= 10; /* in 10 m sec */ - } - - ioctl(0, CONS_BELLTYPE, &bell); - if ((bell & ~2) == 0) - fprintf(stderr, "[=%d;%dB", pitch, duration); -} - - -void -set_keyrates(char *opt) -{ - int arg[2]; - int repeat; - int delay; - int r, d; - - if (!strcmp(opt, "slow")) { - delay = 1000, repeat = 500; - d = 3, r = 31; - } else if (!strcmp(opt, "normal")) { - delay = 500, repeat = 125; - d = 1, r = 15; - } else if (!strcmp(opt, "fast")) { - delay = repeat = 0; - d = r = 0; - } else { - int n; - char *v1; - - delay = strtol(opt, &v1, 0); - if ((delay < 0) || (*v1 != '.')) - goto badopt; - opt = ++v1; - repeat = strtol(opt, &v1, 0); - if ((repeat < 0) || (*opt == '\0') || (*v1 != '\0')) { -badopt: - warnx("argument to -r must be delay.repeat or slow|normal|fast"); - return; - } - for (n = 0; n < ndelays - 1; n++) - if (delay <= delays[n]) - break; - d = n; - for (n = 0; n < nrepeats - 1; n++) - if (repeat <= repeats[n]) - break; - r = n; - } - - arg[0] = delay; - arg[1] = repeat; - if (ioctl(0, KDSETREPEAT, arg)) { - if (ioctl(0, KDSETRAD, (d << 5) | r)) - warn("setting keyboard rate"); - } -} - static char *get_kbd_type_name(int type) { @@ -1066,10 +899,8 @@ void usage() { - fprintf(stderr, "%s\n%s\n%s\n", -"usage: kbdcontrol [-dFKix] [-b duration.pitch | [quiet.]belltype]", -" [-r delay.repeat | speed] [-l mapfile] [-f # string]", -" [-k device] [-L mapfile]"); + fprintf(stderr, "%s\n", +"usage: kbdcontrol [-dKix] [-l mapfile] [-k device] [-L mapfile]"); exit(1); } @@ -1081,9 +912,6 @@ while((opt = getopt(argc, argv, "b:df:iKk:Fl:L:r:x")) != -1) switch(opt) { - case 'b': - set_bell_values(optarg); - break; case 'd': print_keymap(); break; @@ -1093,13 +921,6 @@ case 'L': load_keymap(optarg, 1); break; - case 'f': - set_functionkey(optarg, - nextarg(argc, argv, &optind, 'f')); - break; - case 'F': - load_default_functionkeys(); - break; case 'i': show_kbd_info(); break; @@ -1108,9 +929,6 @@ break; case 'k': set_keyboard(optarg); - break; - case 'r': - set_keyrates(optarg); break; case 'x': hex = 1; Index: vidcontrol/vidcontrol.1 =================================================================== RCS file: /home/ncvs/src/usr.sbin/vidcontrol/vidcontrol.1,v retrieving revision 1.39 diff -u -r1.39 vidcontrol.1 --- vidcontrol/vidcontrol.1 2001/05/29 18:48:13 1.39 +++ vidcontrol/vidcontrol.1 2001/05/30 04:59:44 @@ -13,7 +13,7 @@ .\" @(#)vidcontrol.1 .\" $FreeBSD: src/usr.sbin/vidcontrol/vidcontrol.1,v 1.39 2001/05/29 18:48:13 sobomax Exp $ .\" -.Dd May 27, 2001 +.Dd May 29, 2001 .Dt VIDCONTROL 1 .Os .Sh NAME @@ -21,9 +21,14 @@ .Nd system console control and configuration utility .Sh SYNOPSIS .Nm -.Op Fl CdLPpx +.Op Fl CdGLPpx +.Oo +.Fl B +.Ar duration . Ns Ar pitch | Ar belltype +.Oc .Op Fl b Ar color .Op Fl c Ar appearance +.Op Fl F Ar # Ar string .Oo .Fl f .Op Ar size @@ -35,6 +40,10 @@ .Op Fl l Ar screen_map .Op Fl M Ar char .Op Fl m Cm on | off +.Oo +.Fl R +.Ar delay . Ns Ar repeat | Ar speed +.Oc .Op Fl r Ar foreground Ar background .Op Fl s Ar number .Op Fl t Ar N | Cm off @@ -103,6 +112,24 @@ command below to see available colors. .It Cm show See the supported colors on a given platform. +.It Fl B Xo +.Ar duration . Ns Ar pitch | Ar belltype +.Xc +Set the bell duration in milliseconds and pitch in hertz. +If a +.Ar belltype +argument is specified, it may be one of +.Cm normal +which sets sound parameters back to normal values, +.Cm off +which disables the bell entirely, or +.Cm visual +which sets the bell to visual mode, i.e. flashes the screen instead. +If +.Ar belltype +is preceded by the word +.Cm quiet. , +the bell will not be rung when the ringing process is in the background vty. .It Fl b Ar color Set border color to .Ar color . @@ -120,6 +147,14 @@ The latter is actually a simulation. .It Fl d Print out current output screen map. +.It Fl F Ar # Ar string +Set function key number +.Ar # +to send +.Ar string . +Refer to the man page for the keyboard driver +.Pq e.g. Xr atkbd 4 +for available function keys and their numbers. .It Xo .Fl f .Op Ar size @@ -152,6 +187,8 @@ .Sx EXAMPLES below and the man page for .Xr syscons 4 . +.It Fl G +Set function keys back to the standard definitions. .It Fl g Ar geometry Set the .Ar geometry @@ -207,6 +244,27 @@ but dump contents of the video buffer in a plain text format ignoring nonprintable characters and information about text attributes. +.It Fl R Xo +.Ar delay . Ns Ar repeat | Ar speed +.Xc +Set keyboard +.Ar delay +(250, 500, 750, 1000) +and +.Ar repeat +(34, 38, 42, 46, 50, 55, 59, 63, 68, 76, 84, 92, 100, 110, 118, 126, +136, 152, 168, 184, 200, 220, 236, 252, 272, 304, 336, 368, 400, 440, +472, 504) +rates, or if a +.Ar speed +argument is specified, it may be one of +.Cm slow +(1000.504), +.Cm fast +(250.34) +or +.Cm normal +(500.126). .It Fl r Ar foreground background Change reverse mode colors to .Ar foreground Index: vidcontrol/vidcontrol.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/vidcontrol/vidcontrol.c,v retrieving revision 1.39 diff -u -r1.39 vidcontrol.c --- vidcontrol/vidcontrol.c 2001/05/28 11:05:28 1.39 +++ vidcontrol/vidcontrol.c 2001/05/30 04:59:45 @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -55,12 +56,46 @@ #define DUMP_FMT_REV 1 +char fkey_table[96][MAXFK] = { +/* 01-04 */ "\033[M", "\033[N", "\033[O", "\033[P", +/* 05-08 */ "\033[Q", "\033[R", "\033[S", "\033[T", +/* 09-12 */ "\033[U", "\033[V", "\033[W", "\033[X", +/* 13-16 */ "\033[Y", "\033[Z", "\033[a", "\033[b", +/* 17-20 */ "\033[c", "\033[d", "\033[e", "\033[f", +/* 21-24 */ "\033[g", "\033[h", "\033[i", "\033[j", +/* 25-28 */ "\033[k", "\033[l", "\033[m", "\033[n", +/* 29-32 */ "\033[o", "\033[p", "\033[q", "\033[r", +/* 33-36 */ "\033[s", "\033[t", "\033[u", "\033[v", +/* 37-40 */ "\033[w", "\033[x", "\033[y", "\033[z", +/* 41-44 */ "\033[@", "\033[[", "\033[\\","\033[]", +/* 45-48 */ "\033[^", "\033[_", "\033[`", "\033[{", +/* 49-52 */ "\033[H", "\033[A", "\033[I", "-" , +/* 53-56 */ "\033[D", "\033[E", "\033[C", "+" , +/* 57-60 */ "\033[F", "\033[B", "\033[G", "\033[L", +/* 61-64 */ "\177", "\033[J", "\033[~", "\033[}", +/* 65-68 */ "" , "" , "" , "" , +/* 69-72 */ "" , "" , "" , "" , +/* 73-76 */ "" , "" , "" , "" , +/* 77-80 */ "" , "" , "" , "" , +/* 81-84 */ "" , "" , "" , "" , +/* 85-88 */ "" , "" , "" , "" , +/* 89-92 */ "" , "" , "" , "" , +/* 93-96 */ "" , "" , "" , "" , + }; + char legal_colors[16][16] = { "black", "blue", "green", "cyan", "red", "magenta", "brown", "white", "grey", "lightblue", "lightgreen", "lightcyan", "lightred", "lightmagenta", "yellow", "lightwhite" }; +const int delays[] = {250, 500, 750, 1000}; +const int repeats[] = { 34, 38, 42, 46, 50, 55, 59, 63, + 68, 76, 84, 92, 100, 110, 118, 126, + 136, 152, 168, 184, 200, 220, 236, 252, + 272, 304, 336, 368, 400, 440, 472, 504}; +const int ndelays = (sizeof(delays) / sizeof(int)); +const int nrepeats = (sizeof(repeats) / sizeof(int)); int hex = 0; int number; int vesa_cols = _VESA_800x600_DFL_COLS; @@ -72,11 +107,14 @@ static void usage() { - fprintf(stderr, "%s\n%s\n%s\n%s\n", -"usage: vidcontrol [-CdLPpx] [-b color] [-c appearance] [-f [size] file]", -" [-g geometry] [-h size] [-i adapter | mode] [-l screen_map]", -" [-m on | off] [-M char] [-r foreground background] [-s num]", -" [-t N | off] [mode] [foreground [background]] [show]"); + fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n", +"usage: vidcontrol [-CdGLPpx] [-B duration.pitch | [quiet.]belltype] ", +" [-b color] [-c appearance] [-F # string] [-f [size] file]", +" [-g geometry] [-h size] [-i adapter | mode]", +" [-l screen_map] [-m on | off] [-M char]", +" [-R delay.repeat | speed] [-r foreground background]", +" [-s num] [-t N | off]", +" [mode] [foreground [background]] [show]"); exit(1); } @@ -736,6 +774,136 @@ warn("clear history buffer"); } +void +set_bell_values(char *opt) +{ + int bell, duration, pitch; + + bell = 0; + if (!strncmp(opt, "quiet.", 6)) { + bell = 2; + opt += 6; + } + if (!strcmp(opt, "visual")) + bell |= 1; + else if (!strcmp(opt, "normal")) + duration = 5, pitch = 800; + else if (!strcmp(opt, "off")) + duration = 0, pitch = 0; + else { + char *v1; + + bell = 0; + duration = strtol(opt, &v1, 0); + if ((duration < 0) || (*v1 != '.')) + goto badopt; + opt = ++v1; + pitch = strtol(opt, &v1, 0); + if ((pitch < 0) || (*opt == '\0') || (*v1 != '\0')) { +badopt: + warnx("argument to -B must be duration.pitch or [quiet.]visual|normal|off"); + return; + } + if (pitch != 0) + pitch = 1193182 / pitch; /* in Hz */ + duration /= 10; /* in 10 m sec */ + } + + ioctl(0, CONS_BELLTYPE, &bell); + if ((bell & ~2) == 0) + fprintf(stderr, "[=%d;%dB", pitch, duration); +} + +void +set_keyrates(char *opt) +{ + int arg[2]; + int repeat; + int delay; + int r, d; + + if (!strcmp(opt, "slow")) { + delay = 1000, repeat = 500; + d = 3, r = 31; + } else if (!strcmp(opt, "normal")) { + delay = 500, repeat = 125; + d = 1, r = 15; + } else if (!strcmp(opt, "fast")) { + delay = repeat = 0; + d = r = 0; + } else { + int n; + char *v1; + + delay = strtol(opt, &v1, 0); + if ((delay < 0) || (*v1 != '.')) + goto badopt; + opt = ++v1; + repeat = strtol(opt, &v1, 0); + if ((repeat < 0) || (*opt == '\0') || (*v1 != '\0')) { +badopt: + warnx("argument to -R must be delay.repeat or slow|normal|fast"); + return; + } + for (n = 0; n < ndelays - 1; n++) + if (delay <= delays[n]) + break; + d = n; + for (n = 0; n < nrepeats - 1; n++) + if (repeat <= repeats[n]) + break; + r = n; + } + + arg[0] = delay; + arg[1] = repeat; + if (ioctl(0, KDSETREPEAT, arg)) { + if (ioctl(0, KDSETRAD, (d << 5) | r)) + warn("setting keyboard rate"); + } +} + +void +load_default_functionkeys() +{ + fkeyarg_t fkey; + int i; + + for (i=0; i NUM_FKEYS) { + warnx("function key number must be between 1 and %d", + NUM_FKEYS); + return; + } + if ((fkey.flen = strlen(string)) > MAXFK) { + warnx("function key string too long (%d > %d)", + fkey.flen, MAXFK); + return; + } + strcpy(fkey.keydef, string); + fkey.keynum -= 1; + if (ioctl(0, SETFKEY, &fkey) < 0) + warn("setting function key"); +} + int main(int argc, char **argv) { @@ -749,8 +917,12 @@ /* Not reached */ if (ioctl(0, CONS_GETINFO, &info) < 0) err(1, "must be on a virtual console"); - while((opt = getopt(argc, argv, "b:Cc:df:g:h:i:l:LM:m:pPr:s:t:x")) != -1) + while((opt = getopt(argc, argv, + "B:b:Cc:dF:f:Gg:h:i:l:LM:m:pPR:r:s:t:x")) != -1) switch(opt) { + case 'B': + set_bell_values(optarg); + break; case 'b': set_border_color(optarg); break; @@ -763,6 +935,10 @@ case 'd': print_scrnmap(); break; + case 'F': + set_functionkey(optarg, + nextarg(argc, argv, &optind, 'f', 1)); + break; case 'f': type = optarg; font = nextarg(argc, argv, &optind, 'f', 0); @@ -772,6 +948,9 @@ } load_font(type, font); break; + case 'G': + load_default_functionkeys(); + break; case 'g': if (sscanf(optarg, "%dx%d", &vesa_cols, &vesa_rows) != 2) { @@ -802,6 +981,9 @@ break; case 'P': dump_screen(DUMP_TXT); + break; + case 'R': + set_keyrates(optarg); break; case 'r': set_reverse_colors(argc, argv, &optind); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message