9fans archive / 1995 / 11 / 26 /    prev next

From: John Carmack johnc@idc...
Subject: nextstation mouse
Date: Sun, 5 Nov 1995 01:30:10 -0500

Here is a modification to get an adjustable, accelerative cursor =
from the standard two button NeXT mouse.

After adding this, you can modify the mouse rate by typing:

echo 'speed 3' > /dev/mousectl

John Carmack
Id Software



in 9/next/screen.c:

Add the variable:

/* JDC: for mouse acceleration */
int	mouse_speed =3D 2;

In the kbdmouseintr() function, replace the mousetrack call with:

/*				mousetrack(b, 3*-dx, 3*-dy);
JDC*/
{
int	speed;

speed =3D abs(dx) > abs(dy) ? abs(dx) : abs(dy);
speed =3D speed*speed*mouse_speed;
mousetrack(b, speed*-dx, speed*-dy);
}

change mousectl to accept a "speed" parameter.

void
mousectl(char *arg)
{
	int n;
	char *field[3];

	n =3D getfields(arg, field, 3, " ");
	if(strncmp(field[0], "serial", 6) =3D=3D 0){
		switch(n){
		case 1:
			serialmouse(atoi(field[0]+6), 0, 1);
			break;
		case 2:
			serialmouse(atoi(field[1]), 0, 0);
			break;
		case 3:
		default:
			serialmouse(atoi(field[1]), field[2], 0);
			break;
		}
	}
/* JDC */
	else if (!strcmp(field[0], "speed") && n =3D=3D 2)
	{
		mouse_speed =3D atoi(field[1]);
		if (mouse_speed < 1)
			mouse_speed =3D 1;
 	}
=09
	else
		error(Ebadctl);
}