summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2015-07-06 15:22:45 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2015-07-09 11:27:53 +1000
commit4a463ca70228eaf0d3b676b6d7392b3cd5eb8f00 (patch)
tree74e88844373b629243653845a1b0e73f072f3afa
parent3dcf28b919ae598506852b408829a6627168e803 (diff)
downloadlibinput-4a463ca70228eaf0d3b676b6d7392b3cd5eb8f00.tar.gz
touchpad: work thumb detection into the tap state machine
Most thumbs are detected a few events into the sequence. Work this into parts of the tapping state machine. Only the most common use-case is handled here - if the first finger ends up being marked as a thumb, we return to the idle state and ignore that touch sequence. At any other state, we handle thumbs like any other finger. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--doc/touchpad-tap-state-machine.svg18
-rw-r--r--src/evdev-mt-touchpad-tap.c47
2 files changed, 65 insertions, 0 deletions
diff --git a/doc/touchpad-tap-state-machine.svg b/doc/touchpad-tap-state-machine.svg
index 89c34fa0..b1c5995b 100644
--- a/doc/touchpad-tap-state-machine.svg
+++ b/doc/touchpad-tap-state-machine.svg
@@ -1179,5 +1179,23 @@
[Not supported by viewer]</text>
</switch>
</g>
+ <path d="M 2095.54 407 C 2098.34 403.86 2102.32 402.05 2106.52 402 L 2140.49 402 C 2144.69 402.05 2148.67 403.86 2151.47 407 L 2171.45 430 C 2172.01 431.28 2172.01 432.72 2171.45 434 L 2151.47 457 C 2148.67 460.14 2144.69 461.95 2140.49 462 L 2106.52 462 C 2102.32 461.95 2098.34 460.14 2095.54 457 L 2075.56 434 C 2075 432.72 2075 431.28 2075.56 430 L 2095.54 407 Z" fill="#ff99cc" stroke="#000000" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/>
+ <g fill="#000000" font-family="Helvetica" text-anchor="middle" font-size="12px">
+ <text x="2123.25" y="435.75">
+ thumb</text>
+ </g>
+ <path d="M 1801.42 332 L 2068.92 415.05" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/>
+ <path d="M 2073.93 416.61 L 2066.21 417.88 L 2068.92 415.05 L 2068.28 411.19 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/>
+ <path d="M 2152.5 488.7 C 2168.62 494.91 2186.38 494.91 2202.5 488.7 C 2218.62 482.5 2236.38 482.5 2252.5 488.7 L 2252.5 541.28 C 2236.38 535.08 2218.62 535.08 2202.5 541.28 C 2186.38 547.49 2168.62 547.49 2152.5 541.28 L 2152.5 488.7 Z" fill="#ffd966" stroke="#000000" stroke-width="2" stroke-miterlimit="10" pointer-events="none"/>
+ <g fill="#000000" font-family="Helvetica" text-anchor="middle" font-size="12px">
+ <text x="2202.25" y="518.75">
+ TOUCH_DEAD</text>
+ </g>
+ <path d="M 2152.05 462 L 2167.18 477.89" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/>
+ <path d="M 2170.8 481.69 L 2163.43 479.03 L 2167.18 477.89 L 2168.5 474.21 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/>
+ <path d="M 2217.81 547.5 L 2324.65 774.24" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/>
+ <path d="M 2326.89 778.99 L 2320.74 774.15 L 2324.65 774.24 L 2327.07 771.16 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/>
+ <path d="M 1959.61 577 L 2084.82 466.22" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/>
+ <path d="M 2088.75 462.74 L 2085.83 470 L 2084.82 466.22 L 2081.19 464.76 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/>
</g>
</svg>
diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index a43e235e..9bbf6b88 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -47,6 +47,7 @@ enum tap_event {
TAP_EVENT_RELEASE,
TAP_EVENT_BUTTON,
TAP_EVENT_TIMEOUT,
+ TAP_EVENT_THUMB,
};
/*****************************************
@@ -93,6 +94,7 @@ tap_event_to_str(enum tap_event event)
CASE_RETURN_STRING(TAP_EVENT_RELEASE);
CASE_RETURN_STRING(TAP_EVENT_TIMEOUT);
CASE_RETURN_STRING(TAP_EVENT_BUTTON);
+ CASE_RETURN_STRING(TAP_EVENT_THUMB);
}
return NULL;
}
@@ -166,6 +168,10 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp,
case TAP_EVENT_BUTTON:
tp->tap.state = TAP_STATE_DEAD;
break;
+ case TAP_EVENT_THUMB:
+ log_bug_libinput(libinput,
+ "invalid tap event, no fingers down, no thumb\n");
+ break;
}
}
@@ -193,6 +199,12 @@ tp_tap_touch_handle_event(struct tp_dispatch *tp,
case TAP_EVENT_BUTTON:
tp->tap.state = TAP_STATE_DEAD;
break;
+ case TAP_EVENT_THUMB:
+ tp->tap.state = TAP_STATE_IDLE;
+ t->tap.is_thumb = true;
+ t->tap.state = TAP_TOUCH_STATE_DEAD;
+ tp_tap_clear_timer(tp);
+ break;
}
}
@@ -216,6 +228,11 @@ tp_tap_hold_handle_event(struct tp_dispatch *tp,
case TAP_EVENT_BUTTON:
tp->tap.state = TAP_STATE_DEAD;
break;
+ case TAP_EVENT_THUMB:
+ tp->tap.state = TAP_STATE_IDLE;
+ t->tap.is_thumb = true;
+ t->tap.state = TAP_TOUCH_STATE_DEAD;
+ break;
}
}
@@ -244,6 +261,8 @@ tp_tap_tapped_handle_event(struct tp_dispatch *tp,
tp->tap.state = TAP_STATE_DEAD;
tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED);
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -275,6 +294,8 @@ tp_tap_touch2_handle_event(struct tp_dispatch *tp,
case TAP_EVENT_BUTTON:
tp->tap.state = TAP_STATE_DEAD;
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -299,6 +320,8 @@ tp_tap_touch2_hold_handle_event(struct tp_dispatch *tp,
case TAP_EVENT_BUTTON:
tp->tap.state = TAP_STATE_DEAD;
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -328,6 +351,8 @@ tp_tap_touch3_handle_event(struct tp_dispatch *tp,
case TAP_EVENT_BUTTON:
tp->tap.state = TAP_STATE_DEAD;
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -351,6 +376,8 @@ tp_tap_touch3_hold_handle_event(struct tp_dispatch *tp,
case TAP_EVENT_BUTTON:
tp->tap.state = TAP_STATE_DEAD;
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -375,6 +402,8 @@ tp_tap_dragging_or_doubletap_handle_event(struct tp_dispatch *tp,
tp->tap.state = TAP_STATE_DEAD;
tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED);
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -408,6 +437,8 @@ tp_tap_dragging_handle_event(struct tp_dispatch *tp,
tp->tap.state = TAP_STATE_DEAD;
tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED);
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -433,6 +464,8 @@ tp_tap_dragging_wait_handle_event(struct tp_dispatch *tp,
tp->tap.state = TAP_STATE_DEAD;
tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED);
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -459,6 +492,8 @@ tp_tap_dragging_tap_handle_event(struct tp_dispatch *tp,
tp->tap.state = TAP_STATE_DEAD;
tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED);
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -484,6 +519,8 @@ tp_tap_dragging2_handle_event(struct tp_dispatch *tp,
tp->tap.state = TAP_STATE_DEAD;
tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED);
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -518,6 +555,8 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp,
tp->tap.state = TAP_STATE_IDLE;
tp_tap_clear_timer(tp);
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -556,6 +595,8 @@ tp_tap_multitap_down_handle_event(struct tp_dispatch *tp,
tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED);
tp_tap_clear_timer(tp);
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -576,6 +617,8 @@ tp_tap_dead_handle_event(struct tp_dispatch *tp,
case TAP_EVENT_TIMEOUT:
case TAP_EVENT_BUTTON:
break;
+ case TAP_EVENT_THUMB:
+ break;
}
}
@@ -731,6 +774,10 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
}
tp_tap_handle_event(tp, t, TAP_EVENT_MOTION, time);
+ } else if (tp->tap.state != TAP_STATE_IDLE &&
+ t->is_thumb &&
+ !t->tap.is_thumb) {
+ tp_tap_handle_event(tp, t, TAP_EVENT_THUMB, time);
}
}