[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/17] wctablet: save all chars in the query buffer
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 03/17] wctablet: save all chars in the query buffer |
Date: |
Fri, 6 Jan 2017 09:55:31 +0100 |
... instead of storing the first character only, to avoid things break
in case multiple chars are passed in a single wctablet_chr_write call.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
backends/wctablet.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/backends/wctablet.c b/backends/wctablet.c
index 758c9e8..787da49 100644
--- a/backends/wctablet.c
+++ b/backends/wctablet.c
@@ -234,21 +234,25 @@ static void wctablet_handler(void *opaque)
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + tablet->transmit_time);
}
-static int wctablet_chr_write (struct CharDriverState *s,
- const uint8_t *buf, int len)
+static int wctablet_chr_write(struct CharDriverState *s,
+ const uint8_t *buf, int len)
{
TabletState *tablet = (TabletState *) s->opaque;
- uint8_t c = buf[0];
- uint8_t input;
+ uint8_t i, input;
- if (c == 0x40) {
+ for (i = 0; i < len && tablet->query_index < sizeof(tablet->query) - 1;
i++) {
+ tablet->query[tablet->query_index++] = buf[i];
+ }
+ tablet->query[tablet->query_index] = 0;
+
+ while (tablet->query_index > 0 && tablet->query[0] == '@') {
+ memmove(tablet->query, tablet->query + 1, tablet->query_index);
+ tablet->query_index--;
+ }
+ if (!tablet->query_index) {
return len;
}
- tablet->query[tablet->query_index++] = c;
-
- // DPRINTF("Receive: %.2x\n", c);
-
int comm = wctablet_check_command(tablet->query, tablet->query_index);
if (comm == 1) {
--
1.8.3.1
- [Qemu-devel] [PATCH 00/17] add serial wacom tablet emulation (gsoc 2016), Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 02/17] wctablet: add wctablet_queue_output helper, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 08/17] wctablet: drop debug code from wctablet_handler, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 03/17] wctablet: save all chars in the query buffer,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 05/17] wctablet: strip leading \r + \n from buffer, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 14/17] wctablet: misc cleanups, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 01/17] Add wctablet device, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 07/17] wctablet: operate on line speed 9600, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 09/17] wctablet: add wctablet_shift_input, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 15/17] wctablet: switch to new input interface, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 06/17] wctablet: track line speed, reset on speed changes, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 10/17] wctablet: move init/detect sequence, Gerd Hoffmann, 2017/01/06