diff options
Diffstat (limited to 'src/touch-dev.c')
| -rw-r--r-- | src/touch-dev.c | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/src/touch-dev.c b/src/touch-dev.c index b327266..4cc8d55 100644 --- a/src/touch-dev.c +++ b/src/touch-dev.c | |||
| @@ -26,7 +26,6 @@ | |||
| 26 | #include <malloc.h> | 26 | #include <malloc.h> |
| 27 | #include <string.h> | 27 | #include <string.h> |
| 28 | #include <errno.h> | 28 | #include <errno.h> |
| 29 | #include "evbuf.h" | ||
| 30 | 29 | ||
| 31 | /* from mtdev-mapping.h */ | 30 | /* from mtdev-mapping.h */ |
| 32 | #define MT_TOUCH_MAJOR 0 | 31 | #define MT_TOUCH_MAJOR 0 |
| @@ -50,7 +49,6 @@ struct touch_dev_impl { | |||
| 50 | int status; | 49 | int status; |
| 51 | grail_mask_t mask[DIM_TOUCH_BYTES]; | 50 | grail_mask_t mask[DIM_TOUCH_BYTES]; |
| 52 | touch_prop_t prop[DIM_TOUCH_PROP]; | 51 | touch_prop_t prop[DIM_TOUCH_PROP]; |
| 53 | struct evbuf evbuf; | ||
| 54 | struct mtdev mtdev; | 52 | struct mtdev mtdev; |
| 55 | }; | 53 | }; |
| 56 | 54 | ||
| @@ -82,23 +80,6 @@ static void set_caps(struct touch_dev_caps *caps, | |||
| 82 | set_info(caps, TP_PRESSURE, &mtcaps->abs[MT_PRESSURE]); | 80 | set_info(caps, TP_PRESSURE, &mtcaps->abs[MT_PRESSURE]); |
| 83 | } | 81 | } |
| 84 | 82 | ||
| 85 | static int touch_get_fetched(struct touch_dev_impl *x, | ||
| 86 | struct input_event* ev, int ev_max) | ||
| 87 | { | ||
| 88 | struct input_event kev; | ||
| 89 | int count = 0; | ||
| 90 | while (count < ev_max) { | ||
| 91 | while (mtdev_empty(&x->mtdev)) { | ||
| 92 | if (evbuf_empty(&x->evbuf)) | ||
| 93 | return count; | ||
| 94 | evbuf_get(&x->evbuf, &kev); | ||
| 95 | mtdev_put_event(&x->mtdev, &kev); | ||
| 96 | } | ||
| 97 | mtdev_get_event(&x->mtdev, &ev[count++]); | ||
| 98 | } | ||
| 99 | return count; | ||
| 100 | } | ||
| 101 | |||
| 102 | static inline void set_prop(struct touch_dev_impl *x, int code, int value) | 83 | static inline void set_prop(struct touch_dev_impl *x, int code, int value) |
| 103 | { | 84 | { |
| 104 | grail_mask_set(x->mask, code); | 85 | grail_mask_set(x->mask, code); |
| @@ -207,24 +188,12 @@ int touch_dev_idle(struct touch_dev *dev, int fd, int ms) | |||
| 207 | return mtdev_idle(&dev->impl->mtdev, fd, ms); | 188 | return mtdev_idle(&dev->impl->mtdev, fd, ms); |
| 208 | } | 189 | } |
| 209 | 190 | ||
| 210 | int touch_dev_fetch(struct touch_dev *dev, int fd) | 191 | int touch_dev_pull(struct touch_dev *dev, int fd) |
| 211 | { | ||
| 212 | struct touch_dev_impl *x = dev->impl; | ||
| 213 | struct input_event ev; | ||
| 214 | int ret, count = 0; | ||
| 215 | while ((ret = mtdev_fetch_event(&x->mtdev, fd, &ev)) > 0) { | ||
| 216 | evbuf_put(&x->evbuf, &ev); | ||
| 217 | count++; | ||
| 218 | } | ||
| 219 | return count > 0 ? count : ret; | ||
| 220 | } | ||
| 221 | |||
| 222 | int touch_dev_process(struct touch_dev *dev) | ||
| 223 | { | 192 | { |
| 224 | struct touch_dev_impl *x = dev->impl; | 193 | struct touch_dev_impl *x = dev->impl; |
| 225 | struct input_event ev; | 194 | struct input_event ev; |
| 226 | int ret, count = 0, consumed; | 195 | int ret, count = 0, consumed; |
| 227 | while ((ret = touch_get_fetched(x, &ev, 1)) > 0) { | 196 | while ((ret = mtdev_get(&x->mtdev, fd, &ev, 1)) > 0) { |
| 228 | consumed = 0; | 197 | consumed = 0; |
| 229 | if (ev.type == EV_SYN) { | 198 | if (ev.type == EV_SYN) { |
| 230 | if (ev.code == SYN_REPORT) | 199 | if (ev.code == SYN_REPORT) |
