From owner-freebsd-hackers@FreeBSD.ORG Sun Oct 18 20:28:43 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD781106566B for ; Sun, 18 Oct 2009 20:28:43 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id CED3F8FC19 for ; Sun, 18 Oct 2009 20:28:42 +0000 (UTC) Received: from porto.topspin.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id XAA17611; Sun, 18 Oct 2009 23:28:40 +0300 (EEST) (envelope-from avg@icyb.net.ua) Received: from localhost.topspin.kiev.ua ([127.0.0.1]) by porto.topspin.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1MzcMq-000FTs-89; Sun, 18 Oct 2009 23:28:40 +0300 Message-ID: <4ADB7A68.9090906@icyb.net.ua> Date: Sun, 18 Oct 2009 23:28:24 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.23 (X11/20090823) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Ed Schouten Subject: special key (combo) for switching to K_XLATE X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2009 20:28:43 -0000 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