1999-06-06 23:10:49 +04:00
|
|
|
/* $NetBSD: lkc.c,v 1.11 1999/06/06 19:10:49 ragge Exp $ */
|
1998-06-04 19:51:12 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1998 Ludd, University of Lule}, Sweden.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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 at Ludd, University of
|
|
|
|
* Lule}, Sweden and its contributors.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
|
|
*/
|
|
|
|
|
1998-07-05 02:18:13 +04:00
|
|
|
#include "opt_ddb.h"
|
1998-06-04 19:51:12 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
1998-06-20 22:42:50 +04:00
|
|
|
#include <dev/wscons/wsksymvar.h>
|
1998-06-04 19:51:12 +04:00
|
|
|
#include <dev/wscons/wscons_callbacks.h>
|
|
|
|
|
|
|
|
#include <dev/dec/lk201.h>
|
|
|
|
|
|
|
|
#include <machine/vsbus.h>
|
|
|
|
|
1999-06-06 23:10:49 +04:00
|
|
|
#include <dev/qbus/dzreg.h>
|
|
|
|
#include <dev/qbus/dzvar.h>
|
1998-06-04 19:51:12 +04:00
|
|
|
|
|
|
|
#include "ioconf.h"
|
|
|
|
|
|
|
|
static int lkc_match __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void lkc_attach __P((struct device *, struct device *, void *));
|
|
|
|
static int lkc_catch __P((int, int));
|
1998-06-08 00:19:12 +04:00
|
|
|
int lkc_decode __P((int));
|
1998-06-04 19:51:12 +04:00
|
|
|
|
|
|
|
struct lkc_softc {
|
|
|
|
struct device ls_dev;
|
|
|
|
int ls_shifted; /* Shift key pressed */
|
|
|
|
int ls_ctrl; /* Ctrl key pressed */
|
|
|
|
int ls_lastchar; /* last key pressed (for repeat) */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfattach lkc_ca = {
|
|
|
|
sizeof(struct lkc_softc), lkc_match, lkc_attach,
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
lkc_match(parent, cf, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
lkc_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct dz_softc *dz = (void *)parent;
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
dz->sc_catch = lkc_catch; /* Catch keyb & mouse chars fast */
|
1999-06-06 23:10:49 +04:00
|
|
|
bus_space_write_2(dz->sc_iot, dz->sc_ioh, 4, 0x1c18);
|
1998-06-04 19:51:12 +04:00
|
|
|
}
|
|
|
|
|
1999-04-29 20:58:58 +04:00
|
|
|
extern char *q_special[];
|
|
|
|
|
1998-06-04 19:51:12 +04:00
|
|
|
int
|
|
|
|
lkc_catch(line, ch)
|
|
|
|
int line, ch;
|
|
|
|
{
|
1999-04-29 20:58:58 +04:00
|
|
|
int hej, i;
|
|
|
|
char *cp;
|
1998-06-04 19:51:12 +04:00
|
|
|
|
1998-08-10 18:47:16 +04:00
|
|
|
if (line > 0)
|
1998-06-04 19:51:12 +04:00
|
|
|
return 0;
|
|
|
|
|
1998-06-08 00:19:12 +04:00
|
|
|
if ((hej = lkc_decode(ch)) == -1)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (hej > 255) {
|
1998-06-08 19:04:26 +04:00
|
|
|
cp = q_special[hej & 255];
|
1999-04-29 20:58:58 +04:00
|
|
|
for (i = 0; i < strlen(cp); i++)
|
|
|
|
wsdisplay_kbdinput(wsdisplay_cd.cd_devs[0], cp[i]);
|
1998-06-08 00:19:12 +04:00
|
|
|
} else {
|
1998-06-20 22:42:50 +04:00
|
|
|
wsdisplay_kbdinput(wsdisplay_cd.cd_devs[0], (keysym_t)hej);
|
1998-06-08 00:19:12 +04:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
lkc_decode(ch)
|
|
|
|
int ch;
|
|
|
|
{
|
|
|
|
extern unsigned short q_key[], q_shift_key[];
|
|
|
|
static int shifted, ctrl, lastchar;
|
|
|
|
int hej;
|
|
|
|
|
1998-06-04 19:51:12 +04:00
|
|
|
switch (ch) {
|
|
|
|
case KEY_SHIFT:
|
1998-06-08 00:19:12 +04:00
|
|
|
shifted ^= 1;
|
|
|
|
return -1;
|
1998-06-04 19:51:12 +04:00
|
|
|
|
|
|
|
case KEY_UP:
|
1998-06-08 00:19:12 +04:00
|
|
|
shifted = ctrl = 0;
|
|
|
|
return -1;
|
1998-06-04 19:51:12 +04:00
|
|
|
|
|
|
|
case KEY_CONTROL:
|
1998-06-08 00:19:12 +04:00
|
|
|
ctrl ^= 1;
|
|
|
|
return -1;
|
1998-06-04 19:51:12 +04:00
|
|
|
|
|
|
|
case KEY_REPEAT:
|
1998-06-08 00:19:12 +04:00
|
|
|
ch = lastchar;
|
1998-06-04 19:51:12 +04:00
|
|
|
break;
|
|
|
|
|
1998-08-10 18:47:16 +04:00
|
|
|
#if defined(DDB)
|
1998-06-08 00:19:12 +04:00
|
|
|
case 113: /* ESC */
|
|
|
|
if ((shifted & ctrl) == 0)
|
|
|
|
break;
|
|
|
|
Debugger();
|
|
|
|
return -1;
|
|
|
|
#endif
|
1998-06-06 02:02:56 +04:00
|
|
|
case 86:
|
|
|
|
case 87:
|
|
|
|
case 88:
|
|
|
|
case 89:
|
|
|
|
case 90:
|
|
|
|
case 100:
|
|
|
|
case 101:
|
|
|
|
case 102:
|
1998-06-08 00:19:12 +04:00
|
|
|
if ((shifted & ctrl) == 0)
|
1998-06-06 02:02:56 +04:00
|
|
|
break;
|
|
|
|
ch -= 86;
|
|
|
|
if (ch > 10)
|
|
|
|
ch -= 9;
|
1998-06-20 22:42:50 +04:00
|
|
|
wsdisplay_switch(wsdisplay_cd.cd_devs[0], ch, 0);
|
1998-06-08 00:19:12 +04:00
|
|
|
return -1;
|
1998-06-06 02:02:56 +04:00
|
|
|
|
1998-06-04 19:51:12 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-06-08 00:19:12 +04:00
|
|
|
hej = (shifted ? q_shift_key[ch] : q_key[ch]);
|
|
|
|
lastchar = ch;
|
1998-06-04 19:51:12 +04:00
|
|
|
|
1998-06-08 00:19:12 +04:00
|
|
|
if (ctrl)
|
|
|
|
hej &= 31;
|
1998-06-04 19:51:12 +04:00
|
|
|
|
1998-06-08 00:19:12 +04:00
|
|
|
return hej;
|
1998-06-04 19:51:12 +04:00
|
|
|
}
|
1998-06-08 00:19:12 +04:00
|
|
|
|