Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/1031/1

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Allow raw switch while reader is reading.
 [rsc] --rw-rw-r-- M 84748 glenda sys 22495 Oct 31 06:48 sys/src/9/port/devcons.c
	/n/sourcesdump/2005/1031/plan9/sys/src/9/port/devcons.c:962,977 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/port/devcons.c:962,973
	  		buf[n] = 0;
	  		for(a = buf; a;){
	  			if(strncmp(a, "rawon", 5) == 0){
	- 				qlock(&kbd);
	  				kbd.raw = 1;
	  				/* clumsy hack - wake up reader */
	  				ch = 0;
	  				qwrite(kbdq, &ch, 1);			
	- 				qunlock(&kbd);
	  			} else if(strncmp(a, "rawoff", 6) == 0){
	- 				qlock(&kbd);
	  				kbd.raw = 0;
	- 				qunlock(&kbd);
	  			} else if(strncmp(a, "ctlpon", 6) == 0){
	  				kbd.ctlpoff = 0;
	  			} else if(strncmp(a, "ctlpoff", 7) == 0){
 [rsc] --rw-rw-r-- M 84748 glenda sys 12382 Oct 31 14:52 sys/src/9/pc/kbd.c
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:6,11 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:6,13
	  #include	"io.h"
	  #include	"../port/error.h"
	  
	+ extern void mousetrack(int, int, int, int);
	+ 
	  enum {
	  	Data=		0x60,		/* data port */
	  
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:22,28 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:24,29
	  	Cmd=		0x64,		/* command port (write only) */
	  
	  	Spec=		0xF800,		/* Unicode private space */
	- 
	  	PF=		Spec|0x20,	/* num pad function key */
	  	View=		Spec|0x00,	/* view (shift window up) */
	  	KF=		0xF000,		/* function key (begin Unicode private space) */
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:34,39 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:35,41
	  	Num=		Spec|0x65,
	  	Middle=		Spec|0x66,
	  	Altgr=		Spec|0x67,
	+ 	Kmouse=		Spec|0x100,
	  	No=		0x00,		/* peter */
	  
	  	Home=		KF|13,
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:168,173 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:170,176
	  };
	  
	  int mouseshifted;
	+ int kbdbuttons;
	  
	  static Lock i8042lock;
	  static uchar ccc;
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:289,294 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:292,311
	  	return i;
	  }
	  
	+ struct {
	+ 	int esc1;
	+ 	int esc2;
	+ 	int alt;
	+ 	int altgr;
	+ 	int caps;
	+ 	int ctl;
	+ 	int num;
	+ 	int shift;
	+ 	int collecting;
	+ 	int nk;
	+ 	Rune kc[5];
	+ } kbscan;
	+ 
	  /*
	   *  keyboard interrupt
	   */
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:296,305 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:313,318
	  i8042intr(Ureg*, void*)
	  {
	  	int s, c, i;
	- 	static int esc1, esc2;
	- 	static int alt, altgr, caps, ctl, num, shift;
	- 	static int collecting, nk;
	- 	static Rune kc[5];
	  	int keyup;
	  
	  	/*
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:323,329 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:336,342
	  	 */
	  	if(s & Minready){
	  		if(auxputc != nil)
	- 			auxputc(c, shift);
	+ 			auxputc(c, kbscan.shift);
	  		return;
	  	}
	  
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:332,341 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:345,354
	  	 *  of a 3 character sequence (on the safari)
	  	 */
	  	if(c == 0xe0){
	- 		esc1 = 1;
	+ 		kbscan.esc1 = 1;
	  		return;
	  	} else if(c == 0xe1){
	- 		esc2 = 2;
	+ 		kbscan.esc2 = 2;
	  		return;
	  	}
	  
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:348,369 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:361,382
	  		return;
	  	}
	  
	- 	if(esc1){
	+ 	if(kbscan.esc1){
	  		c = kbtabesc1[c];
	- 		esc1 = 0;
	- 	} else if(esc2){
	- 		esc2--;
	+ 		kbscan.esc1 = 0;
	+ 	} else if(kbscan.esc2){
	+ 		kbscan.esc2--;
	  		return;
	- 	} else if(shift)
	+ 	} else if(kbscan.shift)
	  		c = kbtabshift[c];
	- 	else if(altgr)
	+ 	else if(kbscan.altgr)
	  		c = kbtabaltgr[c];
	- 	else if(ctl)
	+ 	else if(kbscan.ctl)
	  		c = kbtabctrl[c];
	  	else
	  		c = kbtab[c];
	  
	- 	if(caps && c<='z' && c>='a')
	+ 	if(kbscan.caps && c<='z' && c>='a')
	  		c += 'A' - 'a';
	  
	  	/*
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:372,389 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:385,410
	  	if(keyup){
	  		switch(c){
	  		case Latin:
	- 			alt = 0;
	+ 			kbscan.alt = 0;
	  			break;
	  		case Shift:
	- 			shift = 0;
	+ 			kbscan.shift = 0;
	  			mouseshifted = 0;
	  			break;
	  		case Ctrl:
	- 			ctl = 0;
	+ 			kbscan.ctl = 0;
	  			break;
	  		case Altgr:
	- 			altgr = 0;
	+ 			kbscan.altgr = 0;
	  			break;
	+ 		case Kmouse|1:
	+ 		case Kmouse|2:
	+ 		case Kmouse|3:
	+ 		case Kmouse|4:
	+ 		case Kmouse|5:
	+ 			kbdbuttons &= ~(1<<(c-Kmouse-1));
	+ 			mousetrack(0, 0, 0, TK2MS(MACHP(0)->ticks));
	+ 			break;
	  		}
	  		return;
	  	}
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:392,432 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:413,453
	   	 *  normal character
	  	 */
	  	if(!(c & (Spec|KF))){
	- 		if(ctl)
	- 			if(alt && c == Del)
	+ 		if(kbscan.ctl)
	+ 			if(kbscan.alt && c == Del)
	  				exit(0);
	- 		if(!collecting){
	+ 		if(!kbscan.collecting){
	  			kbdputc(kbdq, c);
	  			return;
	  		}
	- 		kc[nk++] = c;
	- 		c = latin1(kc, nk);
	+ 		kbscan.kc[kbscan.nk++] = c;
	+ 		c = latin1(kbscan.kc, kbscan.nk);
	  		if(c < -1)	/* need more keystrokes */
	  			return;
	  		if(c != -1)	/* valid sequence */
	  			kbdputc(kbdq, c);
	  		else	/* dump characters */
	- 			for(i=0; i<nk; i++)
	- 				kbdputc(kbdq, kc[i]);
	- 		nk = 0;
	- 		collecting = 0;
	+ 			for(i=0; i<kbscan.nk; i++)
	+ 				kbdputc(kbdq, kbscan.kc[i]);
	+ 		kbscan.nk = 0;
	+ 		kbscan.collecting = 0;
	  		return;
	  	} else {
	  		switch(c){
	  		case Caps:
	- 			caps ^= 1;
	+ 			kbscan.caps ^= 1;
	  			return;
	  		case Num:
	- 			num ^= 1;
	+ 			kbscan.num ^= 1;
	  			return;
	  		case Shift:
	- 			shift = 1;
	+ 			kbscan.shift = 1;
	  			mouseshifted = 1;
	  			return;
	  		case Latin:
	- 			alt = 1;
	+ 			kbscan.alt = 1;
	  			/*
	- 			 * VMware uses Ctl-Alt as the key combination
	+ 			 * VMware and Qemu use Ctl-Alt as the key combination
	  			 * to make the VM give up keyboard and mouse focus.
	  			 * This has the unfortunate side effect that when you
	  			 * come back into focus, Plan 9 thinks you want to type
	/n/sourcesdump/2005/1031/plan9/sys/src/9/pc/kbd.c:435,451 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/pc/kbd.c:456,480
	  			 * As a clumsy hack around this, we look for ctl-alt
	  			 * and don't treat it as the start of a compose sequence.
	  			 */
	- 			if(!ctl){
	- 				collecting = 1;
	- 				nk = 0;
	+ 			if(!kbscan.ctl){
	+ 				kbscan.collecting = 1;
	+ 				kbscan.nk = 0;
	  			}
	  			return;
	  		case Ctrl:
	- 			ctl = 1;
	+ 			kbscan.ctl = 1;
	  			return;
	  		case Altgr:
	- 			altgr = 1;
	- 			collecting = 0;
	+ 			kbscan.altgr = 1;
	+ 			kbscan.collecting = 0;
	+ 			return;
	+ 		case Kmouse|1:
	+ 		case Kmouse|2:
	+ 		case Kmouse|3:
	+ 		case Kmouse|4:
	+ 		case Kmouse|5:
	+ 			kbdbuttons |= 1<<(c-Kmouse-1);
	+ 			mousetrack(0, 0, 0, TK2MS(MACHP(0)->ticks));
	  			return;
	  		}
	  	}
 [rsc] --rw-rw-r-- M 84748 presotto sys 3064 Oct 31 08:04 sys/src/9/port/devkbmap.c
	/n/sourcesdump/2005/1031/plan9/sys/src/9/port/devkbmap.c:118,123 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/port/devkbmap.c:118,126
	  					lp = line;
	  					continue;
	  				}
	+ 				lp = line;
	+ 				while(*lp == ' ' || *lp == '\t')
	+ 					lp++;
	  				m = strtoul(line, &lp, 0);
	  				key = strtoul(lp, &lp, 0);
	  				while(*lp == ' ' || *lp == '\t')
	/n/sourcesdump/2005/1031/plan9/sys/src/9/port/devkbmap.c:125,130 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/port/devkbmap.c:128,141
	  				r = 0;
	  				if(*lp == '\'' && lp[1])
	  					chartorune(&r, lp+1);
	+ 				else if(*lp == '^' && lp[1]){
	+ 					chartorune(&r, lp+1);
	+ 					if(0x40 <= r && r < 0x60)
	+ 						r -= 0x40;
	+ 					else
	+ 						error(Ebadarg);
	+ 				}else if(*lp == 'M' && ('1' <= lp[1] && lp[1] <= '5'))
	+ 					r = 0xF900+lp[1]-'0';
	  				else if(*lp>='0' && *lp<='9') /* includes 0x... */
	  					r = strtoul(lp, &lp, 0);
	  				else
 [rsc] --rw-rw-r-- M 84748 glenda sys 13327 Oct 31 12:38 sys/src/9/port/devmouse.c
	/n/sourcesdump/2005/1031/plan9/sys/src/9/port/devmouse.c:38,43 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/port/devmouse.c:38,45
	  	int	track;		/* dx & dy updated */
	  	int	redraw;		/* update cursor on screen */
	  	ulong	lastcounter;	/* value when /dev/mouse read */
	+ 	ulong	lastresize;
	+ 	ulong	resize;
	  	Rendez	r;
	  	Ref;
	  	QLock;
	/n/sourcesdump/2005/1031/plan9/sys/src/9/port/devmouse.c:70,75 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/port/devmouse.c:72,78
	  Mouseinfo	mouse;
	  Cursorinfo	cursor;
	  int		mouseshifted;
	+ int		kbdbuttons;
	  Cursor		curs;
	  
	  void	Cursortocursor(Cursor*);
	/n/sourcesdump/2005/1031/plan9/sys/src/9/port/devmouse.c:163,168 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/port/devmouse.c:166,172
	  		}
	  		mouse.open = 1;
	  		mouse.ref++;
	+ 		mouse.lastresize = mouse.resize;
	  		unlock(&mouse);
	  		break;
	  	case Qmousein:
	/n/sourcesdump/2005/1031/plan9/sys/src/9/port/devmouse.c:286,291 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/port/devmouse.c:290,299
	  		mouse.lastcounter = m.counter;
	  		if(n > 1+4*12)
	  			n = 1+4*12;
	+ 		if(mouse.lastresize != mouse.resize){
	+ 			mouse.lastresize = mouse.resize;
	+ 			buf[0] = 'r';
	+ 		}
	  		memmove(va, buf, n);
	  		return n;
	  	}
	/n/sourcesdump/2005/1031/plan9/sys/src/9/port/devmouse.c:561,567 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/port/devmouse.c:569,575
	  
	  	lastb = mouse.buttons;
	  	mouse.xy = Pt(x, y);
	- 	mouse.buttons = b;
	+ 	mouse.buttons = b|kbdbuttons;
	  	mouse.redraw = 1;
	  	mouse.counter++;
	  	mouse.msec = msec;
	/n/sourcesdump/2005/1031/plan9/sys/src/9/port/devmouse.c:719,725 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/port/devmouse.c:727,734
	  int
	  mousechanged(void*)
	  {
	- 	return mouse.lastcounter != mouse.counter;
	+ 	return mouse.lastcounter != mouse.counter || 
	+ 		mouse.lastresize != mouse.resize;
	  }
	  
	  Point
	/n/sourcesdump/2005/1031/plan9/sys/src/9/port/devmouse.c:737,739 - 
	/n/sourcesdump/2005/1101/plan9/sys/src/9/port/devmouse.c:746,759
	  	else
	  		mouse.maxacc = mouse.acceleration;
	  }
	+ 
	+ /*
	+  * notify reader that screen has been resized
	+  */
	+ void
	+ mouseresize(void)
	+ {
	+ 	mouse.resize++;
	+ 	wakeup(&mouse.r);
	+ }
	+ 
 [rsc] --rw-rw-r-- M 84748 glenda sys 12382 Oct 31 14:52 sys/src/9/pc/kbd.c


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.