summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-11-20 20:52:12 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-11-20 20:52:12 +0000
commit78cd3d924f3b9c6e1f8fe9473270108afb6a588a (patch)
tree84041e5bdf0726efa20cacdc4a2a1507e25e5399 /sys
parent55fec1d62ee880c647d9e50466a87902ad11b6ba (diff)
Change wsdisplay_kbdinput() to get an aray of keysym_t and a count, instead of
a single keysym_t at a time - this means tty sanity checks will only happen once. Introduce wsdisplay_rawkbdinput() for raw mode input, since raw input is a byte array. As a bonus this allows us to skip the `is this a KS_GROUP_Ascii value' test in that case.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/wscons/wscons_callbacks.h5
-rw-r--r--sys/dev/wscons/wsdisplay.c41
-rw-r--r--sys/dev/wscons/wskbd.c26
3 files changed, 39 insertions, 33 deletions
diff --git a/sys/dev/wscons/wscons_callbacks.h b/sys/dev/wscons/wscons_callbacks.h
index 6d743f342db..48933af6332 100644
--- a/sys/dev/wscons/wscons_callbacks.h
+++ b/sys/dev/wscons/wscons_callbacks.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wscons_callbacks.h,v 1.7 2006/08/05 16:59:57 miod Exp $ */
+/* $OpenBSD: wscons_callbacks.h,v 1.8 2010/11/20 20:52:10 miod Exp $ */
/* $NetBSD: wscons_callbacks.h,v 1.16 2001/11/10 17:14:51 augustss Exp $ */
/*
@@ -41,7 +41,8 @@ void wsdisplay_set_console_kbd(struct wsevsrc *);
/*
* Calls to the display interface from the keyboard interface.
*/
-void wsdisplay_kbdinput(struct device *v, keysym_t);
+void wsdisplay_kbdinput(struct device *v, keysym_t *, int);
+void wsdisplay_rawkbdinput(struct device *v, u_char *, int);
int wsdisplay_switch(struct device *, int, int);
enum wsdisplay_resetops {
WSDISPLAY_RESETEMUL,
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c
index 4bffc3b0ce7..7539cda23e7 100644
--- a/sys/dev/wscons/wsdisplay.c
+++ b/sys/dev/wscons/wsdisplay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplay.c,v 1.102 2010/07/02 17:27:01 nicm Exp $ */
+/* $OpenBSD: wsdisplay.c,v 1.103 2010/11/20 20:52:10 miod Exp $ */
/* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -1579,7 +1579,7 @@ wsdisplay_emulinput(void *v, const u_char *data, u_int count)
* Calls from the keyboard interface.
*/
void
-wsdisplay_kbdinput(struct device *dev, keysym_t ks)
+wsdisplay_kbdinput(struct device *dev, keysym_t *ks, int num)
{
struct wsdisplay_softc *sc = (struct wsdisplay_softc *)dev;
struct wsscreen *scr;
@@ -1587,26 +1587,40 @@ wsdisplay_kbdinput(struct device *dev, keysym_t ks)
int count;
struct tty *tp;
- KASSERT(sc != NULL);
-
scr = sc->sc_focus;
-
if (!scr || !WSSCREEN_HAS_TTY(scr))
return;
- tp = scr->scr_tty;
- if (KS_GROUP(ks) == KS_GROUP_Ascii)
- (*linesw[tp->t_line].l_rint)(KS_VALUE(ks), tp);
- else {
- count = (*scr->scr_dconf->wsemul->translate)
- (scr->scr_dconf->wsemulcookie, ks, &dp);
- while (count-- > 0)
- (*linesw[tp->t_line].l_rint)(*dp++, tp);
+ tp = scr->scr_tty;
+ for (; num > 0; num--, ks++) {
+ if (KS_GROUP(*ks) == KS_GROUP_Ascii)
+ (*linesw[tp->t_line].l_rint)(KS_VALUE(*ks), tp);
+ else {
+ 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
+void
+wsdisplay_rawkbdinput(struct device *dev, u_char *buf, int num)
+{
+ struct wsdisplay_softc *sc = (struct wsdisplay_softc *)dev;
+ struct wsscreen *scr;
+ struct tty *tp;
+
+ scr = sc->sc_focus;
+ if (!scr || !WSSCREEN_HAS_TTY(scr))
+ return;
+
+ tp = scr->scr_tty;
+ while (num-- > 0)
+ (*linesw[tp->t_line].l_rint)(*buf++, tp);
+}
int
wsdisplay_update_rawkbd(struct wsdisplay_softc *sc, struct wsscreen *scr)
{
@@ -1919,7 +1933,6 @@ wsdisplay_reset(struct device *dev, enum wsdisplay_resetops op)
struct wsdisplay_softc *sc = (struct wsdisplay_softc *)dev;
struct wsscreen *scr;
- KASSERT(sc != NULL);
scr = sc->sc_focus;
if (!scr)
diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c
index 6422c5a2c65..2b4ba0720bf 100644
--- a/sys/dev/wscons/wskbd.c
+++ b/sys/dev/wscons/wskbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wskbd.c,v 1.63 2010/11/20 20:47:38 miod Exp $ */
+/* $OpenBSD: wskbd.c,v 1.64 2010/11/20 20:52:11 miod Exp $ */
/* $NetBSD: wskbd.c,v 1.80 2005/05/04 01:52:16 augustss Exp $ */
/*
@@ -500,7 +500,7 @@ wskbd_repeat(void *v)
struct wskbd_softc *sc = (struct wskbd_softc *)v;
int s = spltty();
- if (!sc->sc_repeating) {
+ if (sc->sc_repeating == 0) {
/*
* race condition: a "key up" event came in when wskbd_repeat()
* was already called but not yet spltty()'d
@@ -510,12 +510,9 @@ wskbd_repeat(void *v)
}
if (sc->sc_translating) {
/* deliver keys */
- if (sc->sc_displaydv != NULL) {
- int i;
- for (i = 0; i < sc->sc_repeating; i++)
- wsdisplay_kbdinput(sc->sc_displaydv,
- sc->id->t_symbols[i]);
- }
+ if (sc->sc_displaydv != NULL)
+ wsdisplay_kbdinput(sc->sc_displaydv,
+ sc->id->t_symbols, sc->sc_repeating);
} else {
/* queue event */
wskbd_deliver_event(sc, sc->sc_repeat_type,
@@ -604,7 +601,7 @@ wskbd_input(struct device *dev, u_int type, int value)
{
struct wskbd_softc *sc = (struct wskbd_softc *)dev;
#if NWSDISPLAY > 0
- int num, i;
+ int num;
#endif
#if NWSDISPLAY > 0
@@ -632,10 +629,8 @@ wskbd_input(struct device *dev, u_int type, int value)
WSDISPLAY_SCROLL_RESET);
}
#endif
- for (i = 0; i < num; i++) {
- wsdisplay_kbdinput(sc->sc_displaydv,
- sc->id->t_symbols[i]);
- }
+ wsdisplay_kbdinput(sc->sc_displaydv,
+ sc->id->t_symbols, num);
}
if (sc->sc_keyrepeat_data.del1 != 0) {
@@ -708,12 +703,9 @@ wskbd_rawinput(struct device *dev, u_char *buf, int len)
{
#if NWSDISPLAY > 0
struct wskbd_softc *sc = (struct wskbd_softc *)dev;
- int i;
if (sc->sc_displaydv != NULL)
- for (i = 0; i < len; i++)
- wsdisplay_kbdinput(sc->sc_displaydv, buf[i]);
- /* this is KS_GROUP_Ascii */
+ wsdisplay_rawkbdinput(sc->sc_displaydv, buf, len);
#endif
}
#endif /* WSDISPLAY_COMPAT_RAWKBD */