aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArturo Castro <arturo@openframeworks.cc>2010-04-14 15:34:46 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-04-15 06:10:08 +0200
commit428a29ac5dc8ebf6a1092c2d989fa020d79791af (patch)
treec21c7ca701327d555a89daccf467253b64cc14cb /src
parent80ccdaa7441ab9d729b7736d6a784632e216ba74 (diff)
downloadxorg-input-kobomultitouch-428a29ac5dc8ebf6a1092c2d989fa020d79791af.tar.gz
xorg-input-kobomultitouch-428a29ac5dc8ebf6a1092c2d989fa020d79791af.tar.bz2
xorg-input-kobomultitouch-428a29ac5dc8ebf6a1092c2d989fa020d79791af.zip
Extract pointing fingers
Multi-finger clicks and taps are goverened by the number of pointing fingers on the trackpad. This number can be different from the actual number of fingers on the trackpad. For instance, a finger resting at the bottom of an integrated button, or a finger that accidentally touches the pad during a press, are not pointing fingers. This patch introduces extract_pointers(), which computes the number of pointing fingers on the trackpad, and uses that number to determine the logical button state. [rydberg@euromail.se: various cleanups] Signed-off-by: Arturo Castro <arturo@openframeworks.cc> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src')
-rw-r--r--src/gestures.c44
-rw-r--r--src/memory.h3
2 files changed, 44 insertions, 3 deletions
diff --git a/src/gestures.c b/src/gestures.c
index d075356..915a521 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -29,6 +29,45 @@
static const int FINGER_ATTACK_MS = 70;
static const int FINGER_DECAY_MS = 120;
+static void extract_pointers(struct Gestures *gs, struct MTouch* mt)
+{
+ const struct FingerState *f = mt->state.finger;
+ int i;
+
+ if (mt->state.nfinger < 2) {
+ mt->mem.pointing = mt->state.nfinger;
+ mt->mem.npoint = mt->state.nfinger;
+ mt->mem.ybar = mt->caps.abs_position_y.maximum;
+ return;
+ }
+
+ if (mt->state.nfinger == mt->prev_state.nfinger) {
+ for (i = 0; i < mt->state.nfinger; i++) {
+ if (GETBIT(mt->mem.pointing, i))
+ continue;
+ if (f[i].hw.position_y <= mt->mem.ybar) {
+ mt->mem.pointing = BITONES(mt->state.nfinger);
+ mt->mem.npoint = mt->state.nfinger;
+ return;
+ }
+ }
+ return;
+ }
+
+ mt->mem.pointing = 0;
+ mt->mem.npoint = 0;
+ mt->mem.ybar = mt->caps.yclick;
+ for (i = 0; i < mt->state.nfinger; i++) {
+ if (f[i].hw.position_y > mt->caps.yclick)
+ continue;
+ if (!mt->mem.npoint || f[i].hw.position_y > mt->mem.ybar)
+ mt->mem.ybar = f[i].hw.position_y;
+ SETBIT(mt->mem.pointing, i);
+ mt->mem.npoint++;
+ }
+
+}
+
static void extract_movement(struct Gestures *gs, struct MTouch* mt)
{
const struct FingerState *prev[DIM_FINGER];
@@ -73,9 +112,9 @@ static void extract_buttons(struct Gestures *gs, struct MTouch* mt)
{
unsigned btdata = mt->state.button & BITONES(DIM_BUTTON);
if (mt->state.button == BITMASK(MT_BUTTON_LEFT)) {
- if (mt->state.nfinger == 2)
+ if (mt->mem.npoint == 2)
btdata = BITMASK(MT_BUTTON_RIGHT);
- if (mt->state.nfinger == 3)
+ if (mt->mem.npoint == 3)
btdata = BITMASK(MT_BUTTON_MIDDLE);
}
gs->btmask = (btdata ^ mt->mem.btdata) & BITONES(DIM_BUTTON);
@@ -110,6 +149,7 @@ static void extract_type(struct Gestures *gs, struct MTouch* mt)
void extract_gestures(struct Gestures *gs, struct MTouch* mt)
{
memset(gs, 0, sizeof(struct Gestures));
+ extract_pointers(gs, mt);
extract_movement(gs, mt);
extract_buttons(gs, mt);
extract_type(gs, mt);
diff --git a/src/memory.h b/src/memory.h
index 0ab4d04..3b947b9 100644
--- a/src/memory.h
+++ b/src/memory.h
@@ -25,7 +25,8 @@
#include "mtstate.h"
struct Memory {
- unsigned btdata;
+ unsigned btdata, pointing;
+ int npoint, ybar;
mstime_t move_time;
int move_x, move_y;
};