Update input event structures read from the kernel to match the 1.2 version of the driver.
There are no changes to the exposed interfaces of the mtdev.
The associated kernel driver change is proposed at https://lkml.org/lkml/2016/10/17/1146 .
Signed-off-by: Deepa Dinamani deepa.kernel@gmail.com --- src/evbuf.h | 10 ++++++---- src/iobuf.c | 8 ++++---- src/iobuf.h | 4 +++- 3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/evbuf.h b/src/evbuf.h index 17ea4e7..9ec2da6 100644 --- a/src/evbuf.h +++ b/src/evbuf.h @@ -34,7 +34,7 @@ struct mtdev_evbuf { int head; int tail; - struct input_event buffer[DIM_EVENTS]; + struct raw_input_event buffer[DIM_EVENTS]; };
static inline int evbuf_empty(const struct mtdev_evbuf *evbuf) @@ -43,16 +43,18 @@ static inline int evbuf_empty(const struct mtdev_evbuf *evbuf) }
static inline void evbuf_put(struct mtdev_evbuf *evbuf, - const struct input_event *ev) + struct input_event *ev) { - evbuf->buffer[evbuf->head++] = *ev; + input_to_raw_event(ev, &evbuf->buffer[evbuf->head]); + evbuf->head++; evbuf->head &= DIM_EVENTS - 1; }
static inline void evbuf_get(struct mtdev_evbuf *evbuf, struct input_event *ev) { - *ev = evbuf->buffer[evbuf->tail++]; + raw_input_to_input_event(&evbuf->buffer[evbuf->tail], ev); + evbuf->tail++; evbuf->tail &= DIM_EVENTS - 1; }
diff --git a/src/iobuf.c b/src/iobuf.c index 61ec9c1..6f7c923 100644 --- a/src/iobuf.c +++ b/src/iobuf.c @@ -42,7 +42,7 @@ int mtdev_fetch_event(struct mtdev *dev, int fd, struct input_event *ev) { struct mtdev_iobuf *buf = &dev->state->iobuf; int n = buf->head - buf->tail; - if (n < EVENT_SIZE) { + if (n < RAW_EVENT_SIZE) { if (buf->tail && n > 0) memmove(buf->data, buf->data + buf->tail, n); buf->head = n; @@ -53,10 +53,10 @@ int mtdev_fetch_event(struct mtdev *dev, int fd, struct input_event *ev) return n; buf->head += n; } - if (buf->head - buf->tail < EVENT_SIZE) + if (buf->head - buf->tail < RAW_EVENT_SIZE) return 0; - memcpy(ev, buf->data + buf->tail, EVENT_SIZE); - buf->tail += EVENT_SIZE; + raw_input_to_input_event(buf->data + buf->tail, ev); + buf->tail += RAW_EVENT_SIZE; return 1; }
diff --git a/src/iobuf.h b/src/iobuf.h index 09c26c4..7450b01 100644 --- a/src/iobuf.h +++ b/src/iobuf.h @@ -32,7 +32,9 @@ #include "common.h"
#define EVENT_SIZE sizeof(struct input_event) -#define DIM_BUFFER (DIM_EVENTS * EVENT_SIZE) +#define RAW_EVENT_SIZE sizeof(struct input_event) + +#define DIM_BUFFER (DIM_EVENTS * RAW_EVENT_SIZE)
struct mtdev_iobuf { int head, tail;