qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: avg.tolik@gmail.com, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 05/17] wctablet: strip leading \r + \n from buffer
Date: Fri,  6 Jan 2017 09:55:33 +0100	[thread overview]
Message-ID: <1483692945-9866-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1483692945-9866-1-git-send-email-kraxel@redhat.com>

Should make command detection more robust.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 backends/wctablet.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/backends/wctablet.c b/backends/wctablet.c
index 00498e1..767887e 100644
--- a/backends/wctablet.c
+++ b/backends/wctablet.c
@@ -60,9 +60,9 @@ do {} while (0)
 
 // Avaliable commands
 uint8_t wctablet_commands[WC_COMMANDS_COUNT][7] = {
-    {0x0a, 0x53, 0x50, 0x0a, 0},                // \nSP\n
+    {0x53, 0x50, 0x0a, 0},                      // SP\n
     {0x7e, 0x23, 0},                            // ~#
-    {0x0a, 0x54, 0x45, 0x0a, 0},                // \nTE\n
+    {0x54, 0x45, 0x0a, 0},                      // TE\n
     {0x52, 0x45, 0x0a, 0},                      // RE\n
     {0x41, 0x53, 0x31, 0x0a, 0},                // AS1\n
     {0x49, 0x43, 0x31, 0x0a, 0},                // IC1\n
@@ -70,14 +70,14 @@ uint8_t wctablet_commands[WC_COMMANDS_COUNT][7] = {
     {0x49, 0x54, 0x88, 0x88, 0},                // IT3\r
     {0x53, 0x55, 0x88, 0x88, 0},                // SU3\n
     {0x50, 0x48, 0x31, 0x0a, 0},                // PH1\n
-    {0x0d, 0x53, 0x54, 0x0d, 0},                // \rST\n
-    {0x0d, 0x53, 0x50, 0x0d, 0},                // \rSP\r
+    {0x53, 0x54, 0x0d, 0},                      // ST\n
+    {0x53, 0x50, 0x0d, 0},                      // SP\r
     {0x54, 0x45, 0x0d, 0},                      // TE\r
     {0x53, 0x50, 0x88, 0},                      // SP\n
     {0x23, 0x41, 0x4c, 0x31, 0x0d, 0},          // #AL1\r
     {0x53, 0x54, 0x88, 0},                      // ST\n
-    {0x0d, 0x54, 0x53, 0x88, 0xd, 0},           // \rTS&\r
-    {0x0d, 0x0a, 0x53, 0x50, 0x0d, 0x0a, 0},    // \r\nSP\r\n
+    {0x54, 0x53, 0x88, 0xd, 0},                 // TS&\r
+    {0x53, 0x50, 0x0d, 0x0a, 0},                // SP\r\n
     {0x7e, 0x23, 0x0d, 0}                       // ~#\r
 };
 
@@ -222,7 +222,9 @@ static int wctablet_chr_write(struct CharDriverState *s,
     }
     tablet->query[tablet->query_index] = 0;
 
-    while (tablet->query_index > 0 && tablet->query[0] == '@') {
+    while (tablet->query_index > 0 && (tablet->query[0] == '@'  ||
+                                       tablet->query[0] == '\r' ||
+                                       tablet->query[0] == '\n')) {
         memmove(tablet->query, tablet->query + 1, tablet->query_index);
         tablet->query_index--;
     }
@@ -253,7 +255,7 @@ static int wctablet_chr_write(struct CharDriverState *s,
         }
 
         if (comm == 16) {
-            input = tablet->query[3];
+            input = tablet->query[2];
             uint8_t codes[7] = {
                 0xa3,
                 0x88,
-- 
1.8.3.1

  parent reply	other threads:[~2017-01-06  8:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-06  8:55 [Qemu-devel] [PATCH 00/17] add serial wacom tablet emulation (gsoc 2016) Gerd Hoffmann
2017-01-06  8:55 ` [Qemu-devel] [PATCH 01/17] Add wctablet device Gerd Hoffmann
2017-01-06 13:15   ` Eric Blake
2017-01-06  8:55 ` [Qemu-devel] [PATCH 02/17] wctablet: add wctablet_queue_output helper Gerd Hoffmann
2017-01-06  8:55 ` [Qemu-devel] [PATCH 03/17] wctablet: save all chars in the query buffer Gerd Hoffmann
2017-01-06  8:55 ` [Qemu-devel] [PATCH 04/17] wctablet: drop wctablet_commands_names Gerd Hoffmann
2017-01-06  8:55 ` Gerd Hoffmann [this message]
2017-01-06  8:55 ` [Qemu-devel] [PATCH 06/17] wctablet: track line speed, reset on speed changes Gerd Hoffmann
2017-01-06  8:55 ` [Qemu-devel] [PATCH 07/17] wctablet: operate on line speed 9600 Gerd Hoffmann
2017-01-06  8:55 ` [Qemu-devel] [PATCH 08/17] wctablet: drop debug code from wctablet_handler Gerd Hoffmann
2017-01-06 13:17   ` Eric Blake
2017-01-09  7:50     ` Gerd Hoffmann
2017-01-06  8:55 ` [Qemu-devel] [PATCH 09/17] wctablet: add wctablet_shift_input Gerd Hoffmann
2017-01-06  8:55 ` [Qemu-devel] [PATCH 10/17] wctablet: move init/detect sequence Gerd Hoffmann
2017-01-06  8:55 ` [Qemu-devel] [PATCH 11/17] wctablet: revamp command parser Gerd Hoffmann
2017-01-06  8:55 ` [Qemu-devel] [PATCH 12/17] wctablet: drop timer, hook into chr->accept_input instead Gerd Hoffmann
2017-01-06  8:55 ` [Qemu-devel] [PATCH 13/17] wctablet: drop DPRINTF, add trace events instead Gerd Hoffmann
2017-01-06 13:19   ` Eric Blake
2017-01-06  8:55 ` [Qemu-devel] [PATCH 14/17] wctablet: misc cleanups Gerd Hoffmann
2017-01-06 13:19   ` Eric Blake
2017-01-06  8:55 ` [Qemu-devel] [PATCH 15/17] wctablet: switch to new input interface Gerd Hoffmann
2017-01-06  8:55 ` [Qemu-devel] [PATCH 16/17] wctablet: update file comment Gerd Hoffmann
2017-01-06 13:20   ` Eric Blake
2017-01-06  8:55 ` [Qemu-devel] [PATCH 17/17] wctablet: implement ST and SP commands Gerd Hoffmann
2017-01-06  9:22 ` [Qemu-devel] [PATCH 00/17] add serial wacom tablet emulation (gsoc 2016) no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1483692945-9866-6-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=avg.tolik@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).