- When kbdMapChar() was modified to support returning multi-character

mappings, it broke Ctrl-Space; fix that.
- Clean up lk201.c a little.
This commit is contained in:
ad 1999-11-29 15:02:38 +00:00
parent a24fb44ddf
commit 0daccde651
5 changed files with 111 additions and 131 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dc.c,v 1.51 1999/11/19 02:17:01 simonb Exp $ */
/* $NetBSD: dc.c,v 1.52 1999/11/29 15:02:38 ad Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: dc.c,v 1.51 1999/11/19 02:17:01 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: dc.c,v 1.52 1999/11/29 15:02:38 ad Exp $");
/*
* devDC7085.c --
@ -753,7 +753,10 @@ dcrint(sc)
int c, cc;
int overrun = 0;
struct tty **dc_tty;
#if NRASTERCONSOLE > 0
char *cp;
int cl;
#endif
dc_tty = ((struct dc_softc*)dc_cd.cd_devs[0])->dc_tty; /* XXX */
@ -786,9 +789,9 @@ dcrint(sc)
return;
}
#if NRASTERCONSOLE > 0
if ((cp = kbdMapChar(cc)) == NULL)
if ((cp = kbdMapChar(cc, &cl)) == NULL)
return;
while (*cp)
while (cl--)
rcons_input(0, *cp++);
#endif
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dtop.c,v 1.40 1999/11/13 22:56:56 mhitch Exp $ */
/* $NetBSD: dtop.c,v 1.41 1999/11/29 15:02:38 ad Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -94,7 +94,7 @@ SOFTWARE.
********************************************************/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: dtop.c,v 1.40 1999/11/13 22:56:56 mhitch Exp $");
__KERNEL_RCSID(0, "$NetBSD: dtop.c,v 1.41 1999/11/29 15:02:38 ad Exp $");
#include "rasterconsole.h"
@ -826,7 +826,7 @@ dtop_keyboard_handler(dev, msg, event, outc)
{
u_char *ls, *le, *ns, *ne;
u_char save[11], retc;
int msg_len, c, s;
int msg_len, c, s, cl;
char *cp;
#ifdef RCONS_BRAINDAMAGE
struct tty *tp = DTOP_TTY(0);
@ -905,7 +905,7 @@ dtop_keyboard_handler(dev, msg, event, outc)
ls = &dev->keyboard.last_codes[dev->keyboard.last_codes_count - 1];
for ( ; ls >= le; ls--)
if ((c = *ls) != 0) {
(void) kbdMapChar(c);
(void) kbdMapChar(c, &cl);
if (outc == 0 && dtopDivertXInput &&
(keymodes[(c >> 5) & 0x7] & (1 << (c & 0x1f))))
@ -919,7 +919,7 @@ dtop_keyboard_handler(dev, msg, event, outc)
retc = 0;
for ( ; ns >= ne; ns--)
if (*ns) {
cp = kbdMapChar(*ns);
cp = kbdMapChar(*ns, &cl);
#ifdef DDB
if (*ns == LK_DO) {
spl0();
@ -931,7 +931,7 @@ dtop_keyboard_handler(dev, msg, event, outc)
(*dtopDivertXInput)(*ns);
c = -1; /* consumed by X */
} else if (cp /*&& tp != NULL*/) {
for (; *cp; cp++) {
for (; cl; cl--, cp++) {
#if 0
(*linesw[tp->t_line].l_rint)(*cp, tp);
#else
@ -968,9 +968,8 @@ dtop_keyboard_repeat(arg)
void *arg;
{
dtop_device_t dev = (dtop_device_t)arg;
int i, c;
int i, c, cl;
char *cp;
#if 0
struct tty *tp = DTOP_TTY(0);
#endif
@ -987,8 +986,8 @@ dtop_keyboard_repeat(arg)
continue;
}
if ((cp = kbdMapChar(KEY_REPEAT)) != NULL) {
for (; *cp; cp++) {
if ((cp = kbdMapChar(KEY_REPEAT, &cl)) != NULL) {
for (; cl; cl--, cp++) {
#if 0
(*linesw[tp->t_line].l_rint)(*cp, tp);
#else

View File

@ -1,11 +1,10 @@
/* $NetBSD: lk201.c,v 1.14 1999/04/24 08:01:04 simonb Exp $ */
/* $NetBSD: lk201.c,v 1.15 1999/11/29 15:02:38 ad Exp $ */
/*
* The LK201 keycode mapping routine is here, along with initialization
* functions for the keyboard and mouse.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/syslog.h>
@ -17,16 +16,10 @@
#include <dev/dec/lk201.h>
#include <pmax/dev/lk201var.h>
/* Exported functions */
extern char *kbdMapChar __P((int keycode));
extern void KBDReset __P(( dev_t dev, void (*putc) (dev_t, int) ));
/*
* Keyboard to Ascii, unshifted.
* Keyboard to ASCII, unshifted.
*/
static unsigned char unshiftedAscii[] = {
static u_char unshiftedAscii[] = {
/* 0 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
/* 4 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
/* 8 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
@ -96,7 +89,7 @@ static unsigned char unshiftedAscii[] = {
/*
* Keyboard to Ascii, shifted.
*/
static unsigned char shiftedAscii[] = {
static u_char shiftedAscii[] = {
/* 0 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
/* 4 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
/* 8 */ KBD_NOKEY, KBD_NOKEY, KBD_NOKEY, KBD_NOKEY,
@ -192,59 +185,64 @@ static u_char kbdInitString[] = {
LK_LED_DISABLE, LED_ALL, /* clear keyboard leds */
};
/*
* Keyboard to what the rcons termcap entry expects.
* Keyboard to what the rcons termcap entry expects for long codes.
* XXX function keys are handled specially.
*/
static struct toString {
struct {
int ts_keycode;
int ts_len;
char *ts_string;
} toString[] = { /* termcap name */
{ KBD_UP, "\033[A" }, /* ku */
{ KBD_DOWN, "\033[B" }, /* kd */
{ KBD_RIGHT, "\033[C" }, /* kr */
{ KBD_LEFT, "\033[D" }, /* kl */
{ KBD_REMOVE, "\177" }, /* kD */
{ KBD_NEXT, "\033[222z" }, /* kN */
{ KBD_PREVIOUS, "\033[216z" }, /* kP */
} static toString[] = { /* termcap name */
{ KBD_UP, 3, "\033[A" }, /* ku */
{ KBD_DOWN, 3, "\033[B" }, /* kd */
{ KBD_RIGHT, 3, "\033[C" }, /* kr */
{ KBD_LEFT, 3, "\033[D" }, /* kl */
{ KBD_REMOVE, 1, "\177" }, /* kD */
{ KBD_NEXT, 6, "\033[222z" }, /* kN */
{ KBD_PREVIOUS, 6, "\033[216z" }, /* kP */
};
#define NUM_TOSTRING (sizeof(toString) / sizeof(toString[0]))
static void (*raw_kbd_putc) __P((dev_t dev, int c)) = NULL;
static dev_t lk_out_dev = NODEV;
static void (*raw_kbd_putc) __P((dev_t dev, int c)) = NULL;
static int (*raw_kbd_getc) __P((dev_t dev)) = NULL;
static dev_t lk_out_dev = NODEV;
static dev_t lk_in_dev = NODEV;
/*
* Initialize the Keyboard.
* Initialize the keyboard.
*/
void
KBDReset(kbddev, putc)
dev_t kbddev;
void (*putc) __P((dev_t, int));
{
int i;
static int inKBDReset;
int i;
if (inKBDReset)
return;
inKBDReset = 1;
/* XXX no way to disable keyclick from userspace */
for (i = 0; i < sizeof(kbdInitString); i++) {
(*putc)(kbddev, (int)kbdInitString[i]);
DELAY(20000);
}
inKBDReset = 0;
raw_kbd_putc = putc;
lk_out_dev = kbddev;
}
/*
* Sound the keyboard bell.
*/
void
lk_bell(ring)
int ring;
{
if ((!ring) || (lk_out_dev == NODEV) || (raw_kbd_putc == NULL))
return;
(*raw_kbd_putc)(lk_out_dev, LK_RING_BELL);
@ -252,47 +250,37 @@ lk_bell(ring)
}
/*
* ----------------------------------------------------------------------------
*
* kbdMapChar --
*
* Map characters from the keyboard to ASCII. Return NULL if there is
* no valid mapping.
*
* Results:
* None.
*
* Side effects:
* Remember state of shift, control and caps-lock keys.
*
* ----------------------------------------------------------------------------
* Map characters from the keyboard to ASCII. Return NULL if there is
* no valid mapping. Return length of mapped ASCII in *len - returned
* string is not NUL terminated, as NUL is a valid code.
*/
char *
kbdMapChar(cc)
int cc;
kbdMapChar(cc, len)
int cc, *len;
{
static u_char shiftDown;
static u_char ctrlDown;
static u_char capsLock;
static char buf[8];
static char *lastStr;
char *cp = NULL;
static u_char shiftDown, ctrlDown, capsLock;
static char buf[8], *lastStr;
static int lastLen;
char *cp;
int i;
cp = NULL;
switch (cc) {
case KEY_REPEAT:
cp = lastStr;
goto done;
*len = lastLen;
return (lastStr);
case KEY_UP:
shiftDown = 0;
ctrlDown = 0;
*len = 0;
return (NULL);
case KEY_CAPSLOCK:
capsLock ^= 1;
#if 0
/* XXX causes lockup due to spl??? */
/* XXX may interact badly with Xserver */
/* XXX causes a lockup - why? */
if (capsLock)
(*raw_kbd_putc)(lk_out_dev, LK_LED_ENABLE);
else
@ -300,43 +288,40 @@ kbdMapChar(cc)
(*raw_kbd_putc)(lk_out_dev, LED_1);
#endif
*len = 0;
return (NULL);
case KEY_SHIFT:
case KEY_R_SHIFT:
shiftDown ^= 1;
*len = 0;
return (NULL);
case KEY_CONTROL:
ctrlDown ^= 1;
*len = 0;
return (NULL);
case LK_POWER_ERROR:
case LK_KDOWN_ERROR:
case LK_INPUT_ERROR:
case LK_OUTPUT_ERROR:
log(LOG_WARNING,
"lk201: keyboard error, code=%x\n", cc);
log(LOG_WARNING, "lk201: keyboard error, code=%x\n", cc);
*len = 0;
return (NULL);
}
if (shiftDown)
cc = shiftedAscii[cc];
else
cc = unshiftedAscii[cc];
cc = (shiftDown ? shiftedAscii[cc] : unshiftedAscii[cc]);
/* Map keypad 'Enter' key to return */
if (cc == KBD_KP_ENTER)
cc = KBD_RET;
else if (cc >= KBD_NOKEY) {
int i;
/* XXX slow, although keyboard interrupts aren't frequent */
/* Check for keys that have multi-character codes */
for (i = 0; i < NUM_TOSTRING; i++)
if (toString[i].ts_keycode == cc) {
cp = toString[i].ts_string;
*len = toString[i].ts_len;
break;
}
@ -350,8 +335,9 @@ kbdMapChar(cc)
* except for the 'Help' and 'Do' keys, which we
* return as F15 and F16 since that's what they
* really are.
* XXX termcap can only handle F0->F9. Is this right?
* XXX 'Do' is used for dropping into ddb.
*
* XXX termcap can only handle F0->F9?
* XXX 'Do' is used for dropping into ddb on pmax.
*/
if (cc >= KBD_F1 && cc <= KBD_F6) {
buf[3] = '2';
@ -367,11 +353,10 @@ kbdMapChar(cc)
buf[0] = '\033';
buf[1] = '[';
buf[2] = '2';
buf[5] = '\0';
cp = buf;
*len = 5;
}
}
else if (cc >= 'a' && cc <= 'z') {
} else if (cc >= 'a' && cc <= 'z') {
if (ctrlDown)
cc = cc - 'a' + '\1'; /* ^A */
else if (shiftDown ^ capsLock)
@ -385,78 +370,66 @@ kbdMapChar(cc)
if (cp == NULL) {
buf[0] = cc;
buf[1] = '\0';
cp = buf;
*len = 1;
}
lastStr = cp;
done:
lastLen = *len;
return (cp);
}
static int (*raw_kbd_getc) __P((dev_t dev)) = NULL;
static dev_t lk_in_dev = NODEV;
/*
* Divert input from a serial port to the lk-201 keyboard handler.
*/
void
lk_divert(getfn, in_dev)
int (*getfn) __P ((dev_t dev)) ;
int (*getfn) __P ((dev_t dev));
dev_t in_dev;
{
raw_kbd_getc = getfn;
lk_in_dev = in_dev;
}
/*
* Get an ASCII character off of the keyboard.
* Simply pass the getc request onto the underlying
* serial driver, and map the resulting LK-201 keycode to ASCII.
* FIXME: this design should be thrown away and replaced with a stackable
* "Bstreams"-style driver.
* Get an ASCII character off of the keyboard; simply pass the getc request
* onto the underlying serial driver, and map the resulting LK-201 keycode to
* ASCII.
*/
int
LKgetc(dev)
dev_t dev; /* ignored */
{
int c;
static char *cp;
static int len;
int c;
#if 0
/*XXX*/ printf("LK-201 getc 0x%x( [%d %d]) in_dev [%d %d]\n",
raw_kbd_getc,
major(dev), minor(dev),
major(lk_in_dev), minor(lk_in_dev));
#endif
#ifdef DIAGNOSTIC
if (raw_kbd_getc == NULL) {
panic("Reading from LK-201 before keyboard driver diverted\n");
panic("Reading from LK-201 before kbd driver diverted\n");
return (-1);
}
#endif
for (;;) {
if (cp) {
c = *(unsigned char *)cp++;
if (*cp == '\0')
cp = NULL;
if (len != 0) {
c = *(u_char *)cp++;
len--;
break;
}
/* c = (*cn_tab.cn_kbdgetc)(cn_tab.cn_dev); */
c = (*raw_kbd_getc) (lk_in_dev);
#if 0
/*XXX*/ printf(" 0x%x [%c]", c, c);
#endif
if (c == 0)
return (-1);
cp = kbdMapChar(c & 0xff);
cp = kbdMapChar(c & 0xff, &len);
}
return (c);
}
/*
* Initialize the mouse. (Doesn't really belong here.)
*/
@ -478,22 +451,26 @@ MouseInit(mdev, putc, getc)
return;
}
if (id_byte1 < 0) {
printf("MouseInit: Timeout on %s byte of self-test report\n", "1st");
printf("MouseInit: Timeout on %s byte of self-test report\n",
"1st");
return;
}
id_byte2 = (*getc)(mdev);
if (id_byte2 < 0) {
printf("MouseInit: Timeout on %s byte of self-test report\n", "2nd");
printf("MouseInit: Timeout on %s byte of self-test report\n",
"2nd");
return;
}
id_byte3 = (*getc)(mdev);
if (id_byte3 < 0) {
printf("MouseInit: Timeout on %s byte of self-test report\n", "3rd");
printf("MouseInit: Timeout on %s byte of self-test report\n",
"3rd");
return;
}
id_byte4 = (*getc)(mdev);
if (id_byte4 < 0) {
printf("MouseInit: Timeout on %s byte of self-test report\n", "4th");
printf("MouseInit: Timeout on %s byte of self-test report\n",
"4th");
return;
}
if ((id_byte2 & 0x0f) != 0x2)

View File

@ -1,18 +1,18 @@
/* $NetBSD: lk201var.h,v 1.4 1999/03/22 03:25:29 ad Exp $ */
/* $NetBSD: lk201var.h,v 1.5 1999/11/29 15:02:38 ad Exp $ */
#ifndef _LK201VAR_H_
#define _LK201VAR_H_
#ifdef _KERNEL
extern char *kbdMapChar __P((int));
extern void KBDReset __P((dev_t, void (*)(dev_t, int)));
extern void MouseInit __P((dev_t, void (*)(dev_t, int), int (*)(dev_t)));
extern void mouseInput __P((int cc));
char *kbdMapChar __P((int, int *));
void KBDReset __P((dev_t, void (*)(dev_t, int)));
void MouseInit __P((dev_t, void (*)(dev_t, int), int (*)(dev_t)));
void mouseInput __P((int cc));
int LKgetc __P((dev_t dev));
void lk_divert __P((int (*getfn) __P ((dev_t dev)), dev_t in_dev));
void lk_bell __P ((int ring));
extern int LKgetc __P((dev_t dev));
extern void lk_divert __P((int (*getfn) __P ((dev_t dev)), dev_t in_dev));
extern void lk_bell __P ((int ring));
#endif
#endif /* _LK201VAR_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: scc.c,v 1.52 1999/09/17 20:04:50 thorpej Exp $ */
/* $NetBSD: scc.c,v 1.53 1999/11/29 15:02:39 ad Exp $ */
/*
* Copyright (c) 1991,1990,1989,1994,1995,1996 Carnegie Mellon University
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: scc.c,v 1.52 1999/09/17 20:04:50 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: scc.c,v 1.53 1999/11/29 15:02:39 ad Exp $");
#include "opt_ddb.h"
@ -1140,6 +1140,7 @@ scc_rxintr(sc, chan, regs, unit)
int cc, rr1 = 0, rr2 = 0; /* XXX */
#ifdef HAVE_RCONS
char *cp;
int cl;
#endif
SCC_READ_DATA(regs, chan, cc);
@ -1172,10 +1173,10 @@ scc_rxintr(sc, chan, regs, unit)
return;
}
#ifdef HAVE_RCONS
if ((cp = kbdMapChar(cc)) == NULL)
if ((cp = kbdMapChar(cc, &cl)) == NULL)
return;
while (*cp)
while (cl--)
rcons_input(0, *cp++);
#endif
/*