mouse interface for Sun

Joseph Yip ycy at walt.cc.utexas.edu
Fri Mar 30 04:02:22 AEST 1990


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);
}



More information about the Comp.unix.questions mailing list