summaryrefslogtreecommitdiff
path: root/src/mtstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mtstate.c')
-rw-r--r--src/mtstate.c26
1 files changed, 26 insertions, 0 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 @@
24#define TOUCH_WIDTH(hw) (0.05 * hw->width_major) 24#define TOUCH_WIDTH(hw) (0.05 * hw->width_major)
25#define TOUCH_SCALE(caps) (0.05 * caps->abs_touch_major.maximum) 25#define TOUCH_SCALE(caps) (0.05 * caps->abs_touch_major.maximum)
26 26
27#define THUMB_TOUCH(hw) (1.2 * hw->touch_minor)
28#define THUMB_WIDTH_TOUCH(hw) (3 * hw->touch_major)
29#define THUMB_WIDTH_WIDTH(hw) (1.2 * hw->width_minor)
30#define THUMB_WIDTH_SIZE(hw, caps) (0.15 * get_cap_xsize(caps))
31
27void init_mtstate(struct MTState *s) 32void init_mtstate(struct MTState *s)
28{ 33{
29 memset(s, 0, sizeof(struct MTState)); 34 memset(s, 0, sizeof(struct MTState));
@@ -39,12 +44,33 @@ static int touching_finger(const struct FingerData *hw,
39 return 1; 44 return 1;
40} 45}
41 46
47/*
48 * Thumb detection:
49 *
50 * The thumb is large and oval, even when not pressed hard against the
51 * surface. The width_major parameter is therefore bounded from below
52 * by all three values touch_major, width_minor, and trackpad size.
53 *
54 */
55static int thumb_finger(const struct FingerData *hw,
56 const struct Capabilities *caps)
57{
58 if (!caps->has_touch_major || !caps->has_touch_minor ||
59 !caps->has_width_major || !caps->has_width_minor)
60 return 0;
61 return hw->touch_major > THUMB_TOUCH(hw) &&
62 hw->width_major > THUMB_WIDTH_TOUCH(hw) &&
63 hw->width_major > THUMB_WIDTH_WIDTH(hw) &&
64 hw->width_major > THUMB_WIDTH_SIZE(hw, caps);
65}
66
42static int set_finger(struct MTFinger *f, 67static int set_finger(struct MTFinger *f,
43 const struct FingerState *fs, 68 const struct FingerState *fs,
44 const struct Capabilities *caps) 69 const struct Capabilities *caps)
45{ 70{
46 f->hw = fs->hw; 71 f->hw = fs->hw;
47 f->id = fs->id; 72 f->id = fs->id;
73 f->thumb = thumb_finger(&fs->hw, caps);
48} 74}
49 75
50void extract_mtstate(struct MTState *s, 76void extract_mtstate(struct MTState *s,