From patchwork Wed Aug 10 15:17:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 109384 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BB674B6F71 for ; Thu, 11 Aug 2011 01:18:17 +1000 (EST) Received: from localhost ([::1]:35152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrAXu-0002EE-4c for incoming@patchwork.ozlabs.org; Wed, 10 Aug 2011 11:18:14 -0400 Received: from eggs.gnu.org ([140.186.70.92]:59660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrAXo-0002CK-1o for qemu-devel@nongnu.org; Wed, 10 Aug 2011 11:18:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrAXm-00072q-MR for qemu-devel@nongnu.org; Wed, 10 Aug 2011 11:18:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51447) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrAXm-00072m-8c for qemu-devel@nongnu.org; Wed, 10 Aug 2011 11:18:06 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7AFI54m002207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 10 Aug 2011 11:18:05 -0400 Received: from rincewind.home.kraxel.org (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7AFHu6O023426; Wed, 10 Aug 2011 11:17:59 -0400 Message-ID: <4E42A122.1020004@redhat.com> Date: Wed, 10 Aug 2011 17:17:54 +0200 From: Gerd Hoffmann User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Red Hat/3.1.11-2.el6_1 Thunderbird/3.1.11 MIME-Version: 1.0 To: TeLeMan References: <1312470626-25872-1-git-send-email-kraxel@redhat.com> <1312470626-25872-14-git-send-email-kraxel@redhat.com> In-Reply-To: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH 13/16] usb-hid: add hid_has_events() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi, >> - >> - /* Force poll routine to be run and grab input the first time. */ >> - us->changed = 1; > USB tablet does not work on the winxp guest. I think this code can't be removed. > Attached patch should fix that. cheers, Gerd commit 21635e121ae0f0ab7874152a7c2f96e9d8cd642f Author: Gerd Hoffmann Date: Tue Aug 9 12:35:57 2011 +0200 usb/hid: add hid_pointer_activate, use it 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 diff --git a/hw/hid.c b/hw/hid.c index 7b5ef5f..77339f7 100644 --- 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. */ diff --git a/hw/hid.h b/hw/hid.h index 4a8fa5b..9ce03b1 100644 --- 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); diff --git a/hw/usb-hid.c b/hw/usb-hid.c index e5d57de..6f12751 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -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: