[comp.unix.questions] mouse interface for Sun

ycy@walt.cc.utexas.edu (Joseph Yip) (03/30/90)

I was looking for mouse interface source for the Suns.  Someone
suggested that I should look into "man ms, man mouse"
From "man ms", it mentioned that the mouse will return 3 bytes. The
first byte tells you if any of the buttons are pressed. The value
ranges from 0x80 to 0x87. I wrote a simple program to test it, but the
first byte gave me 0x81 or 0x80 which indicated I pressed some buttons
although I did not. The two other bytes (x and y displacements) were
not right either. It also generated some error messages in my console
window (I opened 4 windows in SunView). I quitted the test program
using CTRL-C and my mouse was lost forever!

By the way, what is the correct way to set the mouse parameters
(threshold, speed, ...)? I need to do an ioctl(). What is the syntax
like?
	ioctl(mousefd,MSIOSETPARMS,...)

Thank you.

Joseph Yip


#include <stdio.h>
#include <stropts.h>

main()
{
	int mfd;
	char mousein[80];
	mfd = open("/dev/mouse",0);
	ioctl(mfd,I_PUSH,"ms");

	while (1) {
		read(mfd,mousein,3);
		printf("%x %d %d\n", mousein[0],mousein[1],mousein[2]);
	}

	close(mfd);
}