From 2323cf93203686e2f19c125f780486fbe2ee327c Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 21 Sep 2010 11:17:02 +0200 Subject: Split pointer status and report status Separate out reporting of the touch state, such that reporting can be deferred. Does not introduce any logic changes. Signed-off-by: Henrik Rydberg --- src/grail-api.c | 31 ++++++++++++++++++++++++++++--- src/grail-impl.h | 2 ++ 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/grail-api.c b/src/grail-api.c index d4ad83d..b7d1ce0 100644 --- a/src/grail-api.c +++ b/src/grail-api.c @@ -62,6 +62,24 @@ static void evput(struct grail_impl *x, struct timeval time, evbuf_put(&x->evbuf, &ev); } +static void report_down(struct grail_impl *impl) +{ + if (impl->report_status) + return; + evput(impl, impl->report_time, EV_KEY, BTN_TOUCH, 1); + evput(impl, impl->report_time, EV_ABS, ABS_X, impl->report_x); + evput(impl, impl->report_time, EV_ABS, ABS_Y, impl->report_y); + impl->report_status = 1; +} + +static void report_up(struct grail_impl *impl, const struct input_event *syn) +{ + if (!impl->report_status) + return; + evput(impl, syn->time, EV_KEY, BTN_TOUCH, 0); + impl->report_status = 0; +} + static void handle_abs_events(struct grail *ge, const struct input_event *syn) { static const int fm_mask = 0x03; @@ -75,9 +93,12 @@ static void handle_abs_events(struct grail *ge, const struct input_event *syn) int ishold = move->single && tap->active && !used_move; int pointer = ismove || ishold; - if (pointer != impl->pointer_status) { - evput(impl, syn->time, EV_KEY, BTN_TOUCH, pointer); - impl->pointer_status = pointer; + 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 (pointer) { if (impl->report_x != impl->pointer_x) { @@ -89,6 +110,10 @@ static void handle_abs_events(struct grail *ge, const struct input_event *syn) impl->report_y = impl->pointer_y; } } + if (impl->pointer_status && !pointer) { + impl->pointer_status = 0; + report_up(impl, syn); + } } static void tp_sync(struct touch_dev *dev, diff --git a/src/grail-impl.h b/src/grail-impl.h index af84a6c..6093a0f 100644 --- a/src/grail-impl.h +++ b/src/grail-impl.h @@ -32,7 +32,9 @@ struct grail_impl { int filter_abs; int pointer_status; int pointer_x, pointer_y; + int report_status; int report_x, report_y; + struct timeval report_time; }; #endif -- cgit v1.2.3