From: Chris Bagwell <ch...@cnpbagwell.com>

Gestures will work on wider range of hardware with different
resolutions now.

Signed-off-by: Chris Bagwell <ch...@cnpbagwell.com>
---

I had developed this on a non-wacom touchscreen originally and didn't
bother to test this version on Bamboo.  Turned out init order was different
and causing -1 to be seen for some values.  Got rid of Default concept for
Gesture info stored in Common structure to prevent being overwrite by -1.

Pushed to github gesture3 branch.

 src/wcmCommon.c         |    8 +++-----
 src/wcmTouchFilter.c    |   36 ++++++++++++++++++++++++++----------
 src/wcmValidateDevice.c |   12 ++++++------
 src/xf86Wacom.c         |    1 +
 src/xf86Wacom.h         |    2 ++
 src/xf86WacomDefs.h     |    4 +---
 6 files changed, 39 insertions(+), 24 deletions(-)

diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index e4ff7d9..9e71c37 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -1393,13 +1393,11 @@ WacomCommonPtr wcmNewCommon(void)
        common->wcmFlags = 0;               /* various flags */
        common->wcmProtocolLevel = WCM_PROTOCOL_4; /* protocol level */
        common->wcmTPCButton = 0;          /* set Tablet PC button on/off */
-       common->wcmGestureParameters.wcmZoomDistance = 50;
-       common->wcmGestureParameters.wcmZoomDistanceDefault = 50;
+       common->wcmGestureParameters.wcmZoomDistance = -1;
        common->wcmGestureParameters.wcmScrollDirection = 0;
-       common->wcmGestureParameters.wcmScrollDistance = 20;
-       common->wcmGestureParameters.wcmScrollDistanceDefault = 20;
+       common->wcmGestureParameters.wcmScrollDistance = -1;
+       common->wcmGestureParameters.wcmInlineDistance = -1;
        common->wcmGestureParameters.wcmTapTime = 250;
-       common->wcmGestureParameters.wcmTapTimeDefault = 250;
        common->wcmRotate = ROTATE_NONE;   /* default tablet rotation to off */
        common->wcmMaxX = 0;               /* max digitizer logical X value */
        common->wcmMaxY = 0;               /* max digitizer logical Y value */
diff --git a/src/wcmTouchFilter.c b/src/wcmTouchFilter.c
index 1600705..0e1e258 100644
--- a/src/wcmTouchFilter.c
+++ b/src/wcmTouchFilter.c
@@ -24,7 +24,6 @@
 #include <math.h>
 
 /* Defines for 2FC Gesture */
-#define WACOM_INLINE_DISTANCE        40
 #define WACOM_HORIZ_ALLOWED           1
 #define WACOM_VERT_ALLOWED            2
 #define WACOM_GESTURE_LAG_TIME       10
@@ -43,6 +42,20 @@
 static void wcmFingerScroll(WacomDevicePtr priv);
 static void wcmFingerZoom(WacomDevicePtr priv);
 
