diff -c -r orig/moused.8 moused/moused.8 *** orig/moused.8 Wed Mar 20 22:46:59 2002 --- moused/moused.8 Wed Mar 20 22:40:22 2002 *************** *** 44,49 **** --- 44,50 ---- .Op Fl r Ar resolution .Op Fl S Ar baudrate .Op Fl a Ar X Ns Op , Ns Ar Y + .Op Fl A Ar twice Ns Op , Ns Ar quadro .Op Fl C Ar threshold .Op Fl m Ar N=M .Op Fl w Ar N *************** *** 161,166 **** --- 162,179 ---- 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 A Ar twice Ns Op , Ns Ar quadro + Accelerate the mouse input dynamically. + If mouse moves more then + .Ar twice + steps at a time, extra movement accelerated twice. + If mouse moves more then + .Ar quadro + steps at a time, extra movement accelerated four times. + If the + .Fl a + option is present, the dynamic acceleration applies before + linear acceleration. .It Fl c Some mice report middle button down events as if the left and right buttons are being pressed. diff -c -r orig/moused.c moused/moused.c *** orig/moused.c Wed Mar 20 22:46:59 2002 --- moused/moused.c Wed Mar 20 22:21:31 2002 *************** *** 389,394 **** --- 389,396 ---- mousemode_t mode; /* protocol information */ float accelx; /* Acceleration in the X axis */ float accely; /* Acceleration in the Y axis */ + int twice; /* Twice acceleration limit in pixels */ + int quadro; /* Quadro acceleration limit in pixels */ } rodent = { flags : 0, portname : NULL, *************** *** 407,412 **** --- 409,416 ---- button2timeout : DFLT_BUTTON2TIMEOUT, accelx : 1.0, accely : 1.0, + twice : 10000, + quadro : 10000 }; /* button status */ *************** *** 474,479 **** --- 478,484 ---- static void hup(int sig); static void cleanup(int sig); static void usage(void); + static int dynaccel (int delta); static int r_identify(void); static char *r_if(int type); *************** *** 513,519 **** for (i = 0; i < MOUSE_MAXBUTTON; ++i) mstate[i] = &bstate[i]; ! 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,524 ---- for (i = 0; i < MOUSE_MAXBUTTON; ++i) mstate[i] = &bstate[i]; ! while((c = getopt(argc,argv,"3C:DE:F:I:PRS:a:A:cdfhi:l:m:p:r:st:w:z:")) != -1) switch(c) { case '3': *************** *** 532,538 **** case 'a': i = sscanf(optarg, "%f,%f", &rodent.accelx, &rodent.accely); if (i == 0) { ! warnx("invalid acceleration argument '%s'", optarg); usage(); } --- 537,543 ---- case 'a': i = sscanf(optarg, "%f,%f", &rodent.accelx, &rodent.accely); if (i == 0) { ! warnx("invalid acceleration argument `%s'", optarg); usage(); } *************** *** 541,546 **** --- 546,560 ---- break; + case 'A': + i = sscanf(optarg, "%d,%d", &rodent.twice, &rodent.quadro); + if (i == 0) { + warnx("invalid dynamic acceleration argument `%s'", optarg); + usage(); + } + + break; + case 'c': rodent.flags |= ChordMiddle; break; *************** *** 943,950 **** if (action2.flags & MOUSE_POSCHANGED) { mouse.operation = MOUSE_MOTION_EVENT; mouse.u.data.buttons = action2.button; ! 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); --- 957,964 ---- if (action2.flags & MOUSE_POSCHANGED) { mouse.operation = MOUSE_MOTION_EVENT; mouse.u.data.buttons = action2.button; ! mouse.u.data.x = dynaccel(action2.dx) * rodent.accelx; ! mouse.u.data.y = dynaccel(action2.dy) * rodent.accely; mouse.u.data.z = action2.dz; if (debug < 2) ioctl(rodent.cfd, CONS_MOUSECTL, &mouse); *************** *** 1010,1021 **** { fprintf(stderr, "%s\n%s\n%s\n%s\n", "usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]", ! " [-a X [,Y]] [-C threshold] [-m N=M] [-w N] [-z N]", ! " [-t ] [-3 [-E timeout]] -p ", " moused [-d] -i -p "); exit(1); } /** ** Mouse interface code, courtesy of XFree86 3.1.2. ** --- 1024,1056 ---- { fprintf(stderr, "%s\n%s\n%s\n%s\n", "usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]", ! " [-a X [,Y]] [-A twice [,quadro]] [-C threshold] [-m N=M]", ! " [-w N] [-z N] [-t ] [-3 [-E timeout]] -p ", " moused [-d] -i -p "); exit(1); } + static int + dynaccel(int delta) + { + int sign=1; + + if (delta<0) + { + sign=-1; + delta=-delta; + } + + if (delta<=rodent.twice) return delta*sign; + + if (delta<=rodent.quadro) + return (rodent.twice+(delta-rodent.twice)*2)*sign; + + return (rodent.twice+ + (rodent.quadro-rodent.twice)*2+ + (delta-rodent.quadro)*4)*sign; + } + /** ** Mouse interface code, courtesy of XFree86 3.1.2. ** *************** *** 2940,2944 **** rodent.mremcfd = -1; } } - --- 2975,2978 ----