On Sat, Aug 27, 2011 at 12:03:19PM -0500, [email protected] wrote:
> From: Chris Bagwell <[email protected]>
>
> Signed-off-by: Chris Bagwell <[email protected]>
> ---
>
> This patch is added to my github gesture3 branch but probably applys
> fine to master as well.
>
> Current 2 finger gesture logic is geared towards resolution of old Bamboo
> linuxwacom driver. It doesn't work well with Linux kernel Bamboo driver
> (it scales up resolution) or various touchscreens of random resolution.
>
> src/wcmCommon.c | 9 +++++----
> src/wcmTouchFilter.c | 36 ++++++++++++++++++++++++++----------
> src/xf86Wacom.c | 1 +
> src/xf86Wacom.h | 2 ++
> src/xf86WacomDefs.h | 1 +
> 5 files changed, 35 insertions(+), 14 deletions(-)
>
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index e4ff7d9..1d38196 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -1393,11 +1393,12 @@ 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.wcmZoomDistanceDefault = -1;
git grep shows that wcmZoomDistanceDefault isn't used anywhere anymore. Best
to remove it in that case. same with wcmScrollDistanceDefault.
> common->wcmGestureParameters.wcmScrollDirection = 0;
> - common->wcmGestureParameters.wcmScrollDistance = 20;
> - common->wcmGestureParameters.wcmScrollDistanceDefault = 20;
> + common->wcmGestureParameters.wcmScrollDistance = -1;
> + common->wcmGestureParameters.wcmScrollDistanceDefault = -1;
> + common->wcmGestureParameters.wcmInlineDistance = -1;
> common->wcmGestureParameters.wcmTapTime = 250;
> common->wcmGestureParameters.wcmTapTimeDefault = 250;
> common->wcmRotate = ROTATE_NONE; /* default tablet rotation to off */
> 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);
where do these numbers come from again?
shouldn't they have defines?
> +}
> +
> 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/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..65b7088 100644
> --- a/src/xf86WacomDefs.h
> +++ b/src/xf86WacomDefs.h
> @@ -414,6 +414,7 @@ typedef struct {
> 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 wcmInlineDistance; /* maximum distance between fingers for
> scroll gesture */
this should probably be named something like maxScrollDistance to be more
explanatory.
Cheers,
Peter
> int wcmScrollDistanceDefault; /* default minimum motion before sending
> a scroll gesture */
> int wcmGestureUsed; /* retain used gesture count within one
> in-prox event */
> int wcmTapTime; /* minimum time between taps for a right
> click */
> --
> 1.7.6
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel