From nobody Mon Apr 29 06:10:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502232555788586.6782867869674; Tue, 8 Aug 2017 15:49:15 -0700 (PDT) Received: from localhost ([::1]:44788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfDJI-0003kE-Bu for importer@patchew.org; Tue, 08 Aug 2017 18:49:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfDIV-0003JB-Rp for qemu-devel@nongnu.org; Tue, 08 Aug 2017 18:48:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfDIQ-0001no-Ts for qemu-devel@nongnu.org; Tue, 08 Aug 2017 18:48:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52028) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfDIQ-0001mA-NN for qemu-devel@nongnu.org; Tue, 08 Aug 2017 18:48:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F2E620272 for ; Tue, 8 Aug 2017 22:48:15 +0000 (UTC) Received: from localhost (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEE2C503CA; Tue, 8 Aug 2017 22:48:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3F2E620272 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 9 Aug 2017 00:47:50 +0200 Message-Id: <20170808224750.23904-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 08 Aug 2017 22:48:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] virtio-input: send rel-wheel events for wheel buttons 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" qemu uses wheel-up/down button events for mouse wheel input, however linux applications typically want REL_WHEEL events. This fixes wheel with linux guests. Tested with X11/wayland, and windows virtio-input driver. Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/input/virtio-input-hid.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index 46c038110c..f46857f0e4 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -196,6 +196,7 @@ static void virtio_input_handle_event(DeviceState *dev,= QemuConsole *src, InputKeyEvent *key; InputMoveEvent *move; InputBtnEvent *btn; + unsigned int map; =20 switch (evt->type) { case INPUT_EVENT_KIND_KEY: @@ -215,9 +216,15 @@ static void virtio_input_handle_event(DeviceState *dev= , QemuConsole *src, break; case INPUT_EVENT_KIND_BTN: btn =3D evt->u.btn.data; - if (keymap_button[btn->button]) { + map =3D keymap_button[btn->button]; + if (map =3D=3D BTN_GEAR_DOWN || map =3D=3D BTN_GEAR_UP) { + event.type =3D cpu_to_le16(EV_REL); + event.code =3D cpu_to_le16(REL_WHEEL); + event.value =3D cpu_to_le32(map =3D=3D BTN_GEAR_DOWN ? -1 : 1); + virtio_input_send(vinput, &event); + } else if (map) { event.type =3D cpu_to_le16(EV_KEY); - event.code =3D cpu_to_le16(keymap_button[btn->button]); + event.code =3D cpu_to_le16(map); event.value =3D cpu_to_le32(btn->down ? 1 : 0); virtio_input_send(vinput, &event); } else { @@ -424,9 +431,9 @@ static struct virtio_input_config virtio_mouse_config[]= =3D { },{ .select =3D VIRTIO_INPUT_CFG_EV_BITS, .subsel =3D EV_REL, - .size =3D 1, + .size =3D 2, .u.bitmap =3D { - (1 << REL_X) | (1 << REL_Y), + (1 << REL_X) | (1 << REL_Y), (1 << (REL_WHEEL - 8)) }, }, { /* end of list */ }, --=20 2.14.0.1.geff633fa0