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

port/devmouse.c (diff list | history)

1993/1006/sys/src/9/port/devmouse.c:251,2571993/1008/sys/src/9/port/devmouse.c:251,257 (short | long)
1993/1006    
long 
mouseread(Chan *c, void *va, long n, ulong offset) 
{ 
	uchar *p; 
1993/1008    
	char buf[4*12+1]; 
1993/1006    
 
	USED(offset); 
	if(c->qid.path & CHDIR) 
1993/1006/sys/src/9/port/devmouse.c:258,2841993/1008/sys/src/9/port/devmouse.c:258,275
1993/1006    
		return devdirread(c, va, n, mousedir, NMOUSE, devgen); 
 
	if(c->qid.path == Qmouse){ 
		/* 
		 * mouse: 
		 *	'm'		1 
		 *	buttons		1 
		 * 	point		8 
		 * 	msec		4 
		 */ 
		if(n < 14) 
			error(Eshort); 
		while(mousechanged(0) == 0) 
			sleep(&mouse.r, mousechanged, 0); 
		lock(&cursor); 
		p = va; 
		p[0] = 'm'; 
		p[1] = mouse.buttons; 
		BPLONG(p+2, mouse.xy.x); 
		BPLONG(p+6, mouse.xy.y); 
		BPLONG(p+10, TK2MS(MACHP(0)->ticks)); 
1993/1008    
		sprint(buf, "%11d %11d %11d %11d", 
			mouse.xy.x, mouse.xy.y, mouse.buttons, 
			TK2MS(MACHP(0)->ticks)); 
1993/1006    
		mouse.lastcounter = mouse.counter; 
		unlock(&cursor); 
		return 14; 
1993/1008    
		if(n > 4*12) 
			n = 4*12; 
		memmove(va, buf, n); 
		return n; 
1993/1006    
	} 
	return 0; 
} 
1993/1006/sys/src/9/port/devmouse.c:286,2921993/1008/sys/src/9/port/devmouse.c:277,283
1993/1006    
long 
mousewrite(Chan *c, void *va, long n, ulong offset) 
{ 
	uchar *p; 
1993/1008    
	char *p; 
1993/1006    
	Point pt; 
	char buf[64]; 
 
1993/1006/sys/src/9/port/devmouse.c:305,3161993/1008/sys/src/9/port/devmouse.c:296,311
1993/1006    
		return n; 
 
	case Qmouse: 
		if(n != 9) 
1993/1008    
		if(n > sizeof buf-1) 
			n = sizeof buf -1; 
		memmove(buf, va, n); 
		buf[n] = 0; 
		p = 0; 
		pt.x = strtoul(buf, &p, 0); 
		if(p == 0) 
1993/1006    
			error(Eshort); 
1993/1008    
		pt.y = strtoul(p, 0, 0); 
1993/1006    
		qlock(&mouse); 
		p = va; 
		pt.x = BGLONG(p+1); 
		pt.y = BGLONG(p+5); 
		if(ptinrect(pt, gscreen.r)){ 
			mouse.xy = pt; 
			mouse.redraw = 1; 
1993/1008/sys/src/9/port/devmouse.c:62,671993/1009/sys/src/9/port/devmouse.c:62,68 (short | long)
1993/1006    
int		mouseshifted; 
int		mousetype; 
int		hwcurs; 
1993/1009    
Cursor	curs; 
1993/1006    
 
Cursor	arrow = 
{ 
1993/1008/sys/src/9/port/devmouse.c:116,1261993/1009/sys/src/9/port/devmouse.c:117,129
1993/1006    
 
enum{ 
	Qdir, 
1993/1009    
	Qcursor, 
1993/1006    
	Qmouse, 
	Qmousectl, 
}; 
 
Dirtab mousedir[]={ 
1993/1009    
	"cursor",	{Qcursor},	0,			0666, 
1993/1006    
	"mouse",	{Qmouse},	0,			0666, 
	"mousectl",	{Qmousectl},	0,			0220, 
}; 
1993/1008/sys/src/9/port/devmouse.c:141,1461993/1009/sys/src/9/port/devmouse.c:144,150
1993/1006    
	if(r == 0) 
		flipping = 1; 
	flipping = 0;	/* howard, why is this necessary to get a black arrow on carrera? */ 
1993/1009    
	curs = arrow; 
1993/1006    
	Cursortocursor(&arrow); 
} 
 
1993/1008/sys/src/9/port/devmouse.c:244,2491993/1009/sys/src/9/port/devmouse.c:248,259
1993/1006    
		lock(&mouse); 
		if(c->qid.path == Qmouse) 
			mouse.open = 0; 
1993/1009    
		if(--mouse.ref == 0){ 
			cursoroff(1); 
			curs = arrow; 
			Cursortocursor(&arrow); 
			cursoron(1); 
		} 
1993/1006    
		unlock(&mouse); 
	} 
} 
1993/1008/sys/src/9/port/devmouse.c:252,2631993/1009/sys/src/9/port/devmouse.c:262,289
1993/1006    
mouseread(Chan *c, void *va, long n, ulong offset) 
{ 
1993/1008    
	char buf[4*12+1]; 
1993/1009    
	uchar *p; 
1993/1006    
 
	USED(offset); 
	if(c->qid.path & CHDIR) 
1993/1009    
	p = va; 
	switch(c->qid.path){ 
	case CHDIR: 
1993/1006    
		return devdirread(c, va, n, mousedir, NMOUSE, devgen); 
 
	if(c->qid.path == Qmouse){ 
1993/1009    
	case Qcursor: 
		if(offset != 0) 
			return 0; 
		if(n < 2*4+2*2*16) 
			error(Eshort); 
		n = 2*4+2*2*16; 
		lock(&cursor); 
		BPLONG(p+0, curs.offset.x); 
		BPLONG(p+4, curs.offset.y); 
		memmove(p+8, curs.clr, 2*16); 
		memmove(p+40, curs.set, 2*16); 
		unlock(&cursor); 
		return n; 
 
	case Qmouse: 
1993/1006    
		while(mousechanged(0) == 0) 
			sleep(&mouse.r, mousechanged, 0); 
		lock(&cursor); 
1993/1008/sys/src/9/port/devmouse.c:281,2911993/1009/sys/src/9/port/devmouse.c:307,332
1993/1006    
	Point pt; 
	char buf[64]; 
 
	USED(offset); 
                 
1993/1009    
	p = va; 
1993/1006    
	switch(c->qid.path){ 
	case CHDIR: 
		error(Eisdir); 
1993/1009    
 
	case Qcursor: 
		cursoroff(1); 
		if(n < 2*4+2*2*16){ 
			curs = arrow; 
			Cursortocursor(&arrow); 
		}else{ 
			n = 2*4+2*2*16; 
			curs.offset.x = BGLONG(p+0); 
			curs.offset.y = BGLONG(p+4); 
			memmove(curs.clr, p+8, 2*16); 
			memmove(curs.set, p+40, 2*16); 
			Cursortocursor(&curs); 
		} 
		cursoron(1); 
		return n; 
1993/1006    
 
	case Qmousectl: 
		if(n >= sizeof(buf)) 
1993/1009/sys/src/9/port/devmouse.c:54,591993/1026/sys/src/9/port/devmouse.c:54,60 (short | long)
1993/1006    
	Lock; 
	int	visible;	/* on screen */ 
	int	disable;	/* from being used */ 
1993/1026    
	int	frozen;	/* from being used */ 
1993/1006    
	Rectangle r;		/* location */ 
}; 
 
1993/1009/sys/src/9/port/devmouse.c:379,3841993/1026/sys/src/9/port/devmouse.c:380,412
1993/1006    
	} 
	if(hwcurs) 
		hwcursset(set.base, clr.base, cursor.offset.x, cursor.offset.y); 
1993/1026    
	unlock(&cursor); 
} 
 
void 
cursorlock(Rectangle r) 
{ 
	if(hwcurs) 
		return; 
	lock(&cursor); 
	if(rectXrect(cursor.r, r)){ 
		cursoroff(0); 
		cursor.frozen = 1; 
	} 
	cursor.disable++; 
	unlock(&cursor); 
} 
 
void 
cursorunlock(void) 
{ 
	if(hwcurs) 
		return; 
	lock(&cursor); 
	cursor.disable--; 
	if(cursor.frozen) 
		cursoron(0); 
	cursor.frozen = 0; 
1993/1006    
	unlock(&cursor); 
} 
 
1993/1026/sys/src/9/port/devmouse.c:326,3311993/1108/sys/src/9/port/devmouse.c:326,335 (short | long)
1993/1009    
			memmove(curs.set, p+40, 2*16); 
			Cursortocursor(&curs); 
		} 
