Add an acceleration option to moused

PR:		28369
Submitted by:	Daniel O'Connor <darius@dons.net.au>
manpage reviewed by:	ru
MFC after:	10 days
This commit is contained in:
George C A Reid 2001-06-25 20:15:34 +00:00
parent 1d79f1bb9a
commit efe4cd6a18
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=78770
2 changed files with 31 additions and 8 deletions

View File

@ -38,11 +38,12 @@
.Nd pass mouse data to the console driver
.Sh SYNOPSIS
.Nm
.Op Fl DPRcdfs
.Op Fl DPRacdfs
.Op Fl I Ar file
.Op Fl F Ar rate
.Op Fl r Ar resolution
.Op Fl S Ar baudrate
.Op Fl a Ar X Ns Op , Ns Ar Y
.Op Fl C Ar threshold
.Op Fl m Ar N=M
.Op Fl w Ar N
@ -153,6 +154,12 @@ mode.
.It Fl S Ar baudrate
Select the baudrate for the serial port (1200 to 9600).
Not all serial mice support this option.
.It Fl a Ar X Ns Op , Ns Ar Y
Accelerate or decelerate the mouse input.
This is a linear acceleration only.
Values less than 1.0 slow down movement, values greater than 1.0 speed it
up.
Specifying only one value sets the acceleration for both axes.
.It Fl c
Some mice report middle button down events
as if the left and right buttons are being pressed.

View File

@ -382,6 +382,8 @@ static struct rodentparam {
long button2timeout; /* 3 button emulation timeout */
mousehw_t hw; /* mouse device hardware information */
mousemode_t mode; /* protocol information */
float accelx; /* Acceleration in the X axis */
float accely; /* Acceleration in the Y axis */
} rodent = {
flags : 0,
portname : NULL,
@ -398,6 +400,8 @@ static struct rodentparam {
mremcfd : -1,
clickthreshold : DFLT_CLICKTHRESHOLD,
button2timeout : DFLT_BUTTON2TIMEOUT,
accelx : 1.0,
accely : 1.0,
};
/* button status */
@ -502,7 +506,7 @@ main(int argc, char *argv[])
for (i = 0; i < MOUSE_MAXBUTTON; ++i)
mstate[i] = &bstate[i];
while((c = getopt(argc,argv,"3C:DE:F:I:PRS:cdfhi:l:m:p:r:st:w:z:")) != -1)
while((c = getopt(argc,argv,"3C:DE:F:I:PRS:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
switch(c) {
case '3':
@ -518,6 +522,18 @@ main(int argc, char *argv[])
}
break;
case 'a':
i = sscanf(optarg, "%f,%f", &rodent.accelx, &rodent.accely);
if (i == 0) {
warnx("invalid acceleration argument '%s'", optarg);
usage();
}
if (i == 1)
rodent.accely = rodent.accelx;
break;
case 'c':
rodent.flags |= ChordMiddle;
break;
@ -919,8 +935,8 @@ moused(void)
if (action2.flags & MOUSE_POSCHANGED) {
mouse.operation = MOUSE_MOTION_EVENT;
mouse.u.data.buttons = action2.button;
mouse.u.data.x = action2.dx;
mouse.u.data.y = action2.dy;
mouse.u.data.x = action2.dx * rodent.accelx;
mouse.u.data.y = action2.dy * rodent.accely;
mouse.u.data.z = action2.dz;
if (debug < 2)
ioctl(rodent.cfd, CONS_MOUSECTL, &mouse);
@ -928,8 +944,8 @@ moused(void)
} else {
mouse.operation = MOUSE_ACTION;
mouse.u.data.buttons = action2.button;
mouse.u.data.x = action2.dx;
mouse.u.data.y = action2.dy;
mouse.u.data.x = action2.dx * rodent.accelx;
mouse.u.data.y = action2.dy * rodent.accely;
mouse.u.data.z = action2.dz;
if (debug < 2)
ioctl(rodent.cfd, CONS_MOUSECTL, &mouse);
@ -986,8 +1002,8 @@ usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n",
"usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]",
" [-C threshold] [-m N=M] [-w N] [-z N] [-t <mousetype>]",
" [-3 [-E timeout]] -p <port>",
" [-a X [,Y]] [-C threshold] [-m N=M] [-w N] [-z N]",
" [-t <mousetype>] [-3 [-E timeout]] -p <port>",
" moused [-d] -i <info> -p <port>");
exit(1);
}