Move the translation of keypad and function keys into the realm of the

terminal emulation. For this, change the interface to wsdisplay_kbdinput()
to take a "keysym_t" as argument. From there, the code is handed to the
appropriate emulation module via a new entry point: "translate".
Nuke the ioctls dealing with global assignment of character sequences
to keypad/function keys.
The "sun" emulation works much better now!
This commit is contained in:
drochner 1998-06-15 17:48:32 +00:00
parent e96a163c22
commit bd3b88b6a6
10 changed files with 162 additions and 236 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: wscons_callbacks.h,v 1.2 1998/06/11 22:03:15 drochner Exp $ */ /* $NetBSD: wscons_callbacks.h,v 1.3 1998/06/15 17:48:32 drochner Exp $ */
/* /*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -46,7 +46,7 @@ void wsdisplay_set_kbd __P((struct device *, struct device *));
/* /*
* Calls to the display interface from the keyboard interface. * Calls to the display interface from the keyboard interface.
*/ */
void wsdisplay_kbdinput __P((struct device *v, const u_char *, u_int)); void wsdisplay_kbdinput __P((struct device *v, keysym_t));
int wsdisplay_switch __P((struct device *, int, int)); int wsdisplay_switch __P((struct device *, int, int));
void wsdisplay_kbdholdscreen __P((struct device *v, int)); void wsdisplay_kbdholdscreen __P((struct device *v, int));

View File

