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/test.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/test.c')
| -rw-r--r-- | src/test.c | 10 |
1 files changed, 4 insertions, 6 deletions
| @@ -27,8 +27,6 @@ static void loop_device(int fd) | |||
| 27 | { | 27 | { |
| 28 | struct Gestures gs; | 28 | struct Gestures gs; |
| 29 | struct MTouch mt; | 29 | struct MTouch mt; |
| 30 | const struct input_event *ev; | ||
| 31 | struct input_event event; | ||
| 32 | if (configure_mtouch(&mt, fd)) { | 30 | if (configure_mtouch(&mt, fd)) { |
| 33 | fprintf(stderr, "error: could not configure device\n"); | 31 | fprintf(stderr, "error: could not configure device\n"); |
| 34 | return; | 32 | return; |
| @@ -37,12 +35,12 @@ static void loop_device(int fd) | |||
| 37 | fprintf(stderr, "error: could not open device\n"); | 35 | fprintf(stderr, "error: could not open device\n"); |
| 38 | return; | 36 | return; |
| 39 | } | 37 | } |
| 40 | while (ev = get_iobuf_event(&mt.buf, fd)) { | 38 | while (poll_iobuf(&mt.buf, fd, 5000)) { |
| 41 | if (parse_event(&mt, ev)) { | 39 | while (read_packet(&mt, fd) > 0) { |
| 42 | extract_gestures(&gs, &mt); | 40 | extract_gestures(&gs, &mt); |
| 43 | output_gesture(&gs); | 41 | output_gesture(&gs); |
| 44 | } | 42 | } |
| 45 | if (mt_is_idle(&mt, fd)) { | 43 | if (has_delayed_gestures(&mt, fd)) { |
| 46 | extract_delayed_gestures(&gs, &mt); | 44 | extract_delayed_gestures(&gs, &mt); |
| 47 | output_gesture(&gs); | 45 | output_gesture(&gs); |
| 48 | } | 46 | } |
| @@ -56,7 +54,7 @@ int main(int argc, char *argv[]) | |||
| 56 | fprintf(stderr, "Usage: test <mtdev>\n"); | 54 | fprintf(stderr, "Usage: test <mtdev>\n"); |
| 57 | return -1; | 55 | return -1; |
| 58 | } | 56 | } |
| 59 | int fd = open(argv[1], O_RDONLY); | 57 | int fd = open(argv[1], O_RDONLY | O_NONBLOCK); |
| 60 | if (fd < 0) { | 58 | if (fd < 0) { |
| 61 | fprintf(stderr, "error: could not open file\n"); | 59 | fprintf(stderr, "error: could not open file\n"); |
| 62 | return -1; | 60 | return -1; |