1993/1108    
		qlock(&mouse); 
		mouse.redraw = 1; 
		mouseclock(); 
		qunlock(&mouse); 
1993/1009    
		cursoron(1); 
		return n; 
1993/1006    
 
1993/1108/sys/src/9/port/devmouse.c:516,5221993/1201/sys/src/9/port/devmouse.c:516,522 (short | long)
1993/1006    
 *  shift & right button is the same as middle button (for 2 button mice) 
 */ 
int 
m3mouseputc(IOQ *q, int c) 
1993/1201    
m3mouseputc(int c) 
1993/1006    
{ 
	static uchar msg[3]; 
	static int nb; 
1993/1108/sys/src/9/port/devmouse.c:525,5311993/1201/sys/src/9/port/devmouse.c:525,530
1993/1006    
	short x; 
	int dx, dy, newbuttons; 
 
	USED(q); 
	/*  
	 *  check bit 6 for consistency 
	 */ 
1993/1108/sys/src/9/port/devmouse.c:557,5631993/1201/sys/src/9/port/devmouse.c:556,562
1993/1006    
 *  shift & right button is the same as middle button (for 2 button mice) 
 */ 
int 
mouseputc(IOQ *q, int c) 
1993/1201    
mouseputc(int c) 
1993/1006    
{ 
	static short msg[5]; 
	static int nb; 
1993/1108/sys/src/9/port/devmouse.c:564,5701993/1201/sys/src/9/port/devmouse.c:563,568
1993/1006    
	static uchar b[] = {0, 4, 2, 6, 1, 5, 3, 7, 0, 2, 2, 6, 1, 5, 3, 7}; 
	int dx, dy, newbuttons; 
 
	USED(q); 
	if((c&0xF0) == 0x80) 
		nb=0; 
	msg[nb] = c; 
1993/1201/sys/src/9/port/devmouse.c:8,131994/0210/sys/src/9/port/devmouse.c:8,14 (short | long)
1993/1006    
#include	"../port/error.h" 
 
#include	"devtab.h" 
1994/0210    
#include	"screen.h" 
1993/1006    
 
/* 
 * Some monochrome screens are reversed from what we like: 
1994/0210/sys/src/9/port/devmouse.c:63,681994/0216/sys/src/9/port/devmouse.c:63,69 (short | long)
1993/1006    
Cursorinfo	cursor; 
int		mouseshifted; 
int		mousetype; 
1994/0216    
int		mouseswap; 
1993/1006    
int		hwcurs; 
1993/1009    
Cursor	curs; 
1993/1006    
 
1994/0210/sys/src/9/port/devmouse.c:260,2701994/0216/sys/src/9/port/devmouse.c:261,273
1993/1006    
	} 
} 
 
1994/0216    
 
1993/1006    
long 
mouseread(Chan *c, void *va, long n, ulong offset) 
{ 
1993/1008    
	char buf[4*12+1]; 
1993/1009    
	uchar *p; 
1994/0216    
	static int map[8] = {0, 4, 2, 6, 1, 5, 3, 7 }; 
1993/1006    
 
1993/1009    
	p = va; 
	switch(c->qid.path){ 
1994/0210/sys/src/9/port/devmouse.c:290,2961994/0216/sys/src/9/port/devmouse.c:293,300
1993/1006    
			sleep(&mouse.r, mousechanged, 0); 
		lock(&cursor); 
1993/1008    
		sprint(buf, "%11d %11d %11d %11d", 
			mouse.xy.x, mouse.xy.y, mouse.buttons, 
1994/0216    
			mouse.xy.x, mouse.xy.y, 
			mouseswap ? map[mouse.buttons&7] : mouse.buttons, 
1993/1008    
			TK2MS(MACHP(0)->ticks)); 
1993/1006    
		mouse.lastcounter = mouse.counter; 
		unlock(&cursor); 
1994/0216/sys/src/9/port/devmouse.c:313,3181994/0325/sys/src/9/port/devmouse.c:313,319 (short | long)
1993/1006    
	Point pt; 
	char buf[64]; 
 
1994/0325    
	USED(offset); 
1993/1009    
	p = va; 
1993/1006    
	switch(c->qid.path){ 
	case CHDIR: 
1994/0325/sys/src/9/port/devmouse.c:115,1231994/0412/sys/src/9/port/devmouse.c:115,137 (short | long)
1993/1006    
	{0, 0, 16, 16} 
}; 
 
1994/0412    
ulong cursorworkbits[16*4]; 
GBitmap cursorwork = 
{ 
	cursorworkbits, 
	0, 
	1, 
	0, 
	{0, 0, 16, 16}, 
	{0, 0, 16, 16} 
}; 
 
1993/1006    
void	Cursortocursor(Cursor*); 
int	mousechanged(void*); 
 
1994/0412    
extern	void	screenload(Rectangle, uchar*, int, int, int); 
extern	void	screenunload(Rectangle, uchar*, int, int, int); 
 
1993/1006    
enum{ 
	Qdir, 
1993/1009    
	Qcursor, 
1994/0325/sys/src/9/port/devmouse.c:156,1661994/0412/sys/src/9/port/devmouse.c:170,183
1993/1006    
{ 
	if(!conf.monitor) 
		return; 
	if(gscreen.ldepth > 3) 
1994/0412    
	if(gscreen.ldepth > 3){ 
1993/1006    
		cursorback.ldepth = 0; 
	else{ 
1994/0412    
		cursorwork.ldepth = 0; 
	}else{ 
1993/1006    
		cursorback.ldepth = gscreen.ldepth; 
		cursorback.width = ((16 << gscreen.ldepth) + 31) >> 5; 
1994/0412    
		cursorwork.ldepth = gscreen.ldepth; 
		cursorwork.width = ((16 << gscreen.ldepth) + 31) >> 5; 
1993/1006    
	} 
	cursoron(1); 
} 
1994/0325/sys/src/9/port/devmouse.c:434,4451994/0412/sys/src/9/port/devmouse.c:451,465
1993/1006    
			cursor.r.min = mouse.xy; 
			cursor.r.max = add(mouse.xy, Pt(16, 16)); 
			cursor.r = raddp(cursor.r, cursor.offset); 
			gbitblt(&cursorback, Pt(0, 0), &gscreen, cursor.r, S); 
			gbitblt(&gscreen, cursor.r.min, 
1994/0412    
			screenunload(cursor.r, (uchar*)cursorworkbits, 
				(16>>3) << gscreen.ldepth, cursorwork.width*BY2WD, 0); 
			memmove(cursorbackbits, cursorworkbits, 16*cursorback.width*BY2WD); 
			gbitblt(&cursorwork, cursorwork.r.min, 
1993/1006    
				&clr, Rect(0, 0, 16, 16), flipping? flipD[D&~S] : D&~S); 
			gbitblt(&gscreen, cursor.r.min, 
1994/0412    
			gbitblt(&cursorwork, cursorwork.r.min, 
1993/1006    
				&set, Rect(0, 0, 16, 16), flipping? flipD[S|D] : S|D); 
			mbbrect(cursor.r); 
1994/0412    
			screenload(cursor.r, (uchar*)cursorworkbits, 
				(16>>3) << gscreen.ldepth, cursorwork.width*BY2WD, 0); 
1993/1006    
		} 
	} 
	if(dolock) 
1994/0325/sys/src/9/port/devmouse.c:454,4641994/0412/sys/src/9/port/devmouse.c:474,482
1993/1006    
	if(dolock) 
		lock(&cursor); 
	if(--cursor.visible == 0) { 
		if(!hwcurs) { 
			gbitblt(&gscreen, cursor.r.min, &cursorback, Rect(0, 0, 16, 16), S); 
			mbbrect(cursor.r); 
			mousescreenupdate(); 
		} 
1994/0412    
		if(!hwcurs) 
			screenload(cursor.r, (uchar*)cursorbackbits, 
				(16>>3) << gscreen.ldepth, cursorback.width*BY2WD, 0); 
1993/1006    
	} 
	if(dolock) 
		unlock(&cursor); 
1994/0325/sys/src/9/port/devmouse.c:480,4861994/0412/sys/src/9/port/devmouse.c:498,503
1993/1006    
		mouse.redraw = 0; 
		cursoroff(0); 
		cursoron(0); 
		mousescreenupdate(); 
		unlock(&cursor); 
	} 
} 
1994/0412/sys/src/9/port/devmouse.c:1,71994/0413/sys/src/9/port/devmouse.c:1,6 (short | long)
1993/1006    
#include	"u.h" 
#include	"../port/lib.h" 
#include	<libg.h> 
#include	<gnot.h> 
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
1994/0412/sys/src/9/port/devmouse.c:57,621994/0413/sys/src/9/port/devmouse.c:56,67
1993/1006    
	int	disable;	/* from being used */ 
1993/1026    
	int	frozen;	/* from being used */ 
1993/1006    
	Rectangle r;		/* location */ 
1994/0413    
 
	int	l; 
	int	tl; 
	int	setop; 
	int	clrop; 
	Rectangle clipr; 
1993/1006    
}; 
 
Mouseinfo	mouse; 
1994/0412/sys/src/9/port/devmouse.c:83,1291994/0413/sys/src/9/port/devmouse.c:88,124
1993/1006    
}; 
 
