From 33be41843e18b6a716ff62982e32c843e7a2bb1f Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 10 Aug 2010 15:26:22 +0100 Subject: Filter kernel touch and tap buttons Reinsert BTN_TOUCH depending on the drag gesture Signed-off-by: Henrik Rydberg --- src/grail-api.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/grail-api.c') diff --git a/src/grail-api.c b/src/grail-api.c index fbd0e83..9774e01 100644 --- a/src/grail-api.c +++ b/src/grail-api.c @@ -36,6 +36,7 @@ struct grail_impl { struct touch_engine engine; struct evbuf evbuf; int filter_abs; + int hack_status; }; static void tp_event(struct touch_engine *engine, @@ -46,6 +47,20 @@ static void tp_event(struct touch_engine *engine, evbuf_put(&x->evbuf, ev); } +static int extra_filtered(const struct input_event *ev) +{ + if (ev->type == EV_KEY) { + switch (ev->code) { + case BTN_TOUCH: + case BTN_TOOL_DOUBLETAP: + case BTN_TOOL_TRIPLETAP: + case BTN_TOOL_QUADTAP: + return 1; + } + } + return 0; +} + static void tp_sync(struct touch_engine *engine, const struct input_event *syn) { @@ -55,11 +70,12 @@ static void tp_sync(struct touch_engine *engine, struct gesture_recognizer *gru = ge->gru; struct touch_frame *frame = &engine->frame; grail_mask_t filtered[DIM_EV_TYPE_BYTES]; - int dofilt, nevent = 0; + int dofilt, hack, nevent = 0; gin_frame_begin(ge, frame); gru_recognize(ge, frame); gin_frame_end(ge, filtered, sizeof(filtered), frame); dofilt = gru->move.multi || gru->move.single && x->filter_abs; + hack = gru->move.single; if (!ge->event) { evbuf_clear(&x->evbuf); @@ -69,9 +85,19 @@ static void tp_sync(struct touch_engine *engine, evbuf_get(&x->evbuf, &ev); if (dofilt && grail_mask_get(filtered, ev.type)) continue; + if (extra_filtered(&ev)) + continue; ge->event(ge, &ev); nevent++; } + if (hack != x->hack_status) { + ev = *syn; + ev.type = EV_KEY; + ev.code = BTN_TOUCH; + ev.value = hack; + ge->event(ge, &ev); + x->hack_status = hack; + } if (nevent) ge->event(ge, syn); } -- cgit v1.2.3