aboutsummaryrefslogtreecommitdiffstats
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)
downloadxorg-input-kobomultitouch-1b9ca90240fc547c140de76d7e2abb51ee4f8d0a.tar.gz
xorg-input-kobomultitouch-1b9ca90240fc547c140de76d7e2abb51ee4f8d0a.tar.bz2
xorg-input-kobomultitouch-1b9ca90240fc547c140de76d7e2abb51ee4f8d0a.zip
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 @@
#include "gestures.h"
+/* timer for cursor stability on finger touch/release */
+static const int AFTER_FINGER_CHANGE_MS = 70;
+
static void extract_movement(struct Gestures *gs, struct MTouch* mt)
{
const struct FingerState *prev[DIM_FINGER];
const struct FingerState *f = mt->state.finger;
- int same_fingers, i;
+ int same_fingers, i, x = 0, y = 0;
if (mt->state.nfinger == 0)
return;
@@ -36,16 +39,25 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt)
same_fingers = same_fingers && prev[i];
}
- 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;
+ x += f[i].hw.position_x;
+ y += f[i].hw.position_y;
+ }
+ x /= mt->state.nfinger;
+ y /= mt->state.nfinger;
+
+ if (!same_fingers) {
+ mt->mem.move_time = mt->state.evtime + AFTER_FINGER_CHANGE_MS;
+ } else if (mt->state.evtime >= mt->mem.move_time) {
+ gs->dx = x - mt->mem.move_x;
+ gs->dy = y - mt->mem.move_y;
+ } else {
+ /* accumulate all movement during delay */
+ return;
}
- gs->dx /= mt->state.nfinger;
- gs->dy /= mt->state.nfinger;
+ mt->mem.move_x = x;
+ mt->mem.move_y = y;
}
static 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 @@
struct Memory {
unsigned btdata;
+ mstime_t move_time;
+ int move_x, move_y;
};
void init_memory(struct Memory *mem);