Changing Mouse sensitivity

Jürgen Appel jappel at linux01.gwdg.de
Mon Apr 16 22:43:02 PDT 2007


Hi,

As an owner of a high resolution bluetooth mouse I was very disappointed that 
I could barely use this mouse with my laptop since its speed was much too 
fast. The Option "Resolution" setting in the xorg.conf had no effect and 
setting a constand decelleration via xset was no option since that would 
render my touchpad unusable.

Since the big google did not find any solution, and since the original code 
was open source and quite well written, I decided to take the matter 
into my own hands and wrote the following patch to add  a per-pointing-device 
option to the xorg.conf that allowed me to change my mouse's sensitivity by 
an arbitrary factor independently from my touchpad response.
The line
  Option       "Sensitivity" ".5"
in the Section "InputDevice" for my mouse now solves all my problems and might 
be of interest for others too.  

Although I cant really think about any use for real values >1, it is still 
possible. However this might make it impossible to point the mouse at certain 
pixels so use it with care.

So please enjoy and let me hear about your opinions about this!

diff -Naur xf86-input-mouse-1.1.2/src/mouse.c 
xf86-input-mouse-1.1.2.ja2/src/mouse.c
--- xf86-input-mouse-1.1.2/src/mouse.c  2006-10-11 16:23:54.000000000 -0600
+++ xf86-input-mouse-1.1.2.ja2/src/mouse.c      2007-04-02 
04:56:24.000000000 -0600
@@ -213,7 +213,8 @@
     OPTION_VMIN,
     OPTION_DRAGLOCKBUTTONS,
     OPTION_DOUBLECLICK_BUTTONS,
-    OPTION_BUTTON_MAPPING
+    OPTION_BUTTON_MAPPING,
+    OPTION_SENSITIVITY
 } MouseOpts;
 
 #ifdef XFree86LOADER
@@ -257,6 +258,7 @@
     { OPTION_DRAGLOCKBUTTONS,  "DragLockButtons",OPTV_STRING,  {0}, FALSE },
     { OPTION_DOUBLECLICK_BUTTONS,"DoubleClickButtons", OPTV_STRING, {0}, 
FALSE },
     { OPTION_BUTTON_MAPPING,   "ButtonMapping",   OPTV_STRING,  {0}, FALSE },
+    { OPTION_SENSITIVITY,      "Sensitivity",     OPTV_REAL,    {0}, FALSE },
     { -1,                      NULL,             OPTV_NONE,    {0}, FALSE }
 };
 #endif
@@ -799,6 +801,12 @@
        xf86Msg(X_CONFIG, "%s: Resolution: %d\n", pInfo->name,
                pMse->resolution);
     }
+
+    if (mPriv->sensitivity 
+       = xf86SetRealOption(pInfo->options, "Sensitivity", 1)) {
+       xf86Msg(X_CONFIG, "%s: Sensitivity: %g\n", pInfo->name,
+               mPriv->sensitivity);
+    }
 }
 
 static void
@@ -2350,8 +2358,9 @@
     MouseDevPtr pMse;
     int zbutton = 0, wbutton = 0, zbuttoncount = 0, wbuttoncount = 0;
     int i, b, buttons = 0;
-
     pMse = pInfo->private;
+    mousePrivPtr    mousepriv = (mousePrivPtr)pMse->mousePriv;
+
     if (pMse->protocolID == PROT_MMHIT)
        b = reverseBits(hitachMap, truebuttons);
     else
@@ -2441,6 +2449,14 @@
        dy = tmp;
     }
 
+    /* Accumulate the scaled dx, dy in the private variables sumdx,sumdy and 
return the integer number part */
+    if (mousepriv) {
+      mousepriv->sumdx+=mousepriv->sensitivity*dx;
+      mousepriv->sumdy+=mousepriv->sensitivity*dy;
+      mousepriv->sumdx-=(dx=(int)(mousepriv->sumdx));
+      mousepriv->sumdy-=(dy=(int)(mousepriv->sumdy));
+    }
+
     /* If mouse wheel movement has to be mapped on a button, we need to
      * loop for button press and release events. */
     do {
diff -Naur xf86-input-mouse-1.1.2/src/mousePriv.h 
xf86-input-mouse-1.1.2.ja2/src/mousePriv.h
--- xf86-input-mouse-1.1.2/src/mousePriv.h      2006-10-11 
16:23:54.000000000 -0600
+++ xf86-input-mouse-1.1.2.ja2/src/mousePriv.h  2007-04-02 
04:56:42.000000000 -0600
@@ -64,6 +64,8 @@
     int                acc;
     CARD32     pnpLast;
     Bool       disablePnPauto;
+    double      sumdx,sumdy; 
+    double      sensitivity;
 } mousePrivRec, *mousePrivPtr;
 
 /* mouse proto flags */

Cheers,
	Jürgen
-- 
GPG key: 
http://pgp.mit.edu:11371/pks/lookup?search=J%FCrgen+Appel&op=get
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.x.org/archives/xorg/attachments/20070416/2c9c9a5c/attachment.pgp>


More information about the xorg mailing list