ulong setbits[16]; 
GBitmap	set = 
1994/0413    
Bitmap	set = 
1993/1006    
{ 
	setbits, 
1994/0413    
	{0, 0, 16, 16}, 
	{0, 0, 16, 16}, 
1993/1006    
	0, 
1994/0413    
	setbits, 
1993/1006    
	1, 
	0, 
	{0, 0, 16, 16}, 
	{0, 0, 16, 16} 
}; 
 
ulong clrbits[16]; 
GBitmap	clr = 
1994/0413    
Bitmap	clr = 
1993/1006    
{ 
	clrbits, 
	0, 
	1, 
	0, 
	{0, 0, 16, 16}, 
	{0, 0, 16, 16} 
}; 
                 
ulong cursorbackbits[16*4]; 
GBitmap cursorback = 
{ 
	cursorbackbits, 
1994/0413    
	{0, 0, 16, 16}, 
1993/1006    
	0, 
1994/0413    
	clrbits, 
1993/1006    
	1, 
	0, 
	{0, 0, 16, 16}, 
	{0, 0, 16, 16} 
}; 
 
1994/0412    
ulong cursorworkbits[16*4]; 
GBitmap cursorwork = 
1994/0413    
ulong backbits[16*5]; 
ulong workbits[16*5]; 
Bitmap cursorwork = 
1994/0412    
{ 
	cursorworkbits, 
1994/0413    
	{0, 0, 16+8, 16}, 
	{0, 0, 16+8, 16}, 
1994/0412    
	0, 
1994/0413    
	workbits, 
1994/0412    
	1, 
	0, 
	{0, 0, 16, 16}, 
	{0, 0, 16, 16} 
}; 
 
1993/1006    
void	Cursortocursor(Cursor*); 
1994/0412/sys/src/9/port/devmouse.c:147,1531994/0413/sys/src/9/port/devmouse.c:142,148
1993/1006    
 
#define	NMOUSE	(sizeof(mousedir)/sizeof(Dirtab)) 
 
extern	GBitmap	gscreen; 
1994/0413    
extern	Bitmap	gscreen; 
1993/1006    
 
void 
mousereset(void) 
1994/0412/sys/src/9/port/devmouse.c:166,1841994/0413/sys/src/9/port/devmouse.c:161,195
1993/1006    
} 
 
void 
1994/0413    
cursorinit(void) 
{ 
	cursorwork.ldepth = gscreen.ldepth; 
	cursorwork.width = ((cursorwork.r.max.x << gscreen.ldepth) + 31) >> 5; 
 
	cursor.l = cursorwork.width*BY2WD; 
 
	if(flipping){ 
		cursor.setop = flipD[S|D]; 
		cursor.clrop = flipD[D&~S]; 
	} else { 
		cursor.setop = S|D; 
		cursor.clrop = D&~S; 
	} 
} 
 
void 
1993/1006    
mouseinit(void) 
{ 
	if(!conf.monitor) 
		return; 
1994/0413    
 
1994/0412    
	if(gscreen.ldepth > 3){ 
1993/1006    
		cursorback.ldepth = 0; 
1994/0412    
		cursorwork.ldepth = 0; 
	}else{ 
1993/1006    
		cursorback.ldepth = gscreen.ldepth; 
		cursorback.width = ((16 << gscreen.ldepth) + 31) >> 5; 
1994/0412    
		cursorwork.ldepth = gscreen.ldepth; 
		cursorwork.width = ((16 << gscreen.ldepth) + 31) >> 5; 
1994/0413    
		print("mouse can't work ldepth > 3"); 
		cursor.disable = 1; 
1993/1006    
	} 
1994/0413    
 
	cursorinit(); 
 
1993/1006    
	cursoron(1); 
} 
 
1994/0412/sys/src/9/port/devmouse.c:187,1921994/0413/sys/src/9/port/devmouse.c:198,204
1993/1006    
{ 
	if(!conf.monitor) 
		error(Egreg); 
1994/0413    
	cursorinit(); 
1993/1006    
	return devattach('m', spec); 
} 
 
1994/0412/sys/src/9/port/devmouse.c:437,4451994/0413/sys/src/9/port/devmouse.c:449,472
1993/1006    
	unlock(&cursor); 
} 
 
1994/0413    
typedef struct 
{ 
	Bitmap *dm; 
	Point p; 
	Bitmap *sm; 
	Rectangle r; 
	Fcode f; 
} XXX; 
 
