diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-20 22:06:12 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-20 22:06:12 +0200 |
commit | e0114e297ab1cd4674bea23f260ce5ec05376a78 (patch) | |
tree | c77fe514ea313c5bcbd9760bb69a06ffa3b4cb86 | |
parent | 7cd883684285b42cb52ecd4fb6460f6eb77f0ef2 (diff) |
Touch: Adjusted tap-and-hold gesture
After the hold has been detected, require a larger motion to begin dragging.
-rw-r--r-- | src/ui/touch.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c index c369c5a5..40e5c5d0 100644 --- a/src/ui/touch.c +++ b/src/ui/touch.c | |||
@@ -118,8 +118,12 @@ iLocalDef float distance_Touch_(const iTouch *d) { | |||
118 | return length_F3(sub_F3(d->pos[0], d->startPos)); | 118 | return length_F3(sub_F3(d->pos[0], d->startPos)); |
119 | } | 119 | } |
120 | 120 | ||
121 | static iBool isStationaryDistance_Touch_(const iTouch *d, int distance) { | ||
122 | return !d->hasMoved && distance_Touch_(d) < distance * get_Window()->pixelRatio; | ||
123 | } | ||
124 | |||
121 | static iBool isStationary_Touch_(const iTouch *d) { | 125 | static iBool isStationary_Touch_(const iTouch *d) { |
122 | return !d->hasMoved && distance_Touch_(d) < tapRadiusPt_ * get_Window()->pixelRatio; | 126 | return isStationaryDistance_Touch_(d, tapRadiusPt_); |
123 | } | 127 | } |
124 | 128 | ||
125 | static void dispatchMotion_Touch_(iFloat3 pos, int buttonState) { | 129 | static void dispatchMotion_Touch_(iFloat3 pos, int buttonState) { |
@@ -372,10 +376,12 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
372 | } | 376 | } |
373 | if (touch->isTapAndHold) { | 377 | if (touch->isTapAndHold) { |
374 | pushPos_Touch_(touch, pos, fing->timestamp); | 378 | pushPos_Touch_(touch, pos, fing->timestamp); |
375 | if (!touch->hasMoved && !isStationary_Touch_(touch)) { | 379 | if (!touch->hasMoved && !isStationaryDistance_Touch_(touch, tapRadiusPt_ * 3)) { |
376 | touch->hasMoved = iTrue; | 380 | touch->hasMoved = iTrue; |
377 | } | 381 | } |
378 | dispatchMotion_Touch_(pos, 0); | 382 | if (touch->hasMoved) { |
383 | dispatchMotion_Touch_(pos, 0); | ||
384 | } | ||
379 | return iTrue; | 385 | return iTrue; |
380 | } | 386 | } |
381 | /* Update touch position. */ | 387 | /* Update touch position. */ |