From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LP5Ww-0002Eb-B3 for qemu-devel@nongnu.org; Mon, 19 Jan 2009 20:35:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LP5Wt-0002Dz-2B for qemu-devel@nongnu.org; Mon, 19 Jan 2009 20:35:49 -0500 Received: from [199.232.76.173] (port=48907 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LP5Ws-0002Dw-TF for qemu-devel@nongnu.org; Mon, 19 Jan 2009 20:35:46 -0500 Received: from smtp1-g21.free.fr ([212.27.42.1]:56712) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LP5Ws-0006EK-0p for qemu-devel@nongnu.org; Mon, 19 Jan 2009 20:35:46 -0500 Received: from smtp1-g21.free.fr (localhost [127.0.0.1]) by smtp1-g21.free.fr (Postfix) with ESMTP id B985B940099 for ; Tue, 20 Jan 2009 02:35:42 +0100 (CET) Received: from laptop (vaf26-2-82-244-111-82.fbx.proxad.net [82.244.111.82]) by smtp1-g21.free.fr (Postfix) with ESMTP id C6E7994004D for ; Tue, 20 Jan 2009 02:35:39 +0100 (CET) From: "=?utf-8?q?Fran=C3=A7ois?= Revol" Date: Tue, 20 Jan 2009 02:36:09 +0100 CET Message-Id: <31769382771-BeMail@laptop> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH] Fix usb-wacom coord scales Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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=5FMAX, 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=5Fwac.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=5FSTYLUS, and right button in the Haiku driver. I don't know how it affects TSLib though, can anyone please test =3F 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 =3F 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=C3=A7ois. Signed-off-by: Fran=C3=A7ois Revol Index: hw/usb-wacom.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- hw/usb-wacom.c (r=C3=A9vision 6369) +++ hw/usb-wacom.c (copie de travail) @@ -132,8 +132,9 @@ { USBWacomState *s =3D opaque; - s->x =3D x; - s->y =3D y; + /* scale to Penpartner resolution */ + s->x =3D (x * 5040 / 0x7FFF); + s->y =3D (y * 3780 / 0x7FFF); s->dz +=3D dz; s->buttons=5Fstate =3D buttons=5Fstate; } @@ -199,26 +200,22 @@ if (s->buttons=5Fstate & MOUSE=5FEVENT=5FLBUTTON) b |=3D 0x01; if (s->buttons=5Fstate & MOUSE=5FEVENT=5FRBUTTON) - b |=3D 0x02; + b |=3D 0x40; if (s->buttons=5Fstate & MOUSE=5FEVENT=5FMBUTTON) - b |=3D 0x04; + b |=3D 0x20; /* eraser */ if (len < 7) return 0; buf[0] =3D s->mode; - buf[5] =3D 0x00; - if (b) { - buf[1] =3D s->x & 0xff; - buf[2] =3D s->x >> 8; - buf[3] =3D s->y & 0xff; - buf[4] =3D s->y >> 8; + buf[5] =3D 0x00 | (b & 0xf0); + buf[1] =3D s->x & 0xff; + buf[2] =3D s->x >> 8; + buf[3] =3D s->y & 0xff; + buf[4] =3D s->y >> 8; + if (b & 0x3f) { buf[6] =3D 0; } else { - buf[1] =3D 0; - buf[2] =3D 0; - buf[3] =3D 0; - buf[4] =3D 0; buf[6] =3D (unsigned char) -127; }