NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/48360 wskbd - support for cn_magic
The following reply was made to PR kern/48360; it has been noted by GNATS.
From: Nat Sloss <nathanialsloss%yahoo.com.au@localhost>
To: "gnats-bugs" <gnats-bugs%netbsd.org@localhost>
Cc:
Subject: Re: kern/48360 wskbd - support for cn_magic
Date: Mon, 10 Mar 2014 22:13:01 +1100
Here is a better patch:
Index: src/sys/dev/wscons/wskbd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/wskbd.c,v
retrieving revision 1.130
diff -u -r1.130 wskbd.c
--- src/sys/dev/wscons/wskbd.c 26 Oct 2010 05:12:34 -0000 1.130
+++ src/sys/dev/wscons/wskbd.c 10 Mar 2014 11:04:02 -0000
@@ -207,6 +207,7 @@
wskbd_hotkey_plugin *sc_hotkey;
void *sc_hotkeycookie;
+ dev_t cn_magicdev; /* device for cnmagic */
};
#define MOD_SHIFT_L (1 << 0)
@@ -241,6 +242,26 @@
dst |= (src & MOD_META_L) ? MOD_META_L : 0; \
dst |= (src & MOD_META_R) ? MOD_META_R : 0; \
} while (0)
+#define ws_check_magic(c, k, s)
\
+ do {
\
+ int _v = (s).cnm_magic[(s).cnm_state];
\
+ int _u = (s).cnm_magic[0];
\
+ if ((c) == CNS_MAGIC_VAL(_u)) {
\
+ if ((s).cnm_state == 0) {
\
+ (s).cnm_state = CNS_MAGIC_NEXT(_v);
\
+ _v = (s).cnm_magic[(s).cnm_state];
\
+ }
\
+ if ((k) == CNS_MAGIC_VAL(_v)) {
\
+ (s).cnm_state = CNS_MAGIC_NEXT(_v);
\
+ if ((s).cnm_state == CNS_TERM) {
\
+ cn_trap();
\
+ (s).cnm_state = 0;
\
+ }
\
+ } else {
\
+ (s).cnm_state = 0;
\
+ }
\
+ }
\
+ } while (/* CONSTCOND */ 0)
static int wskbd_match(device_t, cfdata_t, void *);
static void wskbd_attach(device_t, device_t, void *);
@@ -350,6 +371,9 @@
static bool wskbd_suspend(device_t dv, const pmf_qual_t *);
static void wskbd_repeat(void *v);
+#include <dev/cons.h>
+static struct cnm_state ws_cnm_state;
+
static int wskbd_console_initted;
static struct wskbd_softc *wskbd_console_device;
static struct wskbd_internal wskbd_console_data;
@@ -438,6 +462,11 @@
if (ap->console) {
sc->id = &wskbd_console_data;
+
+ sc->cn_magicdev = cn_tab->cn_dev;
+ cn_init_magic(&ws_cnm_state);
+ cn_set_magic("\x2\x20\xf4"); /* default magic */
+
} else {
sc->id = malloc(sizeof(struct wskbd_internal),
M_DEVBUF, M_WAITOK|M_ZERO);
@@ -526,7 +555,7 @@
wskbd_console_data.t_consops = consops;
wskbd_console_data.t_consaccesscookie = conscookie;
-
+
#if NWSDISPLAY > 0
wsdisplay_set_cons_kbd(wskbd_cngetc, wskbd_cnpollc, wskbd_cnbell);
#endif
@@ -1583,7 +1612,9 @@
return (0);
#if defined(DDB) || defined(KGDB)
+
if (ksym == KS_Cmd_Debugger) {
+#if 0
if (sc->sc_isconsole) {
#ifdef DDB
console_debugger();
@@ -1592,6 +1623,7 @@
kgdb_connect(1);
#endif
}
+#endif
/* discard this key (ddb discarded command modifiers) */
*type = WSCONS_EVENT_KEY_UP;
return (1);
@@ -1713,9 +1745,18 @@
}
/* if this key has a command, process it first */
- if (sc != NULL && kp->command != KS_voidSymbol)
+ if (sc != NULL && kp->command != KS_voidSymbol) {
iscommand = internal_command(sc, &type, kp->command,
kp->group1[0]);
+ if (sc->sc_isconsole && iscommand) {
+ if (kp->command & 0xff)
+ ws_check_magic(2, (kp->command & 0xff),
ws_cnm_state);
+ if ((kp->command >> 8) & 0xff)
+ ws_check_magic(2, ((kp->command >> 8) & 0xff),
+ ws_cnm_state);
+ }
+
+ }
/* Now update modifiers */
switch (kp->group1[0]) {
@@ -1868,12 +1909,32 @@
if (id->t_flags & WSKFL_METAESC) {
id->t_symbols[0] = KS_Escape;
id->t_symbols[1] = res;
+ if (sc != NULL && sc->sc_isconsole) {
+ if (res & 0xff)
+ ws_check_magic(1, (res & 0xff),
ws_cnm_state);
+ if ((res >> 8) & 0xff)
+ ws_check_magic(1, ((res >> 8) &
0xff),
ws_cnm_state);
+ if (KS_Escape & 0xff)
+ ws_check_magic(1, (KS_Escape &
0xff),
ws_cnm_state);
+ if ((KS_Escape >> 8) & 0xff)
+ ws_check_magic(1, ((KS_Escape
>> 8) & 0xff),
ws_cnm_state);
+ }
+
return (2);
} else
res |= 0x80;
}
+
}
id->t_symbols[0] = res;
+
+ if (sc != NULL && sc->sc_isconsole) {
+ if (res & 0xff)
+ ws_check_magic(1, (res & 0xff), ws_cnm_state);
+ if ((res >> 8) & 0xff)
+ ws_check_magic(1, ((res >> 8) & 0xff), ws_cnm_state);
+ }
+
return (1);
}
The magic should be prefixed by \x1 for regular keystrokes or \x2 for wskbd
commands, you cannot mix both types in magic.
Regards,
Nat.
Home |
Main Index |
Thread Index |
Old Index