diff --git a/client/eventsSDL/InputSourceTouch.cpp b/client/eventsSDL/InputSourceTouch.cpp index 0b5d48954..1135a0b52 100644 --- a/client/eventsSDL/InputSourceTouch.cpp +++ b/client/eventsSDL/InputSourceTouch.cpp @@ -83,16 +83,18 @@ void InputSourceTouch::handleEventFingerMotion(const SDL_TouchFingerEvent & tfin break; } case TouchState::TAP_DOWN_SHORT: + case TouchState::TAP_DOWN_LONG_AWAIT: { Point distance = convertTouchToMouse(tfinger) - lastTapPosition; if ( std::abs(distance.x) > params.panningSensitivityThreshold || std::abs(distance.y) > params.panningSensitivityThreshold) { - state = TouchState::TAP_DOWN_PANNING; + state = state == TouchState::TAP_DOWN_SHORT ? TouchState::TAP_DOWN_PANNING : TouchState::TAP_DOWN_PANNING_POPUP; GH.events().dispatchGesturePanningStarted(lastTapPosition); } break; } case TouchState::TAP_DOWN_PANNING: + case TouchState::TAP_DOWN_PANNING_POPUP: { emitPanningEvent(tfinger); break; @@ -103,7 +105,6 @@ void InputSourceTouch::handleEventFingerMotion(const SDL_TouchFingerEvent & tfin break; } case TouchState::TAP_DOWN_LONG: - case TouchState::TAP_DOWN_LONG_AWAIT: { // no-op break; @@ -157,8 +158,11 @@ void InputSourceTouch::handleEventFingerDown(const SDL_TouchFingerEvent & tfinge CSH->getGlobalLobby().activateInterface(); break; } - case TouchState::TAP_DOWN_LONG: case TouchState::TAP_DOWN_LONG_AWAIT: + lastTapPosition = convertTouchToMouse(tfinger); + break; + case TouchState::TAP_DOWN_LONG: + case TouchState::TAP_DOWN_PANNING_POPUP: { // no-op break; @@ -205,9 +209,10 @@ void InputSourceTouch::handleEventFingerUp(const SDL_TouchFingerEvent & tfinger) break; } case TouchState::TAP_DOWN_PANNING: + case TouchState::TAP_DOWN_PANNING_POPUP: { GH.events().dispatchGesturePanningEnded(lastTapPosition, convertTouchToMouse(tfinger)); - state = TouchState::IDLE; + state = state == TouchState::TAP_DOWN_PANNING ? TouchState::IDLE : TouchState::TAP_DOWN_LONG_AWAIT; break; } case TouchState::TAP_DOWN_DOUBLE: diff --git a/client/eventsSDL/InputSourceTouch.h b/client/eventsSDL/InputSourceTouch.h index 19a8cca50..2c1d8490c 100644 --- a/client/eventsSDL/InputSourceTouch.h +++ b/client/eventsSDL/InputSourceTouch.h @@ -45,6 +45,12 @@ enum class TouchState // UP -> transition to IDLE TAP_DOWN_PANNING, + // single finger is moving across screen + // DOWN -> ignored + // MOTION -> emit panning event + // UP -> transition to TAP_DOWN_LONG_AWAIT + TAP_DOWN_PANNING_POPUP, + // two fingers are touching the screen // DOWN -> ??? how to handle 3rd finger? Ignore? // MOTION -> emit pinch event @@ -59,7 +65,7 @@ enum class TouchState // right-click popup is active, waiting for new tap to hide popup // DOWN -> ignored - // MOTION -> ignored + // MOTION -> transition to TAP_DOWN_PANNING_POPUP // UP -> transition to IDLE, generate closePopup() event TAP_DOWN_LONG_AWAIT, }; @@ -79,7 +85,7 @@ struct TouchInputParameters uint32_t doubleTouchToleranceDistance = 50; /// moving finger for distance larger than specified will be qualified as panning gesture instead of long press - uint32_t panningSensitivityThreshold = 10; + uint32_t panningSensitivityThreshold = 15; /// gesture will be qualified as pinch if distance between fingers is at least specified here uint32_t pinchSensitivityThreshold = 10;