]> Git Repo - qemu.git/commitdiff
usb/hid: add hid_pointer_activate, use it
authorGerd Hoffmann <[email protected]>
Tue, 9 Aug 2011 10:35:57 +0000 (12:35 +0200)
committerGerd Hoffmann <[email protected]>
Wed, 10 Aug 2011 12:14:00 +0000 (14:14 +0200)
HID reorganziation broke the usb tablet in windows xp.  The reason is
that xp activates idle before it starts polling, which creates a
chicken-and-egg issue:  We don't call hid_pointer_poll because there are
no pending events.  We don't get any events because the activation code
in hid_pointer_poll is never executed and thus all pointer events are
routed to the PS/2 mouse by qemu.

Fix this by creating a hid_pointer_activate function and call it from
usb-hid when the guest sets the idle state.

Signed-off-by: Gerd Hoffmann <[email protected]>
hw/hid.c
hw/hid.h
hw/usb-hid.c

index 7b5ef5fc92aa4bd3c14cc6061f6e368afb093e1d..77339f7a1204d722c918ddb25f60c8c0dccacadb 100644 (file)
--- a/hw/hid.c
+++ b/hw/hid.c
@@ -218,16 +218,21 @@ static inline int int_clamp(int val, int vmin, int vmax)
     }
 }
 
+void hid_pointer_activate(HIDState *hs)
+{
+    if (!hs->ptr.mouse_grabbed) {
+        qemu_activate_mouse_event_handler(hs->ptr.eh_entry);
+        hs->ptr.mouse_grabbed = 1;
+    }
+}
+
 int hid_pointer_poll(HIDState *hs, uint8_t *buf, int len)
 {
     int dx, dy, dz, b, l;
     int index;
     HIDPointerEvent *e;
 
-    if (!hs->ptr.mouse_grabbed) {
-        qemu_activate_mouse_event_handler(hs->ptr.eh_entry);
-        hs->ptr.mouse_grabbed = 1;
-    }
+    hid_pointer_activate(hs);
 
     /* When the buffer is empty, return the last event.  Relative
        movements will all be zero.  */
index 4a8fa5b63f536af9793b8fbca89a6223e4de79b6..9ce03b118c9db127a8397fc728922f95f8c80b3f 100644 (file)
--- a/hw/hid.h
+++ b/hw/hid.h
@@ -51,6 +51,7 @@ void hid_free(HIDState *hs);
 
 bool hid_has_events(HIDState *hs);
 void hid_set_next_idle(HIDState *hs, int64_t curtime);
+void hid_pointer_activate(HIDState *hs);
 int hid_pointer_poll(HIDState *hs, uint8_t *buf, int len);
 int hid_keyboard_poll(HIDState *hs, uint8_t *buf, int len);
 int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len);
index e5d57de8889f6c5a44e743d6769eea6cb0d992b1..6f12751cdcbb97a5ce5e3a9df6b6f6830513482b 100644 (file)
@@ -454,6 +454,9 @@ static int usb_hid_handle_control(USBDevice *dev, USBPacket *p,
     case SET_IDLE:
         hs->idle = (uint8_t) (value >> 8);
         hid_set_next_idle(hs, qemu_get_clock_ns(vm_clock));
+        if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) {
+            hid_pointer_activate(hs);
+        }
         ret = 0;
         break;
     default:
This page took 0.031009 seconds and 4 git commands to generate.