diff options
author | Alexey Osipov <simba@lerlan.ru> | 2012-01-03 15:13:48 +0700 |
---|---|---|
committer | Jason Gerecke <killertofu@gmail.com> | 2012-01-03 09:25:23 -0800 |
commit | 5ca665dd77b074d95fd0d9191f544b022eaaddd8 (patch) | |
tree | 77fbe442c71bdbfdb246943407ea8602dd273f73 | |
parent | 1c5c25d7b4a4ce0686f6a088d282e437dbadadfe (diff) | |
download | xf86-input-wacom-5ca665dd77b074d95fd0d9191f544b022eaaddd8.tar.gz |
'Left mouse button' dragging support.
First, we define two new GESTURE_ modes:
- GESTURE_PREDRAG_MODE - when first tap happen and we wait for second touch.
- GESTURE_DRAG_MODE - when actual drag happening (left button pressed).
Second, we define tap timeout function wcmSingleFingerTapTimer(), which
simulate single click if no drag operation started within timeout.
Third, we make an exception for GESTURE_DRAG_MODE in wcmCommon.c, because
we actually want cursor movements while dragging. This exception is made
through new function wcmTouchNeedSendEvents().
Now, to do a single tap you just tap (touch and untouch). Actual click
happens after TapTime period.
To drag something you make a tap (touch and untouch) and then quickly
(in TapTime period) touch device again. Then drag.
Signed-off-by: Alexey Osipov <simba@lerlan.ru>
Reviewed-by: Chris Bagwell <chris@cnpgabwell.com>
-rw-r--r-- | src/wcmCommon.c | 4 | ||||
-rw-r--r-- | src/wcmTouchFilter.c | 56 | ||||
-rw-r--r-- | src/wcmTouchFilter.h | 2 |
3 files changed, 52 insertions, 10 deletions
diff --git a/src/wcmCommon.c b/src/wcmCommon.c index 055583d..0f041e3 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -812,8 +812,8 @@ void wcmSendEvents(InputInfoPtr pInfo, const WacomDeviceState* ds) if (type == PAD_ID) wcmSendPadEvents(pInfo, ds, 3, priv->naxes - 3, &valuators[3]); /* pad doesn't post x/y/z */ else { - /* don't move the cursor if in gesture mode */ - if (!priv->common->wcmGestureMode) + /* don't move the cursor if in gesture mode (except drag mode) */ + if ((type != TOUCH_ID) || wcmTouchNeedSendEvents(priv->common)) wcmSendNonPadEvents(pInfo, ds, 0, priv->naxes, valuators); } diff --git a/src/wcmTouchFilter.c b/src/wcmTouchFilter.c index e67777e..0d1f950 100644 --- a/src/wcmTouchFilter.c +++ b/src/wcmTouchFilter.c @@ -1,5 +1,6 @@ /* * Copyright 2009 - 2010 by Ping Cheng, Wacom. <pingc@wacom.com> + * Copyright 2011 by Alexey Osipov. <simba@lerlan.ru> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -34,6 +35,8 @@ #define GESTURE_SCROLL_MODE 2 #define GESTURE_ZOOM_MODE 4 #define GESTURE_LAG_MODE 8 +#define GESTURE_PREDRAG_MODE 16 +#define GESTURE_DRAG_MODE 32 #define WCM_SCROLL_UP 5 /* vertical up */ #define WCM_SCROLL_DOWN 4 /* vertical down */ @@ -140,6 +143,23 @@ static void wcmFingerTapToClick(WacomDevicePtr priv) } } +static CARD32 wcmSingleFingerTapTimer(OsTimerPtr timer, CARD32 time, pointer arg) +{ + WacomDevicePtr priv = (WacomDevicePtr)arg; + WacomCommonPtr common = priv->common; + + if (common->wcmGestureMode == GESTURE_PREDRAG_MODE) + { + /* left button down */ + wcmSendButtonClick(priv, 1, 1); + + /* left button up */ + wcmSendButtonClick(priv, 1, 0); + common->wcmGestureMode = GESTURE_NONE_MODE; + } + + return 0; +} /* A single finger tap is defined as 1 finger tap that lasts less than * wcmTapTime. It results in a left button press. @@ -178,11 +198,10 @@ static void wcmSingleFingerTap(WacomDevicePtr priv) common->wcmGestureParameters.wcmTapTime && ds[1].sample < dsLast[0].sample) { - /* left button down */ - wcmSendButtonClick(priv, 1, 1); + common->wcmGestureMode = GESTURE_PREDRAG_MODE; - /* left button up */ - wcmSendButtonClick(priv, 1, 0); + /* Delay to detect possible drag operation */ + TimerSet(NULL, 0, common->wcmGestureParameters.wcmTapTime, wcmSingleFingerTapTimer, priv); } } } @@ -248,17 +267,19 @@ void wcmGestureFilter(WacomDevicePtr priv, int channel) if (common->wcmGestureMode == GESTURE_NONE_MODE) common->wcmGestureMode = GESTURE_LAG_MODE; } - /* When only 1 finger is in proximity, it can be in either LAG mode - * or NONE mode. + /* When only 1 finger is in proximity, it can be in either LAG mode, + * NONE mode or DRAG mode. * 1 finger LAG mode is a very short time period mainly to debounce * initial touch. - * NONE mode means cursor is allowed to move around. + * NONE and DRAG mode means cursor is allowed to move around. + * DRAG mode in addition means that left button pressed. + * There is no need to bother about LAG_TIME while in DRAG mode. * TODO: This has to use dsLast[0] because of later logic that * wants mode to be NONE still when 1st entering proximity. * That could use some re-arranging/cleanup. * */ - else if (dsLast[0].proximity) + else if (dsLast[0].proximity && common->wcmGestureMode != GESTURE_DRAG_MODE) { CARD32 ms = GetTimeInMillis(); @@ -297,6 +318,16 @@ void wcmGestureFilter(WacomDevicePtr priv, int channel) /* initialize the cursor position */ if (common->wcmGestureMode == GESTURE_NONE_MODE && !channel) goto ret; + + /* got second touch in TapTime interval after first one, + * switch to DRAG mode */ + if (common->wcmGestureMode == GESTURE_PREDRAG_MODE) + { + /* left button down */ + wcmSendButtonClick(priv, 1, 1); + common->wcmGestureMode = GESTURE_DRAG_MODE; + goto ret; + } } if (!ds[0].proximity && !ds[1].proximity) @@ -307,6 +338,10 @@ void wcmGestureFilter(WacomDevicePtr priv, int channel) /* send first finger out prox */ wcmSoftOutEvent(priv->pInfo); + /* if were in DRAG mode, send left button up now */ + if (common->wcmGestureMode == GESTURE_DRAG_MODE) + wcmSendButtonClick(priv, 1, 0); + /* exit gesture mode when both fingers are out */ common->wcmGestureMode = GESTURE_NONE_MODE; common->wcmGestureParameters.wcmScrollDirection = 0; @@ -561,4 +596,9 @@ static void wcmFingerZoom(WacomDevicePtr priv) } } +Bool wcmTouchNeedSendEvents(WacomCommonPtr common) +{ + return !(common->wcmGestureMode & ~GESTURE_DRAG_MODE); +} + /* vim: set noexpandtab tabstop=8 shiftwidth=8: */ diff --git a/src/wcmTouchFilter.h b/src/wcmTouchFilter.h index 38c73fb..331abde 100644 --- a/src/wcmTouchFilter.h +++ b/src/wcmTouchFilter.h @@ -1,5 +1,6 @@ /* * Copyright 2009 - 2010 by Ping Cheng, Wacom. <pingc@wacom.com> + * Copyright 2011 by Alexey Osipov. <simba@lerlan.ru> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,6 +25,7 @@ /****************************************************************************/ void wcmGestureFilter(WacomDevicePtr priv, int channel); +Bool wcmTouchNeedSendEvents(WacomCommonPtr common); /****************************************************************************/ #endif /* __XF86_WCMTOUCHFILTER_H */ |