aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-04-10 23:16:29 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-04-15 06:10:07 +0200
commit32d5f821c5bbefc6eae2319209288ec74079529a (patch)
tree1d9fc4c95215fa0e4308994183a54604ee2bbf1b /src
parent3b76b024a602934495de42ddab6d32c37b2fbfa9 (diff)
downloadxorg-input-kobomultitouch-32d5f821c5bbefc6eae2319209288ec74079529a.tar.gz
xorg-input-kobomultitouch-32d5f821c5bbefc6eae2319209288ec74079529a.tar.bz2
xorg-input-kobomultitouch-32d5f821c5bbefc6eae2319209288ec74079529a.zip
Only extract movement from identical finger configurations
The current code would extract movement from a rapid change from one finger to the next, resulting in unwanted jumps. This patch first checks that the finger configuration is the same before attempting to extract movement. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src')
-rw-r--r--src/gestures.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/gestures.c b/src/gestures.c
index f26aba8..c837d6c 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -23,24 +23,29 @@
static void extract_movement(struct Gestures *gs, struct MTouch* mt)
{
- const struct FingerState *b = mt->state.finger;
- const struct FingerState *e = b + mt->state.nfinger;
- const struct FingerState *p, *fs;
- int dn = 0, i;
- if (mt->state.nfinger == mt->prev_state.nfinger) {
- for (p = b; p != e; p++) {
- fs = find_finger(&mt->prev_state, p->id);
- if (fs) {
- gs->dx += p->hw.position_x - fs->hw.position_x;
- gs->dy += p->hw.position_y - fs->hw.position_y;
- dn++;
- }
- }
+ const struct FingerState *prev[DIM_FINGER];
+ const struct FingerState *f = mt->state.finger;
+ int same_fingers, i;
+
+ if (mt->state.nfinger == 0)
+ return;
+
+ same_fingers = mt->state.nfinger == mt->prev_state.nfinger;
+ for (i = 0; i < mt->state.nfinger; i++) {
+ prev[i] = find_finger(&mt->prev_state, mt->state.finger[i].id);
+ same_fingers = same_fingers && prev[i];
}
- if (dn) {
- gs->dx /= dn;
- gs->dy /= dn;
+
+ if (!same_fingers)
+ return;
+
+ for (i = 0; i < mt->state.nfinger; i++) {
+ gs->dx += f[i].hw.position_x - prev[i]->hw.position_x;
+ gs->dy += f[i].hw.position_y - prev[i]->hw.position_y;
}
+
+ gs->dx /= mt->state.nfinger;
+ gs->dy /= mt->state.nfinger;
}
static void extract_buttons(struct Gestures *gs, struct MTouch* mt)