diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mtstate.c | 26 | ||||
| -rw-r--r-- | src/mtstate.h | 2 |
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 @@ | |||
| 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 | |||
| 27 | void init_mtstate(struct MTState *s) | 32 | void 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 | */ | ||
| 55 | static 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 | |||
| 42 | static int set_finger(struct MTFinger *f, | 67 | static 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 | ||
| 50 | void extract_mtstate(struct MTState *s, | 76 | 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 @@ | |||
| 26 | 26 | ||
| 27 | struct MTFinger { | 27 | struct MTFinger { |
| 28 | struct FingerData hw; | 28 | struct FingerData hw; |
| 29 | int id; | 29 | int id, thumb; |
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | struct MTState { | 32 | struct MTState { |