1993/1006    
void 
cursoron(int dolock) 
{ 
1994/0413    
	int off; 
	Rectangle r; 
	uchar *a; 
	XXX x; 
	extern int graphicssubtile(uchar*, int, int, Rectangle, Rectangle, uchar**); 
 
1993/1006    
	if(cursor.disable) 
		return; 
	if(dolock) 
1994/0412/sys/src/9/port/devmouse.c:451,4651994/0413/sys/src/9/port/devmouse.c:478,513
1993/1006    
			cursor.r.min = mouse.xy; 
			cursor.r.max = add(mouse.xy, Pt(16, 16)); 
			cursor.r = raddp(cursor.r, cursor.offset); 
1994/0412    
			screenunload(cursor.r, (uchar*)cursorworkbits, 
				(16>>3) << gscreen.ldepth, cursorwork.width*BY2WD, 0); 
			memmove(cursorbackbits, cursorworkbits, 16*cursorback.width*BY2WD); 
			gbitblt(&cursorwork, cursorwork.r.min, 
1993/1006    
				&clr, Rect(0, 0, 16, 16), flipping? flipD[D&~S] : D&~S); 
1994/0412    
			gbitblt(&cursorwork, cursorwork.r.min, 
1993/1006    
				&set, Rect(0, 0, 16, 16), flipping? flipD[S|D] : S|D); 
1994/0412    
			screenload(cursor.r, (uchar*)cursorworkbits, 
				(16>>3) << gscreen.ldepth, cursorwork.width*BY2WD, 0); 
1994/0413    
 
			/* bit offset into backup area */ 
			off = ((1<<gscreen.ldepth)*cursor.r.min.x) & 7; 
 
			/* clip the cursor rectangle */ 
			x.dm = &cursorwork; 
			x.p = Pt(off, 0); 
			x.sm = &gscreen; 
			x.r = cursor.r; 
			bitbltclip(&x); 
 
			/* tile width */ 
			cursor.tl = graphicssubtile(0, cursor.l, gscreen.ldepth, 
					gscreen.r, x.r, &a); 
			if(cursor.tl > 0){ 
				/* get tile */ 
				screenunload(x.r, (uchar*)workbits, cursor.tl, cursor.l, 0); 
 
				/* save for cursoroff */ 
				memmove(backbits, workbits, cursor.l*16); 
 
				/* add mouse into work area */ 
				r = Rect(0, 0, Dx(x.r), Dy(x.r)); 
				bitblt(&cursorwork, x.p, &clr, r, cursor.clrop); 
				bitblt(&cursorwork, x.p, &set, r, cursor.setop); 
 
				/* put back tile */ 
				cursor.clipr = x.r; 
				screenload(x.r, (uchar*)workbits, cursor.tl, cursor.l, 0); 
			} 
1993/1006    
		} 
	} 
	if(dolock) 
1994/0412/sys/src/9/port/devmouse.c:473,4831994/0413/sys/src/9/port/devmouse.c:521,528
1993/1006    
		return; 
	if(dolock) 
		lock(&cursor); 
	if(--cursor.visible == 0) { 
1994/0412    
		if(!hwcurs) 
			screenload(cursor.r, (uchar*)cursorbackbits, 
				(16>>3) << gscreen.ldepth, cursorback.width*BY2WD, 0); 
1993/1006    
	} 
1994/0413    
	if(--cursor.visible == 0 && !hwcurs && cursor.tl > 0) 
		screenload(cursor.clipr, (uchar*)backbits, cursor.tl, cursor.l, 0); 
1993/1006    
	if(dolock) 
		unlock(&cursor); 
} 
1994/0413/sys/src/9/port/devmouse.c:9,341994/0414/sys/src/9/port/devmouse.c:9,15 (short | long)
1993/1006    
#include	"devtab.h" 
1994/0210    
#include	"screen.h" 
1993/1006    
 
/* 
 * Some monochrome screens are reversed from what we like: 
 * We want 0's bright and 1's dark. 
 * Indexed by an Fcode, these compensate for the source bitmap being wrong 
 * (exchange S rows) and destination (exchange D columns and invert result) 
 */ 
int flipS[] = { 
	0x0, 0x4, 0x8, 0xC, 0x1, 0x5, 0x9, 0xD, 
	0x2, 0x6, 0xA, 0xE, 0x3, 0x7, 0xB, 0xF 
}; 
                 
int flipD[] = { 
	0xF, 0xD, 0xE, 0xC, 0x7, 0x5, 0x6, 0x4, 
	0xB, 0x9, 0xA, 0x8, 0x3, 0x1, 0x2, 0x0,  
}; 
                 
int flipping;	/* are flip tables being used to transform Fcodes? */ 
                 
typedef struct Mouseinfo	Mouseinfo; 
typedef struct Cursorinfo	Cursorinfo; 
 
struct Mouseinfo 
{ 
1994/0413/sys/src/9/port/devmouse.c:48,761994/0414/sys/src/9/port/devmouse.c:29,40
1993/1006    
	int	open; 
}; 
 
struct Cursorinfo 
{ 
	Cursor; 
	Lock; 
	int	visible;	/* on screen */ 
	int	disable;	/* from being used */ 
1993/1026    
	int	frozen;	/* from being used */ 
1993/1006    
	Rectangle r;		/* location */ 
1994/0413    
                 
	int	l; 
	int	tl; 
	int	setop; 
	int	clrop; 
	Rectangle clipr; 
1993/1006    
}; 
                 
Mouseinfo	mouse; 
Cursorinfo	cursor; 
int		mouseshifted; 
int		mousetype; 
1994/0216    
int		mouseswap; 
1993/1006    
int		hwcurs; 
1993/1009    
Cursor	curs; 
1994/0414    
Cursor		curs; 
1993/1006    
 
Cursor	arrow = 
{ 
1994/0413/sys/src/9/port/devmouse.c:88,1321994/0414/sys/src/9/port/devmouse.c:52,62
1993/1006    
}; 
 
ulong setbits[16]; 
1994/0413    
Bitmap	set = 
1993/1006    
{ 
1994/0413    
	{0, 0, 16, 16}, 
	{0, 0, 16, 16}, 
1993/1006    
	0, 
1994/0413    
	setbits, 
1993/1006    
	1, 
	0, 
}; 
                 
ulong clrbits[16]; 
1994/0413    
Bitmap	clr = 
1993/1006    
{ 
	{0, 0, 16, 16}, 
1994/0413    
	{0, 0, 16, 16}, 
1993/1006    
	0, 
1994/0413    
	clrbits, 
1993/1006    
	1, 
	0, 
}; 
 
1994/0413    
ulong backbits[16*5]; 
ulong workbits[16*5]; 
Bitmap cursorwork = 
1994/0412    
{ 
1994/0413    
	{0, 0, 16+8, 16}, 
	{0, 0, 16+8, 16}, 
1994/0412    
	0, 
1994/0413    
	workbits, 
1994/0412    
	1, 
	0, 
}; 
                 
1993/1006    
void	Cursortocursor(Cursor*); 
int	mousechanged(void*); 
 
1994/0412    
extern	void	screenload(Rectangle, uchar*, int, int, int); 
extern	void	screenunload(Rectangle, uchar*, int, int, int); 
                 
1993/1006    
enum{ 
	Qdir, 
1993/1009    
	Qcursor, 
1994/0413/sys/src/9/port/devmouse.c:147,1951994/0414/sys/src/9/port/devmouse.c:77,95
1993/1006    
void 
mousereset(void) 
{ 
	ulong r; 
                 
	if(!conf.monitor) 
		return; 
 
	getcolor(0, &r, &r, &r); 
	if(r == 0) 
		flipping = 1; 
	flipping = 0;	/* howard, why is this necessary to get a black arrow on carrera? */ 
1993/1009    
	curs = arrow; 
1993/1006    
	Cursortocursor(&arrow); 
} 
 
void 
1994/0413    
cursorinit(void) 
{ 
	cursorwork.ldepth = gscreen.ldepth; 
	cursorwork.width = ((cursorwork.r.max.x << gscreen.ldepth) + 31) >> 5; 
                 
	cursor.l = cursorwork.width*BY2WD; 
                 
	if(flipping){ 
		cursor.setop = flipD[S|D]; 
		cursor.clrop = flipD[D&~S]; 
	} else { 
		cursor.setop = S|D; 
		cursor.clrop = D&~S; 
	} 
} 
                 
void 
1993/1006    
mouseinit(void) 
{ 
	if(!conf.monitor) 
		return; 
1994/0413    
 
1994/0412    
	if(gscreen.ldepth > 3){ 
1994/0413    
		print("mouse can't work ldepth > 3"); 
		cursor.disable = 1; 
1993/1006    
	} 
1994/0413    
                 
	cursorinit(); 
                 
1993/1006    
	cursoron(1); 
} 
 
1994/0413/sys/src/9/port/devmouse.c:198,2041994/0414/sys/src/9/port/devmouse.c:98,103
1993/1006    
{ 
	if(!conf.monitor) 
		error(Egreg); 
1994/0413    
	cursorinit(); 
1993/1006    
	return devattach('m', spec); 
} 
 
1994/0413/sys/src/9/port/devmouse.c:408,4141994/0414/sys/src/9/port/devmouse.c:307,313
1993/1006    
	uchar *p; 
 
	lock(&cursor); 
	memmove(&cursor, c, sizeof(Cursor)); 
1994/0414    
	memmove(&cursor.Cursor, c, sizeof(Cursor)); 
1993/1006    
	for(i=0; i<16; i++){ 
		p = (uchar*)&setbits[i]; 
		*p = c->set[2*i]; 
1994/0413/sys/src/9/port/devmouse.c:417,5321994/0414/sys/src/9/port/devmouse.c:316,326
1993/1006    
		*p = c->clr[2*i]; 
		*(p+1) = c->clr[2*i+1]; 
	} 
	if(hwcurs) 
		hwcursset(set.base, clr.base, cursor.offset.x, cursor.offset.y); 
1994/0414    
	setcursor(setbits, clrbits, cursor.offset.x, cursor.offset.y); 
1993/1026    
	unlock(&cursor); 
} 
 
void 
cursorlock(Rectangle r) 
{ 
	if(hwcurs) 
		return; 
	lock(&cursor); 
	if(rectXrect(cursor.r, r)){ 
		cursoroff(0); 
		cursor.frozen = 1; 
	} 
	cursor.disable++; 
	unlock(&cursor); 
} 
 
void 
cursorunlock(void) 
{ 
	if(hwcurs) 
		return; 
	lock(&cursor); 
	cursor.disable--; 
	if(cursor.frozen) 
		cursoron(0); 
	cursor.frozen = 0; 
1993/1006    
	unlock(&cursor); 
} 
                 
1994/0413    
typedef struct 
{ 
	Bitmap *dm; 
	Point p; 
	Bitmap *sm; 
	Rectangle r; 
	Fcode f; 
} XXX; 
                 
1993/1006    
void 
cursoron(int dolock) 
{ 
1994/0413    
	int off; 
	Rectangle r; 
	uchar *a; 
	XXX x; 
	extern int graphicssubtile(uchar*, int, int, Rectangle, Rectangle, uchar**); 
                 
1993/1006    
	if(cursor.disable) 
		return; 
	if(dolock) 
		lock(&cursor); 
	if(cursor.visible++ == 0){ 
		if(hwcurs) 
			hwcursmove(mouse.xy.x, mouse.xy.y); 
		else { 
			cursor.r.min = mouse.xy; 
			cursor.r.max = add(mouse.xy, Pt(16, 16)); 
			cursor.r = raddp(cursor.r, cursor.offset); 
1994/0413    
                 
			/* bit offset into backup area */ 
			off = ((1<<gscreen.ldepth)*cursor.r.min.x) & 7; 
                 
			/* clip the cursor rectangle */ 
			x.dm = &cursorwork; 
			x.p = Pt(off, 0); 
			x.sm = &gscreen; 
			x.r = cursor.r; 
			bitbltclip(&x); 
                 
			/* tile width */ 
			cursor.tl = graphicssubtile(0, cursor.l, gscreen.ldepth, 
					gscreen.r, x.r, &a); 
			if(cursor.tl > 0){ 
				/* get tile */ 
				screenunload(x.r, (uchar*)workbits, cursor.tl, cursor.l, 0); 
                 
				/* save for cursoroff */ 
				memmove(backbits, workbits, cursor.l*16); 
                 
				/* add mouse into work area */ 
				r = Rect(0, 0, Dx(x.r), Dy(x.r)); 
				bitblt(&cursorwork, x.p, &clr, r, cursor.clrop); 
				bitblt(&cursorwork, x.p, &set, r, cursor.setop); 
                 
				/* put back tile */ 
				cursor.clipr = x.r; 
				screenload(x.r, (uchar*)workbits, cursor.tl, cursor.l, 0); 
			} 
1993/1006    
		} 
	} 
	if(dolock) 
		unlock(&cursor); 
} 
                 
void 
cursoroff(int dolock) 
{ 
	if(cursor.disable) 
		return; 
	if(dolock) 
		lock(&cursor); 
1994/0413    
	if(--cursor.visible == 0 && !hwcurs && cursor.tl > 0) 
		screenload(cursor.clipr, (uchar*)backbits, cursor.tl, cursor.l, 0); 
1993/1006    
	if(dolock) 
		unlock(&cursor); 
} 
                 
/* 
 *  called by the clock routine to redraw the cursor 
 */ 
1994/0413/sys/src/9/port/devmouse.c:651,6541994/0414/sys/src/9/port/devmouse.c:445,454
1993/1006    
{ 
	USED(m); 
	return mouse.lastcounter - mouse.counter; 
1994/0414    
} 
 
Point 
mousexy(void) 
{ 
	return mouse.xy; 
1993/1006    
} 
1994/0414/sys/src/9/port/devmouse.c:51,591994/0520/sys/src/9/port/devmouse.c:51,56 (short | long)
1993/1006    
	} 
}; 
 
ulong setbits[16]; 
ulong clrbits[16]; 
                 
void	Cursortocursor(Cursor*); 
int	mousechanged(void*); 
 
1994/0414/sys/src/9/port/devmouse.c:303,3221994/0520/sys/src/9/port/devmouse.c:300,308
1993/1006    
void 
Cursortocursor(Cursor *c) 
{ 
	int i; 
	uchar *p; 
                 
	lock(&cursor); 
1994/0414    
	memmove(&cursor.Cursor, c, sizeof(Cursor)); 
1993/1006    
	for(i=0; i<16; i++){ 
		p = (uchar*)&setbits[i]; 
		*p = c->set[2*i]; 
		*(p+1) = c->set[2*i+1]; 
		p = (uchar*)&clrbits[i]; 
		*p = c->clr[2*i]; 
		*(p+1) = c->clr[2*i+1]; 
	} 
1994/0414    
	setcursor(setbits, clrbits, cursor.offset.x, cursor.offset.y); 
1994/0520    
	setcursor(c); 
1993/1026    
	unlock(&cursor); 
} 
 
