qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "François Revol" <revol@free.fr>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Fix usb-wacom coord scales
Date: Tue, 20 Jan 2009 02:36:09 +0100 CET	[thread overview]
Message-ID: <31769382771-BeMail@laptop> (raw)

Hi,
I already raised the issue some time ago:
http://article.gmane.org/gmane.comp.emulators.qemu/28295
The wacom tablet code sends coords scaled to INT16_MAX, which seemed
wrong as per the Haiku driver.
At the time I wasn't sure if the maximum used in the driver was model
specific or just some arbitrary value detected on a single item.
It seems the Linux driver also agree on the maximum figures used in the
Haiku driver:
http://lxr.linux.no/linux+v2.6.28.1/drivers/input/tablet/wacom_wac.c#L722

This patch makes sure the coordinates get scaled correctly.

It also changes button mapping a bit, from the copy of the mouse code
which ends up sending unused bits. It maps the middle button to the
eraser, and the rigth button to 0x40 which in the Linux driver ends up
to BTN_STYLUS, and right button in the Haiku driver.
I don't know how it affects TSLib though, can anyone please test ?

The coords are also sent when no button is pressed, it shouldn't break
drivers that work already as they probably cache the coords, and allows
sensible mouse moves when no button is pressed instead of jumping to
the next click. Also, most tablets are able to report position of the
stylus even when it's not yet touching the surface, though the
Penpartner model doesn't seem to be such a model.

This at least makes Haiku usable as guest with vnc and should help too
with other OSes, even though I noticed we had a vmmouse driver
somewhere we could use to use vmport instead of wacom.
Again, can anyone validate with tslib ?
I tried to boot an unbuntu live CD I had but it ended up not detecting
the wacom device, swapping and eventually rebooting my box after 20
minutes, so if anyone can test Linux too...

François.

Signed-off-by: François Revol <revol@free.fr>
Index: hw/usb-wacom.c
===================================================================
--- hw/usb-wacom.c	(révision 6369)
+++ hw/usb-wacom.c	(copie de travail)
@@ -132,8 +132,9 @@
 {
     USBWacomState *s = opaque;

-    s->x = x;
-    s->y = y;
+    /* scale to Penpartner resolution */
+    s->x = (x * 5040 / 0x7FFF);
+    s->y = (y * 3780 / 0x7FFF);
     s->dz += dz;
     s->buttons_state = buttons_state;
 }
@@ -199,26 +200,22 @@
     if (s->buttons_state & MOUSE_EVENT_LBUTTON)
         b |= 0x01;
     if (s->buttons_state & MOUSE_EVENT_RBUTTON)
-        b |= 0x02;
+        b |= 0x40;
     if (s->buttons_state & MOUSE_EVENT_MBUTTON)
-        b |= 0x04;
+        b |= 0x20; /* eraser */

     if (len < 7)
         return 0;

     buf[0] = s->mode;
-    buf[5] = 0x00;
-    if (b) {
-        buf[1] = s->x & 0xff;
-        buf[2] = s->x >> 8;
-        buf[3] = s->y & 0xff;
-        buf[4] = s->y >> 8;
+    buf[5] = 0x00 | (b & 0xf0);
+    buf[1] = s->x & 0xff;
+    buf[2] = s->x >> 8;
+    buf[3] = s->y & 0xff;
+    buf[4] = s->y >> 8;
+    if (b & 0x3f) {
         buf[6] = 0;
     } else {
-        buf[1] = 0;
-        buf[2] = 0;
-        buf[3] = 0;
-        buf[4] = 0;
         buf[6] = (unsigned char) -127;
     }


             reply	other threads:[~2009-01-20  1:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-20  1:36 François Revol [this message]
2009-01-20  1:53 ` [Qemu-devel] [PATCH] Fix usb-wacom coord scales François Revol

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=31769382771-BeMail@laptop \
    --to=revol@free.fr \
    --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).