summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-09-21 10:27:17 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-09-21 12:56:17 +0200
commita23067b7066786ceaa0779324e9120f8b04a6372 (patch)
treec8b18f401defb1d6bdce5799e824285fde2a725b
parentd638d408615427196b031692f8fd14a83a790d30 (diff)
Do not tap when leaving fingers on the pad
The current code will treat a 3-down-2-up as a tap. This patch changes the logic so that taps are only emitted when the number of fingers returns to the baseline. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--src/gestures-tapping.c23
-rw-r--r--src/grail-gestures.h2
2 files changed, 14 insertions, 11 deletions
diff --git a/src/gestures-tapping.c b/src/gestures-tapping.c
index 5474731..cb30168 100644
--- a/src/gestures-tapping.c
+++ b/src/gestures-tapping.c
@@ -46,42 +46,45 @@ int gru_tapping(struct grail *ge,
46 struct tapping_model *state = &gru->tapping; 46 struct tapping_model *state = &gru->tapping;
47 struct move_model *move = &gru->move; 47 struct move_model *move = &gru->move;
48 grail_time_t up = move->time - state->end; 48 grail_time_t up = move->time - state->end;
49 if (move->ntouch && move->ntouch < state->ntouch) 49 if (move->ntouch && move->ntouch < state->mintouch)
50 state->end = move->time; 50 state->end = move->time;
51 if (move->ntouch > state->ntouch) { 51 if (move->ntouch > state->maxtouch) {
52 if (state->active) { 52 if (state->active) {
53 gin_gid_discard(ge, state->gid); 53 gin_gid_discard(ge, state->gid);
54 state->active = 0; 54 state->active = 0;
55 } 55 }
56 state->start = move->time; 56 state->start = move->time;
57 state->ntouch = move->ntouch; 57 state->maxtouch = move->ntouch;
58 set_props(ge->gin, state, move, frame); 58 set_props(ge->gin, state, move, frame);
59 if (state->ntouch <= 5) { 59 if (state->maxtouch <= 5) {
60 int type = GRAIL_TYPE_TAP1 + state->ntouch - 1; 60 int type = GRAIL_TYPE_TAP1 + state->maxtouch - 1;
61 state->gid = gin_gid_begin(ge, type, PRIO_TAP, frame); 61 state->gid = gin_gid_begin(ge, type, PRIO_TAP, frame);
62 state->active = 1; 62 state->active = 1;
63 } 63 }
64 return 0; 64 return 0;
65 } 65 }
66 if (!state->active) { 66 if (!state->active) {
67 state->ntouch = move->ntouch; 67 state->mintouch = move->ntouch;
68 state->maxtouch = move->ntouch;
68 return 0; 69 return 0;
69 } 70 }
70 if (move->ntouch < state->ntouch) { 71 if (move->ntouch <= state->mintouch) {
71 int x = state->prop[GRAIL_PROP_TAP_X]; 72 int x = state->prop[GRAIL_PROP_TAP_X];
72 int y = state->prop[GRAIL_PROP_TAP_Y]; 73 int y = state->prop[GRAIL_PROP_TAP_Y];
73 int t = move->time - state->start; 74 int t = move->time - state->start;
74 if (t < TAP_MIN_GAP_MS || t > move->fm[FM_X].bar_ms || 75 if (t < TAP_MIN_GAP_MS || t > move->fm[FM_X].bar_ms ||
75 up < TAP_MIN_UP_MS) { 76 up < TAP_MIN_UP_MS) {
76 gin_gid_discard(ge, state->gid); 77 gin_gid_discard(ge, state->gid);
77 state->ntouch = move->ntouch; 78 state->mintouch = move->ntouch;
79 state->maxtouch = move->ntouch;
78 state->active = 0; 80 state->active = 0;
79 return 0; 81 return 0;
80 } 82 }
81 state->prop[GRAIL_PROP_TAP_DT] = t; 83 state->prop[GRAIL_PROP_TAP_DT] = t;
82 gin_gid_event(ge, state->gid, x, y, state->ntouch, 84 gin_gid_event(ge, state->gid, x, y, state->maxtouch,
83 state->prop, state->nprop, 1); 85 state->prop, state->nprop, 1);
84 state->ntouch = move->ntouch; 86 state->mintouch = move->ntouch;
87 state->maxtouch = move->ntouch;
85 state->active = 0; 88 state->active = 0;
86 return 1; 89 return 1;
87 } 90 }
diff --git a/src/grail-gestures.h b/src/grail-gestures.h
index 247acf9..36d8e78 100644
--- a/src/grail-gestures.h
+++ b/src/grail-gestures.h
@@ -98,7 +98,7 @@ int gru_winrotate(struct grail *ge,
98 98
99struct tapping_model { 99struct tapping_model {
100 grail_time_t start, end; 100 grail_time_t start, end;
101 int ntouch; 101 int mintouch, maxtouch;
102 int active, gid; 102 int active, gid;
103 int nprop; 103 int nprop;
104 grail_prop_t prop[DIM_GRAIL_PROP]; 104 grail_prop_t prop[DIM_GRAIL_PROP];