From patchwork Fri Jan 20 12:30:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Dennis-Jordan X-Patchwork-Id: 9528213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 983E160459 for ; Fri, 20 Jan 2017 12:31:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86E4626E4E for ; Fri, 20 Jan 2017 12:31:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78B4E28550; Fri, 20 Jan 2017 12:31:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E43A526E4E for ; Fri, 20 Jan 2017 12:31:34 +0000 (UTC) Received: from localhost ([::1]:54158 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUYLt-0007cH-Uu for patchwork-qemu-devel@patchwork.kernel.org; Fri, 20 Jan 2017 07:31:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUYLO-0007YP-R1 for qemu-devel@nongnu.org; Fri, 20 Jan 2017 07:31:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cUYLL-0007gA-22 for qemu-devel@nongnu.org; Fri, 20 Jan 2017 07:31:02 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:32894) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cUYLK-0007fi-SM for qemu-devel@nongnu.org; Fri, 20 Jan 2017 07:30:58 -0500 Received: by mail-wm0-x241.google.com with SMTP id r144so6409191wme.0 for ; Fri, 20 Jan 2017 04:30:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philjordan-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/PTI2Jdvw84tYOLjvcUUI68NsaxvTwB8D0lgUX6aWjI=; b=dJmK9Z2mb+/l8pAhPsRnh9j2W1l+DiCJcy99iBqCjFoAXLIWH2y0N0KelRQcd3zIuB W+8DFnAce67ljTHM39oX9he68wYqxNBxQBFpAomc0vmOKrzdMDtQa8yXTDEjJi80y7gN 5iQJopqYNT7TVgWy0i5qQ7WzQEMJTxpHP2BsFJLZ9jSS5D0MXIJaThousy1Nn78ikyjr k2axztBNvMvMr1HnegynlZ1lecr4wAmEFYxk/hIWwj+/Ylq0TdvJ3e/dNh8F6X4nMq3g Cu8rgxbnwmvWPiwO/HqhnOyyfTHyrtY6/xIWt7LRcW8Nly60+shDs7IHYt5l71JYcV5Y Bm6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/PTI2Jdvw84tYOLjvcUUI68NsaxvTwB8D0lgUX6aWjI=; b=Tx7Vvve55amF9sJmOepEDcFku65VgN1Mi8k8j2uQU0KNkHvlCeRl5GVqIEkNv30n34 CLqaELv5ryWiCsrKo4gn+VlokLNQ6hZpxZYQrQUryEeBXnBEp4Ql9JQZUwFMqaDwQukM dxiTN7NVtmlUwYi+AMPjKMgoiPqOc4f11Ny0OufzYipACV8o6zSRl9AuX8KtM89c9EX/ /lou5oPZ5M5DZysY5aCtRrjpsy7vFM8c7gIgAEqgZClak1LIhrxsLTCgctPHHMaO1/cW UR9wJeY/HAC20BZK90dwuF9FkZPzcOxrpqZ4Q3BiHdOEUbkOjz/uq2GHxbpfjtUmpqfy KfKQ== X-Gm-Message-State: AIkVDXLdtnQa9S5zzMiITTDIuafBJAliQzsObL3wxD7jVgg/kgJCAEuaWvPWqkvVoYe6Fw== X-Received: by 10.223.128.226 with SMTP id 89mr13165649wrl.130.1484915457758; Fri, 20 Jan 2017 04:30:57 -0800 (PST) Received: from Phils-MacBook-Pro-57025.local.eu (37-186-10-86.ip.as39912.net. [37.186.10.86]) by smtp.gmail.com with ESMTPSA id 186sm5749018wmw.24.2017.01.20.04.30.56 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 20 Jan 2017 04:30:57 -0800 (PST) From: Phil Dennis-Jordan To: qemu-devel@nongnu.org Date: Fri, 20 Jan 2017 13:30:17 +0100 Message-Id: <1484915417-10499-3-git-send-email-phil@philjordan.eu> X-Mailer: git-send-email 2.3.2 (Apple Git-55) In-Reply-To: <1484915417-10499-1-git-send-email-phil@philjordan.eu> References: <1484915417-10499-1-git-send-email-phil@philjordan.eu> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH v2 2/2] hw/usb/dev-hid: add a usb-tablet Mac guest compatibility option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Phil Dennis-Jordan , Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Darwin/OS X/macOS's HID driver stack previously did not correctly drive Qemu's simulated USB Tablet. This adds a boolean option "mac_compat" to the device which subtly changes the device's report descriptor so it behaves in a way that Mac guests can handle. Absolute pointing devices with HID Report Descriptor usage page of 0x01 (pointing) are handled by the macOS HID driver as analog sticks, and absolute coordinates are not directly translated to absolute mouse cursor positions. The workaround is to report a usage page of 0x02 (mouse) instead. In combination with the previous commit's boot protocol fix, this allows the usb-tablet to correctly control the mouse cursor in OS X/macOS guest systems. Signed-off-by: Phil Dennis-Jordan --- hw/usb/dev-hid.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index a23e5d4..c4a0d22 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -51,6 +51,7 @@ typedef struct USBHIDState { uint32_t usb_version; char *display; uint32_t head; + bool mac_compat; } USBHIDState; #define TYPE_USB_HID "usb-hid" @@ -599,6 +600,9 @@ static void usb_hid_handle_control(USBDevice *dev, USBPacket *p, memcpy(data, qemu_tablet_hid_report_descriptor, sizeof(qemu_tablet_hid_report_descriptor)); p->actual_length = sizeof(qemu_tablet_hid_report_descriptor); + if (us->mac_compat) { + data[3] = 0x02; /* Set usage to mouse, not pointing (1) */ + } } else if (hs->kind == HID_KEYBOARD) { memcpy(data, qemu_keyboard_hid_report_descriptor, sizeof(qemu_keyboard_hid_report_descriptor)); @@ -801,6 +805,7 @@ static Property usb_tablet_properties[] = { DEFINE_PROP_UINT32("usb_version", USBHIDState, usb_version, 2), DEFINE_PROP_STRING("display", USBHIDState, display), DEFINE_PROP_UINT32("head", USBHIDState, head, 0), + DEFINE_PROP_BOOL("mac_compat", USBHIDState, mac_compat, false), DEFINE_PROP_END_OF_LIST(), };