diff options
Diffstat (limited to 'src/iobuf.c')
| -rw-r--r-- | src/iobuf.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/iobuf.c b/src/iobuf.c index 6d238ec..83e531a 100644 --- a/src/iobuf.c +++ b/src/iobuf.c | |||
| @@ -28,6 +28,18 @@ | |||
| 28 | 28 | ||
| 29 | #include "iobuf.h" | 29 | #include "iobuf.h" |
| 30 | #include "state.h" | 30 | #include "state.h" |
| 31 | #include <poll.h> | ||
| 32 | |||
| 33 | int mtdev_idle(struct mtdev *dev, int fd, int ms) | ||
| 34 | { | ||
| 35 | struct mtdev_state *state = dev->state; | ||
| 36 | struct mtdev_iobuf *buf = &state->iobuf; | ||
| 37 | struct pollfd fds = { fd, POLLIN, 0 }; | ||
| 38 | return evbuf_empty(&state->outbuf) && | ||
| 39 | evbuf_empty(&state->inbuf) && | ||
| 40 | buf->head == buf->tail && | ||
| 41 | poll(&fds, 1, ms) <= 0; | ||
| 42 | } | ||
| 31 | 43 | ||
| 32 | int mtdev_fetch(struct mtdev *dev, struct input_event *ev, int fd) | 44 | int mtdev_fetch(struct mtdev *dev, struct input_event *ev, int fd) |
| 33 | { | 45 | { |
