summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-05-13 23:21:37 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-05-14 01:41:39 +0200
commit31a96545e433128af34f08a0bb993bbc54e90df1 (patch)
tree8b352a2eb50d7a054867112f94f93689f51a1cc4
parentc620cb1319093dca0f0241c04c4c227a40577bdc (diff)
Disable motion with resting thumbs
Disable motion gestures whenever one of the pointing fingers is a thumb. Movement is skipped rather than held, minimizing unpredictable movement after thumb release. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--src/gestures.c9
-rw-r--r--src/memory.c13
-rw-r--r--src/memory.h3
3 files changed, 20 insertions, 5 deletions
diff --git a/src/gestures.c b/src/gestures.c
index b6c3bf4..d061f93 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -25,6 +25,7 @@
25 25
26#include "gestures.h" 26#include "gestures.h"
27 27
28static const int FINGER_THUMB_MS = 400;
28/** 29/**
29 * extract_buttons 30 * extract_buttons
30 * 31 *
@@ -83,11 +84,19 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt)
83 ymove /= nmove; 84 ymove /= nmove;
84 85
85 if (nmove == 1) { 86 if (nmove == 1) {
87 if (mt->mem.moving & mt->mem.thumb) {
88 mt_skip_movement(mt, FINGER_THUMB_MS);
89 return;
90 }
86 gs->dx = xmove; 91 gs->dx = xmove;
87 gs->dy = ymove; 92 gs->dy = ymove;
88 if (gs->dx || gs->dy) 93 if (gs->dx || gs->dy)
89 SETBIT(gs->type, GS_MOVE); 94 SETBIT(gs->type, GS_MOVE);
90 } else { 95 } else {
96 if (mt->mem.moving & mt->mem.thumb) {
97 mt_skip_movement(mt, FINGER_THUMB_MS);
98 return;
99 }
91 gs->dx = xmove; 100 gs->dx = xmove;
92 gs->dy = ymove; 101 gs->dy = ymove;
93 if (abs(gs->dx) > abs(gs->dy)) { 102 if (abs(gs->dx) > abs(gs->dy)) {
diff --git a/src/memory.c b/src/memory.c
index 7d8cda8..9084502 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -46,11 +46,11 @@ void init_memory(struct Memory *mem)
46/** 46/**
47 * update_configuration 47 * update_configuration
48 * 48 *
49 * Update the same, fingers, added memory variables. 49 * Update the same, fingers, added, and thumb memory variables.
50 * 50 *
51 * Precondition: none 51 * Precondition: none
52 * 52 *
53 * Postcondition: same, fingers, added are set 53 * Postcondition: same, fingers, added, thumb are set
54 * 54 *
55 */ 55 */
56static void update_configuration(struct Memory *m, 56static void update_configuration(struct Memory *m,
@@ -66,6 +66,11 @@ static void update_configuration(struct Memory *m,
66 SETBIT(m->added, i); 66 SETBIT(m->added, i);
67 m->same = m->fingers == fingers && m->added == 0; 67 m->same = m->fingers == fingers && m->added == 0;
68 m->fingers = fingers; 68 m->fingers = fingers;
69 if (!m->same)
70 m->thumb = 0;
71 foreach_bit(i, fingers)
72 if (f[i].thumb)
73 SETBIT(m->thumb, i);
69} 74}
70 75
71/** 76/**
@@ -73,7 +78,7 @@ static void update_configuration(struct Memory *m,
73 * 78 *
74 * Update the pointing and ybar memory variables. 79 * Update the pointing and ybar memory variables.
75 * 80 *
76 * Precondition: fingers, added are set 81 * Precondition: fingers, added, thumb are set
77 * 82 *
78 * Postcondition: pointing, ybar are set 83 * Postcondition: pointing, ybar are set
79 * 84 *
@@ -121,7 +126,7 @@ static void update_pointers(struct Memory *m,
121 * When moving is nonzero, gestures can be extracted from the dx and dy 126 * When moving is nonzero, gestures can be extracted from the dx and dy
122 * variables. These variables should be cleared after use. 127 * variables. These variables should be cleared after use.
123 * 128 *
124 * Precondition: fingers, added, pointing are set 129 * Precondition: fingers, added, thumb, pointing are set
125 * 130 *
126 * Postcondition: pending, moving, mvhold, mvforget, dx, dy are set 131 * Postcondition: pending, moving, mvhold, mvforget, dx, dy are set
127 * 132 *
diff --git a/src/memory.h b/src/memory.h
index cc7bf55..8ffbdab 100644
--- a/src/memory.h
+++ b/src/memory.h
@@ -31,6 +31,7 @@
31 * @same: true if the finger configuration is unchanged 31 * @same: true if the finger configuration is unchanged
32 * @fingers: bitmask of fingers on the pad 32 * @fingers: bitmask of fingers on the pad
33 * @added: bitmask of new fingers on the pad 33 * @added: bitmask of new fingers on the pad
34 * @thumb: bitmask of thumbs on the pad
34 * @pointing: bitmask of pointing fingers 35 * @pointing: bitmask of pointing fingers
35 * @pending: bitmask of tentatively moving fingers 36 * @pending: bitmask of tentatively moving fingers
36 * @moving: bitmask of moving fingers 37 * @moving: bitmask of moving fingers
@@ -43,7 +44,7 @@
43 */ 44 */
44struct Memory { 45struct Memory {
45 unsigned btdata, same; 46 unsigned btdata, same;
46 unsigned fingers, added; 47 unsigned fingers, added, thumb;
47 unsigned pointing, pending, moving; 48 unsigned pointing, pending, moving;
48 int ybar; 49 int ybar;
49 mstime_t mvhold, mvforget; 50 mstime_t mvhold, mvforget;