plan 9 kernel history: overview | file list | diff list

1992/1020/pc/kbd.c (diff list | history)

1992/1017/sys/src/9/pc/kbd.c:10,151992/1020/sys/src/9/pc/kbd.c:10,17 (short | long | prev | next)
1991/0731    
#include	<gnot.h> 
#include	"screen.h" 
 
1992/1020    
extern Mouseinfo mouse; 
 
1991/0702    
enum { 
	Data=		0x60,	/* data port */ 
 
1992/1017/sys/src/9/pc/kbd.c:109,1221992/1020/sys/src/9/pc/kbd.c:111,123
1991/0905    
 */ 
1991/0703    
KIOQ	kbdq; 
1991/0905    
 
1991/0911    
static int mousebuttons; 
1992/0811    
static int keybuttons; 
1992/1015    
static uchar ccc; 
1992/1017    
static int mousetype; 
static int mouseport; 
static int shift; 
1992/1020    
extern int mouseshifted; 
1991/0911    
 
1991/0905    
                 
1992/0904    
enum 
{ 
1992/1015    
	/* controller command byte */ 
1992/1017/sys/src/9/pc/kbd.c:135,1411992/1020/sys/src/9/pc/kbd.c:136,141
1991/0703    
 
1992/1017    
static void	kbdintr(Ureg*); 
static int	ps2mouseputc(IOQ*, int); 
static int	m3mouseputc(IOQ*, int); 
1992/1015    
 
1991/0803    
/* 
 *  wait for output no longer busy 
1992/1017/sys/src/9/pc/kbd.c:279,2841992/1020/sys/src/9/pc/kbd.c:279,287
1992/1016    
	if(mousetype) 
1992/1017    
		error(Emouseset); 
1992/0811    
 
1992/1020    
	if(port >= 2 || port < 0) 
		error(Ebadarg); 
 
1992/0904    
	/* set up /dev/eia0 as the mouse */ 
1992/1017    
	uartspecial(port, 0, &mouseq, setspeed ? 1200 : 0); 
	if(type && *type == 'M') 
1992/1017/sys/src/9/pc/kbd.c:338,3441992/1020/sys/src/9/pc/kbd.c:341,346
1991/0731    
	static short msg[3]; 
	static int nb; 
1992/0918    
	static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 5, 2, 3, 6, 7 }; 
1991/0731    
	extern Mouseinfo mouse; 
 
1992/1015    
	USED(q);		/* not */ 
1991/0731    
	/*  
1992/1017/sys/src/9/pc/kbd.c:355,3621992/1020/sys/src/9/pc/kbd.c:357,363
1991/0731    
		if(msg[0] & 0x20) 
			msg[2] |= 0xFF00; 
 
1992/0918    
		mousebuttons = b[(msg[0]&7) | (shift ? 8 : 0)]; 
1992/0811    
		mouse.newbuttons = mousebuttons | keybuttons; 
1992/1020    
		mouse.newbuttons = b[(msg[0]&7) | (shift ? 8 : 0)] | keybuttons; 
1991/0731    
		mouse.dx = msg[1]; 
		mouse.dy = -msg[2]; 
		mouse.track = 1; 
1992/1017/sys/src/9/pc/kbd.c:367,4201992/1020/sys/src/9/pc/kbd.c:368,373
1991/0703    
} 
 
/* 
1992/1017    
 *  microsoft 3 button, 7 bit bytes 
 * 
 *	byte 0 -	1  L  R Y7 Y6 X7 X6 
 *	byte 1 -	0 X5 X4 X3 X2 X1 X0 
 *	byte 2 -	0 Y5 Y4 Y3 Y2 Y1 Y0 
 *	byte 3 -	0  M  x  x  x  x  x	(optional) 
 * 
 *  shift & left button is the same as middle button (for 2 button mice) 
 */ 
static int 
m3mouseputc(IOQ *q, int c) 
{ 
	static uchar msg[3]; 
	static int nb; 
	static uchar b[] = { 0, 4, 1, 5, 0, 4, 3, 7 }; 
	extern Mouseinfo mouse; 
                 
	USED(q);		/* not */ 
                 
	/*  
	 *  check bit 6 for consistency 
	 */ 
	if(nb==0){ 
		if((c&0x40) != 0){ 
			/* must be 4th (M button) byte */ 
			mousebuttons = (mousebuttons & ~Mbutton) | ((c&0x2)?Mbutton:0); 
			mouse.newbuttons = mousebuttons | keybuttons; 
			mouse.dx = 0; 
			mouse.dy = 0; 
			mouse.track = 0; 
			mouseclock(); 
			return 0; 
		} 
	} 
	msg[nb] = c; 
	if(++nb == 3){ 
		nb = 0; 
		mousebuttons = b[(msg[0]>>4)&3 | (shift ? 4 : 0)]; 
		mouse.newbuttons = mousebuttons | keybuttons; 
		mouse.dx = (((msg[0]&3)<<7) | msg[1]) - 128; 
		mouse.dy = (((msg[0]&0xc)<<5) | msg[2]) - 128; 
		mouse.track = 1; 
		mouseclock(); 
	} 
	return 0; 
} 
                 
/* 
 *  set/change mouse configuration 
 */ 
void 
1992/1017/sys/src/9/pc/kbd.c:424,4361992/1020/sys/src/9/pc/kbd.c:377,395
1992/1017    
	char *field[3]; 
 
