diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-06-21 18:56:49 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-06-21 18:56:49 +0200 |
| commit | 7380af2c93dc83f4f09e293717d46eadf7799e89 (patch) | |
| tree | 2eb11199ef87e3181411bb848252bb5d6fed0be6 /src/mtouch.c | |
| parent | 71168e1fb794f4a24e97177508bb1d54ae24b266 (diff) | |
Simplify event reading
This patch puts the reading code more in line with the upcoming
mtdev library, and should remove some spurious input behavior.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/mtouch.c')
| -rw-r--r-- | src/mtouch.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/mtouch.c b/src/mtouch.c index 14c0fd9..f7a2710 100644 --- a/src/mtouch.c +++ b/src/mtouch.c | |||
| @@ -48,6 +48,23 @@ int open_mtouch(struct MTouch *mt, int fd) | |||
| 48 | return 0; | 48 | return 0; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | |||
| 52 | int get_mtouch(struct MTouch *mt, int fd, struct input_event* ev, int ev_max) | ||
| 53 | { | ||
| 54 | const struct input_event *kev; | ||
| 55 | int count = 0; | ||
| 56 | while (count < ev_max) { | ||
| 57 | while (mtdev_empty(&mt->dev)) { | ||
| 58 | kev = get_iobuf_event(&mt->buf, fd); | ||
| 59 | if (!kev) | ||
| 60 | return count; | ||
| 61 | mtdev_put(&mt->dev, &mt->caps, kev); | ||
| 62 | } | ||
| 63 | mtdev_get(&mt->dev, &ev[count++]); | ||
| 64 | } | ||
| 65 | return count; | ||
| 66 | } | ||
| 67 | |||
| 51 | int close_mtouch(struct MTouch *mt, int fd) | 68 | int close_mtouch(struct MTouch *mt, int fd) |
| 52 | { | 69 | { |
| 53 | if (use_grab) { | 70 | if (use_grab) { |
| @@ -58,11 +75,15 @@ int close_mtouch(struct MTouch *mt, int fd) | |||
| 58 | return 0; | 75 | return 0; |
| 59 | } | 76 | } |
| 60 | 77 | ||
| 61 | int parse_event(struct MTouch *mt, const struct input_event *ev) | 78 | int read_packet(struct MTouch *mt, int fd) |
| 62 | { | 79 | { |
| 63 | mtdev_put(&mt->dev, &mt->caps, ev); | 80 | struct input_event ev; |
| 64 | if (!modify_hwstate(&mt->hs, &mt->dev, &mt->caps)) | 81 | int ret; |
| 65 | return 0; | 82 | while ((ret = get_mtouch(mt, fd, &ev, 1)) > 0) |
| 83 | if (hwstate_read(&mt->hs, &mt->caps, &ev)) | ||
| 84 | break; | ||
| 85 | if (ret <= 0) | ||
| 86 | return ret; | ||
| 66 | extract_mtstate(&mt->state, &mt->hs, &mt->caps); | 87 | extract_mtstate(&mt->state, &mt->hs, &mt->caps); |
| 67 | #if 0 | 88 | #if 0 |
| 68 | output_mtstate(&mt->state); | 89 | output_mtstate(&mt->state); |
| @@ -74,10 +95,9 @@ int parse_event(struct MTouch *mt, const struct input_event *ev) | |||
| 74 | return 1; | 95 | return 1; |
| 75 | } | 96 | } |
| 76 | 97 | ||
| 77 | int mt_is_idle(struct MTouch *mt, int fd) | 98 | int has_delayed_gestures(struct MTouch *mt, int fd) |
| 78 | { | 99 | { |
| 79 | return mt->mem.wait && | 100 | return mt->mem.wait && |
| 80 | evbuf_empty(&mt->dev.outbuf) && | 101 | mtdev_empty(&mt->dev) && |
| 81 | evbuf_empty(&mt->dev.inbuf) && | ||
| 82 | poll_iobuf(&mt->buf, fd, mt->mem.wait) == 0; | 102 | poll_iobuf(&mt->buf, fd, mt->mem.wait) == 0; |
| 83 | } | 103 | } |