@ -1,4 +1,4 @@
/* $NetBSD: wscons_glue.c,v 1.2 1998/05/23 01:06:36 thorpej Exp $ */ /* $NetBSD: wscons_glue.c,v 1.3 1998/06/15 17:48:32 drochner Exp $ */
/* /*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -33,12 +33,13 @@
static const char _copyright[] __attribute__ ((unused)) = static const char _copyright[] __attribute__ ((unused)) =
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved."; "Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
static const char _rcsid[] __attribute__ ((unused)) = static const char _rcsid[] __attribute__ ((unused)) =
"$NetBSD: wscons_glue.c,v 1.2 1998/05/23 01:06:36 thorpej Exp $"; "$NetBSD: wscons_glue.c,v 1.3 1998/06/15 17:48:32 drochner Exp $";
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/device.h> #include <sys/device.h>
#include <dev/wscons/wsksymvar.h>
#include <dev/wscons/wscons_callbacks.h> #include <dev/wscons/wscons_callbacks.h>
#include "wskbd.h" #include "wskbd.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsconsio.h,v 1.3 1998/06/11 22:15:14 drochner Exp $ */ /* $NetBSD: wsconsio.h,v 1.4 1998/06/15 17:48:33 drochner Exp $ */
/* /*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -135,14 +135,6 @@ struct wskbd_map_data {
#define WSKBDIO_GETENCODING _IOR('W', 15, int) #define WSKBDIO_GETENCODING _IOR('W', 15, int)
#define WSKBDIO_SETENCODING _IOW('W', 16, int) #define WSKBDIO_SETENCODING _IOW('W', 16, int)
/* Manipulate strings of function keys */
struct wskbd_string_data {
u_int keycode; /* keycode to change */
char value[WSKBD_STRING_LEN]; /* string data */
};
#define WSKBDIO_GETSTRING _IOR('W', 17, struct wskbd_string_data)
#define WSKBDIO_SETSTRING _IOW('W', 18, struct wskbd_string_data)
/* internal use only */ /* internal use only */
#define WSKBDIO_SETMODE _IOW('W', 19, int) #define WSKBDIO_SETMODE _IOW('W', 19, int)
#define WSKBDIO_GETMODE _IOR('W', 20, int) #define WSKBDIO_GETMODE _IOR('W', 20, int)

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsdisplay.c,v 1.7 1998/06/12 18:15:27 drochner Exp $ */ /* $NetBSD: wsdisplay.c,v 1.8 1998/06/15 17:48:33 drochner Exp $ */
/* /*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -33,7 +33,7 @@
static const char _copyright[] __attribute__ ((unused)) = static const char _copyright[] __attribute__ ((unused)) =
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved."; "Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
static const char _rcsid[] __attribute__ ((unused)) = static const char _rcsid[] __attribute__ ((unused)) =
"$NetBSD: wsdisplay.c,v 1.7 1998/06/12 18:15:27 drochner Exp $"; "$NetBSD: wsdisplay.c,v 1.8 1998/06/15 17:48:33 drochner Exp $";
#include <sys/param.h> #include <sys/param.h>
#include <sys/conf.h> #include <sys/conf.h>
@ -51,6 +51,8 @@ static const char _rcsid[] __attribute__ ((unused)) =
#include <dev/wscons/wsconsio.h> #include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsdisplayvar.h> #include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsksymvar.h>
#include <dev/wscons/wsksymdef.h>
#include <dev/wscons/wsemulvar.h> #include <dev/wscons/wsemulvar.h>
#include <dev/wscons/wscons_callbacks.h> #include <dev/wscons/wscons_callbacks.h>
#include <dev/cons.h> #include <dev/cons.h>
@ -922,13 +924,14 @@ wsdisplay_emulinput(v, data, count)
* Calls from the keyboard interface. * Calls from the keyboard interface.
*/ */
void void
wsdisplay_kbdinput(dev, data, count) wsdisplay_kbdinput(dev, ks)
struct device *dev; struct device *dev;
const u_char *data; keysym_t ks;
u_int count;
{ {
struct wsdisplay_softc *sc = (struct wsdisplay_softc *)dev; struct wsdisplay_softc *sc = (struct wsdisplay_softc *)dev;
struct wsscreen *scr; struct wsscreen *scr;
char *dp;
int count;
struct tty *tp; struct tty *tp;
KASSERT(sc != NULL); KASSERT(sc != NULL);
@ -940,8 +943,15 @@ wsdisplay_kbdinput(dev, data, count)
return; return;
tp = scr->scr_tty; tp = scr->scr_tty;
while (count-- > 0)
(*linesw[tp->t_line].l_rint)(*data++, tp); if (KS_GROUP(ks) == KS_GROUP_Ascii)
(*linesw[tp->t_line].l_rint)(KS_VALUE(ks), tp);
else if (WSSCREEN_HAS_EMULATOR(scr)) {
count = (*scr->scr_dconf->wsemul->translate)
(scr->scr_dconf->wsemulcookie, ks, &dp);
while (count-- > 0)
(*linesw[tp->t_line].l_rint)(*dp++, tp);
}
} }
#ifdef WSDISPLAY_COMPAT_RAWKBD #ifdef WSDISPLAY_COMPAT_RAWKBD

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsemul_dumb.c,v 1.2 1998/05/14 20:49:57 drochner Exp $ */ /* $NetBSD: wsemul_dumb.c,v 1.3 1998/06/15 17:48:33 drochner Exp $ */
/* /*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -33,7 +33,7 @@
static const char _copyright[] __attribute__ ((unused)) = static const char _copyright[] __attribute__ ((unused)) =
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved."; "Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
static const char _rcsid[] __attribute__ ((unused)) = static const char _rcsid[] __attribute__ ((unused)) =
"$NetBSD: wsemul_dumb.c,v 1.2 1998/05/14 20:49:57 drochner Exp $"; "$NetBSD: wsemul_dumb.c,v 1.3 1998/06/15 17:48:33 drochner Exp $";
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -52,6 +52,7 @@ void *wsemul_dumb_attach __P((int console, const struct wsscreen_descr *,
void *, int, int, void *, long)); void *, int, int, void *, long));
void wsemul_dumb_output __P((void *cookie, const u_char *data, u_int count, void wsemul_dumb_output __P((void *cookie, const u_char *data, u_int count,
int)); int));
int wsemul_dumb_translate __P((void *cookie, keysym_t, char **));
void wsemul_dumb_detach __P((void *cookie, u_int *crowp, u_int *ccolp)); void wsemul_dumb_detach __P((void *cookie, u_int *crowp, u_int *ccolp));
const struct wsemul_ops wsemul_dumb_ops = { const struct wsemul_ops wsemul_dumb_ops = {
@ -59,6 +60,7 @@ const struct wsemul_ops wsemul_dumb_ops = {
wsemul_dumb_cnattach, wsemul_dumb_cnattach,
wsemul_dumb_attach, wsemul_dumb_attach,
wsemul_dumb_output, wsemul_dumb_output,
wsemul_dumb_translate,
wsemul_dumb_detach, wsemul_dumb_detach,
}; };
@ -207,6 +209,15 @@ wsemul_dumb_output(cookie, data, count, kernel)
(*edp->emulops->cursor)(edp->emulcookie, 1, edp->crow, edp->ccol); (*edp->emulops->cursor)(edp->emulcookie, 1, edp->crow, edp->ccol);
} }
int
wsemul_dumb_translate(cookie, in, out)
void *cookie;
keysym_t in;
char **out;
{
return (0);
}
void void
wsemul_dumb_detach(cookie, crowp, ccolp) wsemul_dumb_detach(cookie, crowp, ccolp)
void *cookie; void *cookie;

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsemul_sun.c,v 1.5 1998/05/24 10:56:16 drochner Exp $ */ /* $NetBSD: wsemul_sun.c,v 1.6 1998/06/15 17:48:33 drochner Exp $ */
/* /*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -33,7 +33,7 @@
static const char _copyright[] __attribute__ ((unused)) = static const char _copyright[] __attribute__ ((unused)) =
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved."; "Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
static const char _rcsid[] __attribute__ ((unused)) = static const char _rcsid[] __attribute__ ((unused)) =
"$NetBSD: wsemul_sun.c,v 1.5 1998/05/24 10:56:16 drochner Exp $"; "$NetBSD: wsemul_sun.c,v 1.6 1998/06/15 17:48:33 drochner Exp $";
/* XXX DESCRIPTION/SOURCE OF INFORMATION */ /* XXX DESCRIPTION/SOURCE OF INFORMATION */
@ -46,6 +46,7 @@ static const char _rcsid[] __attribute__ ((unused)) =
#include <dev/wscons/wsconsio.h> #include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsdisplayvar.h> #include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsemulvar.h> #include <dev/wscons/wsemulvar.h>
#include <dev/wscons/wsksymdef.h>
#include <dev/wscons/ascii.h> #include <dev/wscons/ascii.h>
#include "opt_wskernattr.h" #include "opt_wskernattr.h"
@ -56,6 +57,7 @@ void *wsemul_sun_attach __P((int console, const struct wsscreen_descr *,
void *, int, int, void *, long)); void *, int, int, void *, long));
void wsemul_sun_output __P((void *cookie, const u_char *data, u_int count, void wsemul_sun_output __P((void *cookie, const u_char *data, u_int count,
int)); int));
int wsemul_sun_translate __P((void *cookie, keysym_t, char **));
void wsemul_sun_detach __P((void *cookie, u_int *crowp, u_int *ccolp)); void wsemul_sun_detach __P((void *cookie, u_int *crowp, u_int *ccolp));
const struct wsemul_ops wsemul_sun_ops = { const struct wsemul_ops wsemul_sun_ops = {
@ -63,6 +65,7 @@ const struct wsemul_ops wsemul_sun_ops = {
wsemul_sun_cnattach, wsemul_sun_cnattach,
wsemul_sun_attach, wsemul_sun_attach,
wsemul_sun_output, wsemul_sun_output,
wsemul_sun_translate,
wsemul_sun_detach, wsemul_sun_detach,
}; };
@ -547,6 +550,83 @@ wsemul_sun_output(cookie, data, count, kernel)
(*edp->emulops->cursor)(edp->emulcookie, 1, edp->crow, edp->ccol); (*edp->emulops->cursor)(edp->emulcookie, 1, edp->crow, edp->ccol);
} }
static char *sun_fkeys[] = {
"\033[224z", /* F1 */
"\033[225z",
"\033[226z",
"\033[227z",
"\033[228z",
"\033[229z",
"\033[230z",
"\033[231z",
"\033[232z",
"\033[233z", /* F10 */
};
int
wsemul_sun_translate(cookie, in, out)
void *cookie;
keysym_t in;
char **out;
{
static char c;
if (KS_GROUP(in) == KS_GROUP_Keypad && (in & 0x80) == 0) {
c = in & 0xff; /* turn into ASCII */
*out = &c;
return (1);
}
if (in >= KS_f1 && in <= KS_f10) {
*out = sun_fkeys[in - KS_f1];
return (6);
}
if (in >= KS_F1 && in <= KS_F10) {
*out = sun_fkeys[in - KS_F1];
return (6);
}
if (in >= KS_KP_F1 && in <= KS_KP_F4) {
*out = sun_fkeys[in - KS_KP_F1];
return (6);
}
switch (in) {
case KS_Home:
case KS_KP_Home:
case KS_KP_Begin:
*out = "\033[214z";
return (6);
case KS_Prior:
case KS_KP_Prior:
*out = "\033[216z";
return (6);
case KS_Next:
case KS_KP_Next:
*out = "\033[222z";
return (6);
case KS_Up:
case KS_KP_Up:
*out = "\033[A";
return (3);
case KS_Down:
case KS_KP_Down:
*out = "\033[B";
return (3);
case KS_Left:
case KS_KP_Left:
*out = "\033[D";
return (3);
case KS_Right:
case KS_KP_Right:
*out = "\033[C";
return (3);
case KS_KP_Delete:
*out = "\177";
return (1);
}
return (0);
}
void void
wsemul_sun_detach(cookie, crowp, ccolp) wsemul_sun_detach(cookie, crowp, ccolp)
void *cookie; void *cookie;

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsemulvar.h,v 1.3 1998/05/14 20:49:57 drochner Exp $ */ /* $NetBSD: wsemulvar.h,v 1.4 1998/06/15 17:48:33 drochner Exp $ */
/* /*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -42,6 +42,7 @@ struct wsemul_ops {
int, int, void *, long)); int, int, void *, long));
void (*output) __P((void *cookie, const u_char *data, u_int count, void (*output) __P((void *cookie, const u_char *data, u_int count,
int)); int));
int (*translate) __P((void *, keysym_t, char **));
void (*detach) __P((void *cookie, u_int *crow, u_int *ccol)); void (*detach) __P((void *cookie, u_int *crow, u_int *ccol));
}; };
@ -55,6 +56,9 @@ extern const struct wsemul_ops wsemul_dumb_ops;
#ifdef WSEMUL_SUN #ifdef WSEMUL_SUN
extern const struct wsemul_ops wsemul_sun_ops; extern const struct wsemul_ops wsemul_sun_ops;
#endif #endif
#ifdef WSEMUL_VT100
extern const struct wsemul_ops wsemul_vt100_ops;
#endif
const struct wsemul_ops *wsemul_pick __P((const char *)); const struct wsemul_ops *wsemul_pick __P((const char *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: wskbd.c,v 1.8 1998/06/13 14:28:50 drochner Exp $ */ /* $NetBSD: wskbd.c,v 1.9 1998/06/15 17:48:33 drochner Exp $ */
/* /*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -36,7 +36,7 @@
static const char _copyright[] __attribute__ ((unused)) = static const char _copyright[] __attribute__ ((unused)) =
"Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved."; "Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.";
static const char _rcsid[] __attribute__ ((unused)) = static const char _rcsid[] __attribute__ ((unused)) =
"$NetBSD: wskbd.c,v 1.8 1998/06/13 14:28:50 drochner Exp $"; "$NetBSD: wskbd.c,v 1.9 1998/06/15 17:48:33 drochner Exp $";
/* /*
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -149,8 +149,7 @@ struct wskbd_softc {
struct wskbd_keyrepeat_data sc_keyrepeat_data; struct wskbd_keyrepeat_data sc_keyrepeat_data;
int sc_repeating; /* we've called timeout() */ int sc_repeating; /* we've called timeout() */
const u_char *sc_repeatstr; /* repeated character (string) */ keysym_t sc_repeatsym; /* repeated symbol */
u_int sc_repeatstrlen; /* repeated character (string) len */
int sc_translating; /* xlate to chars for emulation */ int sc_translating; /* xlate to chars for emulation */
@ -186,7 +185,7 @@ void wskbd_attach __P((struct device *, struct device *, void *));
static inline void update_leds __P((struct wskbd_internal *)); static inline void update_leds __P((struct wskbd_internal *));
static inline void update_modifier __P((struct wskbd_internal *, u_int, int, int)); static inline void update_modifier __P((struct wskbd_internal *, u_int, int, int));
static int internal_command __P((struct wskbd_softc *, u_int *, keysym_t)); static int internal_command __P((struct wskbd_softc *, u_int *, keysym_t));
static char *wskbd_translate __P((struct wskbd_internal *, u_int, int)); static keysym_t wskbd_translate __P((struct wskbd_internal *, u_int, int));
static void wskbd_holdscreen __P((struct wskbd_softc *, int)); static void wskbd_holdscreen __P((struct wskbd_softc *, int));
@ -362,13 +361,10 @@ wskbd_repeat(v)
int s = spltty(); int s = spltty();
KASSERT(sc->sc_repeating); KASSERT(sc->sc_repeating);
if (sc->sc_repeatstrlen != 0) { if (sc->sc_displaydv != NULL)
if (sc->sc_displaydv != NULL) wsdisplay_kbdinput(sc->sc_displaydv, sc->sc_repeatsym);
wsdisplay_kbdinput(sc->sc_displaydv, sc->sc_repeatstr, timeout(wskbd_repeat, sc,
sc->sc_repeatstrlen); (hz * sc->sc_keyrepeat_data.delN) / 1000);
timeout(wskbd_repeat, sc,
(hz * sc->sc_keyrepeat_data.delN) / 1000);
}
splx(s); splx(s);
} }
@ -381,7 +377,7 @@ wskbd_input(dev, type, value)
struct wskbd_softc *sc = (struct wskbd_softc *)dev; struct wskbd_softc *sc = (struct wskbd_softc *)dev;
struct wscons_event *ev; struct wscons_event *ev;
struct timeval xxxtime; struct timeval xxxtime;
const char *cp; keysym_t ks;
int put; int put;
if (sc->sc_repeating) { if (sc->sc_repeating) {
@ -394,20 +390,16 @@ wskbd_input(dev, type, value)
* send upstream. * send upstream.
*/ */
if (sc->sc_translating) { if (sc->sc_translating) {
cp = wskbd_translate(sc->id, type, value); ks = wskbd_translate(sc->id, type, value);
if (cp != NULL) { if (ks != KS_voidSymbol) {
sc->sc_repeatstr = cp; sc->sc_repeatsym = ks;
sc->sc_repeatstrlen = strlen(cp); if (sc->sc_displaydv != NULL)
if (sc->sc_repeatstrlen != 0) { wsdisplay_kbdinput(sc->sc_displaydv,
if (sc->sc_displaydv != NULL) sc->sc_repeatsym);
wsdisplay_kbdinput(sc->sc_displaydv,
sc->sc_repeatstr, sc->sc_repeating = 1;
sc->sc_repeatstrlen); timeout(wskbd_repeat, sc,
(hz * sc->sc_keyrepeat_data.del1) / 1000);
sc->sc_repeating = 1;
timeout(wskbd_repeat, sc,
(hz * sc->sc_keyrepeat_data.del1) / 1000);
}
} }
return; return;
} }
@ -446,8 +438,11 @@ wskbd_rawinput(dev, buf, len)
int len; int len;
{ {
struct wskbd_softc *sc = (struct wskbd_softc *)dev; struct wskbd_softc *sc = (struct wskbd_softc *)dev;
int i;
wsdisplay_kbdinput(sc->sc_displaydv, buf, len); for (i = 0; i < len; i++)
wsdisplay_kbdinput(sc->sc_displaydv, buf[i]);
/* this is KS_GROUP_Ascii */
} }
#endif #endif
@ -608,7 +603,6 @@ wskbd_displayioctl(dev, cmd, data, flag, p)
struct wskbd_softc *sc = (struct wskbd_softc *)dev; struct wskbd_softc *sc = (struct wskbd_softc *)dev;
struct wskbd_bell_data *ubdp, *kbdp; struct wskbd_bell_data *ubdp, *kbdp;
struct wskbd_keyrepeat_data *ukdp, *kkdp; struct wskbd_keyrepeat_data *ukdp, *kkdp;
struct wskbd_string_data *usdp;
struct wskbd_map_data *umdp; struct wskbd_map_data *umdp;
void *buf; void *buf;
int len, error; int len, error;
@ -742,24 +736,6 @@ getkeyrepeat:
if (error == 0) if (error == 0)
sc->id->t_layout = *((kbd_t *)data); sc->id->t_layout = *((kbd_t *)data);
return(error); return(error);
case WSKBDIO_GETSTRING:
usdp = (struct wskbd_string_data *)data;
if (usdp->keycode < 0 || usdp->keycode >= sc->sc_maplen)
return(EINVAL);
buf = wskbd_get_string(usdp->keycode);
if (buf == NULL)
return(EINVAL);
bcopy(buf, usdp->value, WSKBD_STRING_LEN);
return(0);
case WSKBDIO_SETSTRING:
if ((flag & FWRITE) == 0)
return (EACCES);
usdp = (struct wskbd_string_data *)data;
if (usdp->keycode < 0 || usdp->keycode >= sc->sc_maplen)
return(EINVAL);
return(wskbd_set_string(usdp->keycode, usdp->value));
} }
/* /*
@ -852,7 +828,7 @@ wskbd_cngetc(dev)
{ {
u_int type; u_int type;
int data; int data;
char *cp; keysym_t ks;
if (!wskbd_console_initted) if (!wskbd_console_initted)
return 0; return 0;
@ -861,13 +837,14 @@ wskbd_cngetc(dev)
!wskbd_console_device->sc_translating) !wskbd_console_device->sc_translating)
return 0; return 0;
do { for(;;) {
(*wskbd_console_data.t_getc)(wskbd_console_data.t_accesscookie, (*wskbd_console_data.t_getc)(wskbd_console_data.t_accesscookie,
&type, &data); &type, &data);
cp = wskbd_translate(&wskbd_console_data, type, data); ks = wskbd_translate(&wskbd_console_data, type, data);
} while (cp == NULL || cp[1] != '\0');
if (KS_GROUP(ks) == KS_GROUP_Ascii)
return(cp[0]); return (KS_VALUE(ks));
}
} }
void void
@ -977,7 +954,7 @@ internal_command(sc, type, ksym)
return (0); return (0);
} }
static char * static keysym_t
wskbd_translate(id, type, value) wskbd_translate(id, type, value)
struct wskbd_internal *id; struct wskbd_internal *id;
u_int type; u_int type;
@ -987,7 +964,6 @@ wskbd_translate(id, type, value)
keysym_t ksym, res, *group; keysym_t ksym, res, *group;
struct wscons_keymap kpbuf, *kp; struct wscons_keymap kpbuf, *kp;
int iscommand = 0; int iscommand = 0;
static char result[2];
if (sc != NULL) { if (sc != NULL) {
if (value < 0 || value >= sc->sc_maplen) { if (value < 0 || value >= sc->sc_maplen) {
@ -995,7 +971,7 @@ wskbd_translate(id, type, value)
printf("wskbd_translate: keycode %d out of range\n", printf("wskbd_translate: keycode %d out of range\n",
value); value);
#endif #endif
return(NULL); return (KS_voidSymbol);
} }
kp = sc->sc_map + value; kp = sc->sc_map + value;
} else { } else {
@ -1061,7 +1037,7 @@ wskbd_translate(id, type, value)
/* If this is a key release or we are in command mode, we are done */ /* If this is a key release or we are in command mode, we are done */
if (type != WSCONS_EVENT_KEY_DOWN || iscommand) { if (type != WSCONS_EVENT_KEY_DOWN || iscommand) {
update_leds(id); update_leds(id);
return(NULL); return (KS_voidSymbol);
} }
/* Get the keysym */ /* Get the keysym */
@ -1123,7 +1099,7 @@ wskbd_translate(id, type, value)
if (res == KS_voidSymbol) { if (res == KS_voidSymbol) {
update_leds(id); update_leds(id);
return(NULL); return (res);
} }
if (id->t_composelen > 0) { if (id->t_composelen > 0) {
@ -1132,13 +1108,13 @@ wskbd_translate(id, type, value)
res = wskbd_compose_value(id->t_composebuf); res = wskbd_compose_value(id->t_composebuf);
update_modifier(id, 0, 0, MOD_COMPOSE); update_modifier(id, 0, 0, MOD_COMPOSE);
} else { } else {
return(NULL); return (KS_voidSymbol);
} }
} }
update_leds(id); update_leds(id);
/* We are done, return the string */ /* We are done, return the symbol */
if (KS_GROUP(res) == KS_GROUP_Ascii) { if (KS_GROUP(res) == KS_GROUP_Ascii) {
if (MOD_ONESET(id, MOD_ANYCONTROL)) { if (MOD_ONESET(id, MOD_ANYCONTROL)) {
if ((res >= KS_at && res <= KS_z) || res == KS_space) if ((res >= KS_at && res <= KS_z) || res == KS_space)
@ -1154,12 +1130,5 @@ wskbd_translate(id, type, value)
res |= 0x80; res |= 0x80;
} }
if (KS_GROUP(res) == KS_GROUP_Ascii || return (res);
(KS_GROUP(res) == KS_GROUP_Keypad && (res & 0x80) == 0)) {
result[0] = res & 0xff;
result[1] = '\0';
return(result);
} else {
return(wskbd_get_string(res));
}
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: wskbdutil.c,v 1.3 1998/04/20 10:47:36 hannken Exp $ */ /* $NetBSD: wskbdutil.c,v 1.4 1998/06/15 17:48:33 drochner Exp $ */
/*- /*-
* Copyright (c) 1997 The NetBSD Foundation, Inc. * Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -180,80 +180,7 @@ static struct compose_tab_s {
#define COMPOSE_SIZE sizeof(compose_tab)/sizeof(compose_tab[0]) #define COMPOSE_SIZE sizeof(compose_tab)/sizeof(compose_tab[0])
static struct string_tab_s {
keysym_t ksym;
char value[WSKBD_STRING_LEN];
} string_tab[] = {
{ KS_f1, "\033[OP" },
{ KS_f2, "\033[OQ" },
{ KS_f3, "\033[OR" },
{ KS_f4, "\033[OS" },
{ KS_f5, "\033[15~" },
{ KS_f6, "\033[17~" },
{ KS_f7, "\033[18~" },
{ KS_f8, "\033[19~" },
{ KS_f9, "\033[20~" },
{ KS_f10, "\033[21~" },
{ KS_f11, "\033[23~" },
{ KS_f12, "\033[24~" },
{ KS_f13, "\033[25~" },
{ KS_f14, "\033[26~" },
{ KS_f15, "\033[28~" },
{ KS_f16, "\033[29~" },
{ KS_f17, "\033[31~" },
{ KS_f18, "\033[32~" },
{ KS_f19, "\033[33~" },
{ KS_f20, "\033[34~" },
{ KS_F1, "\033[OP" },
{ KS_F2, "\033[OQ" },
{ KS_F3, "\033[OR" },
{ KS_F4, "\033[OS" },
{ KS_F5, "\033[15~" },
{ KS_F6, "\033[17~" },
{ KS_F7, "\033[18~" },
{ KS_F8, "\033[19~" },
{ KS_F9, "\033[20~" },
{ KS_F10, "\033[21~" },
{ KS_F11, "\033[23~" },
{ KS_F12, "\033[24~" },
{ KS_F13, "\033[25~" },
{ KS_F14, "\033[26~" },
{ KS_F15, "\033[28~" },
{ KS_F16, "\033[29~" },
{ KS_F17, "\033[31~" },
{ KS_F18, "\033[32~" },
{ KS_F19, "\033[33~" },
{ KS_F20, "\033[34~" },
{ KS_KP_F1, "\033[OP" },
{ KS_KP_F2, "\033[OQ" },
{ KS_KP_F3, "\033[OR" },
{ KS_KP_F4, "\033[OS" },
{ KS_KP_Home, "\033[H" },
{ KS_Home, "\033[H" },
{ KS_KP_Left, "\033[D" },
{ KS_Left, "\033[D" },
{ KS_KP_Up, "\033[A" },
{ KS_Up, "\033[A" },
{ KS_KP_Right, "\033[C" },
{ KS_Right, "\033[C" },
{ KS_KP_Down, "\033[B" },
{ KS_Down, "\033[B" },
{ KS_KP_Prior, "\033[I" },
{ KS_Prior, "\033[I" },
{ KS_KP_Next, "\033[G" },
{ KS_Next, "\033[G" },
{ KS_KP_End, "\033[F" },
{ KS_End, "\033[F" },
{ KS_KP_Begin, "\033[H" },
{ KS_KP_Insert, "\033[L" },
{ KS_Insert, "\033[L" },
{ KS_KP_Delete, "\b" }
};
#define STRING_SIZE sizeof(string_tab)/sizeof(string_tab[0])
static int compose_tab_inorder = 0; static int compose_tab_inorder = 0;
static int string_tab_inorder = 0;
static inline int compose_tab_cmp __P((struct compose_tab_s *, struct compose_tab_s *)); static inline int compose_tab_cmp __P((struct compose_tab_s *, struct compose_tab_s *));
static keysym_t ksym_upcase __P((keysym_t)); static keysym_t ksym_upcase __P((keysym_t));
@ -304,70 +231,6 @@ wskbd_compose_value(compose_buf)
return(KS_voidSymbol); return(KS_voidSymbol);
} }
char *
wskbd_get_string(sym)
keysym_t sym;
{
int i, j;
struct string_tab_s v;
if (! string_tab_inorder) {
/* Insertion sort. */
for (i = 1; i < STRING_SIZE; i++) {
v = string_tab[i];
/* find correct slot, moving others up */
for (j = i; --j >= 0 && v.ksym < string_tab[j].ksym; )
string_tab[j + 1] = string_tab[j];
string_tab[j + 1] = v;
}
string_tab_inorder = 1;
}
for (j = 0, i = STRING_SIZE; i != 0; i /= 2) {
if (string_tab[j + i/2].ksym == sym)
return(string_tab[j + i/2].value);
else if (string_tab[j + i/2].ksym < sym) {
j += i/2 + 1;
i--;
}
}
return(NULL);
}
int
wskbd_set_string(sym, data)
keysym_t sym;
char *data;
{
int i, j;
struct string_tab_s v;
if (! string_tab_inorder) {
/* Insertion sort. */
for (i = 1; i < STRING_SIZE; i++) {
v = string_tab[i];
/* find correct slot, moving others up */
for (j = i; --j >= 0 && v.ksym < string_tab[j].ksym; )
string_tab[j + 1] = string_tab[j];
string_tab[j + 1] = v;
}
string_tab_inorder = 1;
}
for (j = 0, i = STRING_SIZE; i != 0; i /= 2) {
if (string_tab[j + i/2].ksym == sym) {
bcopy(data, string_tab[j + i/2].value, WSKBD_STRING_LEN);
return(0);
} else if (string_tab[j + i/2].ksym < sym) {
j += i/2 + 1;
i--;
}
}
return(EINVAL);
}
static const u_char latin1_to_upper[256] = { static const u_char latin1_to_upper[256] = {
/* 0 8 1 9 2 a 3 b 4 c 5 d 6 e 7 f */ /* 0 8 1 9 2 a 3 b 4 c 5 d 6 e 7 f */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsksymvar.h,v 1.4 1998/04/09 13:09:47 hannken Exp $ */ /* $NetBSD: wsksymvar.h,v 1.5 1998/06/15 17:48:33 drochner Exp $ */
/*- /*-
* Copyright (c) 1997 The NetBSD Foundation, Inc. * Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -39,8 +39,6 @@
#ifndef _DEV_WSCONS_WSKSYMVAR_H_ #ifndef _DEV_WSCONS_WSKSYMVAR_H_
#define _DEV_WSCONS_WSKSYMVAR_H_ #define _DEV_WSCONS_WSKSYMVAR_H_
#define WSKBD_STRING_LEN 8 /* Function keys, 7 chars+NUL */
#ifndef _KERNEL #ifndef _KERNEL
#include <sys/types.h> #include <sys/types.h>
#endif #endif
@ -71,8 +69,6 @@ void wskbd_init_keymap __P((int, struct wscons_keymap **, int *));
int wskbd_load_keymap __P((kbd_t, const struct wscons_keydesc *, int, int wskbd_load_keymap __P((kbd_t, const struct wscons_keydesc *, int,
struct wscons_keymap **, int *)); struct wscons_keymap **, int *));
keysym_t wskbd_compose_value __P((keysym_t *)); keysym_t wskbd_compose_value __P((keysym_t *));
char * wskbd_get_string __P((keysym_t));
int wskbd_set_string __P((keysym_t, char *));
#endif #endif