diff options
| -rw-r--r-- | usr.sbin/moused/moused.8 | 9 | ||||
| -rw-r--r-- | usr.sbin/moused/moused.c | 30 |
2 files changed, 31 insertions, 8 deletions
diff --git a/usr.sbin/moused/moused.8 b/usr.sbin/moused/moused.8 index b4128a9983d1..8a04cfce8924 100644 --- a/usr.sbin/moused/moused.8 +++ b/usr.sbin/moused/moused.8 @@ -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. diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c index 77a0c782ec15..8944d93b7474 100644 --- a/usr.sbin/moused/moused.c +++ b/usr.sbin/moused/moused.c @@ -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); } |
