The I4 scrollring appears as absolute axis (0 - 71) to us, but as
ring-shaped device to the user. Hence, a coordinate transition from 0..71 or
71..0 is common but must be interpreted as a negative or postive movement
direction, respectively.

Add code to detect this by simply assuming that if the direct delta of
old_x → x is larger than the indirect delta (across the axis range
boundary), a wraparound happened. In that casel, switch the delta used for
scroll wheel button emulation around.

Signed-off-by: Peter Hutterer <[email protected]>
---
 src/wcmCommon.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 93837f7..bd1a198 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -405,7 +405,23 @@ static int getWheelButton(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        if ( (ds->abswheel != priv->oldWheel) && IsPad(priv) &&
            (priv->oldProximity == ds->proximity))
        {
+               int wrap_delta;
                value = priv->oldWheel - ds->abswheel;
+
+               /* Wraparound detection. If the distance oldvalue..value is
+                * larger than the oldvalue..value considering the
+                * wraparound, assume wraparound and readjust */
+               if (value < 0)
+                       wrap_delta = ((MAX_PAD_RING + 1) + priv->oldWheel) - 
ds->abswheel;
+               else
+                       wrap_delta = priv->oldWheel - ((MAX_PAD_RING + 1) + 
ds->abswheel);
+
+               DBG(12, priv, "wrap detection for %d (old %d): %d (wrap %d)\n",
+                   ds->abswheel, priv->oldWheel, value, wrap_delta);
+
+               if (abs(wrap_delta) < abs(value))
+                       value = wrap_delta;
+
                fakeButton = (value > 0) ? priv->wheelup : priv->wheeldn;
                *fakeKey = (value > 0) ? priv->wheel_keys[2] : 
priv->wheel_keys[3];
        }
-- 
1.7.3.4


------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to