* [Qemu-devel] [PATCH] Fix usb-wacom coord scales
@ 2009-01-20 1:36 François Revol
2009-01-20 1:53 ` François Revol
0 siblings, 1 reply; 2+ messages in thread
From: François Revol @ 2009-01-20 1:36 UTC (permalink / raw)
To: qemu-devel
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;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-01-20 1:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-20 1:36 [Qemu-devel] [PATCH] Fix usb-wacom coord scales François Revol
2009-01-20 1:53 ` François Revol
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).