summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-09-21 11:17:02 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-09-21 12:56:17 +0200
commit2323cf93203686e2f19c125f780486fbe2ee327c (patch)
treeed37daff12c36926ff17ac87702a41aa479027d7
parenta23067b7066786ceaa0779324e9120f8b04a6372 (diff)
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 <rydberg@euromail.se>
-rw-r--r--src/grail-api.c31
-rw-r--r--src/grail-impl.h2
2 files changed, 30 insertions, 3 deletions
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,
62 evbuf_put(&x->evbuf, &ev); 62 evbuf_put(&x->evbuf, &ev);
63} 63}
64 64
65static void report_down(struct grail_impl *impl)
66{
67 if (impl->report_status)
68 return;
69 evput(impl, impl->report_time, EV_KEY, BTN_TOUCH, 1);
70 evput(impl, impl->report_time, EV_ABS, ABS_X, impl->report_x);
71 evput(impl, impl->report_time, EV_ABS, ABS_Y, impl->report_y);
72 impl->report_status = 1;
73}
74
75static void report_up(struct grail_impl *impl, const struct input_event *syn)
76{
77 if (!impl->report_status)
78 return;
79 evput(impl, syn->time, EV_KEY, BTN_TOUCH, 0);
80 impl->report_status = 0;
81}
82
65static void handle_abs_events(struct grail *ge, const struct input_event *syn) 83static void handle_abs_events(struct grail *ge, const struct input_event *syn)
66{ 84{
67 static const int fm_mask = 0x03; 85 static const int fm_mask = 0x03;
@@ -75,9 +93,12 @@ static void handle_abs_events(struct grail *ge, const struct input_event *syn)
75 int ishold = move->single && tap->active && !used_move; 93 int ishold = move->single && tap->active && !used_move;
76 int pointer = ismove || ishold; 94 int pointer = ismove || ishold;
77 95
78 if (pointer != impl->pointer_status) { 96 if (!impl->pointer_status && pointer) {
79 evput(impl, syn->time, EV_KEY, BTN_TOUCH, pointer); 97 impl->report_x = impl->pointer_x;
80 impl->pointer_status = pointer; 98 impl->report_y = impl->pointer_y;
99 impl->report_time = syn->time;
100 impl->pointer_status = 1;
101 report_down(impl);
81 } 102 }
82 if (pointer) { 103 if (pointer) {
83 if (impl->report_x != impl->pointer_x) { 104 if (impl->report_x != impl->pointer_x) {
@@ -89,6 +110,10 @@ static void handle_abs_events(struct grail *ge, const struct input_event *syn)
89 impl->report_y = impl->pointer_y; 110 impl->report_y = impl->pointer_y;
90 } 111 }
91 } 112 }
113 if (impl->pointer_status && !pointer) {
114 impl->pointer_status = 0;
115 report_up(impl, syn);
116 }
92} 117}
93 118
94static void tp_sync(struct touch_dev *dev, 119static 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 {
32 int filter_abs; 32 int filter_abs;
33 int pointer_status; 33 int pointer_status;
34 int pointer_x, pointer_y; 34 int pointer_x, pointer_y;
35 int report_status;
35 int report_x, report_y; 36 int report_x, report_y;
37 struct timeval report_time;
36}; 38};
37 39
38#endif 40#endif