2004-07-30 15:08:03 +04:00
|
|
|
/* $NetBSD: util.c,v 1.20 2004/07/30 11:08:03 jmmv Exp $ */
|
1998-12-28 17:01:16 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Juergen Hannken-Illjes.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <dev/wscons/wsconsio.h>
|
|
|
|
#include <dev/wscons/wsksymdef.h>
|
|
|
|
#include <err.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "wsconsctl.h"
|
|
|
|
|
|
|
|
#define TABLEN(t) (sizeof(t)/sizeof(t[0]))
|
|
|
|
|
|
|
|
extern struct wskbd_map_data kbmap; /* from keyboard.c */
|
|
|
|
extern struct wskbd_map_data newkbmap; /* from map_parse.y */
|
|
|
|
|
|
|
|
struct nameint {
|
|
|
|
int value;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct nameint kbtype_tab[] = {
|
2001-09-19 16:45:24 +04:00
|
|
|
{ WSKBD_TYPE_LK201, "lk201" },
|
|
|
|
{ WSKBD_TYPE_LK401, "lk401" },
|
|
|
|
{ WSKBD_TYPE_PC_XT, "pc-xt" },
|
|
|
|
{ WSKBD_TYPE_PC_AT, "pc-at" },
|
|
|
|
{ WSKBD_TYPE_USB, "usb" },
|
|
|
|
{ WSKBD_TYPE_HPC_KBD, "hpc-kbd" },
|
|
|
|
{ WSKBD_TYPE_HPC_BTN, "hpc-btn" },
|
|
|
|
{ WSKBD_TYPE_ARCHIMEDES, "archimedes" },
|
|
|
|
{ WSKBD_TYPE_RISCPC, "riscpc" },
|
2001-12-04 07:31:56 +03:00
|
|
|
{ WSKBD_TYPE_ADB, "adb" },
|
|
|
|
{ WSKBD_TYPE_HIL, "hil" },
|
2002-01-13 21:16:10 +03:00
|
|
|
{ WSKBD_TYPE_AMIGA, "amiga" },
|
2002-12-10 16:05:09 +03:00
|
|
|
{ WSKBD_TYPE_MAPLE, "maple" },
|
2003-02-01 02:32:21 +03:00
|
|
|
{ WSKBD_TYPE_ATARI, "atari" },
|
2004-01-21 18:39:34 +03:00
|
|
|
{ WSKBD_TYPE_SUN, "sun" },
|
|
|
|
{ WSKBD_TYPE_SUN5, "sun-type5" },
|
1998-12-28 17:01:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct nameint mstype_tab[] = {
|
2001-09-19 16:45:24 +04:00
|
|
|
{ WSMOUSE_TYPE_VSXXX, "dec-tc" },
|
|
|
|
{ WSMOUSE_TYPE_PS2, "ps2" },
|
|
|
|
{ WSMOUSE_TYPE_USB, "usb" },
|
|
|
|
{ WSMOUSE_TYPE_LMS, "logitech-bus" },
|
|
|
|
{ WSMOUSE_TYPE_MMS, "ms-inport" },
|
|
|
|
{ WSMOUSE_TYPE_TPANEL, "touch-panel" },
|
|
|
|
{ WSMOUSE_TYPE_NEXT, "next" },
|
|
|
|
{ WSMOUSE_TYPE_ARCHIMEDES, "archimedes" },
|
2001-12-04 07:31:56 +03:00
|
|
|
{ WSMOUSE_TYPE_HIL, "hil" },
|
2002-01-13 21:16:10 +03:00
|
|
|
{ WSMOUSE_TYPE_AMIGA, "amiga" },
|
2002-02-24 05:01:40 +03:00
|
|
|
{ WSMOUSE_TYPE_MAXINE, "dec-maxine" },
|
2002-12-10 16:05:09 +03:00
|
|
|
{ WSMOUSE_TYPE_MAPLE, "maple" },
|
1998-12-28 17:01:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct nameint dpytype_tab[] = {
|
1998-12-30 16:54:03 +03:00
|
|
|
{ WSDISPLAY_TYPE_UNKNOWN, "unknown" },
|
2000-03-13 13:43:15 +03:00
|
|
|
{ WSDISPLAY_TYPE_PM_MONO, "dec-pm-mono" },
|
|
|
|
{ WSDISPLAY_TYPE_PM_COLOR, "dec-pm-color" },
|
1998-12-28 17:01:16 +03:00
|
|
|
{ WSDISPLAY_TYPE_CFB, "dec-cfb" },
|
2000-03-13 13:43:15 +03:00
|
|
|
{ WSDISPLAY_TYPE_XCFB, "dec-xcfb" },
|
1998-12-28 17:01:16 +03:00
|
|
|
{ WSDISPLAY_TYPE_MFB, "dec-mfb" },
|
|
|
|
{ WSDISPLAY_TYPE_SFB, "dec-sfb" },
|
|
|
|
{ WSDISPLAY_TYPE_ISAVGA, "vga-isa" },
|
|
|
|
{ WSDISPLAY_TYPE_PCIVGA, "vga-pci" },
|
|
|
|
{ WSDISPLAY_TYPE_TGA, "dec-tga-pci" },
|
|
|
|
{ WSDISPLAY_TYPE_SFBP, "dec-sfb+" },
|
|
|
|
{ WSDISPLAY_TYPE_PCIMISC, "generic-pci" },
|
2000-03-13 13:43:15 +03:00
|
|
|
{ WSDISPLAY_TYPE_NEXTMONO, "next-mono" },
|
2001-12-04 12:56:31 +03:00
|
|
|
{ WSDISPLAY_TYPE_PX, "dec-px" },
|
|
|
|
{ WSDISPLAY_TYPE_PXG, "dec-pxg" },
|
|
|
|
{ WSDISPLAY_TYPE_TX, "dec-tx" },
|
2000-03-13 13:43:15 +03:00
|
|
|
{ WSDISPLAY_TYPE_HPCFB, "generic-hpc" },
|
2001-09-19 16:45:24 +04:00
|
|
|
{ WSDISPLAY_TYPE_VIDC, "arm-vidc" },
|
|
|
|
{ WSDISPLAY_TYPE_SPX, "dec-spx" },
|
|
|
|
{ WSDISPLAY_TYPE_GPX, "dec-gpx" },
|
|
|
|
{ WSDISPLAY_TYPE_LCG, "dec-lcg" },
|
|
|
|
{ WSDISPLAY_TYPE_VAX_MONO, "dec-vax-mono" },
|
|
|
|
{ WSDISPLAY_TYPE_SB_P9100, "sparcbook-p9100" },
|
|
|
|
{ WSDISPLAY_TYPE_EGA, "ega" },
|
|
|
|
{ WSDISPLAY_TYPE_DCPVR, "dreamcast-pvr" },
|
2001-12-04 07:31:56 +03:00
|
|
|
{ WSDISPLAY_TYPE_GATOR, "hp-gator" },
|
|
|
|
{ WSDISPLAY_TYPE_TOPCAT, "hp-topcat" },
|
|
|
|
{ WSDISPLAY_TYPE_RENAISSANCE, "hp-renaissance" },
|
|
|
|
{ WSDISPLAY_TYPE_CATSEYE, "hp-catseye" },
|
|
|
|
{ WSDISPLAY_TYPE_DAVINCI, "hp-davinci" },
|
|
|
|
{ WSDISPLAY_TYPE_TIGER, "hp-tiger" },
|
|
|
|
{ WSDISPLAY_TYPE_HYPERION, "hp-hyperion" },
|
2002-01-13 21:16:10 +03:00
|
|
|
{ WSDISPLAY_TYPE_AMIGACC, "amiga-cc" },
|
2004-04-03 02:16:52 +04:00
|
|
|
{ WSDISPLAY_TYPE_SUN24, "sun24" },
|
|
|
|
{ WSDISPLAY_TYPE_NEWPORT, "sgi-newport" },
|
|
|
|
{ WSDISPLAY_TYPE_GR2, "sgi-gr2" },
|
|
|
|
{ WSDISPLAY_TYPE_SUNCG12, "suncg12" },
|
|
|
|
{ WSDISPLAY_TYPE_SUNCG14, "suncg14" },
|
|
|
|
{ WSDISPLAY_TYPE_SUNTCX, "suntcx" },
|
|
|
|
{ WSDISPLAY_TYPE_SUNFFB, "sunffb" },
|
1998-12-28 17:01:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct nameint kbdenc_tab[] = {
|
1999-11-10 19:49:38 +03:00
|
|
|
KB_ENCTAB
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct nameint kbdvar_tab[] = {
|
|
|
|
KB_VARTAB
|
1998-12-28 17:01:16 +03:00
|
|
|
};
|
|
|
|
|
Implement support to dynamically change wscons console and kernel colors.
Two new ioctls are added to the wsdisplay device, named WSDISPLAY_GMSGATTRS
and WSDISPLAY_SMSGATTRS, used to retrieve the actual values and set them,
respectively (the name, if you are wondering, comes from "message attributes").
A new emulop is added to the underlying display driver (only vga, for now)
which sets the new attribute for the whole screen, without having to clear
it. This is optional, which means that this also works with other drivers
that don't have this new operation.
Five new kernel options have been added, although only documented in
i386 kernels (for now):
- WSDISPLAY_CUSTOM_OUTPUT, which enables the ioctls described above to
change the colors dynamically from userland. This is enabled by default
in the GENERIC kernel (as well as others) but disabled on all INSTALL*
kernels (as this feature is useless there).
- WS_DEFAULT_COLATTR, WS_DEFAULT_MONOATTR, WS_DEFAULT_BG and WS_DEFAULT_FG,
which specify the default colors for the console at boot time. These have
the same meaning as the (already existing) WS_KERNEL_* variables.
wsconsctl is modified to add msg.default.{attrs,bg,fg} and
msg.kernel.{attrs,bg,fg} to the display part, so that colors can be changed
after boot.
Tested on NetBSD/i386 with vga (and vga in mono mode), and on NetBSD/mac68k.
No objections in tech-kern@.
2004-07-28 16:34:02 +04:00
|
|
|
static struct nameint color_tab[] = {
|
|
|
|
{ WSCOL_UNSUPPORTED, "unsupported" },
|
|
|
|
{ WSCOL_BLACK, "black" },
|
|
|
|
{ WSCOL_RED, "red" },
|
|
|
|
{ WSCOL_GREEN, "green" },
|
|
|
|
{ WSCOL_BROWN, "brown" },
|
|
|
|
{ WSCOL_BLUE, "blue" },
|
|
|
|
{ WSCOL_MAGENTA, "magenta" },
|
|
|
|
{ WSCOL_CYAN, "cyan" },
|
|
|
|
{ WSCOL_WHITE, "white" },
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct nameint attr_tab[] = {
|
|
|
|
{ WSATTR_NONE, "none" },
|
|
|
|
{ WSATTR_REVERSE, "reverse" },
|
|
|
|
{ WSATTR_HILIT, "hilit" },
|
|
|
|
{ WSATTR_BLINK, "blink" },
|
|
|
|
{ WSATTR_UNDERLINE, "underline" },
|
|
|
|
{ WSATTR_WSCOLORS, "color" },
|
|
|
|
};
|
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
static struct field *field_tab;
|
|
|
|
static int field_tab_len;
|
|
|
|
|
|
|
|
static char *int2name __P((int, int, struct nameint *, int));
|
|
|
|
static int name2int __P((char *, struct nameint *, int));
|
|
|
|
static void print_kmap __P((struct wskbd_map_data *));
|
|
|
|
|
|
|
|
void
|
|
|
|
field_setup(ftab, len)
|
|
|
|
struct field *ftab;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
field_tab = ftab;
|
|
|
|
field_tab_len = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct field *
|
|
|
|
field_by_name(name)
|
|
|
|
char *name;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < field_tab_len; i++)
|
|
|
|
if (strcmp(field_tab[i].name, name) == 0)
|
|
|
|
return(field_tab + i);
|
|
|
|
|
|
|
|
errx(1, "%s: not found", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct field *
|
|
|
|
field_by_value(addr)
|
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < field_tab_len; i++)
|
|
|
|
if (field_tab[i].valp == addr)
|
|
|
|
return(field_tab + i);
|
|
|
|
|
|
|
|
errx(1, "internal error: field_by_value: not found");
|
|
|
|
}
|
|
|
|
|
2004-07-30 15:08:03 +04:00
|
|
|
void
|
|
|
|
field_disable_by_value(addr)
|
|
|
|
void *addr;
|
|
|
|
{
|
|
|
|
struct field *f;
|
|
|
|
|
|
|
|
f = field_by_value(addr);
|
|
|
|
f->flags |= FLG_DISABLED;
|
|
|
|
}
|
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
static char *
|
|
|
|
int2name(val, uflag, tab, len)
|
|
|
|
int val;
|
|
|
|
int uflag;
|
|
|
|
struct nameint *tab;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
static char tmp[20];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
if (tab[i].value == val)
|
|
|
|
return(tab[i].name);
|
|
|
|
|
|
|
|
if (uflag) {
|
|
|
|
snprintf(tmp, sizeof(tmp), "unknown_%d", val);
|
|
|
|
return(tmp);
|
|
|
|
} else
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
name2int(val, tab, len)
|
|
|
|
char *val;
|
|
|
|
struct nameint *tab;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
if (strcmp(tab[i].name, val) == 0)
|
|
|
|
return(tab[i].value);
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pr_field(f, sep)
|
|
|
|
struct field *f;
|
|
|
|
char *sep;
|
|
|
|
{
|
|
|
|
char *p;
|
1999-11-10 19:49:38 +03:00
|
|
|
u_int flags;
|
Implement support to dynamically change wscons console and kernel colors.
Two new ioctls are added to the wsdisplay device, named WSDISPLAY_GMSGATTRS
and WSDISPLAY_SMSGATTRS, used to retrieve the actual values and set them,
respectively (the name, if you are wondering, comes from "message attributes").
A new emulop is added to the underlying display driver (only vga, for now)
which sets the new attribute for the whole screen, without having to clear
it. This is optional, which means that this also works with other drivers
that don't have this new operation.
Five new kernel options have been added, although only documented in
i386 kernels (for now):
- WSDISPLAY_CUSTOM_OUTPUT, which enables the ioctls described above to
change the colors dynamically from userland. This is enabled by default
in the GENERIC kernel (as well as others) but disabled on all INSTALL*
kernels (as this feature is useless there).
- WS_DEFAULT_COLATTR, WS_DEFAULT_MONOATTR, WS_DEFAULT_BG and WS_DEFAULT_FG,
which specify the default colors for the console at boot time. These have
the same meaning as the (already existing) WS_KERNEL_* variables.
wsconsctl is modified to add msg.default.{attrs,bg,fg} and
msg.kernel.{attrs,bg,fg} to the display part, so that colors can be changed
after boot.
Tested on NetBSD/i386 with vga (and vga in mono mode), and on NetBSD/mac68k.
No objections in tech-kern@.
2004-07-28 16:34:02 +04:00
|
|
|
int first, i, mask;
|
1998-12-28 17:01:16 +03:00
|
|
|
|
|
|
|
if (sep)
|
|
|
|
printf("%s%s", f->name, sep);
|
|
|
|
|
|
|
|
switch (f->format) {
|
|
|
|
case FMT_UINT:
|
|
|
|
printf("%u", *((u_int *) f->valp));
|
|
|
|
break;
|
2002-04-07 14:40:04 +04:00
|
|
|
case FMT_STRING:
|
|
|
|
printf("\"%s\"", *((char **) f->valp));
|
|
|
|
break;
|
1998-12-28 17:01:16 +03:00
|
|
|
case FMT_KBDTYPE:
|
|
|
|
p = int2name(*((u_int *) f->valp), 1,
|
|
|
|
kbtype_tab, TABLEN(kbtype_tab));
|
|
|
|
printf("%s", p);
|
|
|
|
break;
|
|
|
|
case FMT_MSTYPE:
|
|
|
|
p = int2name(*((u_int *) f->valp), 1,
|
|
|
|
mstype_tab, TABLEN(mstype_tab));
|
|
|
|
printf("%s", p);
|
|
|
|
break;
|
|
|
|
case FMT_DPYTYPE:
|
|
|
|
p = int2name(*((u_int *) f->valp), 1,
|
|
|
|
dpytype_tab, TABLEN(dpytype_tab));
|
|
|
|
printf("%s", p);
|
|
|
|
break;
|
|
|
|
case FMT_KBDENC:
|
|
|
|
p = int2name(KB_ENCODING(*((u_int *) f->valp)), 1,
|
|
|
|
kbdenc_tab, TABLEN(kbdenc_tab));
|
|
|
|
printf("%s", p);
|
|
|
|
|
1999-11-10 19:49:38 +03:00
|
|
|
flags = KB_VARIANT(*((u_int *) f->valp));
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
if (!(flags & (1 << i)))
|
|
|
|
continue;
|
|
|
|
p = int2name(flags & (1 << i), 1,
|
|
|
|
kbdvar_tab, TABLEN(kbdvar_tab));
|
1998-12-28 17:01:16 +03:00
|
|
|
printf(".%s", p);
|
1999-11-10 19:49:38 +03:00
|
|
|
}
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
|
|
|
case FMT_KBMAP:
|
|
|
|
print_kmap((struct wskbd_map_data *) f->valp);
|
|
|
|
break;
|
Implement support to dynamically change wscons console and kernel colors.
Two new ioctls are added to the wsdisplay device, named WSDISPLAY_GMSGATTRS
and WSDISPLAY_SMSGATTRS, used to retrieve the actual values and set them,
respectively (the name, if you are wondering, comes from "message attributes").
A new emulop is added to the underlying display driver (only vga, for now)
which sets the new attribute for the whole screen, without having to clear
it. This is optional, which means that this also works with other drivers
that don't have this new operation.
Five new kernel options have been added, although only documented in
i386 kernels (for now):
- WSDISPLAY_CUSTOM_OUTPUT, which enables the ioctls described above to
change the colors dynamically from userland. This is enabled by default
in the GENERIC kernel (as well as others) but disabled on all INSTALL*
kernels (as this feature is useless there).
- WS_DEFAULT_COLATTR, WS_DEFAULT_MONOATTR, WS_DEFAULT_BG and WS_DEFAULT_FG,
which specify the default colors for the console at boot time. These have
the same meaning as the (already existing) WS_KERNEL_* variables.
wsconsctl is modified to add msg.default.{attrs,bg,fg} and
msg.kernel.{attrs,bg,fg} to the display part, so that colors can be changed
after boot.
Tested on NetBSD/i386 with vga (and vga in mono mode), and on NetBSD/mac68k.
No objections in tech-kern@.
2004-07-28 16:34:02 +04:00
|
|
|
case FMT_COLOR:
|
|
|
|
p = int2name(*((u_int *) f->valp), 1,
|
|
|
|
color_tab, TABLEN(color_tab));
|
|
|
|
printf("%s", p);
|
|
|
|
break;
|
|
|
|
case FMT_ATTRS:
|
|
|
|
mask = 0x10;
|
|
|
|
first = 1;
|
|
|
|
while (mask > 0) {
|
|
|
|
if (*((u_int *) f->valp) & mask) {
|
|
|
|
p = int2name(*((u_int *) f->valp) & mask, 1,
|
|
|
|
attr_tab, TABLEN(attr_tab));
|
|
|
|
printf("%s%s", first ? "" : ",", p);
|
|
|
|
first = 0;
|
|
|
|
}
|
|
|
|
mask >>= 1;
|
|
|
|
}
|
|
|
|
if (first)
|
|
|
|
printf("none");
|
|
|
|
break;
|
1998-12-28 17:01:16 +03:00
|
|
|
default:
|
|
|
|
errx(1, "internal error: pr_field: no format %d", f->format);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rd_field(f, val, merge)
|
|
|
|
struct field *f;
|
|
|
|
char *val;
|
|
|
|
int merge;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u_int u;
|
|
|
|
char *p;
|
|
|
|
struct wscons_keymap *mp;
|
|
|
|
|
|
|
|
switch (f->format) {
|
|
|
|
case FMT_UINT:
|
|
|
|
if (sscanf(val, "%u", &u) != 1)
|
|
|
|
errx(1, "%s: not a number", val);
|
|
|
|
if (merge)
|
|
|
|
*((u_int *) f->valp) += u;
|
|
|
|
else
|
|
|
|
*((u_int *) f->valp) = u;
|
|
|
|
break;
|
2002-04-07 14:40:04 +04:00
|
|
|
case FMT_STRING:
|
|
|
|
if ((*((char **) f->valp) = strdup(val)) == NULL)
|
|
|
|
err(1, "strdup");
|
|
|
|
break;
|
1998-12-28 17:01:16 +03:00
|
|
|
case FMT_KBDENC:
|
|
|
|
p = strchr(val, '.');
|
|
|
|
if (p != NULL)
|
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
i = name2int(val, kbdenc_tab, TABLEN(kbdenc_tab));
|
|
|
|
if (i == -1)
|
|
|
|
errx(1, "%s: not a valid encoding", val);
|
|
|
|
*((u_int *) f->valp) = i;
|
|
|
|
|
1999-11-10 19:49:38 +03:00
|
|
|
while (p) {
|
|
|
|
val = p;
|
|
|
|
p = strchr(p, '.');
|
|
|
|
if (p != NULL)
|
|
|
|
*p++ = '\0';
|
|
|
|
i = name2int(val, kbdvar_tab, TABLEN(kbdvar_tab));
|
|
|
|
if (i == -1)
|
|
|
|
errx(1, "%s: not a valid variant", val);
|
|
|
|
*((u_int *) f->valp) |= i;
|
|
|
|
}
|
1998-12-28 17:01:16 +03:00
|
|
|
break;
|
|
|
|
case FMT_KBMAP:
|
|
|
|
if (! merge)
|
|
|
|
kbmap.maplen = 0;
|
|
|
|
map_scan_setinput(val);
|
|
|
|
yyparse();
|
|
|
|
if (merge) {
|
|
|
|
if (newkbmap.maplen < kbmap.maplen)
|
|
|
|
newkbmap.maplen = kbmap.maplen;
|
|
|
|
for (i = 0; i < kbmap.maplen; i++) {
|
|
|
|
mp = newkbmap.map + i;
|
|
|
|
if (mp->command == KS_voidSymbol &&
|
|
|
|
mp->group1[0] == KS_voidSymbol &&
|
|
|
|
mp->group1[1] == KS_voidSymbol &&
|
|
|
|
mp->group2[0] == KS_voidSymbol &&
|
|
|
|
mp->group2[1] == KS_voidSymbol)
|
|
|
|
*mp = kbmap.map[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
kbmap.maplen = newkbmap.maplen;
|
|
|
|
bcopy(newkbmap.map, kbmap.map,
|
|
|
|
kbmap.maplen*sizeof(struct wscons_keymap));
|
|
|
|
break;
|
Implement support to dynamically change wscons console and kernel colors.
Two new ioctls are added to the wsdisplay device, named WSDISPLAY_GMSGATTRS
and WSDISPLAY_SMSGATTRS, used to retrieve the actual values and set them,
respectively (the name, if you are wondering, comes from "message attributes").
A new emulop is added to the underlying display driver (only vga, for now)
which sets the new attribute for the whole screen, without having to clear
it. This is optional, which means that this also works with other drivers
that don't have this new operation.
Five new kernel options have been added, although only documented in
i386 kernels (for now):
- WSDISPLAY_CUSTOM_OUTPUT, which enables the ioctls described above to
change the colors dynamically from userland. This is enabled by default
in the GENERIC kernel (as well as others) but disabled on all INSTALL*
kernels (as this feature is useless there).
- WS_DEFAULT_COLATTR, WS_DEFAULT_MONOATTR, WS_DEFAULT_BG and WS_DEFAULT_FG,
which specify the default colors for the console at boot time. These have
the same meaning as the (already existing) WS_KERNEL_* variables.
wsconsctl is modified to add msg.default.{attrs,bg,fg} and
msg.kernel.{attrs,bg,fg} to the display part, so that colors can be changed
after boot.
Tested on NetBSD/i386 with vga (and vga in mono mode), and on NetBSD/mac68k.
No objections in tech-kern@.
2004-07-28 16:34:02 +04:00
|
|
|
case FMT_COLOR:
|
|
|
|
i = name2int(val, color_tab, TABLEN(color_tab));
|
|
|
|
if (i == -1)
|
|
|
|
errx(1, "%s: not a valid color", val);
|
|
|
|
*((u_int *) f->valp) = i;
|
|
|
|
break;
|
|
|
|
case FMT_ATTRS:
|
|
|
|
p = val;
|
|
|
|
while (p) {
|
|
|
|
val = p;
|
|
|
|
p = strchr(p, ',');
|
|
|
|
if (p != NULL)
|
|
|
|
*p++ = '\0';
|
|
|
|
i = name2int(val, attr_tab, TABLEN(attr_tab));
|
|
|
|
if (i == -1)
|
|
|
|
errx(1, "%s: not a valid attribute", val);
|
|
|
|
*((u_int *) f->valp) |= i;
|
|
|
|
}
|
|
|
|
break;
|
1998-12-28 17:01:16 +03:00
|
|
|
default:
|
|
|
|
errx(1, "internal error: rd_field: no format %d", f->format);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_kmap(map)
|
|
|
|
struct wskbd_map_data *map;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct wscons_keymap *mp;
|
|
|
|
|
|
|
|
for (i = 0; i < map->maplen; i++) {
|
|
|
|
mp = map->map + i;
|
|
|
|
|
|
|
|
if (mp->command == KS_voidSymbol &&
|
|
|
|
mp->group1[0] == KS_voidSymbol &&
|
|
|
|
mp->group1[1] == KS_voidSymbol &&
|
|
|
|
mp->group2[0] == KS_voidSymbol &&
|
|
|
|
mp->group2[1] == KS_voidSymbol)
|
|
|
|
continue;
|
|
|
|
printf("\n");
|
|
|
|
printf("keycode %u =", i);
|
|
|
|
if (mp->command != KS_voidSymbol)
|
|
|
|
printf(" %s", ksym2name(mp->command));
|
|
|
|
printf(" %s", ksym2name(mp->group1[0]));
|
|
|
|
if (mp->group1[0] != mp->group1[1] ||
|
|
|
|
mp->group1[0] != mp->group2[0] ||
|
|
|
|
mp->group1[0] != mp->group2[1]) {
|
|
|
|
printf(" %s", ksym2name(mp->group1[1]));
|
|
|
|
if (mp->group1[0] != mp->group2[0] ||
|
|
|
|
mp->group1[1] != mp->group2[1]) {
|
|
|
|
printf(" %s", ksym2name(mp->group2[0]));
|
|
|
|
printf(" %s", ksym2name(mp->group2[1]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|