Return to BSD News archive
Received: by minnie.vk1xwt.ampr.org with NNTP id AA6935 ; Fri, 15 Jan 93 10:39:28 EST Path: sserve!manuel.anu.edu.au!munnari.oz.au!bunyip.cc.uq.oz.au!uqcspe!cs.uq.oz.au!cjb From: cjb@cs.uq.oz.au (Christopher J Biggs) Newsgroups: comp.unix.bsd Subject: [386BSD] Some patches to syscons driver Message-ID: <11711@uqcspe.cs.uq.oz.au> Date: 17 Jan 93 05:59:39 GMT Sender: news@cs.uq.oz.au Reply-To: cjb@cs.uq.oz.au Lines: 293 I recently installed Soeren Schmidt's syscons PC console driver on my 386BSD system, replacing my own rather hacked up version of the original pccons driver. The syscons driver seems to think that the RIGHT-control and -alt keys return separate scancodes, rather than an 0xE0 escape code as in a PC 101-key keyboard. The existing code to handle 0xE0 codes was wrong, as the delay between receiving the two codes of an extended keypress is long enough for the driver to reset the extend keypress flag (esc_flag). I fixed this (mostly by cribbing from pccons). I've patched the driver to do the following things: Distinguish PROPERLY between left- and right-ctl/alt keys Introduce a META key (useful for emacs) Allow CTL-SPACE to return ASCII NUL Swap CTRL and CAPS The patches below are meant to be installed wherever you unpacked the syscons (v1) distribution. To get the added functionality, add the line option KBD101 to your config file and remake (or just #define KBD101 at top of syscons.c). Enjoy, C J Biggs. ------------ CUT HERE --------------------- *** console.h.orig Tue Jan 5 08:25:37 1993 --- console.h Sat Jan 16 15:01:25 1993 *************** *** 44,51 **** --- 44,53 ---- #define CONS_80x50TEXT _IO('c', 103) /* compatibility to old pccons & X386 */ + /* #define CONSOLE_X_MODE_ON _IO('t', 121) #define CONSOLE_X_MODE_OFF _IO('t', 122) + */ #define KD_TEXT 0 #define KD_GRAPHICS 1 *************** *** 108,113 **** --- 110,118 ---- #define LCTR 0x09 #define RCTR 0x7b #define RALT 0x7c + #ifdef KBD101 + #define META 0x7f /* Picked this at random. cjb */ + #endif #define F_SCR 11 /* switch to first screen */ #define L_SCR 26 /* switch to last screen */ *** kbdtables.h.orig Tue Jan 5 08:26:30 1993 --- kbdtables.h Sat Jan 16 15:01:36 1993 *************** *** 77,83 **** /* sc=37 */ '*', '*', '*', '*', '*', '*', '*', '*', 0x33, 0x00, /* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, /* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, ! /* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, /* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, /* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, /* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, --- 77,83 ---- /* sc=37 */ '*', '*', '*', '*', '*', '*', '*', '*', 0x33, 0x00, /* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, /* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, ! /* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, /* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, /* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, /* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, *************** *** 130,135 **** --- 130,137 ---- #else + /* HACK HACK -- LEFT alt is now META, CAPS and LEFT ctl are swapped */ + keymap_t key_map = { 107, /* US iso8859 keymap */ /* alt * scan cntrl alt alt cntrl *************** *** 165,171 **** --- 167,177 ---- /* sc=1a */ '[', '{', 0x1B, 0x1B, '[', '{', 0x1B, 0x1B, 0x00, 0x00, /* sc=1b */ ']', '}', 0x1D, 0x1D, ']', '}', 0x1D, 0x1D, 0x00, 0x00, /* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00, + #ifdef KBD101 + /* sc=1d */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, + #else /* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, + #endif /* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01, /* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01, /* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01, *************** *** 192,200 **** --- 198,212 ---- /* sc=35 */ '/', '?', NOP, NOP, '/', '?', NOP, NOP, 0x33, 0x00, /* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, /* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00, + #ifdef KBD101 + /* sc=38 */ META, META, META, META, META, META, META, META, 0xFF, 0x00, + /* sc=39 */ ' ', ' ', 0x0, ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, + /* sc=3a */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, + #else /* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, /* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, /* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, + #endif /* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, /* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, /* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, *** syscons.c.orig Tue Jan 5 08:27:17 1993 --- syscons.c Sat Jan 16 15:01:44 1993 *************** *** 124,129 **** --- 124,132 ---- static u_short *crtat = 0; static u_int addr_6845 = MONO_BASE; static u_char shfts, ctls, alts, caps, num, stp, scroll; + #ifdef KBD101 + static u_char metas; + #endif static const u_int n_fkey_tab = sizeof (fkey_tab) / sizeof (*fkey_tab); static int cur_cursor_pos = -1; static int in_putc, nx_scr; *************** *** 1249,1259 **** u_char dt; u_int state, action; struct key_t *key; ! static u_int esc_flag; loop: - esc_flag = 0; - next_code: /* First see if there is something in the keyboard port */ if (inb (KBSTAT) & 1) dt = inb (KBDATA); --- 1252,1260 ---- u_char dt; u_int state, action; struct key_t *key; ! static u_int esc_flag=0; loop: /* First see if there is something in the keyboard port */ if (inb (KBSTAT) & 1) dt = inb (KBDATA); *************** *** 1274,1284 **** if (cur_scr_stat->status & KBD_RAW_MODE) return dt; ! if ((dt & ~1) == 0xE0) { ! esc_flag = dt - 0xE0 + 1; ! goto next_code; } if ((dt & 0x7F) >= key_map.n_keys) goto loop; state = (shfts ? 1 : 0 ) | (2 * (ctls ? 1 : 0)) | (4 * (alts ? 1 : 0)); --- 1275,1301 ---- if (cur_scr_stat->status & KBD_RAW_MODE) return dt; ! if (dt == 0xE0) { ! esc_flag = 1; ! goto loop; } + + + #ifdef KBD101 + /* Well, MY keyboard doesn't return scancodes above 0x58, and the + original version of syscons reckons RCTR and RALT live up here. + In my world they share LCTR and LALT but with esc_flag set. + Here's a quick and-dirty hack to map a to b. */ + + if ( ((dt&0x7f)==0x1d/*LCTR*/) && (esc_flag)) + dt=((dt&0x80)|0x5a); /* RCTR */ + else + if (((dt&0x7f)==0x38/*LALT*/) && (esc_flag)) + dt=((dt&0x80)|0x5d);/*RALT*/ + #endif + esc_flag=0; + if ((dt & 0x7F) >= key_map.n_keys) goto loop; state = (shfts ? 1 : 0 ) | (2 * (ctls ? 1 : 0)) | (4 * (alts ? 1 : 0)); *************** *** 1287,1292 **** --- 1304,1310 ---- || ((key->flgs & FLAG_LOCK_N) && num)) state ^= 1; + /* Check for make/break */ action = key->map[state]; if (dt & 0x80) { *************** *** 1305,1310 **** --- 1323,1333 ---- case RCTR: ctls &= ~2; break; + #ifdef KBD101 + case META: + metas = 0x0; + break; + #endif case LALT: alts &= ~1; break; *************** *** 1344,1349 **** --- 1367,1377 ---- case RCTR: ctls |= 2; break; + #ifdef KBD101 + case META: + metas = 0x80; + break; + #endif case LALT: alts |= 1; break; *************** *** 1356,1367 **** break; } if (action >= F_FN && action <= L_FN) { return (action | FKEY); } ! return (action); } } ! else return (action); } goto loop; } --- 1384,1407 ---- break; } if (action >= F_FN && action <= L_FN) { + #ifdef KBD101 + return (action | FKEY) ^ metas; + #else return (action | FKEY); + #endif } ! #ifdef KBD101 ! return (action ^ metas); ! #else ! return action; ! #endif } } ! #ifdef KBD101 ! else return (action ^ metas ); ! #else ! else return action; ! #endif } goto loop; } *************** *** 1483,1486 **** } } ! #endif --- 1523,1527 ---- } } ! ! #endif -- Christopher J Biggs cjb@cs.uq.oz.au | "You can have peace, or you can Department of Computer Science, | have freedom. Don't ever count on The University of Queensland, Australia | having both..." -- Lazarus Long ------------veni vidi nuclei deceiri - I came, I saw, I dumped core------------