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) | |
download | xorg-input-kobomultitouch-7380af2c93dc83f4f09e293717d46eadf7799e89.tar.gz xorg-input-kobomultitouch-7380af2c93dc83f4f09e293717d46eadf7799e89.tar.bz2 xorg-input-kobomultitouch-7380af2c93dc83f4f09e293717d46eadf7799e89.zip |
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) return 0; } + +int get_mtouch(struct MTouch *mt, int fd, struct input_event* ev, int ev_max) +{ + const struct input_event *kev; + int count = 0; + while (count < ev_max) { + while (mtdev_empty(&mt->dev)) { + kev = get_iobuf_event(&mt->buf, fd); + if (!kev) + return count; + mtdev_put(&mt->dev, &mt->caps, kev); + } + mtdev_get(&mt->dev, &ev[count++]); + } + return count; +} + int close_mtouch(struct MTouch *mt, int fd) { if (use_grab) { @@ -58,11 +75,15 @@ int close_mtouch(struct MTouch *mt, int fd) return 0; } -int parse_event(struct MTouch *mt, const struct input_event *ev) +int read_packet(struct MTouch *mt, int fd) { - mtdev_put(&mt->dev, &mt->caps, ev); - if (!modify_hwstate(&mt->hs, &mt->dev, &mt->caps)) - return 0; + struct input_event ev; + int ret; + while ((ret = get_mtouch(mt, fd, &ev, 1)) > 0) + if (hwstate_read(&mt->hs, &mt->caps, &ev)) + break; + if (ret <= 0) + return ret; extract_mtstate(&mt->state, &mt->hs, &mt->caps); #if 0 output_mtstate(&mt->state); @@ -74,10 +95,9 @@ int parse_event(struct MTouch *mt, const struct input_event *ev) return 1; } -int mt_is_idle(struct MTouch *mt, int fd) +int has_delayed_gestures(struct MTouch *mt, int fd) { return mt->mem.wait && - evbuf_empty(&mt->dev.outbuf) && - evbuf_empty(&mt->dev.inbuf) && + mtdev_empty(&mt->dev) && poll_iobuf(&mt->buf, fd, mt->mem.wait) == 0; } |