From patchwork Wed Jan 25 17:24:35 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: 719766 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v7sQY1GvSz9ry7 for ; Thu, 26 Jan 2017 04:25:57 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=philjordan-eu.20150623.gappssmtp.com header.i=@philjordan-eu.20150623.gappssmtp.com header.b="aGBBGgw1"; dkim-atps=neutral Received: from localhost ([::1]:33317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWRKU-00075k-Oj for incoming@patchwork.ozlabs.org; Wed, 25 Jan 2017 12:25:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWRJZ-0006Nc-Ik for qemu-devel@nongnu.org; Wed, 25 Jan 2017 12:24:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWRJW-0000Dc-Eh for qemu-devel@nongnu.org; Wed, 25 Jan 2017 12:24:57 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:35166) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cWRJW-0000DQ-7K for qemu-devel@nongnu.org; Wed, 25 Jan 2017 12:24:54 -0500 Received: by mail-wm0-x244.google.com with SMTP id d140so44114938wmd.2 for ; Wed, 25 Jan 2017 09:24:52 -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; bh=82rT1rmHjTWhuwgCRKfcd79qqm72nUz64VcBFmNeuU4=; b=aGBBGgw1DgoV/fuYHqI97iVIXDbLwa38DK4e5XdGgFTeuEjrVQibM0SnzWG0ruDIR1 0Sxuj3zChpZYJcxw25lMTdsdpFqhoq5gk4lTBsnB93STA+2gQXffEmAtJ7o9ezh292Dt 8Ho6sFkl9mLx0zhyH+WWZM5Rb2/tE/pNLs3UMKLyp7sl5/EH+TBZAPHnRLJnLoR+O/Ep DDdcQmXQypBpAmyTbcCC3cZaAFiJ9EBcLvmHjbpZcPisutfX1tpfVdi7B+jx4MLWCyKq 96zcF0uWwonYsSLqX/G0nYbTWhHtc4GV60fGfd/azqCFlFWyMzwsa2T8PEBQlrZo6Zkd dA0g== 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; bh=82rT1rmHjTWhuwgCRKfcd79qqm72nUz64VcBFmNeuU4=; b=koKXzvjMjg8FRkXtOpG4CQNNXLcj4l+63T32hQZ+pARNMlLMQ+82+AF3QTP0OZeSRe 2v/GQrcEbB3XYa3EcmcxDUA8gArWNyJeOj4NiteTnyewhrE4D+LiA9st1tT3uZ+KIb+C IL7jgFL26NpaYIzZdqChz7xLr70o/SIFyFmpYHnP6d4DUCPpE4AIV3hTG2Ky8XoNr0vM tQq/hSbezPIDwmgUSvfu1pSTzkJK9ZjPcByt/Tkm6o4xVL/gQJnNHqbsl1/EwOu2Kg3T nvQMD9Zq85JgyAy/SN95ozR323cuMsMr6ErhnsiIMMYfKuJjA6beeP9cGtFWaBTtO+89 sOPA== X-Gm-Message-State: AIkVDXLqZ4BcZ7b37kdGvLeHnNPH0/uxhV/K1S7aYfPhyRis0zrWZvWY5slUJHoMJtMh0Q== X-Received: by 10.28.218.4 with SMTP id r4mr22701503wmg.105.1485365091514; Wed, 25 Jan 2017 09:24:51 -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 l140sm32521354wmg.12.2017.01.25.09.24.50 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Jan 2017 09:24:50 -0800 (PST) From: Phil Dennis-Jordan To: qemu-devel@nongnu.org Date: Wed, 25 Jan 2017 18:24:35 +0100 Message-Id: <1485365075-32702-1-git-send-email-phil@philjordan.eu> X-Mailer: git-send-email 2.3.2 (Apple Git-55) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH v3] hw/usb/dev-hid: Improve guest compatibility of usb-tablet 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: "Gabriel L. Somlo" , Gerd Hoffmann , Phil Dennis-Jordan Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 1. Set bInterfaceProtocol to 0x00 for usb-tablet. This should be non-zero for boot protocol devices only, which the usb-tablet is not. 2. Set the usb-tablet's usage to "mouse" in the report descriptor. The boot protocol of 0x02 specifically confused OS X/macOS' HID driver stack, causing it to generate additional bogus HID events with relative motion in addition to the tablet's absolute coordinate events. Absolute pointing devices with HID Report Descriptor usage of 0x01 (pointing) are treated by the macOS HID driver as analog sticks, and absolute coordinates are not directly translated to absolute mouse cursor positions. Changing it to 0x02 (mouse) fixes the problem, and does not have any adverse effect in other operating systems and windowing systems. (VMWare does the same thing.) Signed-off-by: Phil Dennis-Jordan --- Changelog ========= v2 -> v3: * v2 Thread was "[PATCH v2 0/2] hw/usb/dev-hid: Make usb-tablet work with OS X/macOS guests" * Changing the report descriptor to 0x02 (mouse) does not seem to have an adverse effect on any guests, so just change it for everyone instead of adding an option. * The 2 patches are now tiny, so combine them back into one. v1 -> v2: * v1 Thread was "[PATCH] hw/usb/dev-hid: add a Mac guest compatibility option to usb-tablet" * Always apply the boot protocol (bInterfaceProtocol) change to usb-tablet, not just when the Mac compatibility option is active. The original value of 0x02 was determined to be incorrect according to the spec anyway. * As the boot protocol change is permanent, separate interface and device descriptor constants for the Mac/non-Mac variants of the tablet are no longer required, and have been removed. hw/usb/dev-hid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index 24d05f7..dda0bf0 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -144,7 +144,7 @@ static const USBDescIface desc_iface_tablet = { .bInterfaceNumber = 0, .bNumEndpoints = 1, .bInterfaceClass = USB_CLASS_HID, - .bInterfaceProtocol = 0x02, + .bInterfaceProtocol = 0x00, .ndesc = 1, .descs = (USBDescOther[]) { { @@ -174,7 +174,7 @@ static const USBDescIface desc_iface_tablet2 = { .bInterfaceNumber = 0, .bNumEndpoints = 1, .bInterfaceClass = USB_CLASS_HID, - .bInterfaceProtocol = 0x02, + .bInterfaceProtocol = 0x00, .ndesc = 1, .descs = (USBDescOther[]) { { @@ -487,7 +487,7 @@ static const uint8_t qemu_mouse_hid_report_descriptor[] = { static const uint8_t qemu_tablet_hid_report_descriptor[] = { 0x05, 0x01, /* Usage Page (Generic Desktop) */ - 0x09, 0x01, /* Usage (Pointer) */ + 0x09, 0x02, /* Usage (Mouse) */ 0xa1, 0x01, /* Collection (Application) */ 0x09, 0x01, /* Usage (Pointer) */ 0xa1, 0x00, /* Collection (Physical) */