Skip to content

Commit

Permalink
touchpad: simplify tapping state machine by eliminating the multitap …
Browse files Browse the repository at this point in the history
…states

Alternating between TAPPED and DRAGGING_OR_MULTITAP on repeated taps is enough, no need for more states.
  • Loading branch information
satrmb authored and whot committed Nov 26, 2019
1 parent bba7975 commit 29785df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 136 deletions.
2 changes: 1 addition & 1 deletion doc/touchpad-tap-state-machine.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 5 additions & 132 deletions src/evdev-mt-touchpad-tap.c
Expand Up @@ -71,9 +71,6 @@ tap_state_to_str(enum tp_tap_state state)
CASE_RETURN_STRING(TAP_STATE_DRAGGING_OR_DOUBLETAP);
CASE_RETURN_STRING(TAP_STATE_DRAGGING_OR_TAP);
CASE_RETURN_STRING(TAP_STATE_DRAGGING_2);
CASE_RETURN_STRING(TAP_STATE_MULTITAP);
CASE_RETURN_STRING(TAP_STATE_MULTITAP_DOWN);
CASE_RETURN_STRING(TAP_STATE_MULTITAP_PALM);
CASE_RETURN_STRING(TAP_STATE_DEAD);
}
return NULL;
Expand Down Expand Up @@ -540,11 +537,15 @@ tp_tap_dragging_or_doubletap_handle_event(struct tp_dispatch *tp,
tp->tap.state = TAP_STATE_DRAGGING_2;
break;
case TAP_EVENT_RELEASE:
tp->tap.state = TAP_STATE_MULTITAP;
tp->tap.state = TAP_STATE_TAPPED;
tp_tap_notify(tp,
tp->tap.saved_release_time,
1,
LIBINPUT_BUTTON_STATE_RELEASED);
tp_tap_notify(tp,
tp->tap.saved_press_time,
1,
LIBINPUT_BUTTON_STATE_PRESSED);
tp->tap.saved_release_time = time;
tp_tap_set_timer(tp, time);
break;
Expand Down Expand Up @@ -712,124 +713,6 @@ tp_tap_dragging2_handle_event(struct tp_dispatch *tp,
}
}

static void
tp_tap_multitap_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
{
switch (event) {
case TAP_EVENT_RELEASE:
log_tap_bug(tp, t, event);
break;
case TAP_EVENT_TOUCH:
tp->tap.state = TAP_STATE_MULTITAP_DOWN;
tp_tap_notify(tp,
tp->tap.saved_press_time,
1,
LIBINPUT_BUTTON_STATE_PRESSED);
tp->tap.saved_press_time = time;
tp_tap_set_timer(tp, time);
break;
case TAP_EVENT_MOTION:
log_tap_bug(tp, t, event);
break;
case TAP_EVENT_TIMEOUT:
tp->tap.state = TAP_STATE_IDLE;
tp_tap_notify(tp,
tp->tap.saved_press_time,
1,
LIBINPUT_BUTTON_STATE_PRESSED);
tp_tap_notify(tp,
tp->tap.saved_release_time,
1,
LIBINPUT_BUTTON_STATE_RELEASED);
break;
case TAP_EVENT_BUTTON:
tp->tap.state = TAP_STATE_IDLE;
tp_tap_clear_timer(tp);
break;
case TAP_EVENT_THUMB:
case TAP_EVENT_PALM:
break;
case TAP_EVENT_PALM_UP:
break;
}
}

static void
tp_tap_multitap_down_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event,
uint64_t time)
{
switch (event) {
case TAP_EVENT_RELEASE:
tp->tap.state = TAP_STATE_MULTITAP;
tp_tap_notify(tp,
tp->tap.saved_release_time,
1,
LIBINPUT_BUTTON_STATE_RELEASED);
tp->tap.saved_release_time = time;
tp_tap_set_timer(tp, time);
break;
case TAP_EVENT_TOUCH:
tp->tap.state = TAP_STATE_DRAGGING_2;
tp_tap_clear_timer(tp);
break;
case TAP_EVENT_MOTION:
case TAP_EVENT_TIMEOUT:
tp->tap.state = TAP_STATE_DRAGGING;
tp_tap_clear_timer(tp);
break;
case TAP_EVENT_BUTTON:
tp->tap.state = TAP_STATE_DEAD;
tp_tap_notify(tp,
tp->tap.saved_release_time,
1,
LIBINPUT_BUTTON_STATE_RELEASED);
tp_tap_clear_timer(tp);
break;
case TAP_EVENT_THUMB:
break;
case TAP_EVENT_PALM:
tp->tap.state = TAP_STATE_MULTITAP_PALM;
break;
case TAP_EVENT_PALM_UP:
break;
}
}

static void
tp_tap_multitap_palm_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event,
uint64_t time)
{
switch (event) {
case TAP_EVENT_RELEASE:
log_tap_bug(tp, t, event);
break;
case TAP_EVENT_TOUCH:
tp->tap.state = TAP_STATE_MULTITAP_DOWN;
break;
case TAP_EVENT_MOTION:
break;
case TAP_EVENT_TIMEOUT:
case TAP_EVENT_BUTTON:
tp->tap.state = TAP_STATE_IDLE;
tp_tap_clear_timer(tp);
tp_tap_notify(tp,
tp->tap.saved_release_time,
1,
LIBINPUT_BUTTON_STATE_RELEASED);
break;
case TAP_EVENT_THUMB:
case TAP_EVENT_PALM:
case TAP_EVENT_PALM_UP:
break;
}
}

static void
tp_tap_dead_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
Expand Down Expand Up @@ -910,15 +793,6 @@ tp_tap_handle_event(struct tp_dispatch *tp,
case TAP_STATE_DRAGGING_2:
tp_tap_dragging2_handle_event(tp, t, event, time);
break;
case TAP_STATE_MULTITAP:
tp_tap_multitap_handle_event(tp, t, event, time);
break;
case TAP_STATE_MULTITAP_DOWN:
tp_tap_multitap_down_handle_event(tp, t, event, time);
break;
case TAP_STATE_MULTITAP_PALM:
tp_tap_multitap_palm_handle_event(tp, t, event, time);
break;
case TAP_STATE_DEAD:
tp_tap_dead_handle_event(tp, t, event, time);
break;
Expand Down Expand Up @@ -1085,7 +959,6 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
case TAP_STATE_DRAGGING_OR_TAP:
case TAP_STATE_TOUCH_2:
case TAP_STATE_TOUCH_3:
case TAP_STATE_MULTITAP_DOWN:
filter_motion = 1;
break;

Expand Down
3 changes: 0 additions & 3 deletions src/evdev-mt-touchpad.h
Expand Up @@ -103,9 +103,6 @@ enum tp_tap_state {
TAP_STATE_DRAGGING,
TAP_STATE_DRAGGING_WAIT,
TAP_STATE_DRAGGING_2,
TAP_STATE_MULTITAP,
TAP_STATE_MULTITAP_DOWN,
TAP_STATE_MULTITAP_PALM,
TAP_STATE_DEAD, /**< finger count exceeded */
};

Expand Down

0 comments on commit 29785df

Please sign in to comment.