special key (combo) for switching to K_XLATE
Andriy Gapon
avg at icyb.net.ua
Sun Oct 18 20:28:43 UTC 2009
Guys,
please take a look at the following hackish ugly code.
This is just a proof of concept.
It allows me to use an extended multimedia key (that generates 0xe0 0x32 code
sequence) on my keyboard to break out of K_RAW into K_XLATE.
The code is slightly tested and seems to work.
It allowed me to switch out of X terminal to a normal console terminal when X
server hanged. Then I could kill X and relatively easily recover from the
situation that previously require either a remote access (e.g. through network)
or a reboot.
What do you think about having such a capability in syscons?
Of course, the mode switch should be triggered by some key combination is
possible to produce on any/most supported keyboards and also should be hard to
press by accident.
Note that I haven't (again) checked this code with WITNESS.
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index d158f85..e543765 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -3127,6 +3127,7 @@ scgetc(sc_softc_t *sc, u_int flags)
#endif
u_int c;
int this_scr;
+ static int e0 = 0;
int f;
int i;
@@ -3159,8 +3160,22 @@ next_code:
if (!(flags & SCGETC_CN))
random_harvest(&c, sizeof(c), 1, 0, RANDOM_KEYBOARD);
- if (scp->kbd_mode != K_XLATE)
+ if (scp->kbd_mode != K_XLATE) {
+ if (scp->kbd_mode == K_RAW) {
+ if (e0) {
+ e0 = 0;
+ if (KEYCHAR(c) == 0x32) {
+ printf("kbd_mode: %d => %d\n", scp->kbd_mode, K_XLATE);
+ scp->kbd_mode = K_XLATE;
+ kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
+ return NOKEY;
+ }
+ }
+ else if (KEYCHAR(c) == 0xe0)
+ e0 = 1;
+ }
return KEYCHAR(c);
+ }
/* if scroll-lock pressed allow history browsing */
if (!ISGRAPHSC(scp) && scp->history && scp->status & SLKED) {
--
Andriy Gapon
More information about the freebsd-hackers
mailing list