aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-05-14 01:30:05 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-05-14 01:41:39 +0200
commitc620cb1319093dca0f0241c04c4c227a40577bdc (patch)
treecdfe7d9b42b7b7b83e3268e14b2ac2bf11f3208f
parentc8c74659d27b9eb0d45342db9a4969389e20f26a (diff)
downloadxorg-input-kobomultitouch-c620cb1319093dca0f0241c04c4c227a40577bdc.tar.gz
xorg-input-kobomultitouch-c620cb1319093dca0f0241c04c4c227a40577bdc.tar.bz2
xorg-input-kobomultitouch-c620cb1319093dca0f0241c04c4c227a40577bdc.zip
Add resting thumb detection to MTFinger
Robust thumb detection is essential for more advanced gestures, thumbs being responsible for many false positives. One major feature of the thumb is that its shape is oval, regardless of applied pressure. An index finger pressed hard against the surface also turns oval, but the touch/width ratio then increases significantly. This suggests that it is possible to uniquely identify a resting thumb as a finger with oval shape and normal touch/with ratio. This patch adds detection of resting thumbs to the MTFinger structure. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--src/mtstate.c26
-rw-r--r--src/mtstate.h2
2 files changed, 27 insertions, 1 deletions
diff --git a/src/mtstate.c b/src/mtstate.c
index c3bcc78..1e2eeef 100644
--- a/src/mtstate.c
+++ b/src/mtstate.c
@@ -24,6 +24,11 @@
#define TOUCH_WIDTH(hw) (0.05 * hw->width_major)
#define TOUCH_SCALE(caps) (0.05 * caps->abs_touch_major.maximum)
+#define THUMB_TOUCH(hw) (1.2 * hw->touch_minor)
+#define THUMB_WIDTH_TOUCH(hw) (3 * hw->touch_major)
+#define THUMB_WIDTH_WIDTH(hw) (1.2 * hw->width_minor)
+#define THUMB_WIDTH_SIZE(hw, caps) (0.15 * get_cap_xsize(caps))
+
void init_mtstate(struct MTState *s)
{
memset(s, 0, sizeof(struct MTState));
@@ -39,12 +44,33 @@ static int touching_finger(const struct FingerData *hw,
return 1;
}
+/*
+ * Thumb detection:
+ *
+ * The thumb is large and oval, even when not pressed hard against the
+ * surface. The width_major parameter is therefore bounded from below
+ * by all three values touch_major, width_minor, and trackpad size.
+ *
+ */
+static int thumb_finger(const struct FingerData *hw,
+ const struct Capabilities *caps)
+{
+ if (!caps->has_touch_major || !caps->has_touch_minor ||
+ !caps->has_width_major || !caps->has_width_minor)
+ return 0;
+ return hw->touch_major > THUMB_TOUCH(hw) &&
+ hw->width_major > THUMB_WIDTH_TOUCH(hw) &&
+ hw->width_major > THUMB_WIDTH_WIDTH(hw) &&
+ hw->width_major > THUMB_WIDTH_SIZE(hw, caps);
+}
+
static int set_finger(struct MTFinger *f,
const struct FingerState *fs,
const struct Capabilities *caps)
{
f->hw = fs->hw;
f->id = fs->id;
+ f->thumb = thumb_finger(&fs->hw, caps);
}
void extract_mtstate(struct MTState *s,
diff --git a/src/mtstate.h b/src/mtstate.h
index a8feaa4..ac0b18d 100644
--- a/src/mtstate.h
+++ b/src/mtstate.h
@@ -26,7 +26,7 @@
struct MTFinger {
struct FingerData hw;
- int id;
+ int id, thumb;
};
struct MTState {