summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/grail-api.c47
1 files changed, 40 insertions, 7 deletions
diff --git a/src/grail-api.c b/src/grail-api.c
index 255c6c2..9fa58a2 100644
--- a/src/grail-api.c
+++ b/src/grail-api.c
@@ -130,26 +130,59 @@ void grail_get_units(const struct grail *ge,
130static void flush_events(struct grail *ge) 130static void flush_events(struct grail *ge)
131{ 131{
132 struct grail_impl *impl = ge->impl; 132 struct grail_impl *impl = ge->impl;
133 struct input_event ev; 133 struct input_event iev;
134 134
135 grailbuf_clear(&impl->gbuf); 135 grailbuf_clear(&impl->gbuf);
136 while (!evbuf_empty(&impl->evbuf)) { 136 while (!evbuf_empty(&impl->evbuf)) {
137 evbuf_get(&impl->evbuf, &ev); 137 evbuf_get(&impl->evbuf, &iev);
138 if (ge->event) 138 if (ge->event)
139 ge->event(ge, &ev); 139 ge->event(ge, &iev);
140 }
141}
142
143static int skip_event(const struct input_event *ev, int count)
144{
145 switch (ev->type) {
146 case EV_ABS:
147 return 1;
148 case EV_KEY:
149 return ev->code >= BTN_DIGI && ev->code < BTN_WHEEL;
150 case EV_SYN:
151 switch (ev->code) {
152 case SYN_MT_REPORT:
153 return 1;
154 case SYN_REPORT:
155 return count == 0;
156 default:
157 return 0;
158 }
159 default:
160 return 0;
140 } 161 }
141} 162}
142 163
143static void flush_gestures(struct grail *ge) 164static void flush_gestures(struct grail *ge)
144{ 165{
145 struct grail_impl *impl = ge->impl; 166 struct grail_impl *impl = ge->impl;
146 struct grail_event ev; 167 struct input_event iev;
168 struct grail_event gev;
169 int count = 0;
147 170
148 evbuf_clear(&impl->evbuf); 171 while (!evbuf_empty(&impl->evbuf)) {
172 evbuf_get(&impl->evbuf, &iev);
173 if (skip_event(&iev, count))
174 continue;
175 if (ge->event)
176 ge->event(ge, &iev);
177 if (iev.type == EV_SYN && iev.code == SYN_REPORT)
178 count = 0;
179 else
180 count++;
181 }
149 while (!grailbuf_empty(&impl->gbuf)) { 182 while (!grailbuf_empty(&impl->gbuf)) {
150 grailbuf_get(&impl->gbuf, &ev); 183 grailbuf_get(&impl->gbuf, &gev);
151 if (ge->gesture) 184 if (ge->gesture)
152 ge->gesture(ge, &ev); 185 ge->gesture(ge, &gev);
153 } 186 }
154} 187}
155 188