touchpad: move the tap state bug messages to a helper function

There's no need for a custom error message everywhere, it's better to log the
current state and the event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2017-11-06 14:22:06 +10:00
parent 8f92b09112
commit cad73f4023

View file

@ -96,6 +96,16 @@ tap_event_to_str(enum tap_event event)
return NULL;
}
static inline void
log_tap_bug(struct tp_dispatch *tp, enum tap_event event)
{
evdev_log_bug_libinput(tp->device,
"invalid tap event %s in state %s\n",
tap_event_to_str(event),
tap_state_to_str(tp->tap.state));
}
static void
tp_tap_notify(struct tp_dispatch *tp,
uint64_t time,
@ -158,8 +168,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp,
case TAP_EVENT_RELEASE:
break;
case TAP_EVENT_MOTION:
evdev_log_bug_libinput(tp->device,
"invalid tap event, no fingers are down\n");
log_tap_bug(tp, event);
break;
case TAP_EVENT_TIMEOUT:
break;
@ -167,8 +176,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp,
tp->tap.state = TAP_STATE_DEAD;
break;
case TAP_EVENT_THUMB:
evdev_log_bug_libinput(tp->device,
"invalid tap event, no fingers down, no thumb\n");
log_tap_bug(tp, event);
break;
}
}
@ -256,8 +264,7 @@ tp_tap_tapped_handle_event(struct tp_dispatch *tp,
switch (event) {
case TAP_EVENT_MOTION:
case TAP_EVENT_RELEASE:
evdev_log_bug_libinput(tp->device,
"invalid tap event when fingers are up\n");
log_tap_bug(tp, event);
break;
case TAP_EVENT_TOUCH:
tp->tap.state = TAP_STATE_DRAGGING_OR_DOUBLETAP;
@ -592,8 +599,7 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp,
{
switch (event) {
case TAP_EVENT_RELEASE:
evdev_log_bug_libinput(tp->device,
"invalid tap event, no fingers are down\n");
log_tap_bug(tp, event);
break;
case TAP_EVENT_TOUCH:
tp->tap.state = TAP_STATE_MULTITAP_DOWN;
@ -605,8 +611,7 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp,
tp_tap_set_timer(tp, time);
break;
case TAP_EVENT_MOTION:
evdev_log_bug_libinput(tp->device,
"invalid tap event, no fingers are down\n");
log_tap_bug(tp, event);
break;
case TAP_EVENT_TIMEOUT:
tp->tap.state = TAP_STATE_IDLE;