From d9a9cafc00cf1ccfeb72c9d86644144687884ef4 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 21 Sep 2010 12:55:24 +0200 Subject: Add tap emulation Touchscreens always emit a button event when touching the screen. Trackpads, however, are considered hovering while touching the pad, and instead uses taps to emits button events, which is traditionally implemented elsewhere, and thus leaves a functionality discrepancy. This patch adds tap emulation to grail, utilizing gesture engine. Signed-off-by: Henrik Rydberg --- src/grail-api.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/grail-api.c b/src/grail-api.c index b7d1ce0..bf5a7df 100644 --- a/src/grail-api.c +++ b/src/grail-api.c @@ -89,18 +89,32 @@ static void handle_abs_events(struct grail *ge, const struct input_event *syn) struct move_model *move = &gru->move; struct tapping_model *tap = &gru->tapping; int used_move = grail_mask_count(gin->types, sizeof(gin->types)); + int used_tap = grail_mask_get(gin->types, GRAIL_TYPE_TAP1); int ismove = move->single && (move->active & fm_mask) && !used_move; int ishold = move->single && tap->active && !used_move; - int pointer = ismove || ishold; + int istap = gru->tapping.tap == 1 && !used_tap; + int pointer = move->single; if (!impl->pointer_status && pointer) { impl->report_x = impl->pointer_x; impl->report_y = impl->pointer_y; impl->report_time = syn->time; impl->pointer_status = 1; - report_down(impl); + if (!used_move) + report_down(impl); + return; } - if (pointer) { + + if (ishold) + return; + + if (istap) { + report_down(impl); + evput(impl, impl->report_time, EV_KEY, BTN_LEFT, 1); + evput(impl, impl->report_time, EV_SYN, SYN_REPORT, 0); + evput(impl, syn->time, EV_KEY, BTN_LEFT, 0); + } else if (ismove) { + report_down(impl); if (impl->report_x != impl->pointer_x) { evput(impl, syn->time, EV_ABS, ABS_X, impl->pointer_x); impl->report_x = impl->pointer_x; -- cgit v1.2.3