]> xenbits.xensource.com Git - qemu-xen-4.3-testing.git/commitdiff
usb-hid.c: fix usb mouse wheel
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 11 Dec 2008 18:04:47 +0000 (18:04 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 11 Dec 2008 18:04:47 +0000 (18:04 +0000)
This patch fixes the usb mouse wheel of usb devices.

[ Previously, tablets would fail to subtract dz from e->dz thus
  producing an infinite stream of reports; also the wheel direction
  inversions had been multipled by merge damage resulting in the wrong
  number of inversions for mice. -iwj ]

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
hw/usb-hid.c

index 1c6bd09e520c1606e2140830b3a49213da213380..e4e58f2ea829e90e6fed05874079ae33f61fd869 100644 (file)
@@ -568,6 +568,7 @@ static int usb_pointer_poll(USBHIDState *hs, uint8_t *buf, int len)
 
     dz = int_clamp(e->dz, -128, 127);
 
+    e->dz -= dz;
     if (s->xyrel) {
         dx = int_clamp(e->xdx, -128, 127);
         dy = int_clamp(e->ydy, -128, 127);
@@ -586,9 +587,6 @@ static int usb_pointer_poll(USBHIDState *hs, uint8_t *buf, int len)
        QUEUE_INCR(s->head);
     }
 
-    /* Appears we have to invert the wheel direction */
-    dz = 0 - dz;
-
     b = 0;
     if (e->buttons_state & MOUSE_EVENT_LBUTTON)
         b |= 0x01;
@@ -611,9 +609,6 @@ static int usb_pointer_poll(USBHIDState *hs, uint8_t *buf, int len)
        break;
 
     case USB_TABLET:
-       /* Appears we have to invert the wheel direction */
-       dz = 0 - dz;
-
        buf[0] = b;
        buf[1] = dx & 0xff;
        buf[2] = dx >> 8;