	n = getfields(arg, field, 3, ' '); 
	if(n < 1) 
		return; 
	if(strncmp(field[0], "serial", 6) == 0){ 
		if(n > 1) 
			serialmouse(atoi(field[1]), field[2], 0); 
		else 
1992/1020    
		switch(n){ 
		case 1: 
1992/1017    
			serialmouse(atoi(field[0]+6), 0, 1); 
1992/1020    
			break; 
		case 2: 
			serialmouse(atoi(field[1]), 0, 0); 
			break; 
		case 3: 
		default: 
			serialmouse(atoi(field[1]), field[2], 0); 
			break; 
		} 
1992/1017    
	} else if(strcmp(field[0], "ps2") == 0){ 
		ps2mouse(); 
	} else if(strcmp(field[0], "accelerated") == 0){ 
1992/1017/sys/src/9/pc/kbd.c:472,4941992/1020/sys/src/9/pc/kbd.c:431,443
1992/0811    
mbon(int val) 
1991/0911    
{ 
1992/0811    
	keybuttons |= val; 
	mouse.newbuttons = mousebuttons | keybuttons; 
1991/0911    
	mouse.dx = 0; 
	mouse.dy = 0; 
	mouse.track = 1; 
	spllo();		/* mouse tracking kills uart0 */ 
	mouseclock(); 
1992/1020    
	mousebuttons(keybuttons); 
1991/0911    
} 
1992/0811    
static void 
mboff(int val) 
{ 
	keybuttons &= ~val; 
	mouse.newbuttons = mousebuttons | keybuttons; 
	mouse.dx = 0; 
	mouse.dy = 0; 
	mouse.track = 1; 
	spllo();		/* mouse tracking kills uart0 */ 
	mouseclock(); 
1992/1020    
	mousebuttons(keybuttons); 
1992/0811    
} 
1991/0911    
 
/* 
1992/1017/sys/src/9/pc/kbd.c:564,5701992/1020/sys/src/9/pc/kbd.c:513,519
1991/0703    
	if(keyup){ 
		switch(c){ 
		case Shift: 
			shift = 0; 
1992/1020    
			mouseshifted = shift = 0; 
1991/0703    
			break; 
		case Ctrl: 
			ctl = 0; 
1992/1017/sys/src/9/pc/kbd.c:631,6371992/1020/sys/src/9/pc/kbd.c:580,586
1991/0703    
			num ^= 1; 
1991/0731    
			return 0; 
1991/0703    
		case Shift: 
			shift = 1; 
1992/1020    
			mouseshifted = shift = 1; 
1991/0731    
			return 0; 
1991/0703    
		case Latin: 
			lstate = 1; 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)