summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-20 22:06:12 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-20 22:06:12 +0200
commite0114e297ab1cd4674bea23f260ce5ec05376a78 (patch)
treec77fe514ea313c5bcbd9760bb69a06ffa3b4cb86 /src
parent7cd883684285b42cb52ecd4fb6460f6eb77f0ef2 (diff)
Touch: Adjusted tap-and-hold gesture
After the hold has been detected, require a larger motion to begin dragging.
Diffstat (limited to 'src')
-rw-r--r--src/ui/touch.c12
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
121static iBool isStationaryDistance_Touch_(const iTouch *d, int distance) {
122 return !d->hasMoved && distance_Touch_(d) < distance * get_Window()->pixelRatio;
123}
124
121static iBool isStationary_Touch_(const iTouch *d) { 125static 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
125static void dispatchMotion_Touch_(iFloat3 pos, int buttonState) { 129static 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. */