summaryrefslogtreecommitdiff
path: root/src
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 /src
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>
Diffstat (limited to 'src')
-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 @@
#include "gestures.h"
+static const int FINGER_THUMB_MS = 400;
/**
* extract_buttons
*
@@ -83,11 +84,19 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt)
ymove /= nmove;
if (nmove == 1) {
+ if (mt->mem.moving & mt->mem.thumb) {
+ mt_skip_movement(mt, FINGER_THUMB_MS);
+ return;
+ }
gs->dx = xmove;
gs->dy = ymove;
if (gs->dx || gs->dy)
SETBIT(gs->type, GS_MOVE);
} else {
+ if (mt->mem.moving & mt->mem.thumb) {
+ mt_skip_movement(mt, FINGER_THUMB_MS);
+ return;
+ }
gs->dx = xmove;
gs->dy = ymove;
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)
/**
* update_configuration
*
- * Update the same, fingers, added memory variables.
+ * Update the same, fingers, added, and thumb memory variables.
*
* Precondition: none
*
- * Postcondition: same, fingers, added are set
+ * Postcondition: same, fingers, added, thumb are set
*
*/
static void update_configuration(struct Memory *m,
@@ -66,6 +66,11 @@ static void update_configuration(struct Memory *m,
SETBIT(m->added, i);
m->same = m->fingers == fingers && m->added == 0;
m->fingers = fingers;
+ if (!m->same)
+ m->thumb = 0;
+ foreach_bit(i, fingers)
+ if (f[i].thumb)
+ SETBIT(m->thumb, i);
}
/**
@@ -73,7 +78,7 @@ static void update_configuration(struct Memory *m,
*
* Update the pointing and ybar memory variables.
*
- * Precondition: fingers, added are set
+ * Precondition: fingers, added, thumb are set
*
* Postcondition: pointing, ybar are set
*
@@ -121,7 +126,7 @@ static void update_pointers(struct Memory *m,
* When moving is nonzero, gestures can be extracted from the dx and dy
* variables. These variables should be cleared after use.
*
- * Precondition: fingers, added, pointing are set
+ * Precondition: fingers, added, thumb, pointing are set
*
* Postcondition: pending, moving, mvhold, mvforget, dx, dy are set
*
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 @@
* @same: true if the finger configuration is unchanged
* @fingers: bitmask of fingers on the pad
* @added: bitmask of new fingers on the pad
+ * @thumb: bitmask of thumbs on the pad
* @pointing: bitmask of pointing fingers
* @pending: bitmask of tentatively moving fingers
* @moving: bitmask of moving fingers
@@ -43,7 +44,7 @@
*/
struct Memory {
unsigned btdata, same;
- unsigned fingers, added;
+ unsigned fingers, added, thumb;
unsigned pointing, pending, moving;
int ybar;
mstime_t mvhold, mvforget;