I've noticed many USB mice respond with far too great velocity with
wsmoused. I found these two posts:

http://cvs.openbsd.org/cgi-bin/query-pr-wrapper?full=yes&numbers=4031

and a similar patch by miod that uses -x gain and -y gain from wsmoused:

http://openbsd.monkey.org/tech/200503/msg00030.html

Both fixes work by dividing the 'stride' of each mouse movement event by a 
factor, which on mice of high DPI seems to round out to mostly 0's and cause 
the cursor to feel jagged and unweildy.

Instead, the patch below drops every n mouse event for the x and y axis as 
specified by the -x decel and -y decel values specified as arguments.

Using the "Kingsis Peripherals Evoluent VerticalMouse 3" mouse, which has a 
button to change between 2600, 1800, 1300, and 800 DPI, I found varying values 
of -x and -y values worked really great to make all DPI's behave very 
acceptably, whereas 800 DPI.

I also pulled quite a few other mice in the office, and they were all very 
quick of varying speeds, but were coerced to behave well by using -x decel and 
-y decel values, usually between 3 and 15.

Thanks,
Jeff Quast


Index: wsmoused.8
===================================================================
RCS file: /cvs/src/usr.sbin/wsmoused/wsmoused.8,v
retrieving revision 1.18
diff -u wsmoused.8
--- wsmoused.8  5 Jun 2009 06:50:52 -0000       1.18
+++ wsmoused.8  3 Sep 2009 19:44:10 -0000
@@ -42,6 +42,8 @@
 .Oc
 .Op Fl p Ar device
 .Op Fl t Ar type
+.Op Fl x Ar decel
+.Op Fl y Ar decel
 .Sh DESCRIPTION
 .Nm
 listens for mouse events on the specified
@@ -170,6 +172,14 @@
 .It Ar mmhitab
 Hitachi tablet protocol.
 .El
+.It Fl x Ar decel
+Specify the deceleration factor for the X axis of the device.
+The default value is 1.
+If the mouse cursor moves too fast, you may want to increase this value.
+.It Fl y Ar decel
+Specify the deceleration factor for the Y axis of the device.
+The default value is 1.
+If the mouse cursor moves too fast, you may want to increase this value.
 .El
 .Pp
 .Nm
Index: wsmoused.c
===================================================================
RCS file: /cvs/src/usr.sbin/wsmoused/wsmoused.c,v
retrieving revision 1.25
diff -u wsmoused.c
--- wsmoused.c  21 Jun 2009 16:13:18 -0000      1.25
+++ wsmoused.c  3 Sep 2009 19:44:10 -0000
@@ -97,6 +97,10 @@
        .wmode = 0,
        .mfd = -1,
        .clickthreshold = 500,  /* 0.5 sec */
+       .xdecel = 1,
+       .ydecel = 1,
+       .xmov = 0,
+       .ymov = 0,
 };
 
 /* identify the type of a wsmouse supported mouse */
@@ -341,6 +345,17 @@
        struct wscons_event mapped_event;
 
        if (IS_MOTION_EVENT(event->type)) {
+               if ((mouse.xdecel > 1)
+                   && (event->type == WSCONS_EVENT_MOUSE_DELTA_X)) {
+                       mouse.xmov++;
+                       if (mouse.xmov % mouse.xdecel)
+                               return 1;
+               } else if ((mouse.ydecel > 1)
+                   && (event->type == WSCONS_EVENT_MOUSE_DELTA_Y)) {
+                       mouse.ymov++;
+                       if (mouse.ymov % mouse.ydecel)
+                               return 1;
+               }
                ioctl(mouse.cfd, WSDISPLAYIO_WSMOUSED, event);
                return 1;
        } else if (IS_BUTTON_EVENT(event->type) &&
@@ -519,7 +534,8 @@
 usage(void)
 {
        fprintf(stderr, "usage: %s [-2dfi] [-C thresh] [-D device] [-I file]"
-           " [-M N=M]\n\t[-p device] [-t type]\n", __progname);
+           " [-M N=M]\n\t[-p device] [-t type] [-x decel] [-y decel]\n",
+           __progname);
        exit(1);
 }
 
@@ -530,8 +546,9 @@
        unsigned int type;
        int opt;
        int i;
+       const char *errstr;
 
-#define GETOPT_STRING "2dfhip:t:C:D:I:M:"
+#define GETOPT_STRING "2dfhip:t:x:y:C:D:I:M:"
        while ((opt = (getopt(argc, argv, GETOPT_STRING))) != -1) {
                switch (opt) {
                case '2':
@@ -572,6 +589,27 @@
                        warnx("no such mouse protocol `%s'", optarg);
                        usage();
                        break;
+               case 'x':
+#define MAX_DECELERATION 100 /* max num of event drops for mouse movement */
+                       mouse.xdecel = strtonum(optarg, 1,
+                           MAX_DECELERATION, &errstr);
+                       if (errstr != NULL) {
+                               warnx("X axis deceleration factor `%s' is %s, "
+                                   "acceptable range is 1-%d",
+                                   optarg, errstr, MAX_DECELERATION);
+                               usage();
+                       }
+                       break;
+               case 'y':
+                       mouse.ydecel = strtonum(optarg, 1,
+                           MAX_DECELERATION, &errstr);
+                       if (errstr != NULL) {
+                               warnx("Y axis deceleration factor `%s' is %s, "
+                                  "acceptable range is 1-%d",
+                                  optarg, errstr, MAX_DECELERATION);
+                               usage();
+                       }
+               break;
                case 'C':
 #define MAX_CLICKTHRESHOLD 2000 /* max delay for double click */
                        mouse.clickthreshold = atoi(optarg);
Index: wsmoused.h
===================================================================
RCS file: /cvs/src/usr.sbin/wsmoused/wsmoused.h,v
retrieving revision 1.8
diff -u wsmoused.h
--- wsmoused.h  21 Jun 2009 16:13:18 -0000      1.8
+++ wsmoused.h  3 Sep 2009 19:44:10 -0000
@@ -107,6 +107,10 @@
        int mfd;                /* mouse file descriptor */
        int cfd;                /* console file descriptor */
        long clickthreshold;    /* double click speed in msec */
+       int xdecel;             /* x-axis deceleration factor */
+       int ydecel;             /* y-axis deceleration factor */
+       unsigned int xmov;      /* x-axis movement tracking */
+       unsigned int ymov;      /* y-axis movement tracking */
 } mouse_t;
 
 /* Mouse buttons */

Reply via email to