From 8bb5dd1174de2ba0c3fdf560329b1298c3ba3540 Mon Sep 17 00:00:00 2001 From: Agnelo Vaz Date: Wed, 1 Jul 2015 15:38:25 +0100 Subject: [PATCH] Prevent Tap UP event occuring at end of Longpress Change-Id: Ic50adb215648f52816a83c5f5c9d3b17a54c7e08 Signed-off-by: Agnelo Vaz --- .../common/events/tap-gesture-detector.cpp | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/adaptors/common/events/tap-gesture-detector.cpp b/adaptors/common/events/tap-gesture-detector.cpp index 06bce598b..af7949bc8 100644 --- a/adaptors/common/events/tap-gesture-detector.cpp +++ b/adaptors/common/events/tap-gesture-detector.cpp @@ -82,11 +82,20 @@ void TapGestureDetector::SendEvent(const Integration::TouchEvent& event) case Touched: { + unsigned long deltaBetweenTouchDownTouchUp = abs( event.time - mTouchTime ) ; + if ( pointState == TouchPoint::Up ) { - mLastTapTime = mTouchTime; - EmitSingleTap( event.time, point ); - mState = Registered; + if ( deltaBetweenTouchDownTouchUp < MAXIMUM_TIME_ALLOWED ) + { + mLastTapTime = mTouchTime; + EmitSingleTap( event.time, point ); + mState = Registered; + } + else + { + mState = Clear; + } } else if (pointState == TouchPoint::Interrupted) { @@ -99,18 +108,27 @@ void TapGestureDetector::SendEvent(const Integration::TouchEvent& event) { if ( pointState == TouchPoint::Up ) { - // This is a possible multiple tap, so has it been quick enough ? - unsigned long timeDelta = abs( event.time - mLastTapTime ); - if ( timeDelta > MAXIMUM_TIME_ALLOWED ) + unsigned long deltaBetweenTouchDownTouchUp = abs( event.time - mTouchTime ) ; + + if ( deltaBetweenTouchDownTouchUp < MAXIMUM_TIME_ALLOWED ) { - mLastTapTime = event.time; - EmitSingleTap( event.time, point ); - mState = Registered; + // This is a possible multiple tap, so has it been quick enough ? + unsigned long timeDelta = abs( event.time - mLastTapTime ); + if ( timeDelta > MAXIMUM_TIME_ALLOWED ) // If exceeded time between taps then just a single tap. + { + mLastTapTime = event.time; + EmitSingleTap( event.time, point ); + mState = Registered; + } + else + { + ++mTapsRegistered; + EmitGesture( Gesture::Started, event.time ); + mState = Clear; + } } - else + else // Delta between touch down and touch up too long to be considered a Tap event { - ++mTapsRegistered; - EmitGesture( Gesture::Started, event.time ); mState = Clear; } } -- 2.34.1