1994/0520/sys/src/9/port/devmouse.c:36,541994/0521/sys/src/9/port/devmouse.c:36,53 (short | long)
1994/0216    
int		mouseswap; 
1994/0414    
Cursor		curs; 
1993/1006    
 
Cursor	arrow = 
{ 
	{-1, -1}, 
	{0xFF, 0xE0, 0xFF, 0xE0, 0xFF, 0xC0, 0xFF, 0x00, 
	 0xFF, 0x00, 0xFF, 0x80, 0xFF, 0xC0, 0xFF, 0xE0, 
	 0xE7, 0xF0, 0xE3, 0xF8, 0xC1, 0xFC, 0x00, 0xFE, 
	 0x00, 0x7F, 0x00, 0x3E, 0x00, 0x1C, 0x00, 0x08, 
1994/0521    
Cursor	arrow = { 
	{ -1, -1 }, 
	{ 0xFF, 0xFF, 0x80, 0x01, 0x80, 0x02, 0x80, 0x0C,  
	  0x80, 0x10, 0x80, 0x10, 0x80, 0x08, 0x80, 0x04,  
	  0x80, 0x02, 0x80, 0x01, 0x80, 0x02, 0x8C, 0x04,  
	  0x92, 0x08, 0x91, 0x10, 0xA0, 0xA0, 0xC0, 0x40,  
1993/1006    
	}, 
	{0x00, 0x00, 0x7F, 0xC0, 0x7F, 0x00, 0x7C, 0x00, 
	 0x7E, 0x00, 0x7F, 0x00, 0x6F, 0x80, 0x67, 0xC0, 
	 0x43, 0xE0, 0x41, 0xF0, 0x00, 0xF8, 0x00, 0x7C, 
	 0x00, 0x3E, 0x00, 0x1C, 0x00, 0x08, 0x00, 0x00, 
	} 
1994/0521    
	{ 0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFC, 0x7F, 0xF0,  
	  0x7F, 0xE0, 0x7F, 0xE0, 0x7F, 0xF0, 0x7F, 0xF8,  
	  0x7F, 0xFC, 0x7F, 0xFE, 0x7F, 0xFC, 0x73, 0xF8,  
	  0x61, 0xF0, 0x60, 0xE0, 0x40, 0x40, 0x00, 0x00,  
	}, 
1993/1006    
}; 
 
void	Cursortocursor(Cursor*); 
1994/0521/sys/src/9/port/devmouse.c:321,3271994/0624/sys/src/9/port/devmouse.c:321,327 (short | long)
1993/1006    
	if(mouse.redraw && canlock(&cursor)){ 
		mouse.redraw = 0; 
		cursoroff(0); 
		cursoron(0); 
1994/0624    
		mouse.redraw = cursoron(0); 
1993/1006    
		unlock(&cursor); 
	} 
} 
1994/0624/sys/src/9/port/devmouse.c:363,3691994/0730/sys/src/9/port/devmouse.c:363,369 (short | long)
1993/1006    
 *  shift & right button is the same as middle button (for 2 button mice) 
 */ 
int 
1993/1201    
m3mouseputc(int c) 
1994/0730    
m3mouseputc(void *q, int c) 
1993/1006    
{ 
	static uchar msg[3]; 
	static int nb; 
1994/0624/sys/src/9/port/devmouse.c:372,3771994/0730/sys/src/9/port/devmouse.c:372,379
1993/1006    
	short x; 
	int dx, dy, newbuttons; 
 
1994/0730    
	USED(q); 
 
1993/1006    
	/*  
	 *  check bit 6 for consistency 
	 */ 
1994/0624/sys/src/9/port/devmouse.c:403,4091994/0730/sys/src/9/port/devmouse.c:405,411
1993/1006    
 *  shift & right button is the same as middle button (for 2 button mice) 
 */ 
int 
1993/1201    
mouseputc(int c) 
1994/0730    
mouseputc(void *q, int c) 
1993/1006    
{ 
	static short msg[5]; 
	static int nb; 
1994/0624/sys/src/9/port/devmouse.c:410,4151994/0730/sys/src/9/port/devmouse.c:412,418
1993/1006    
	static uchar b[] = {0, 4, 2, 6, 1, 5, 3, 7, 0, 2, 2, 6, 1, 5, 3, 7}; 
	int dx, dy, newbuttons; 
 
1994/0730    
	USED(q); 
1993/1006    
	if((c&0xF0) == 0x80) 
		nb=0; 
	msg[nb] = c; 
1994/0730/sys/src/9/port/devmouse.c:324,3291994/0913/sys/src/9/port/devmouse.c:324,330 (short | long)
1994/0624    
		mouse.redraw = cursoron(0); 
1993/1006    
		unlock(&cursor); 
	} 
1994/0913    
	graphicsactive(0); 
1993/1006    
} 
 
/* 
1994/0730/sys/src/9/port/devmouse.c:350,3551994/0913/sys/src/9/port/devmouse.c:351,357
1993/1006    
	mouse.buttons = b; 
	mouse.redraw = 1; 
	wakeup(&mouse.r); 
1994/0913    
	graphicsactive(1); 
1993/1006    
} 
 
/* 
1994/0913/sys/src/9/port/devmouse.c:216,2291994/1013/sys/src/9/port/devmouse.c:216,229 (short | long)
1993/1006    
		while(mousechanged(0) == 0) 
			sleep(&mouse.r, mousechanged, 0); 
		lock(&cursor); 
1993/1008    
		sprint(buf, "%11d %11d %11d %11d", 
1994/1013    
		sprint(buf, "m%11d %11d %11d %11d", 
1994/0216    
			mouse.xy.x, mouse.xy.y, 
			mouseswap ? map[mouse.buttons&7] : mouse.buttons, 
1993/1008    
			TK2MS(MACHP(0)->ticks)); 
1993/1006    
		mouse.lastcounter = mouse.counter; 
		unlock(&cursor); 
1993/1008    
		if(n > 4*12) 
			n = 4*12; 
1994/1013    
		if(n > 1+4*12) 
			n = 1+4*12; 
1993/1008    
		memmove(va, buf, n); 
		return n; 
1993/1006    
	} 
1994/0913/sys/src/9/port/devmouse.c:277,2831994/1013/sys/src/9/port/devmouse.c:277,283
1993/1008    
		memmove(buf, va, n); 
		buf[n] = 0; 
		p = 0; 
		pt.x = strtoul(buf, &p, 0); 
1994/1013    
		pt.x = strtoul(buf+1, &p, 0); 
1993/1008    
		if(p == 0) 
1993/1006    
			error(Eshort); 
1993/1008    
		pt.y = strtoul(p, 0, 0); 
1994/1013/sys/src/9/port/devmouse.c:230,2351995/0108/sys/src/9/port/devmouse.c:230,241 (short | long)
1993/1006    
	return 0; 
} 
 
1995/0108    
Block* 
mousebread(Chan *c, long n, ulong offset) 
{ 
	return devbread(c, n, offset); 
} 
 
1993/1006    
long 
mousewrite(Chan *c, void *va, long n, ulong offset) 
{ 
1994/1013/sys/src/9/port/devmouse.c:294,2991995/0108/sys/src/9/port/devmouse.c:300,311
1993/1006    
 
	error(Egreg); 
	return -1; 
1995/0108    
} 
 
long 
mousebwrite(Chan *c, Block *bp, ulong offset) 
{ 
	return devbwrite(c, bp, offset); 
1993/1006    
} 
 
void 
1995/0108/sys/src/9/port/devmouse.c:146,1701995/0804/sys/src/9/port/devmouse.c:146,167 (short | long)
1993/1006    
} 
 
void 
mousecreate(Chan *c, char *name, int omode, ulong perm) 
1995/0804    
mousecreate(Chan*, char*, int, ulong) 
1993/1006    
{ 
	if(!conf.monitor) 
		error(Egreg); 
	USED(c, name, omode, perm); 
	error(Eperm); 
} 
 
void 
mouseremove(Chan *c) 
1995/0804    
mouseremove(Chan*) 
1993/1006    
{ 
	USED(c); 
	error(Eperm); 
} 
 
void 
mousewstat(Chan *c, char *db) 
1995/0804    
mousewstat(Chan*, char*) 
1993/1006    
{ 
	USED(c, db); 
	error(Eperm); 
} 
 
1995/0108/sys/src/9/port/devmouse.c:237,2491995/0804/sys/src/9/port/devmouse.c:234,245
1995/0108    
} 
 
1993/1006    
long 
mousewrite(Chan *c, void *va, long n, ulong offset) 
1995/0804    
mousewrite(Chan *c, void *va, long n, ulong) 
1993/1006    
{ 
1993/1008    
	char *p; 
1993/1006    
	Point pt; 
	char buf[64]; 
 
1994/0325    
	USED(offset); 
1993/1009    
	p = va; 
1993/1006    
	switch(c->qid.path){ 
	case CHDIR: 
1995/0108/sys/src/9/port/devmouse.c:377,3831995/0804/sys/src/9/port/devmouse.c:373,379
1993/1006    
 *  shift & right button is the same as middle button (for 2 button mice) 
 */ 
int 
1994/0730    
m3mouseputc(void *q, int c) 
1995/0804    
m3mouseputc(void*, int c) 
1993/1006    
{ 
	static uchar msg[3]; 
	static int nb; 
1995/0108/sys/src/9/port/devmouse.c:386,3931995/0804/sys/src/9/port/devmouse.c:382,387
1993/1006    
	short x; 
	int dx, dy, newbuttons; 
 
1994/0730    
	USED(q); 
                 
1993/1006    
	/*  
	 *  check bit 6 for consistency 
	 */ 
1995/0108/sys/src/9/port/devmouse.c:419,4251995/0804/sys/src/9/port/devmouse.c:413,419
1993/1006    
 *  shift & right button is the same as middle button (for 2 button mice) 
 */ 
int 
1994/0730    
mouseputc(void *q, int c) 
1995/0804    
mouseputc(void*, int c) 
1993/1006    
{ 
	static short msg[5]; 
	static int nb; 
1995/0108/sys/src/9/port/devmouse.c:426,4321995/0804/sys/src/9/port/devmouse.c:420,425
1993/1006    
	static uchar b[] = {0, 4, 2, 6, 1, 5, 3, 7, 0, 2, 2, 6, 1, 5, 3, 7}; 
	int dx, dy, newbuttons; 
 
1994/0730    
	USED(q); 
1993/1006    
	if((c&0xF0) == 0x80) 
		nb=0; 
	msg[nb] = c; 
1995/0108/sys/src/9/port/devmouse.c:443,4511995/0804/sys/src/9/port/devmouse.c:436,443
1993/1006    
} 
 
int 
mousechanged(void *m) 
1995/0804    
mousechanged(void*) 
1993/1006    
{ 
	USED(m); 
	return mouse.lastcounter - mouse.counter; 
1994/0414    
} 
 
1995/0804/sys/src/9/port/devmouse.c:212,2181995/0812/sys/src/9/port/devmouse.c:212,221 (short | long)
1993/1009    
	case Qmouse: 
1993/1006    
		while(mousechanged(0) == 0) 
			sleep(&mouse.r, mousechanged, 0); 
		lock(&cursor); 
1995/0812    
 
		while(!canlock(&cursor)) 
			tsleep(&up->sleep, return0, 0, TK2MS(1)); 
 
1994/1013    
		sprint(buf, "m%11d %11d %11d %11d", 
1994/0216    
			mouse.xy.x, mouse.xy.y, 
			mouseswap ? map[mouse.buttons&7] : mouse.buttons, 
1995/0812/sys/src/9/port/devmouse.c:27,321995/1216/sys/src/9/port/devmouse.c:27,34 (short | long)
1993/1006    
	Ref; 
	QLock; 
	int	open; 
1995/1216    
	int	acceleration; 
	int	maxacc; 
1993/1006    
}; 
 
Mouseinfo	mouse; 
1995/0812/sys/src/9/port/devmouse.c:272,2781995/1216/sys/src/9/port/devmouse.c:274,283
1993/1006    
		if(n >= sizeof(buf)) 
			n = sizeof(buf)-1; 
		strncpy(buf, va, n); 
		buf[n] = 0; 
1995/1216    
		if(buf[n - 1] == '\n') 
			buf[n-1] = 0; 
		else 
			buf[n] = 0; 
1993/1006    
		mousectl(buf); 
		return n; 
 
1995/0812/sys/src/9/port/devmouse.c:338,3431995/1216/sys/src/9/port/devmouse.c:343,376
1994/0913    
	graphicsactive(0); 
1993/1006    
} 
 
1995/1216    
static int 
scale(int x) 
{ 
	int sign = 1; 
 
	if(x < 0){ 
		sign = -1; 
		x = -x; 
	} 
	switch(x){ 
	case 0: 
	case 1: 
	case 2: 
	case 3: 
		break; 
	case 4: 
		x = 6 + (mouse.acceleration>>2); 
		break; 
	case 5: 
		x = 9 + (mouse.acceleration>>1); 
		break; 
	default: 
		x *= mouse.maxacc; 
		break; 
	} 
	return sign*x; 
} 
 
1993/1006    
/* 
 *  called at interrupt level to update the structure and 
 *  awaken any waiting procs. 
1995/0812/sys/src/9/port/devmouse.c:347,3521995/1216/sys/src/9/port/devmouse.c:380,389
1993/1006    
{ 
	int x, y; 
 
1995/1216    
	if(mouse.acceleration){ 
		dx = scale(dx); 
		dy = scale(dy); 
	} 
1993/1006    
	x = mouse.xy.x + dx; 
	if(x < gscreen.r.min.x) 
		x = gscreen.r.min.x; 
1995/0812/sys/src/9/port/devmouse.c:448,4511995/1216/sys/src/9/port/devmouse.c:485,500
1994/0414    
mousexy(void) 
{ 
	return mouse.xy; 
1995/1216    
} 
 
void 
mouseaccelerate(char *x) 
{ 
	if(x == 0) 
		x = "1"; 
	mouse.acceleration = atoi(x); 
	if(mouse.acceleration < 3) 
		mouse.maxacc = 2; 
	else 
		mouse.maxacc = mouse.acceleration; 
1993/1006    
} 
1995/1216/sys/src/9/port/devmouse.c:6,121996/0223/sys/src/9/port/devmouse.c:6,11 (short | long)
1993/1006    
#include	"fns.h" 
#include	"../port/error.h" 
 
#include	"devtab.h" 
1994/0210    
#include	"screen.h" 
1993/1006    
 
typedef struct Mouseinfo	Mouseinfo; 
1996/0223/sys/src/9/port/devmouse.c:1,61997/0201/sys/src/9/port/devmouse.c:1,6 (short | long)
1993/1006    
#include	"u.h" 
#include	"../port/lib.h" 
#include	<libg.h> 
1997/0201    
#include	<libgb.h> 
1993/1006    
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
1997/0201/sys/src/9/port/devmouse.c:1,61997/0202/sys/src/9/port/devmouse.c:1,6 (short | long)
1993/1006    
#include	"u.h" 
#include	"../port/lib.h" 
1997/0201    
#include	<libgb.h> 
1997/0202    
#include	<libg.h> 
1993/1006    
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
1997/0202/sys/src/9/port/devmouse.c:1,111997/0327/sys/src/9/port/devmouse.c:1,11 (short | long)
1993/1006    
#include	"u.h" 
#include	"../port/lib.h" 
1997/0202    
#include	<libg.h> 
1993/1006    
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
#include	"../port/error.h" 
 
1997/0327    
#include	<libg.h> 
1994/0210    
#include	"screen.h" 
1993/1006    
 
typedef struct Mouseinfo	Mouseinfo; 
1997/0202/sys/src/9/port/devmouse.c:53,581997/0327/sys/src/9/port/devmouse.c:53,59
1993/1006    
 
void	Cursortocursor(Cursor*); 
int	mousechanged(void*); 
1997/0327    
static void mouseclock(void); 
1993/1006    
 
enum{ 
	Qdir, 
1997/0202/sys/src/9/port/devmouse.c:67,771997/0327/sys/src/9/port/devmouse.c:68,76
1993/1006    
	"mousectl",	{Qmousectl},	0,			0220, 
}; 
 
#define	NMOUSE	(sizeof(mousedir)/sizeof(Dirtab)) 
                 
1994/0413    
extern	Bitmap	gscreen; 
1993/1006    
 
void 
1997/0327    
static void 
1993/1006    
mousereset(void) 
{ 
	if(!conf.monitor) 
1997/0202/sys/src/9/port/devmouse.c:79,871997/0327/sys/src/9/port/devmouse.c:78,87
1993/1006    
 
1993/1009    
	curs = arrow; 
1993/1006    
	Cursortocursor(&arrow); 
1997/0327    
	addclock0link(mouseclock); 
1993/1006    
} 
 
void 
1997/0327    
static void 
1993/1006    
mouseinit(void) 
{ 
	if(!conf.monitor) 
1997/0202/sys/src/9/port/devmouse.c:90,961997/0327/sys/src/9/port/devmouse.c:90,96
1993/1006    
	cursoron(1); 
} 
 
Chan* 
1997/0327    
static Chan* 
1993/1006    
mouseattach(char *spec) 
{ 
	if(!conf.monitor) 
1997/0202/sys/src/9/port/devmouse.c:98,1041997/0327/sys/src/9/port/devmouse.c:98,104
1993/1006    
	return devattach('m', spec); 
} 
 
Chan* 
1997/0327    
static Chan* 
1993/1006    
mouseclone(Chan *c, Chan *nc) 
{ 
	nc = devclone(c, nc); 
1997/0202/sys/src/9/port/devmouse.c:107,1251997/0327/sys/src/9/port/devmouse.c:107,125
1993/1006    
	return nc; 
} 
 
int 
1997/0327    
static int 
1993/1006    
mousewalk(Chan *c, char *name) 
{ 
	return devwalk(c, name, mousedir, NMOUSE, devgen); 
1997/0327    
	return devwalk(c, name, mousedir, nelem(mousedir), devgen); 
1993/1006    
} 
 
void 
1997/0327    
static void 
1993/1006    
mousestat(Chan *c, char *db) 
{ 
	devstat(c, db, mousedir, NMOUSE, devgen); 
1997/0327    
	devstat(c, db, mousedir, nelem(mousedir), devgen); 
1993/1006    
} 
 
Chan* 
1997/0327    
static Chan* 
1993/1006    
mouseopen(Chan *c, int omode) 
{ 
	switch(c->qid.path){ 
1997/0202/sys/src/9/port/devmouse.c:146,1521997/0327/sys/src/9/port/devmouse.c:146,152
1993/1006    
	return c; 
} 
 
void 
1997/0327    
static void 
1995/0804    
mousecreate(Chan*, char*, int, ulong) 
1993/1006    
{ 
	if(!conf.monitor) 
1997/0202/sys/src/9/port/devmouse.c:154,1721997/0327/sys/src/9/port/devmouse.c:154,160
1993/1006    
	error(Eperm); 
} 
 
void 
1995/0804    
mouseremove(Chan*) 
1993/1006    
{ 
	error(Eperm); 
} 
                 
void 
1995/0804    
mousewstat(Chan*, char*) 
1993/1006    
{ 
	error(Eperm); 
} 
                 
void 
1997/0327    
static void 
1993/1006    
mouseclose(Chan *c) 
{ 
	if(c->qid.path!=CHDIR && (c->flag&COPEN)){ 
1997/0202/sys/src/9/port/devmouse.c:184,1901997/0327/sys/src/9/port/devmouse.c:172,178
1993/1006    
} 
 
1994/0216    
 
1993/1006    
long 
1997/0327    
static long 
1993/1006    
mouseread(Chan *c, void *va, long n, ulong offset) 
{ 
1993/1008    
	char buf[4*12+1]; 
1997/0202/sys/src/9/port/devmouse.c:194,2001997/0327/sys/src/9/port/devmouse.c:182,188
1993/1009    
	p = va; 
	switch(c->qid.path){ 
	case CHDIR: 
1993/1006    
		return devdirread(c, va, n, mousedir, NMOUSE, devgen); 
1997/0327    
		return devdirread(c, va, n, mousedir, nelem(mousedir), devgen); 
1993/1006    
 
1993/1009    
	case Qcursor: 
		if(offset != 0) 
1997/0202/sys/src/9/port/devmouse.c:231,2431997/0327/sys/src/9/port/devmouse.c:219,225
1993/1006    
	return 0; 
} 
 
1995/0108    
Block* 
mousebread(Chan *c, long n, ulong offset) 
{ 
	return devbread(c, n, offset); 
} 
                 
1993/1006    
long 
1997/0327    
static long 
1995/0804    
mousewrite(Chan *c, void *va, long n, ulong) 
1993/1006    
{ 
1993/1008    
	char *p; 
1997/0202/sys/src/9/port/devmouse.c:305,3151997/0327/sys/src/9/port/devmouse.c:287,309
1993/1006    
	return -1; 
1995/0108    
} 
 
long 
mousebwrite(Chan *c, Block *bp, ulong offset) 
{ 
	return devbwrite(c, bp, offset); 
1993/1006    
} 
1997/0327    
Dev mousedevtab = { 
	mousereset, 
	mouseinit, 
	mouseattach, 
	mouseclone, 
	mousewalk, 
	mousestat, 
	mouseopen, 
	mousecreate, 
	mouseclose, 
	mouseread, 
	devbread, 
	mousewrite, 
	devbwrite, 
	devremove, 
	devwstat, 
}; 
1993/1006    
 
void 
Cursortocursor(Cursor *c) 
1997/0202/sys/src/9/port/devmouse.c:324,3301997/0327/sys/src/9/port/devmouse.c:318,324
1993/1006    
/* 
 *  called by the clock routine to redraw the cursor 
 */ 
void 
1997/0327    
static void 
1993/1006    
mouseclock(void) 
{ 
	if(mouse.track){ 
Too many diffs (26 > 25). Stopping.


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