touchpad: change the stylus palm arbitration to process touches

Previously, on touch toggle (invoked by the tablet when a pen goes in
proximity) the touchpad cleared the state and ignored any events. Since we
ignore touches that we didn't see the touch begin for, this handled the cases
of a touch remaining after proximity out.

This code pre-dates palm detection, so let's take the bluetack off and instead
integrate it with proper palm detectino.
This commit is contained in:
Peter Hutterer 2018-02-19 14:19:53 +10:00
parent 402b179bc7
commit da74aab7f7
2 changed files with 25 additions and 10 deletions

View file

@ -907,6 +907,19 @@ tp_palm_detect_pressure_triggered(struct tp_dispatch *tp,
return t->palm.state == PALM_PRESSURE; return t->palm.state == PALM_PRESSURE;
} }
static bool
tp_palm_detect_arbitration_triggered(struct tp_dispatch *tp,
struct tp_touch *t,
uint64_t time)
{
if (!tp->in_arbitration)
return false;
t->palm.state = PALM_ARBITRATION;
return true;
}
static void static void
tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
{ {
@ -916,6 +929,9 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
if (tp_palm_detect_pressure_triggered(tp, t, time)) if (tp_palm_detect_pressure_triggered(tp, t, time))
goto out; goto out;
if (tp_palm_detect_arbitration_triggered(tp, t, time))
goto out;
if (tp_palm_detect_dwt_triggered(tp, t, time)) if (tp_palm_detect_dwt_triggered(tp, t, time))
goto out; goto out;
@ -965,6 +981,9 @@ out:
case PALM_TOUCH_SIZE: case PALM_TOUCH_SIZE:
palm_state = "touch size"; palm_state = "touch size";
break; break;
case PALM_ARBITRATION:
palm_state = "arbitration";
break;
case PALM_NONE: case PALM_NONE:
default: default:
abort(); abort();
@ -1600,9 +1619,6 @@ tp_interface_process(struct evdev_dispatch *dispatch,
{ {
struct tp_dispatch *tp = tp_dispatch(dispatch); struct tp_dispatch *tp = tp_dispatch(dispatch);
if (tp->ignore_events)
return;
switch (e->type) { switch (e->type) {
case EV_ABS: case EV_ABS:
if (tp->has_mt) if (tp->has_mt)
@ -2291,15 +2307,15 @@ tp_interface_toggle_touch(struct evdev_dispatch *dispatch,
bool enable) bool enable)
{ {
struct tp_dispatch *tp = tp_dispatch(dispatch); struct tp_dispatch *tp = tp_dispatch(dispatch);
bool ignore_events = !enable; bool arbitrate = !enable;
if (ignore_events == tp->ignore_events) if (arbitrate == tp->in_arbitration)
return; return;
if (ignore_events) if (arbitrate)
tp_clear_state(tp); tp_clear_state(tp);
tp->ignore_events = ignore_events; tp->in_arbitration = arbitrate;
} }
static struct evdev_dispatch_interface tp_interface = { static struct evdev_dispatch_interface tp_interface = {

View file

@ -60,6 +60,7 @@ enum touch_palm_state {
PALM_TOOL_PALM, PALM_TOOL_PALM,
PALM_PRESSURE, PALM_PRESSURE,
PALM_TOUCH_SIZE, PALM_TOUCH_SIZE,
PALM_ARBITRATION,
}; };
enum button_event { enum button_event {
@ -239,9 +240,7 @@ struct tp_dispatch {
bool has_mt; bool has_mt;
bool semi_mt; bool semi_mt;
/* true if we're reading events (i.e. not suspended) but we're bool in_arbitration; /* pen/touch arbitration */
* ignoring them */
bool ignore_events;
unsigned int num_slots; /* number of slots */ unsigned int num_slots; /* number of slots */
unsigned int ntouches; /* no slots inc. fakes */ unsigned int ntouches; /* no slots inc. fakes */