Hi,

I hope I'm not the only one being annoyed by the fast movement of wsmouse when
in text mode, and this one can be useful.

Here is a patch that slows down the cursor by reducing the mouse coordinates
proportionally to the console font size.
I confess I have only tried it on this laptop with its Synaptics touchpad and
some other USB mouses.

Anyone else interested ?

Thierry

Index: sys/dev/wscons/wsdisplay.c
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wsdisplay.c,v
retrieving revision 1.124
diff -u -p -r1.124 wsdisplay.c
--- dev/wscons/wsdisplay.c      8 Sep 2015 11:13:20 -0000       1.124
+++ dev/wscons/wsdisplay.c      26 Nov 2015 20:28:48 -0000
@@ -2463,27 +2463,39 @@ ctrl_event(struct wsdisplay_softc *sc, u
 void
 mouse_moverel(struct wsscreen *scr, int dx, int dy)
 {
+       static int acc_dx, acc_dy;
        struct wsscreen_internal *dconf = scr->scr_dconf;
+       const struct wsscreen_descr *descr = dconf->scrdata;
        u_int old_mouse = scr->mouse;
        int mouse_col = scr->mouse % N_COLS(dconf);
        int mouse_row = scr->mouse / N_COLS(dconf);
+       int norm_dx, norm_dy;
+
+       /* accumulate movement and calculate character equivalent */
+       acc_dx += dx;
+       if ((norm_dx = acc_dx / descr->fontwidth )) acc_dx -= descr->fontwidth  
* norm_dx;
+       acc_dy += dy;
+       if ((norm_dy = acc_dy / descr->fontheight)) acc_dy -= descr->fontheight 
* norm_dy;
+
+       /* bail out if mouse hasn't virtually moved */
+       if (norm_dx == 0 && norm_dy == 0) return;
 
        /* update position */
-       if (mouse_col + dx >= MAXCOL(dconf))
+       if (mouse_col + norm_dx >= MAXCOL(dconf))
                mouse_col = MAXCOL(dconf);
        else {
-               if (mouse_col + dx <= 0)
+               if (mouse_col + norm_dx <= 0)
                        mouse_col = 0;
                else
-                       mouse_col += dx;
+                       mouse_col += norm_dx;
        }
-       if (mouse_row + dy >= MAXROW(dconf))
+       if (mouse_row + norm_dy >= MAXROW(dconf))
                mouse_row = MAXROW(dconf);
        else {
-               if (mouse_row + dy <= 0)
+               if (mouse_row + norm_dy <= 0)
                        mouse_row = 0;
                else
-                       mouse_row += dy;
+                       mouse_row += norm_dy;
        }
        scr->mouse = mouse_row * N_COLS(dconf) + mouse_col;
 

Reply via email to