summaryrefslogtreecommitdiff
path: root/src/ui/touch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/touch.c')
-rw-r--r--src/ui/touch.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c
index aee5a383..0749bc7c 100644
--- a/src/ui/touch.c
+++ b/src/ui/touch.c
@@ -256,6 +256,11 @@ static iFloat3 gestureVector_Touch_(const iTouch *d) {
256 return sub_F3(d->pos[0], d->pos[lastIndex]); 256 return sub_F3(d->pos[0], d->pos[lastIndex]);
257} 257}
258 258
259static uint32_t gestureSpan_Touch_(const iTouch *d) {
260 const size_t lastIndex = iMin(d->posCount - 1, lastIndex_Touch_);
261 return d->posTime[0] - d->posTime[lastIndex];
262}
263
259static void update_TouchState_(void *ptr) { 264static void update_TouchState_(void *ptr) {
260 iWindow *win = get_Window(); 265 iWindow *win = get_Window();
261 const iWidget *oldHover = win->hover; 266 const iWidget *oldHover = win->hover;
@@ -668,11 +673,14 @@ iBool processEvent_Touch(const SDL_Event *ev) {
668#endif 673#endif
669 if (touch->edge && !isStationary_Touch_(touch)) { 674 if (touch->edge && !isStationary_Touch_(touch)) {
670 const iFloat3 gesture = gestureVector_Touch_(touch); 675 const iFloat3 gesture = gestureVector_Touch_(touch);
676 const uint32_t duration = gestureSpan_Touch_(touch);
671 const float pixel = window->pixelRatio; 677 const float pixel = window->pixelRatio;
672 const int moveDir = x_F3(gesture) < -pixel ? -1 : x_F3(gesture) > pixel ? +1 : 0; 678 const int moveDir = x_F3(gesture) < -pixel ? -1 : x_F3(gesture) > pixel ? +1 : 0;
673 const int didAbort = (touch->edge == left_TouchEdge && moveDir < 0) || 679 const int didAbort = (touch->edge == left_TouchEdge && moveDir < 0) ||
674 (touch->edge == right_TouchEdge && moveDir > 0); 680 (touch->edge == right_TouchEdge && moveDir > 0);
675 postCommandf_App("edgeswipe.ended abort:%d side:%d id:%llu", didAbort, touch->edge, touch->id); 681 postCommandf_App("edgeswipe.ended abort:%d side:%d id:%llu speed:%d", didAbort,
682 touch->edge, touch->id,
683 (int) (duration > 0 ? length_F3(gesture) / (duration / 1000.0f) : 0));
676 remove_ArrayIterator(&i); 684 remove_ArrayIterator(&i);
677 continue; 685 continue;
678 } 686 }
@@ -696,8 +704,8 @@ iBool processEvent_Touch(const SDL_Event *ev) {
696 } 704 }
697 /* Edge swipes do not generate momentum. */ 705 /* Edge swipes do not generate momentum. */
698 const size_t lastIndex = iMin(touch->posCount - 1, lastIndex_Touch_); 706 const size_t lastIndex = iMin(touch->posCount - 1, lastIndex_Touch_);
699 const uint32_t duration = nowTime - touch->startTime;
700 const iFloat3 gestureVector = sub_F3(pos, touch->pos[lastIndex]); 707 const iFloat3 gestureVector = sub_F3(pos, touch->pos[lastIndex]);
708 const uint32_t duration = nowTime - touch->startTime;
701 iFloat3 velocity = zero_F3(); 709 iFloat3 velocity = zero_F3();
702#if 0 710#if 0
703 if (touch->edge && fabsf(2 * x_F3(gestureVector)) > fabsf(y_F3(gestureVector)) && 711 if (touch->edge && fabsf(2 * x_F3(gestureVector)) > fabsf(y_F3(gestureVector)) &&