+void wcmInitGestureSizes(InputInfoPtr pInfo)
+{
+       WacomDevicePtr priv = (WacomDevicePtr) pInfo->private;
+       WacomCommonPtr common = priv->common;
+       WacomGesturesParameters *gp = &common->wcmGestureParameters;
+
+       if (gp->wcmZoomDistance == -1)
+               gp->wcmZoomDistance = priv->maxX * (1600.0 / 14720);
+       if (gp->wcmScrollDistance == -1)
+               gp->wcmScrollDistance = priv->maxX * (640.0 / 14720);
+       if (gp->wcmInlineDistance == -1)
+               gp->wcmInlineDistance = priv->maxX * (1280.0 / 14720);
+}
+
 static double touchDistance(WacomDeviceState ds0, WacomDeviceState ds1)
 {
        int xDelta = ds0.x - ds1.x;
@@ -61,17 +74,18 @@ static Bool pointsInLine(WacomCommonPtr common, 
WacomDeviceState ds0,
                        WACOM_HORIZ_ALLOWED : WACOM_VERT_ALLOWED;
        int vertical_rotated = (rotated) ?
                        WACOM_VERT_ALLOWED : WACOM_HORIZ_ALLOWED;
+       int inline_distance = common->wcmGestureParameters.wcmInlineDistance;
 
        if (!common->wcmGestureParameters.wcmScrollDirection)
        {
-               if ((abs(ds0.x - ds1.x) < WACOM_INLINE_DISTANCE) &&
-                       (abs(ds0.y - ds1.y) > WACOM_INLINE_DISTANCE))
+               if ((abs(ds0.x - ds1.x) < inline_distance) &&
+                       (abs(ds0.y - ds1.y) > inline_distance))
                {
                        common->wcmGestureParameters.wcmScrollDirection = 
horizon_rotated;
                        ret = TRUE;
                }
-               if ((abs(ds0.y - ds1.y) < WACOM_INLINE_DISTANCE) &&
-                       (abs(ds0.x - ds1.x) > WACOM_INLINE_DISTANCE))
+               if ((abs(ds0.y - ds1.y) < inline_distance) &&
+                       (abs(ds0.x - ds1.x) > inline_distance))
                {
                        common->wcmGestureParameters.wcmScrollDirection = 
vertical_rotated;
                        ret = TRUE;
@@ -79,12 +93,12 @@ static Bool pointsInLine(WacomCommonPtr common, 
WacomDeviceState ds0,
        }
        else if (common->wcmGestureParameters.wcmScrollDirection == 
vertical_rotated)
        {
-               if (abs(ds0.y - ds1.y) < WACOM_INLINE_DISTANCE)
+               if (abs(ds0.y - ds1.y) < inline_distance)
                        ret = TRUE;
        }
        else if (common->wcmGestureParameters.wcmScrollDirection == 
horizon_rotated)
        {
-               if (abs(ds0.x - ds1.x) < WACOM_INLINE_DISTANCE)
+               if (abs(ds0.x - ds1.x) < inline_distance)
                        ret = TRUE;
        }
        return ret;
@@ -414,6 +428,7 @@ static void wcmFingerScroll(WacomDevicePtr priv)
        int midPoint_old = 0;
        int i = 0, dist = 0;
        WacomFilterState filterd;  /* borrow this struct */
+       int inline_distance = common->wcmGestureParameters.wcmInlineDistance;
 
        DBG(10, priv, "\n");
 
@@ -421,7 +436,7 @@ static void wcmFingerScroll(WacomDevicePtr priv)
        {
                if (abs(touchDistance(ds[0], ds[1]) -
                        touchDistance(common->wcmGestureState[0],
-                       common->wcmGestureState[1])) < WACOM_INLINE_DISTANCE)
+                       common->wcmGestureState[1])) < inline_distance)
                {
                        /* two fingers stay close to each other all the time and
                         * move in vertical or horizontal direction together
@@ -511,6 +526,7 @@ static void wcmFingerZoom(WacomDevicePtr priv)
        int count, button;
        int dist = touchDistance(common->wcmGestureState[0],
                        common->wcmGestureState[1]);
+       int inline_distance = common->wcmGestureParameters.wcmInlineDistance;
 
        DBG(10, priv, "\n");
 
@@ -520,13 +536,13 @@ static void wcmFingerZoom(WacomDevicePtr priv)
                if (abs(touchDistance(ds[0], ds[1]) -
                        touchDistance(common->wcmGestureState[0],
                                      common->wcmGestureState[1])) >
-                       (3 * WACOM_INLINE_DISTANCE))
+                       (3 * inline_distance))
                {
                        /* left button might be down, send it up first */
                        wcmSendButtonClick(priv, 1, 0);
 
                        /* fingers moved apart more than 3 times
-                        * WACOM_INLINE_DISTANCE, zoom mode is entered */
+                        * wcmInlineDistance, zoom mode is entered */
                        common->wcmGestureMode = GESTURE_ZOOM_MODE;
                }
        }
diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c
index e0a78d9..955bdea 100644
--- a/src/wcmValidateDevice.c
+++ b/src/wcmValidateDevice.c
@@ -878,12 +878,12 @@ Bool wcmParseOptions(InputInfoPtr pInfo, Bool is_primary, 
Bool is_dependent)
        {
                int gesture_is_on;
 
-               /* GestureDefault was off for all devices
+               /* Gesture was off for all devices
                 * except when multi-touch is supported */
-               common->wcmGestureDefault = 1;
+               common->wcmGesture = 1;
 
                gesture_is_on = xf86SetBoolOption(pInfo->options, "Gesture",
-                                           common->wcmGestureDefault);
+                                           common->wcmGesture);
 
                if (is_primary || IsTouch(priv))
                        common->wcmGesture = gesture_is_on;
@@ -893,15 +893,15 @@ Bool wcmParseOptions(InputInfoPtr pInfo, Bool is_primary, 
Bool is_dependent)
 
                common->wcmGestureParameters.wcmZoomDistance =
                        xf86SetIntOption(pInfo->options, "ZoomDistance",
-                       common->wcmGestureParameters.wcmZoomDistanceDefault);
+                       common->wcmGestureParameters.wcmZoomDistance);
 
                common->wcmGestureParameters.wcmScrollDistance =
                        xf86SetIntOption(pInfo->options, "ScrollDistance",
-                       common->wcmGestureParameters.wcmScrollDistanceDefault);
+                       common->wcmGestureParameters.wcmScrollDistance);
 
                common->wcmGestureParameters.wcmTapTime =
                        xf86SetIntOption(pInfo->options, "TapTime",
-                       common->wcmGestureParameters.wcmTapTimeDefault);
+                       common->wcmGestureParameters.wcmTapTime);
        }
 
        /* Swap stylus buttons 2 and 3 for Tablet PCs */
diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index 16561b5..62738a6 100644
--- a/src/xf86Wacom.c
+++ b/src/xf86Wacom.c
@@ -436,6 +436,7 @@ static int wcmDevInit(DeviceIntPtr pWcm)
        {
                wcmInitialToolSize(pInfo);
                wcmMappingFactor(pInfo);
+               wcmInitGestureSizes(pInfo);
        }
 
        if (!wcmInitAxes(pWcm))
diff --git a/src/xf86Wacom.h b/src/xf86Wacom.h
index 60353dc..72d06bb 100644
--- a/src/xf86Wacom.h
+++ b/src/xf86Wacom.h
@@ -128,6 +128,8 @@ Bool wcmAreaListOverlap(WacomToolAreaPtr area, 
WacomToolAreaPtr list);
 
 /* calculate the proper tablet to screen mapping factor */
 void wcmMappingFactor(InputInfoPtr pInfo);
+/* calculate gesture sizes based on tablet sizes */
+void wcmInitGestureSizes(InputInfoPtr pInfo);
 
 /* validation */
 extern Bool wcmIsAValidType(InputInfoPtr pInfo, const char* type);
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index 94eee2e..6e1549a 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -411,10 +411,9 @@ extern WacomDeviceClass gWacomISDV4Device;
 
 typedef struct {
        int wcmZoomDistance;           /* minimum distance for a zoom touch 
gesture */
-       int wcmZoomDistanceDefault;    /* default minimum distance for a zoom 
touch gesture */
        int wcmScrollDistance;         /* minimum motion before sending a 
scroll gesture */
        int wcmScrollDirection;        /* store the vertical or horizontal bit 
in use */
-       int wcmScrollDistanceDefault;  /* default minimum motion before sending 
a scroll gesture */
+       int wcmInlineDistance;         /* maximum distance between fingers for 
scroll gesture */
        int wcmGestureUsed;            /* retain used gesture count within one 
in-prox event */
        int wcmTapTime;                /* minimum time between taps for a right 
click */
        int wcmTapTimeDefault;         /* default minimum time between taps for 
a right click */
@@ -480,7 +479,6 @@ struct _WacomCommonRec
        int wcmTouch;                /* disable/enable touch event */
        int wcmTouchDefault;         /* default to disable when not supported */
        int wcmGesture;              /* disable/enable touch gesture */
-       int wcmGestureDefault;       /* default touch gesture to disable when 
not supported */
        int wcmGestureMode;            /* data is in Gesture Mode? */
        WacomDeviceState wcmGestureState[MAX_FINGERS]; /* inital state when in 
gesture mode */
        WacomGesturesParameters wcmGestureParameters;
-- 
1.7.6


------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to