summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArturo Castro <arturo@openframeworks.cc>2010-04-11 00:21:38 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-04-15 06:10:07 +0200
commit1b9ca90240fc547c140de76d7e2abb51ee4f8d0a (patch)
tree6f6a762bf196e481fcfd2533800f73831d724de6
parent40b3cd568e8cc64a5f7f748f2003d90aa5e738ef (diff)
Delay movement after a finger configuration change
The current code responds to finger movement immediately after a finger has been placed on the trackpad, even if the touch is accidental. This patch delays the effect of the finger by 70 ms, resulting in fewer accidental movements. Signed-off-by: Arturo Castro <arturo@openframeworks.cc> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--src/gestures.c28
-rw-r--r--src/memory.h2
2 files changed, 22 insertions, 8 deletions
diff --git a/src/gestures.c b/src/gestures.c
index e032214..b04c679 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -21,11 +21,14 @@
21 21
22#include "gestures.h" 22#include "gestures.h"
23 23
24/* timer for cursor stability on finger touch/release */
25static const int AFTER_FINGER_CHANGE_MS = 70;
26
24static void extract_movement(struct Gestures *gs, struct MTouch* mt) 27static void extract_movement(struct Gestures *gs, struct MTouch* mt)
25{ 28{
26 const struct FingerState *prev[DIM_FINGER]; 29 const struct FingerState *prev[DIM_FINGER];
27 const struct FingerState *f = mt->state.finger; 30 const struct FingerState *f = mt->state.finger;
28 int same_fingers, i; 31 int same_fingers, i, x = 0, y = 0;
29 32
30 if (mt->state.nfinger == 0) 33 if (mt->state.nfinger == 0)
31 return; 34 return;
@@ -36,16 +39,25 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt)
36 same_fingers = same_fingers && prev[i]; 39 same_fingers = same_fingers && prev[i];
37 } 40 }
38 41
39 if (!same_fingers)
40 return;
41
42 for (i = 0; i < mt->state.nfinger; i++) { 42 for (i = 0; i < mt->state.nfinger; i++) {
43 gs->dx += f[i].hw.position_x - prev[i]->hw.position_x; 43 x += f[i].hw.position_x;
44 gs->dy += f[i].hw.position_y - prev[i]->hw.position_y; 44 y += f[i].hw.position_y;
45 }
46 x /= mt->state.nfinger;
47 y /= mt->state.nfinger;
48
49 if (!same_fingers) {
50 mt->mem.move_time = mt->state.evtime + AFTER_FINGER_CHANGE_MS;
51 } else if (mt->state.evtime >= mt->mem.move_time) {
52 gs->dx = x - mt->mem.move_x;
53 gs->dy = y - mt->mem.move_y;
54 } else {
55 /* accumulate all movement during delay */
56 return;
45 } 57 }
46 58
47 gs->dx /= mt->state.nfinger; 59 mt->mem.move_x = x;
48 gs->dy /= mt->state.nfinger; 60 mt->mem.move_y = y;
49} 61}
50 62
51static void extract_buttons(struct Gestures *gs, struct MTouch* mt) 63static void extract_buttons(struct Gestures *gs, struct MTouch* mt)
diff --git a/src/memory.h b/src/memory.h
index a6c51ec..0ab4d04 100644
--- a/src/memory.h
+++ b/src/memory.h
@@ -26,6 +26,8 @@
26 26
27struct Memory { 27struct Memory {
28 unsigned btdata; 28 unsigned btdata;
29 mstime_t move_time;
30 int move_x, move_y;
29}; 31};
30 32
31void init_memory(struct Memory *mem); 33void init_memory(struct Memory *mem);