*BSD News Article 8315


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!news.hawaii.edu!ames!sun-barr!olivea!uunet!kithrup!sef
From: sef@kithrup.COM (Sean Eric Fagan)
Newsgroups: comp.unix.bsd
Subject: Re: [386BSD] Enhanced pccons w/source
Keywords: virtual screens, changeable keymap, SYSV386 ioctl's ....
Message-ID: <1992Nov29.220238.5719@kithrup.COM>
Date: 29 Nov 92 22:02:38 GMT
References: <kmdac.722774624@login.dkuug.dk>
Organization: Kithrup Enterprises, Ltd.
Lines: 231

Here is a set of diffs to the enhanced pccons.  It fixes a couple of bugs
that made it impossible to compile, and also adds the ability to specify
some useful key values (such as control-2 being 0x00).  Note that the change
for the latter increases the size of the table, by turning the array of
u_char's into an array of u_shorts.  We've been using this for a while, and
haven't had too many problems (none that I thought were related to my
changes).

It's so *nice* to have multiscreens(tm) again! :)

*** console.h	Wed Nov 25 15:26:56 1992
--- /sys/sys/console.h	Sat Nov 28 04:30:52 1992
***************
*** 63,69 ****
  struct keymap {
  	u_short	n_keys;
  	struct key_t {
! 		u_char map[NUM_STATES];
  		u_char spcl;
  		u_char flgs;
  	} key[NUM_KEYS];
--- 63,69 ----
  struct keymap {
  	u_short	n_keys;
  	struct key_t {
! 		u_short map[NUM_STATES];
  		u_char spcl;
  		u_char flgs;
  	} key[NUM_KEYS];
***************
*** 79,94 ****
  
  #define F(x)		((x)+F_FN-1)
  #define	S(x)		((x)+F_SCR-1)
! #define NOP		0x00
! #define LSH		0x02
! #define RSH		0x03
! #define CLK		0x04
! #define NLK		0x05
! #define SLK		0x06
! #define LALT		0x07
! #define LCTR		0x09
! #define RCTR		0x7b
! #define RALT		0x7c
  
  #define F_SCR		11	/* switch to first screen */
  #define L_SCR		26	/* switch to last screen */
--- 79,94 ----
  
  #define F(x)		((x)+F_FN-1)
  #define	S(x)		((x)+F_SCR-1)
! #define NOP		0x0101
! #define LSH		0x0200
! #define RSH		0x0300
! #define CLK		0x0400
! #define NLK		0x0500
! #define SLK		0x0600
! #define LALT		0x0700
! #define LCTR		0x0900
! #define RCTR		0x7b00
! #define RALT		0x7c00
  
  #define F_SCR		11	/* switch to first screen */
  #define L_SCR		26	/* switch to last screen */
*** kbdtables.h	Wed Nov 25 23:12:42 1992
--- /sys/i386/isa/kbdtables.h	Fri Nov 27 21:30:47 1992
***************
*** 141,147 ****
  /* sc=00 */  NOP,   NOP,   NOP,   NOP,   NOP,   NOP,   NOP,   NOP,  0xFF, 0x00,
  /* sc=01 */ 0x1B,  0x1B,   NOP,   NOP,  0x1B,  0x1B,   NOP,   NOP,  0x33, 0x00,
  /* sc=02 */  '1',   '!',   NOP,   NOP,   '1',   '!',   NOP,   NOP,  0x33, 0x00,
! /* sc=03 */  '2',   '@',   NOP,   NOP,   '2',   '@',   NOP,   NOP,  0x00, 0x00,
  /* sc=04 */  '3',   '#',   NOP,   NOP,   '3',   '#',   NOP,   NOP,  0x33, 0x00,
  /* sc=05 */  '4',   '$',   NOP,   NOP,   '4',   '$',   NOP,   NOP,  0x33, 0x00,
  /* sc=06 */  '5',   '%',   NOP,   NOP,   '5',   '%',   NOP,   NOP,  0x33, 0x00,
--- 141,147 ----
  /* sc=00 */  NOP,   NOP,   NOP,   NOP,   NOP,   NOP,   NOP,   NOP,  0xFF, 0x00,
  /* sc=01 */ 0x1B,  0x1B,   NOP,   NOP,  0x1B,  0x1B,   NOP,   NOP,  0x33, 0x00,
  /* sc=02 */  '1',   '!',   NOP,   NOP,   '1',   '!',   NOP,   NOP,  0x33, 0x00,
! /* sc=03 */  '2',   '@',  0x00,  0x00,   '2',   '@',   NOP,   NOP,  0x00, 0x00,
  /* sc=04 */  '3',   '#',   NOP,   NOP,   '3',   '#',   NOP,   NOP,  0x33, 0x00,
  /* sc=05 */  '4',   '$',   NOP,   NOP,   '4',   '$',   NOP,   NOP,  0x33, 0x00,
  /* sc=06 */  '5',   '%',   NOP,   NOP,   '5',   '%',   NOP,   NOP,  0x33, 0x00,
***************
*** 151,158 ****
  /* sc=0a */  '9',   '(',   NOP,   NOP,   '9',   '(',   NOP,   NOP,  0x33, 0x00,
  /* sc=0b */  '0',   ')',   NOP,   NOP,   '0',   ')',   NOP,   NOP,  0x33, 0x00,
  /* sc=0c */  '-',   '_',  0x1F,  0x1F,   '-',   '_',  0x1F,  0x1F,  0x00, 0x00,
! /* sc=0d */  '='',  '+',   NOP,   NOP,   '=',   '+',   NOP,   NOP,  0x33, 0x00,
! /* sc=0e */ 0x08,  0x08,  0x7F,  0x7F,  0x08,  0x08,  0x7F,  0x7F,  0x00, 0x00,
  /* sc=0f */ 0x09,  0x08,   NOP,   NOP,  0x09,  0x08,   NOP,   NOP,  0x77, 0x00,
  /* sc=10 */  'q',   'Q',  0x11,  0x11,   'q',   'Q',  0x11,  0x11,  0x00, 0x01,
  /* sc=11 */  'w',   'W',  0x17,  0x17,   'w',   'W',  0x17,  0x17,  0x00, 0x01,
--- 151,158 ----
  /* sc=0a */  '9',   '(',   NOP,   NOP,   '9',   '(',   NOP,   NOP,  0x33, 0x00,
  /* sc=0b */  '0',   ')',   NOP,   NOP,   '0',   ')',   NOP,   NOP,  0x33, 0x00,
  /* sc=0c */  '-',   '_',  0x1F,  0x1F,   '-',   '_',  0x1F,  0x1F,  0x00, 0x00,
! /* sc=0d */  '=',   '+',   NOP,   NOP,   '=',   '+',   NOP,   NOP,  0x33, 0x00,
! /* sc=0e */ 0x7F,  0x7F,  0x08,  0x08,  0x7F,  0x7F,  0x08,  0x08,  0x00, 0x00,
  /* sc=0f */ 0x09,  0x08,   NOP,   NOP,  0x09,  0x08,   NOP,   NOP,  0x77, 0x00,
  /* sc=10 */  'q',   'Q',  0x11,  0x11,   'q',   'Q',  0x11,  0x11,  0x00, 0x01,
  /* sc=11 */  'w',   'W',  0x17,  0x17,   'w',   'W',  0x17,  0x17,  0x00, 0x01,
***************
*** 178,184 ****
  /* sc=25 */  'k',   'K',  0x0B,  0x0B,   'k',   'K',  0x0B,  0x0B,  0x00, 0x01,
  /* sc=26 */  'l',   'L',  0x0C,  0x0C,   'l',   'L',  0x0C,  0x0C,  0x00, 0x01,
  /* sc=27 */  ';',   ':',   NOP,   NOP,   ';',   ':',   NOP,   NOP,  0x33, 0x00,
! /* sc=28 */  '\'',  '"',   NOP,   NOP,   ''\',  '"',   NOP,   NOP,  0x33, 0x00,
  /* sc=29 */  '`',   '~',   NOP,   NOP,   '`',   '~',   NOP,   NOP,  0x33, 0x00,
  /* sc=2a */  LSH,   LSH,   LSH,   LSH,   LSH,   LSH,   LSH,   LSH,  0xFF, 0x00,
  /* sc=2b */  '\\',  '|',  0x1C,  0x1C,   '\\',  '|',  0x1C,  0x1C,  0x00, 0x00,
--- 178,184 ----
  /* sc=25 */  'k',   'K',  0x0B,  0x0B,   'k',   'K',  0x0B,  0x0B,  0x00, 0x01,
  /* sc=26 */  'l',   'L',  0x0C,  0x0C,   'l',   'L',  0x0C,  0x0C,  0x00, 0x01,
  /* sc=27 */  ';',   ':',   NOP,   NOP,   ';',   ':',   NOP,   NOP,  0x33, 0x00,
! /* sc=28 */  '\'',  '"',   NOP,   NOP,   '\'',   '"',   NOP,   NOP,  0x33, 0x00,
  /* sc=29 */  '`',   '~',   NOP,   NOP,   '`',   '~',   NOP,   NOP,  0x33, 0x00,
  /* sc=2a */  LSH,   LSH,   LSH,   LSH,   LSH,   LSH,   LSH,   LSH,  0xFF, 0x00,
  /* sc=2b */  '\\',  '|',  0x1C,  0x1C,   '\\',  '|',  0x1C,  0x1C,  0x00, 0x00,
*** pccons.c	Wed Nov 25 15:57:44 1992
--- /sys/i386/isa/pccons.c	Sat Nov 28 04:40:09 1992
***************
*** 196,202 ****
  void reset_cpu(void);
  u_int sgetc(int noblock);
  int pg(char *p, int q, int r, int s, int t, int u, int v, int w, int x, int y, int z);
! static int getchar(void);
  int pcmmap(dev_t dev, int offset, int nprot);
  static void set_mode(int mode);
  static load_font(int segment, struct vidfont_t *font);
--- 196,202 ----
  void reset_cpu(void);
  u_int sgetc(int noblock);
  int pg(char *p, int q, int r, int s, int t, int u, int v, int w, int x, int y, int z);
! /*static*/ int getchar(void);
  int pcmmap(dev_t dev, int offset, int nprot);
  static void set_mode(int mode);
  static load_font(int segment, struct vidfont_t *font);
***************
*** 1219,1225 ****
  
  	if ((dt & 0x7F) >= key_map.n_keys)
  		goto loop;
! 	state = shfts | 2 * ctls | 4 * alts;
  	key = &key_map.key[dt & 0x7F];
  	if (((key->flgs & FLAG_LOCK_C) && caps)
  	    || ((key->flgs & FLAG_LOCK_N) && num))
--- 1219,1225 ----
  
  	if ((dt & 0x7F) >= key_map.n_keys)
  		goto loop;
! 	state = (shfts ? 1 : 0 ) | 2 * ctls | 4 * alts;
  	key = &key_map.key[dt & 0x7F];
  	if (((key->flgs & FLAG_LOCK_C) && caps)
  	    || ((key->flgs & FLAG_LOCK_N) && num))
***************
*** 1226,1239 ****
  		state ^= 1;
  
  	/* Check for make/break */
! 	if (action = key->map[state]) {
  		if (dt & 0x80) {
  			/* break */
  			if (key->spcl & 0x80) {
  				switch (action) {
  				case LSH:
  				case RSH:
! 					shfts = 0;
  					break;
  				case LCTR:
  				case RCTR:
--- 1226,1241 ----
  		state ^= 1;
  
  	/* Check for make/break */
! 	if ((action = key->map[state]) != NOP) {
  		if (dt & 0x80) {
  			/* break */
  			if (key->spcl & 0x80) {
  				switch (action) {
  				case LSH:
+ 					shfts &= ~1;
+ 					break;
  				case RSH:
! 					shfts &= ~2;
  					break;
  				case LCTR:
  				case RCTR:
***************
*** 1265,1272 ****
  		
  				/* NON-LOCKING KEYS */
  				case LSH:
  				case RSH:
! 					shfts = 1;
  					break;
  				case LCTR:
  				case RCTR:
--- 1267,1276 ----
  		
  				/* NON-LOCKING KEYS */
  				case LSH:
+ 					shfts |= 1;
+ 					break;
  				case RSH:
! 					shfts |= 2;
  					break;
  				case LCTR:
  				case RCTR:
***************
*** 1302,1308 ****
  }
  
  
! static int getchar()
  {
  	register char thechar;
  	register delay;
--- 1306,1312 ----
  }
  
  
! /*static*/ int getchar()
  {
  	register char thechar;
  	register delay;
-- 
Sean Eric Fagan  | "we will probably just crash immediately; but at least
sef@kithrup.COM  |  we will have written less code."
-----------------+                 -- Chris Torek (torek@ee.lbl.gov)
Any opinions expressed are my own, and generally unpopular with others.