shithub: 9intro

ref: 2b99422480d596ebc26921c87c6bb81a07949f3e
dir: /src/mouse.c/

View raw version
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <draw.h>
#include <mouse.h>

void
threadmain(int , char*[])
{
	Mousectl*mctl;
	Mouse	m;

	fmtinstall('P', Pfmt);
	mctl = initmouse("/dev/mouse", nil);
	if (mctl == nil)
		sysfatal("initmouse: %r");
	while(recv(mctl->c, &m) >= 0){
		print("mouse pos=%P\tbuttons=%d\n", m.xy, m.buttons);
		if (m.buttons == 7)
			break;
	}
	closemouse(mctl);
	exits(nil);
}