From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPQJf-0006QW-Px for qemu-devel@nongnu.org; Fri, 06 Jan 2017 03:56:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPQJd-0008LY-4F for qemu-devel@nongnu.org; Fri, 06 Jan 2017 03:56:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60708) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cPQJc-0008L0-Vu for qemu-devel@nongnu.org; Fri, 06 Jan 2017 03:56:01 -0500 From: Gerd Hoffmann Date: Fri, 6 Jan 2017 09:55:31 +0100 Message-Id: <1483692945-9866-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1483692945-9866-1-git-send-email-kraxel@redhat.com> References: <1483692945-9866-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 03/17] wctablet: save all chars in the query buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: avg.tolik@gmail.com, Gerd Hoffmann ... 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 --- 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