qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Fix usb-wacom coord scales


From: François Revol
Subject: [Qemu-devel] [PATCH] Fix usb-wacom coord scales
Date: Tue, 20 Jan 2009 02:36:09 +0100 CET

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 <address@hidden>
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 via email to

[Prev in Thread] Current Thread [Next in Thread]