From e567cb0792ea3dc2cd68c46628332c1f8bbb173d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Appel?= Date: Mon, 23 Apr 2007 15:54:08 +0200 Subject: [PATCH] Added "Sensitivity" option. Use for slowing down high resolution mice. --- man/mousedrv.man | 9 +++++++++ src/mouse.c | 22 +++++++++++++++++++++- src/mousePriv.h | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/man/mousedrv.man b/man/mousedrv.man index 231935c..714fb05 100644 --- a/man/mousedrv.man +++ b/man/mousedrv.man @@ -210,6 +210,15 @@ Sets the resolution of the device in counts per inch. Setting this is only supported for some mice, including some PS/2 mice on some platforms. Default: whatever the mouse is already set to. .TP 7 +.BI "Option \*qSensitivity\*q \*q" float \*q +Mouse movements are multiplied by this float before being processed. Use this +mechanism to slow down high resolution mice. Because values bigger than 1.0 +will result in not all pixels on the screen being accessible, you should better +use mouse acceleration (see +.BR "man xset" ) +for speeding up low resolution mice. +Default: 1.0 +.TP 7 .BI "Option \*qDragLockButtons\*q \*q" "L1 B2 L3 B4" \*q Sets \*qdrag lock buttons\*q that simulate holding a button down, so that low dexterity people do not have to hold a button down at the diff --git a/src/mouse.c b/src/mouse.c index aea0e55..d11c9ba 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -213,7 +213,8 @@ typedef enum { OPTION_VMIN, OPTION_DRAGLOCKBUTTONS, OPTION_DOUBLECLICK_BUTTONS, - OPTION_BUTTON_MAPPING + OPTION_BUTTON_MAPPING, + OPTION_SENSITIVITY } MouseOpts; #ifdef XFree86LOADER @@ -257,6 +258,7 @@ static const OptionInfoRec mouseOptions[] = { { 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 @@ MouseHWOptions(InputInfoPtr pInfo) xf86Msg(X_CONFIG, "%s: Resolution: %d\n", pInfo->name, pMse->resolution); } + + if (mPriv->sensitivity + = xf86SetRealOption(pInfo->options, "Sensitivity", 1.0)) { + xf86Msg(X_CONFIG, "%s: Sensitivity: %g\n", pInfo->name, + mPriv->sensitivity); + } } static void @@ -2365,10 +2373,13 @@ MousePostEvent(InputInfoPtr pInfo, int truebuttons, int dx, int dy, int dz, int dw) { MouseDevPtr pMse; + mousePrivPtr mousepriv; int zbutton = 0, wbutton = 0, zbuttoncount = 0, wbuttoncount = 0; int i, b, buttons = 0; pMse = pInfo->private; + mousepriv = (mousePrivPtr)pMse->mousePriv; + if (pMse->protocolID == PROT_MMHIT) b = reverseBits(hitachMap, truebuttons); else @@ -2458,6 +2469,15 @@ MousePostEvent(InputInfoPtr pInfo, int truebuttons, dy = tmp; } + /* Accumulate the scaled dx, dy in the private variables + fracdx,fracdy and return the integer number part */ + if (mousepriv) { + mousepriv->fracdx += mousepriv->sensitivity*dx; + mousepriv->fracdy += mousepriv->sensitivity*dy; + mousepriv->fracdx -= ( dx=(int)(mousepriv->fracdx) ); + mousepriv->fracdy -= ( dy=(int)(mousepriv->fracdy) ); + } + /* If mouse wheel movement has to be mapped on a button, we need to * loop for button press and release events. */ do { diff --git a/src/mousePriv.h b/src/mousePriv.h index 262d029..79dcdd1 100644 --- a/src/mousePriv.h +++ b/src/mousePriv.h @@ -64,6 +64,8 @@ typedef struct { int acc; CARD32 pnpLast; Bool disablePnPauto; + float fracdx,fracdy; + float sensitivity; } mousePrivRec, *mousePrivPtr; /* mouse proto flags */