From 982b30507632b984bed1169d074d905a9a5d2990 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Sun, 16 Aug 2009 21:33:43 -0700 Subject: [PATCH] [PATCH] Allow 0 as wheel emulation button for unconditional scrolling (#20529) If wheel emulation is on and the emulation button is 0, then any x/y motion of the device is converted into wheel events. The device becomes a scrolling-only device. Signed-off-by: Dima Kogan Signed-off-by: Dima Kogan --- man/mousedrv.man | 3 ++- src/mouse.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/man/mousedrv.man b/man/mousedrv.man index bc6773f..e805335 100644 --- a/man/mousedrv.man +++ b/man/mousedrv.man @@ -155,7 +155,8 @@ press/release events as specified for the .B XAxisMapping and .B YAxisMapping -settings. Default: 4. +settings. If set to 0, no button is required and any motion of the device +is converted into wheel events. Default: 4. .TP 7 .BI "Option \*qEmulateWheelInertia\*q \*q" integer \*q Specifies how far (in pixels) the pointer must move to generate button diff --git a/src/mouse.c b/src/mouse.c index dd3eb2e..1899edc 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -2059,7 +2059,10 @@ MouseDoPostEvent(InputInfoPtr pInfo, int buttons, int dx, int dy) if (pMse->emulateWheel) { /* Emulate wheel button handling */ - wheelButtonMask = 1 << (pMse->wheelButton - 1); + if(pMse->wheelButton == 0) + wheelButtonMask = 0; + else + wheelButtonMask = 1 << (pMse->wheelButton - 1); if (change & wheelButtonMask) { if (buttons & wheelButtonMask) { @@ -2081,9 +2084,10 @@ MouseDoPostEvent(InputInfoPtr pInfo, int buttons, int dx, int dy) } else ms = pMse->wheelButtonExpires - GetTimeInMillis (); - /* Intercept wheel emulation. */ - if (buttons & wheelButtonMask) { - if (ms <= 0) { + /* Intercept wheel emulation if the necessary button is depressed or + if no button is necessary */ + if ((buttons & wheelButtonMask) || wheelButtonMask==0) { + if (ms <= 0 || wheelButtonMask==0) { /* Y axis movement */ if (pMse->negativeY != MSE_NOAXISMAP) { pMse->wheelYDistance += dy; -- 1.6.2.4