From nobody Fri Apr 19 23:31:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678968445; cv=none; d=zohomail.com; s=zohoarc; b=nzRwKG25s+dNMqVHf9HcNsZSn9wCAYtkE0RzjOa28tvVUpOQa5nhmBSOhGf3YK2U3bYhCyFv7g5TJuZSWR3QJjTHKCyxjgoM5oGZRGi9ho/cwm084diOFdGelkVEIvs4F4IpA2XisnuNZ3jIL0wAEEHQNhEEYUEA/s3JDZLEQwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678968445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YmJGY41XqyCGRPeTDO3+MBEiUMQeBjAmMfYNNBfiDjs=; b=JmDaXuAhPxHj2ddWhkzpvmlGueBV9ai+LwqqgSUHrBAZBZ71MobQwZkZ4BOTlv6sJg/GuwIq/netCqhMpbIboh9627sMUwbZmyaHjZ9QYPj8C/62xaWmbzXkVLaCuNPmqZ9xYEi8TqIy20CU6nT/XcvFl/47Owq4bioE+5oOgiY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678968445954554.2449542211538; Thu, 16 Mar 2023 05:07:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcmMA-0002hr-Ca; Thu, 16 Mar 2023 08:05:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmM7-0002hE-AD for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmM5-0002lS-HH for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:15 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-602-YcNiZK7-O12jEvVdIulLBg-1; Thu, 16 Mar 2023 08:05:10 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D0C91C06EEB; Thu, 16 Mar 2023 12:05:10 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.33.36.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8C4B1410F1B; Thu, 16 Mar 2023 12:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678968312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YmJGY41XqyCGRPeTDO3+MBEiUMQeBjAmMfYNNBfiDjs=; b=epY4txrcrF4pde+aCDVzPncHKbnrJE+9uWvAC0MzyWr4pTPjbEjNSWIlxJ7UaBlnuAfrTg kShup/E5wO3wA87w9EMmIQiDqhxmyNjld47oT/Hvf4sSP5MGk+Y91i1yEfzY+wGQN40b0m GRUQ4ETi+Kv48ws3hXILNtEf5DSZv6o= X-MC-Unique: YcNiZK7-O12jEvVdIulLBg-1 From: Sergio Lopez To: qemu-devel@nongnu.org Cc: Eric Blake , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Pavel Dovgalyuk , "Michael S. Tsirkin" , Markus Armbruster , Gerd Hoffmann , Paolo Bonzini , Sergio Lopez Subject: [PATCH v2 1/6] virtio-input: generalize virtio_input_key_config() Date: Thu, 16 Mar 2023 13:06:19 +0100 Message-Id: <20230316120624.46410-2-slp@redhat.com> In-Reply-To: <20230316120624.46410-1-slp@redhat.com> References: <20230316120624.46410-1-slp@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=slp@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678968447605100002 As there are other bitmap-based config properties that need to be dealt in a similar fashion as VIRTIO_INPUT_CFG_EV_BITS, generalize the function to receive select and subsel as arguments, and rename it to virtio_input_extend_config() Signed-off-by: Sergio Lopez Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/input/virtio-input-hid.c | 38 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index a7a244a95d..d28dab69ba 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -44,30 +44,31 @@ static const unsigned short axismap_abs[INPUT_AXIS__MAX= ] =3D { =20 /* ----------------------------------------------------------------- */ =20 -static void virtio_input_key_config(VirtIOInput *vinput, - const unsigned short *keymap, - size_t mapsize) +static void virtio_input_extend_config(VirtIOInput *vinput, + const unsigned short *map, + size_t mapsize, + uint8_t select, uint8_t subsel) { - virtio_input_config keys; + virtio_input_config ext; int i, bit, byte, bmax =3D 0; =20 - memset(&keys, 0, sizeof(keys)); + memset(&ext, 0, sizeof(ext)); for (i =3D 0; i < mapsize; i++) { - bit =3D keymap[i]; + bit =3D map[i]; if (!bit) { continue; } byte =3D bit / 8; bit =3D bit % 8; - keys.u.bitmap[byte] |=3D (1 << bit); + ext.u.bitmap[byte] |=3D (1 << bit); if (bmax < byte+1) { bmax =3D byte+1; } } - keys.select =3D VIRTIO_INPUT_CFG_EV_BITS; - keys.subsel =3D EV_KEY; - keys.size =3D bmax; - virtio_input_add_config(vinput, &keys); + ext.select =3D select; + ext.subsel =3D subsel; + ext.size =3D bmax; + virtio_input_add_config(vinput, &ext); } =20 static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src, @@ -281,8 +282,9 @@ static void virtio_keyboard_init(Object *obj) =20 vhid->handler =3D &virtio_keyboard_handler; virtio_input_init_config(vinput, virtio_keyboard_config); - virtio_input_key_config(vinput, qemu_input_map_qcode_to_linux, - qemu_input_map_qcode_to_linux_len); + virtio_input_extend_config(vinput, qemu_input_map_qcode_to_linux, + qemu_input_map_qcode_to_linux_len, + VIRTIO_INPUT_CFG_EV_BITS, EV_KEY); } =20 static const TypeInfo virtio_keyboard_info =3D { @@ -373,8 +375,9 @@ static void virtio_mouse_init(Object *obj) virtio_input_init_config(vinput, vhid->wheel_axis ? virtio_mouse_config_v2 : virtio_mouse_config_v1); - virtio_input_key_config(vinput, keymap_button, - ARRAY_SIZE(keymap_button)); + virtio_input_extend_config(vinput, keymap_button, + ARRAY_SIZE(keymap_button), + VIRTIO_INPUT_CFG_EV_BITS, EV_KEY); } =20 static const TypeInfo virtio_mouse_info =3D { @@ -497,8 +500,9 @@ static void virtio_tablet_init(Object *obj) virtio_input_init_config(vinput, vhid->wheel_axis ? virtio_tablet_config_v2 : virtio_tablet_config_v1); - virtio_input_key_config(vinput, keymap_button, - ARRAY_SIZE(keymap_button)); + virtio_input_extend_config(vinput, keymap_button, + ARRAY_SIZE(keymap_button), + VIRTIO_INPUT_CFG_EV_BITS, EV_KEY); } =20 static const TypeInfo virtio_tablet_info =3D { --=20 2.38.1 From nobody Fri Apr 19 23:31:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678968388; cv=none; d=zohomail.com; s=zohoarc; b=Z67Nojd4ymSYKABrtxut0HnUSZSZP4j81XRmRiAtil/qlQdRm28uIuwZwIkPuT/iAIpmq4eLc8q3HKsrEzZf11FIZ3bD7DHtJGzi9Npvl44gRWTyXGjuwFwDTqVaa0QQF9UGjrYiOMaxDW/tNvJssEiNdHsbxFQ0fXDNySZORdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678968388; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aqsQaWrWYEA1dOgXV6EY799w70U5nBg8XBVK8rkTfwo=; b=by8hYZDMLhW7zZQeseJRaFiQCoEtQLftxehvmxhnRbuG8USL4UBkQYv3wvYaFBUvz3x+Wopmi3vS4TY67w499nE6PHQf2sTO90ciCr2DR3AsEahJE4STjCT8E5tDRLWoTcj41/N/cWxVT17T0GBoWDoqq6kq1AqX7HF5MPbrklA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678968388323445.8694153466355; Thu, 16 Mar 2023 05:06:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcmMC-0002id-TX; Thu, 16 Mar 2023 08:05:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmM8-0002hQ-PC for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmM6-0002li-N3 for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:16 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-513-VNyZfQMzO4y_ebxm2lbhhQ-1; Thu, 16 Mar 2023 08:05:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2019210146F7; Thu, 16 Mar 2023 12:05:12 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.33.36.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99F22140EBF4; Thu, 16 Mar 2023 12:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678968314; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aqsQaWrWYEA1dOgXV6EY799w70U5nBg8XBVK8rkTfwo=; b=bYv9bnBmTB69UeyZsZMC0VdLNBX7XAsrG3DL+/iMQX8BFGke4f5sqsFOMOTDhn32Z60BaF vGSwEly2LV3E9ZxaSM3Bb8sr/DpNLr1aVf+WezZCjsYcUW+a7Ab3asHe55PKGhaAt3Xtez wIUoDHU3viz5A34m0u9uGlAa1Vd9HKI= X-MC-Unique: VNyZfQMzO4y_ebxm2lbhhQ-1 From: Sergio Lopez To: qemu-devel@nongnu.org Cc: Eric Blake , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Pavel Dovgalyuk , "Michael S. Tsirkin" , Markus Armbruster , Gerd Hoffmann , Paolo Bonzini , Sergio Lopez Subject: [PATCH v2 2/6] ui: add the infrastructure to support MT events Date: Thu, 16 Mar 2023 13:06:20 +0100 Message-Id: <20230316120624.46410-3-slp@redhat.com> In-Reply-To: <20230316120624.46410-1-slp@redhat.com> References: <20230316120624.46410-1-slp@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=slp@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678968389268100001 Content-Type: text/plain; charset="utf-8" Add the required infrastructure to support generating multitouch events. Signed-off-by: Sergio Lopez Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/ui/input.h | 3 +++ qapi/ui.json | 45 ++++++++++++++++++++++++++++++++++++++++--- replay/replay-input.c | 18 +++++++++++++++++ ui/input.c | 6 ++++++ ui/trace-events | 1 + 5 files changed, 70 insertions(+), 3 deletions(-) diff --git a/include/ui/input.h b/include/ui/input.h index c86219a1c1..2a3dffd417 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -8,9 +8,12 @@ #define INPUT_EVENT_MASK_BTN (1< 0x7ffff +# +# Since: 8.1 +## +{ 'struct' : 'InputMultitouchEvent', + 'data' : { 'type' : 'InputMultitouchType', + 'slot' : 'int', + 'tracking-id': 'int', + 'axis' : 'InputAxis', + 'value' : 'int' } } + ## # @InputEventKind: # # Since: 2.0 ## { 'enum': 'InputEventKind', - 'data': [ 'key', 'btn', 'rel', 'abs' ] } + 'data': [ 'key', 'btn', 'rel', 'abs', 'mtt' ] } =20 ## # @InputKeyEventWrapper: @@ -1101,6 +1130,14 @@ { 'struct': 'InputMoveEventWrapper', 'data': { 'data': 'InputMoveEvent' } } =20 +## +# @InputMultitouchEventWrapper: +# +# Since: 8.1 +## +{ 'struct': 'InputMultitouchEventWrapper', + 'data': { 'data': 'InputMultitouchEvent' } } + ## # @InputEvent: # @@ -1112,6 +1149,7 @@ # - 'btn': Input event of pointer buttons # - 'rel': Input event of relative pointer motion # - 'abs': Input event of absolute pointer motion +# - 'mtt': Input event of Multitouch # # Since: 2.0 ## @@ -1121,7 +1159,8 @@ 'data' : { 'key' : 'InputKeyEventWrapper', 'btn' : 'InputBtnEventWrapper', 'rel' : 'InputMoveEventWrapper', - 'abs' : 'InputMoveEventWrapper' } } + 'abs' : 'InputMoveEventWrapper', + 'mtt' : 'InputMultitouchEventWrapper' } } =20 ## # @input-send-event: diff --git a/replay/replay-input.c b/replay/replay-input.c index 1147e3d34e..092f6b5ee9 100644 --- a/replay/replay-input.c +++ b/replay/replay-input.c @@ -22,6 +22,7 @@ void replay_save_input_event(InputEvent *evt) InputKeyEvent *key; InputBtnEvent *btn; InputMoveEvent *move; + InputMultitouchEvent *mtt; replay_put_dword(evt->type); =20 switch (evt->type) { @@ -58,6 +59,14 @@ void replay_save_input_event(InputEvent *evt) replay_put_dword(move->axis); replay_put_qword(move->value); break; + case INPUT_EVENT_KIND_MTT: + mtt =3D evt->u.mtt.data; + replay_put_dword(mtt->type); + replay_put_qword(mtt->slot); + replay_put_qword(mtt->tracking_id); + replay_put_dword(mtt->axis); + replay_put_qword(mtt->value); + break; case INPUT_EVENT_KIND__MAX: /* keep gcc happy */ break; @@ -73,6 +82,7 @@ InputEvent *replay_read_input_event(void) InputBtnEvent btn; InputMoveEvent rel; InputMoveEvent abs; + InputMultitouchEvent mtt; =20 evt.type =3D replay_get_dword(); switch (evt.type) { @@ -109,6 +119,14 @@ InputEvent *replay_read_input_event(void) evt.u.abs.data->axis =3D (InputAxis)replay_get_dword(); evt.u.abs.data->value =3D replay_get_qword(); break; + case INPUT_EVENT_KIND_MTT: + evt.u.mtt.data =3D &mtt; + evt.u.mtt.data->type =3D (InputMultitouchType)replay_get_dword(); + evt.u.mtt.data->slot =3D replay_get_qword(); + evt.u.mtt.data->tracking_id =3D replay_get_qword(); + evt.u.mtt.data->axis =3D (InputAxis)replay_get_dword(); + evt.u.mtt.data->value =3D replay_get_qword(); + break; case INPUT_EVENT_KIND__MAX: /* keep gcc happy */ break; diff --git a/ui/input.c b/ui/input.c index f2d1e7a3a7..f788db20f7 100644 --- a/ui/input.c +++ b/ui/input.c @@ -212,6 +212,7 @@ static void qemu_input_event_trace(QemuConsole *src, In= putEvent *evt) InputKeyEvent *key; InputBtnEvent *btn; InputMoveEvent *move; + InputMultitouchEvent *mtt; =20 if (src) { idx =3D qemu_console_get_index(src); @@ -250,6 +251,11 @@ static void qemu_input_event_trace(QemuConsole *src, I= nputEvent *evt) name =3D InputAxis_str(move->axis); trace_input_event_abs(idx, name, move->value); break; + case INPUT_EVENT_KIND_MTT: + mtt =3D evt->u.mtt.data; + name =3D InputAxis_str(mtt->axis); + trace_input_event_mtt(idx, name, mtt->value); + break; case INPUT_EVENT_KIND__MAX: /* keep gcc happy */ break; diff --git a/ui/trace-events b/ui/trace-events index 977577fbba..6747361745 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -90,6 +90,7 @@ input_event_key_qcode(int conidx, const char *qcode, bool= down) "con %d, key qco input_event_btn(int conidx, const char *btn, bool down) "con %d, button %s= , down %d" input_event_rel(int conidx, const char *axis, int value) "con %d, axis %s,= value %d" input_event_abs(int conidx, const char *axis, int value) "con %d, axis %s,= value 0x%x" +input_event_mtt(int conidx, const char *axis, int value) "con %d, axis %s,= value 0x%x" input_event_sync(void) "" input_mouse_mode(int absolute) "absolute %d" =20 --=20 2.38.1 From nobody Fri Apr 19 23:31:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678968375; cv=none; d=zohomail.com; s=zohoarc; b=Y5W74LOcduToTHa03Pq7cVXTEJiD/uuiS494yjvS/0uO21TT6CMKTuUBWHpuCLRRNF5+qYjYJjY59TcvbwVMrprj96syVyQp8aVkpVQ884Fhpzq8awadJZwajz7HrWJ50jucxkwM+B+SAjqckB1B05QDvWbhG1Mit6vfGTVxM4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678968375; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=U7IkFMqg212H5O5pqypIqnLu5f0vym6RzCwLYnidtQA=; b=cu7PTFnd+uAMOJvxB6rZqEIREKjH8Vy3I669L5Gs6CcnbL88flowyICVcQqq6ZUnl3GbtP6jwjDhT9l6WDi/H9/euptREsIeCyqS7zUFt9KpEd3H6SquMZcLKVlU0MQ+2Noj2igotO9YLWz8QVKWLRlJWUBdEcG2PWrfI/iIyFI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678968375689939.9046103430542; Thu, 16 Mar 2023 05:06:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcmMB-0002iG-Sn; Thu, 16 Mar 2023 08:05:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmMA-0002hq-2h for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmM8-0002m9-6C for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:17 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-133-t-3Kq0OINyiCfX5kPFeqYg-1; Thu, 16 Mar 2023 08:05:14 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D49E496DC98; Thu, 16 Mar 2023 12:05:13 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.33.36.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C1C6140EBF4; Thu, 16 Mar 2023 12:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678968315; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U7IkFMqg212H5O5pqypIqnLu5f0vym6RzCwLYnidtQA=; b=Cgo2KNVrcstDtiSo68gMMCXSUdq1VI11L211EMAKI46pxvcN/isijyFuSl+eCkoMdts2pL S0REYZS1JRqY/iTcuvw3DM47lh/ftXFlkDJkKwtWzz6FLRhFCaNf/PER3TXYTP60RSmFDF xk0QF/F63xwDemqXytHGvTfHscrax7w= X-MC-Unique: t-3Kq0OINyiCfX5kPFeqYg-1 From: Sergio Lopez To: qemu-devel@nongnu.org Cc: Eric Blake , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Pavel Dovgalyuk , "Michael S. Tsirkin" , Markus Armbruster , Gerd Hoffmann , Paolo Bonzini , Sergio Lopez Subject: [PATCH v2 3/6] virtio-input: add a virtio-mulitouch device Date: Thu, 16 Mar 2023 13:06:21 +0100 Message-Id: <20230316120624.46410-4-slp@redhat.com> In-Reply-To: <20230316120624.46410-1-slp@redhat.com> References: <20230316120624.46410-1-slp@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=slp@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678968377993100007 Content-Type: text/plain; charset="utf-8" Add a virtio-multitouch device to the family of devices emulated by virtio-input implementing the Multi-touch protocol as descripted here: https://www.kernel.org/doc/html/latest/input/multi-touch-protocol.html?high= light=3Dmulti+touch This patch just add the device itself, without connecting it to any backends. The following patches will add a PCI-based multitouch device, some helpers in "ui" and will enable the GTK3 backend to transpose multi-touch events from the host to the guest. Signed-off-by: Sergio Lopez Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/input/virtio-input-hid.c | 118 ++++++++++++++++++++++++++++++- include/hw/virtio/virtio-input.h | 9 +-- 2 files changed, 120 insertions(+), 7 deletions(-) diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index d28dab69ba..742235d3fa 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -16,9 +16,10 @@ =20 #include "standard-headers/linux/input.h" =20 -#define VIRTIO_ID_NAME_KEYBOARD "QEMU Virtio Keyboard" -#define VIRTIO_ID_NAME_MOUSE "QEMU Virtio Mouse" -#define VIRTIO_ID_NAME_TABLET "QEMU Virtio Tablet" +#define VIRTIO_ID_NAME_KEYBOARD "QEMU Virtio Keyboard" +#define VIRTIO_ID_NAME_MOUSE "QEMU Virtio Mouse" +#define VIRTIO_ID_NAME_TABLET "QEMU Virtio Tablet" +#define VIRTIO_ID_NAME_MULTITOUCH "QEMU Virtio Multitouch" =20 /* ----------------------------------------------------------------- */ =20 @@ -30,6 +31,7 @@ static const unsigned short keymap_button[INPUT_BUTTON__M= AX] =3D { [INPUT_BUTTON_WHEEL_DOWN] =3D BTN_GEAR_DOWN, [INPUT_BUTTON_SIDE] =3D BTN_SIDE, [INPUT_BUTTON_EXTRA] =3D BTN_EXTRA, + [INPUT_BUTTON_TOUCH] =3D BTN_TOUCH, }; =20 static const unsigned short axismap_rel[INPUT_AXIS__MAX] =3D { @@ -42,6 +44,11 @@ static const unsigned short axismap_abs[INPUT_AXIS__MAX]= =3D { [INPUT_AXIS_Y] =3D ABS_Y, }; =20 +static const unsigned short axismap_tch[INPUT_AXIS__MAX] =3D { + [INPUT_AXIS_X] =3D ABS_MT_POSITION_X, + [INPUT_AXIS_Y] =3D ABS_MT_POSITION_Y, +}; + /* ----------------------------------------------------------------- */ =20 static void virtio_input_extend_config(VirtIOInput *vinput, @@ -81,6 +88,7 @@ static void virtio_input_handle_event(DeviceState *dev, Q= emuConsole *src, InputKeyEvent *key; InputMoveEvent *move; InputBtnEvent *btn; + InputMultitouchEvent *mtt; =20 switch (evt->type) { case INPUT_EVENT_KIND_KEY: @@ -137,6 +145,24 @@ static void virtio_input_handle_event(DeviceState *dev= , QemuConsole *src, event.value =3D cpu_to_le32(move->value); virtio_input_send(vinput, &event); break; + case INPUT_EVENT_KIND_MTT: + mtt =3D evt->u.mtt.data; + if (mtt->type =3D=3D INPUT_MULTITOUCH_TYPE_DATA) { + event.type =3D cpu_to_le16(EV_ABS); + event.code =3D cpu_to_le16(axismap_tch[mtt->axis]); + event.value =3D cpu_to_le32(mtt->value); + virtio_input_send(vinput, &event); + } else { + event.type =3D cpu_to_le16(EV_ABS); + event.code =3D cpu_to_le16(ABS_MT_SLOT); + event.value =3D cpu_to_le32(mtt->slot); + virtio_input_send(vinput, &event); + event.type =3D cpu_to_le16(EV_ABS); + event.code =3D cpu_to_le16(ABS_MT_TRACKING_ID); + event.value =3D cpu_to_le32(mtt->tracking_id); + virtio_input_send(vinput, &event); + } + break; default: /* keep gcc happy */ break; @@ -515,12 +541,98 @@ static const TypeInfo virtio_tablet_info =3D { =20 /* ----------------------------------------------------------------- */ =20 +static QemuInputHandler virtio_multitouch_handler =3D { + .name =3D VIRTIO_ID_NAME_MULTITOUCH, + .mask =3D INPUT_EVENT_MASK_BTN | INPUT_EVENT_MASK_MTT, + .event =3D virtio_input_handle_event, + .sync =3D virtio_input_handle_sync, +}; + +static struct virtio_input_config virtio_multitouch_config[] =3D { + { + .select =3D VIRTIO_INPUT_CFG_ID_NAME, + .size =3D sizeof(VIRTIO_ID_NAME_MULTITOUCH), + .u.string =3D VIRTIO_ID_NAME_MULTITOUCH, + },{ + .select =3D VIRTIO_INPUT_CFG_ID_DEVIDS, + .size =3D sizeof(struct virtio_input_devids), + .u.ids =3D { + .bustype =3D const_le16(BUS_VIRTUAL), + .vendor =3D const_le16(0x0627), /* same we use for usb hid de= vices */ + .product =3D const_le16(0x0003), + .version =3D const_le16(0x0001), + }, + },{ + .select =3D VIRTIO_INPUT_CFG_ABS_INFO, + .subsel =3D ABS_MT_SLOT, + .size =3D sizeof(virtio_input_absinfo), + .u.abs.min =3D const_le32(INPUT_EVENT_SLOTS_MIN), + .u.abs.max =3D const_le32(INPUT_EVENT_SLOTS_MAX), + },{ + .select =3D VIRTIO_INPUT_CFG_ABS_INFO, + .subsel =3D ABS_MT_TRACKING_ID, + .size =3D sizeof(virtio_input_absinfo), + .u.abs.min =3D const_le32(INPUT_EVENT_SLOTS_MIN), + .u.abs.max =3D const_le32(INPUT_EVENT_SLOTS_MAX), + },{ + .select =3D VIRTIO_INPUT_CFG_ABS_INFO, + .subsel =3D ABS_MT_POSITION_X, + .size =3D sizeof(virtio_input_absinfo), + .u.abs.min =3D const_le32(INPUT_EVENT_ABS_MIN), + .u.abs.max =3D const_le32(INPUT_EVENT_ABS_MAX), + },{ + .select =3D VIRTIO_INPUT_CFG_ABS_INFO, + .subsel =3D ABS_MT_POSITION_Y, + .size =3D sizeof(virtio_input_absinfo), + .u.abs.min =3D const_le32(INPUT_EVENT_ABS_MIN), + .u.abs.max =3D const_le32(INPUT_EVENT_ABS_MAX), + }, + { /* end of list */ }, +}; + +static void virtio_multitouch_init(Object *obj) +{ + VirtIOInputHID *vhid =3D VIRTIO_INPUT_HID(obj); + VirtIOInput *vinput =3D VIRTIO_INPUT(obj); + unsigned short abs_props[] =3D { + INPUT_PROP_DIRECT, + }; + unsigned short abs_bits[] =3D { + ABS_MT_SLOT, + ABS_MT_TRACKING_ID, + ABS_MT_POSITION_X, + ABS_MT_POSITION_Y, + }; + + vhid->handler =3D &virtio_multitouch_handler; + virtio_input_init_config(vinput, virtio_multitouch_config); + virtio_input_extend_config(vinput, keymap_button, + ARRAY_SIZE(keymap_button), + VIRTIO_INPUT_CFG_EV_BITS, EV_KEY); + virtio_input_extend_config(vinput, abs_props, + ARRAY_SIZE(abs_props), + VIRTIO_INPUT_CFG_PROP_BITS, 0); + virtio_input_extend_config(vinput, abs_bits, + ARRAY_SIZE(abs_bits), + VIRTIO_INPUT_CFG_EV_BITS, EV_ABS); +} + +static const TypeInfo virtio_multitouch_info =3D { + .name =3D TYPE_VIRTIO_MULTITOUCH, + .parent =3D TYPE_VIRTIO_INPUT_HID, + .instance_size =3D sizeof(VirtIOInputHID), + .instance_init =3D virtio_multitouch_init, +}; + +/* ----------------------------------------------------------------- */ + static void virtio_register_types(void) { type_register_static(&virtio_input_hid_info); type_register_static(&virtio_keyboard_info); type_register_static(&virtio_mouse_info); type_register_static(&virtio_tablet_info); + type_register_static(&virtio_multitouch_info); } =20 type_init(virtio_register_types) diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-in= put.h index f2da63d309..08f1591424 100644 --- a/include/hw/virtio/virtio-input.h +++ b/include/hw/virtio/virtio-input.h @@ -24,10 +24,11 @@ OBJECT_DECLARE_TYPE(VirtIOInput, VirtIOInputClass, #define VIRTIO_INPUT_GET_PARENT_CLASS(obj) \ OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT) =20 -#define TYPE_VIRTIO_INPUT_HID "virtio-input-hid-device" -#define TYPE_VIRTIO_KEYBOARD "virtio-keyboard-device" -#define TYPE_VIRTIO_MOUSE "virtio-mouse-device" -#define TYPE_VIRTIO_TABLET "virtio-tablet-device" +#define TYPE_VIRTIO_INPUT_HID "virtio-input-hid-device" +#define TYPE_VIRTIO_KEYBOARD "virtio-keyboard-device" +#define TYPE_VIRTIO_MOUSE "virtio-mouse-device" +#define TYPE_VIRTIO_TABLET "virtio-tablet-device" +#define TYPE_VIRTIO_MULTITOUCH "virtio-multitouch-device" =20 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHID, VIRTIO_INPUT_HID) #define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \ --=20 2.38.1 From nobody Fri Apr 19 23:31:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678968375; cv=none; d=zohomail.com; s=zohoarc; b=NBg75bozju3mhtNLKqoOf8g/8kF3zMk5/Z1KQS5pzxkhCpupfKIhcY1VzSt+BYNPlkCoWgWhzVKMApyV5mwxnA79WJI+nKl+rlPIWwD/QhzjxT/qkvt/rLAE6M9tWC7oNBxgvqlrEdZlEZPlmAE69/4c9UGR7bjJr80iw5T7tJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678968375; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ff6O1LUrjHpdNQA+7OBeBAi0nqNJ5LPOQ5OBs9URK9I=; b=TsYBG/qKZ5M7tdn9IbZsproujfkbT7/Pz/IzpKQr5Ho8PZhLnCQSkAy0fAjbZs++pCtxVzmu7J0Kfqwjjv97kRZW0+kZgDNiVECVZtnKNfO0q9N0jx4QoyXDzcLJin0UgEaGz94t/eOFLRk1mCOmu7VwDDeLzRbUpzWHIBKnVyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16789683757321000.0240190731146; Thu, 16 Mar 2023 05:06:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcmME-0002ig-6K; Thu, 16 Mar 2023 08:05:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmMB-0002iF-Fg for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmM9-0002mQ-TB for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:19 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-321-5q3y3QBkM8izghDxNzQlTw-1; Thu, 16 Mar 2023 08:05:16 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 99113857FB8; Thu, 16 Mar 2023 12:05:15 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.33.36.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EEF0140EBF4; Thu, 16 Mar 2023 12:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678968317; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ff6O1LUrjHpdNQA+7OBeBAi0nqNJ5LPOQ5OBs9URK9I=; b=UiXAdH56Lwi/lV4ayGEXhxVodXacTuSD51Uf4Dfb0ah0F9j2XmUKKzgJ307gV9ahup1Fk0 jU+DdTFZjRf9ssO4QNjG5n2QcHyCAohEq5YzaQuqiQMALJd4BjiIBAVscMMzLOoRmuBP3B LJ37iDKcu2DigPHJngCuAW1TviwRwMw= X-MC-Unique: 5q3y3QBkM8izghDxNzQlTw-1 From: Sergio Lopez To: qemu-devel@nongnu.org Cc: Eric Blake , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Pavel Dovgalyuk , "Michael S. Tsirkin" , Markus Armbruster , Gerd Hoffmann , Paolo Bonzini , Sergio Lopez Subject: [PATCH v2 4/6] virtio-input-pci: add virtio-multitouch-pci Date: Thu, 16 Mar 2023 13:06:22 +0100 Message-Id: <20230316120624.46410-5-slp@redhat.com> In-Reply-To: <20230316120624.46410-1-slp@redhat.com> References: <20230316120624.46410-1-slp@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=slp@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678968377783100005 Content-Type: text/plain; charset="utf-8" Add virtio-multitouch-pci, a Multitouch-capable input device, to the list of devices that can be provided by virtio-input-pci. Signed-off-by: Sergio Lopez Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/virtio/virtio-input-pci.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/hw/virtio/virtio-input-pci.c b/hw/virtio/virtio-input-pci.c index a9d0992389..a53edf46c4 100644 --- a/hw/virtio/virtio-input-pci.c +++ b/hw/virtio/virtio-input-pci.c @@ -25,10 +25,11 @@ struct VirtIOInputPCI { VirtIOInput vdev; }; =20 -#define TYPE_VIRTIO_INPUT_HID_PCI "virtio-input-hid-pci" -#define TYPE_VIRTIO_KEYBOARD_PCI "virtio-keyboard-pci" -#define TYPE_VIRTIO_MOUSE_PCI "virtio-mouse-pci" -#define TYPE_VIRTIO_TABLET_PCI "virtio-tablet-pci" +#define TYPE_VIRTIO_INPUT_HID_PCI "virtio-input-hid-pci" +#define TYPE_VIRTIO_KEYBOARD_PCI "virtio-keyboard-pci" +#define TYPE_VIRTIO_MOUSE_PCI "virtio-mouse-pci" +#define TYPE_VIRTIO_TABLET_PCI "virtio-tablet-pci" +#define TYPE_VIRTIO_MULTITOUCH_PCI "virtio-multitouch-pci" OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHIDPCI, VIRTIO_INPUT_HID_PCI) =20 struct VirtIOInputHIDPCI { @@ -102,6 +103,14 @@ static void virtio_tablet_initfn(Object *obj) TYPE_VIRTIO_TABLET); } =20 +static void virtio_multitouch_initfn(Object *obj) +{ + VirtIOInputHIDPCI *dev =3D VIRTIO_INPUT_HID_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VIRTIO_MULTITOUCH); +} + static const TypeInfo virtio_input_pci_info =3D { .name =3D TYPE_VIRTIO_INPUT_PCI, .parent =3D TYPE_VIRTIO_PCI, @@ -140,6 +149,13 @@ static const VirtioPCIDeviceTypeInfo virtio_tablet_pci= _info =3D { .instance_init =3D virtio_tablet_initfn, }; =20 +static const VirtioPCIDeviceTypeInfo virtio_multitouch_pci_info =3D { + .generic_name =3D TYPE_VIRTIO_MULTITOUCH_PCI, + .parent =3D TYPE_VIRTIO_INPUT_HID_PCI, + .instance_size =3D sizeof(VirtIOInputHIDPCI), + .instance_init =3D virtio_multitouch_initfn, +}; + static void virtio_pci_input_register(void) { /* Base types: */ @@ -150,6 +166,7 @@ static void virtio_pci_input_register(void) virtio_pci_types_register(&virtio_keyboard_pci_info); virtio_pci_types_register(&virtio_mouse_pci_info); virtio_pci_types_register(&virtio_tablet_pci_info); + virtio_pci_types_register(&virtio_multitouch_pci_info); } =20 type_init(virtio_pci_input_register) --=20 2.38.1 From nobody Fri Apr 19 23:31:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678968419; cv=none; d=zohomail.com; s=zohoarc; b=PnDLCyH/MXIzAH7mzHihd6YbfLO8CGNVLAMbJAzd47fDtq1jYBgd/ANVVq9vdmG+daT6K4wKaDMZW1oIaJ2k/hM5gtRt0MueD5U043D1QztkjDIKSqXWCwdVuCCGAp6Vu/UUxOiP4J3Vj7zU/eAJpgpFLSRwx7Zx1V9NOPNF1mA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678968419; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZTRCSFCROj1GSLym6gTBjuTBu7m41D87hqy/XMN02+c=; b=YFH7RgnSc5kJRkDI8iSoKVUG/q+CgWQZDbgcIL8gjDp4FbtmC420dteHoBXHtAQl2VtvXAPg4G91IpX1eM1xg4LmK64Zel2bWAqV/vKf8jV/su0CJnh5hE3JnXZc1bkyyWCuYwxJ9xIgR1Ngw4cHcK4Y09c45tQQVxKI0iXRSZk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678968419716123.29996521218402; Thu, 16 Mar 2023 05:06:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcmMI-0002jW-4O; Thu, 16 Mar 2023 08:05:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmMD-0002ie-QO for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmMC-0002n8-Bd for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:21 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-40VyF_5SNr6XZtuv-N5_eA-1; Thu, 16 Mar 2023 08:05:18 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 59F5010146EE; Thu, 16 Mar 2023 12:05:17 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.33.36.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5DCE140EBF4; Thu, 16 Mar 2023 12:05:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678968319; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZTRCSFCROj1GSLym6gTBjuTBu7m41D87hqy/XMN02+c=; b=QIIeSa88a5pLRZ1eWj/LrFpn6mwl2gZwvSXqiCmNqT8cAbIeBRjb+kVFsRg/d+jGJa9tFs YBhpoU8QJ6fzdLbLKEOBdExunnyXm3w38Gk9HZ68Jszm/LCwCAJLr+hWRf4WW5OI66Ku5U G4W6wehX/5XDnVNJyN2SXBC9d3k9YDc= X-MC-Unique: 40VyF_5SNr6XZtuv-N5_eA-1 From: Sergio Lopez To: qemu-devel@nongnu.org Cc: Eric Blake , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Pavel Dovgalyuk , "Michael S. Tsirkin" , Markus Armbruster , Gerd Hoffmann , Paolo Bonzini , Sergio Lopez Subject: [PATCH v2 5/6] ui: add helpers for virtio-multitouch events Date: Thu, 16 Mar 2023 13:06:23 +0100 Message-Id: <20230316120624.46410-6-slp@redhat.com> In-Reply-To: <20230316120624.46410-1-slp@redhat.com> References: <20230316120624.46410-1-slp@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=slp@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678968421438100003 Add helpers for generating Multi-touch events from the UI backends that can be sent to the guest through a virtio-multitouch device. Signed-off-by: Sergio Lopez Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/ui/input.h | 5 +++++ ui/input.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/ui/input.h b/include/ui/input.h index 2a3dffd417..c37251e1e9 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -64,6 +64,11 @@ int qemu_input_scale_axis(int value, void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value); void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, int min_in, int max_in); +void qemu_input_queue_mtt(QemuConsole *src, InputMultitouchType type, int = slot, + int tracking_id); +void qemu_input_queue_mtt_abs(QemuConsole *src, InputAxis axis, int value, + int min_in, int max_in, + int slot, int tracking_id); =20 void qemu_input_check_mode_change(void); void qemu_add_mouse_mode_change_notifier(Notifier *notify); diff --git a/ui/input.c b/ui/input.c index f788db20f7..34331b7b0b 100644 --- a/ui/input.c +++ b/ui/input.c @@ -547,6 +547,42 @@ void qemu_input_queue_abs(QemuConsole *src, InputAxis = axis, int value, qemu_input_event_send(src, &evt); } =20 +void qemu_input_queue_mtt(QemuConsole *src, InputMultitouchType type, + int slot, int tracking_id) +{ + InputMultitouchEvent mtt =3D { + .type =3D type, + .slot =3D slot, + .tracking_id =3D tracking_id, + }; + InputEvent evt =3D { + .type =3D INPUT_EVENT_KIND_MTT, + .u.mtt.data =3D &mtt, + }; + + qemu_input_event_send(src, &evt); +} + +void qemu_input_queue_mtt_abs(QemuConsole *src, InputAxis axis, int value, + int min_in, int max_in, int slot, int tracki= ng_id) +{ + InputMultitouchEvent mtt =3D { + .type =3D INPUT_MULTITOUCH_TYPE_DATA, + .slot =3D slot, + .tracking_id =3D tracking_id, + .axis =3D axis, + .value =3D qemu_input_scale_axis(value, min_in, max_in, + INPUT_EVENT_ABS_MIN, + INPUT_EVENT_ABS_MAX), + }; + InputEvent evt =3D { + .type =3D INPUT_EVENT_KIND_MTT, + .u.mtt.data =3D &mtt, + }; + + qemu_input_event_send(src, &evt); +} + void qemu_input_check_mode_change(void) { static int current_is_absolute; --=20 2.38.1 From nobody Fri Apr 19 23:31:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678968450; cv=none; d=zohomail.com; s=zohoarc; b=fsYqOfPp6Rxa7NreO7+/YpqqUaifPD2gm+g08AWxbc1vLBH7NJt+Xf9PJDNcGtYUfbzhGYyZSCtmzEdHDSxCkJJUit6ZOizrBYCGDZcC76dtEnmoWbaFFPIIHetSfia6iStPEox70/hhHhSVoCEd32GoI+YMDdq8Zebrt0c4Rck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678968450; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BFXEqi3+afrhJ6fKwOMxcErtjjrlJEkqPpu5/+P9lp4=; b=geoAMqr/ASWscbKUa0+q9mdG38qEa+5+UpLuMU7vkgd3/EeQt5WS3Ox8N2XApA0JxWw/je/tvC/V8NplQlRdhsRONRlwgnFKlyZD6sGPUVaqjSjj9RV9Bbw5Rmy/TKWPcgqk6I7RpfVqZxbAS632fKFoUH+QfStMiBok75JMRF8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678968450855797.3936109339314; Thu, 16 Mar 2023 05:07:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcmMK-0002lT-3F; Thu, 16 Mar 2023 08:05:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmMH-0002jS-K0 for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcmMF-0002pb-PE for qemu-devel@nongnu.org; Thu, 16 Mar 2023 08:05:25 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-176--elP1ARMODmbaDirN3Hf8Q-1; Thu, 16 Mar 2023 08:05:19 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2A6921C06EEE; Thu, 16 Mar 2023 12:05:19 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.33.36.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97757140EBF4; Thu, 16 Mar 2023 12:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678968322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BFXEqi3+afrhJ6fKwOMxcErtjjrlJEkqPpu5/+P9lp4=; b=Vn5BUPlxHMu2qHt+alvkOxovZ1J8FZ/dskWetO0Ylihpd6Dh5Nz/vfeOVWlkn8OcfF0ugJ pTitzhsAk7+tVLLFY2dFSzrdNKFO8ZFXzlKE4zT/8FGha6T2AsC8Z7P36ngKlXi+L6SBDA vnZ84BYfk862dHBSfu2SbAuQ3eV2b1M= X-MC-Unique: -elP1ARMODmbaDirN3Hf8Q-1 From: Sergio Lopez To: qemu-devel@nongnu.org Cc: Eric Blake , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Pavel Dovgalyuk , "Michael S. Tsirkin" , Markus Armbruster , Gerd Hoffmann , Paolo Bonzini , Sergio Lopez Subject: [PATCH v2 6/6] ui/gtk: enable backend to send multi-touch events Date: Thu, 16 Mar 2023 13:06:24 +0100 Message-Id: <20230316120624.46410-7-slp@redhat.com> In-Reply-To: <20230316120624.46410-1-slp@redhat.com> References: <20230316120624.46410-1-slp@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=slp@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678968451628100002 Content-Type: text/plain; charset="utf-8" GTK3 provides the infrastructure to receive and process multi-touch events through the "touch-event" signal and the GdkEventTouch type. Make use of it to transpose events from the host to the guest. This allows users of machines with hardware capable of receiving multi-touch events to run guests that can also receive those events and interpret them as gestures, when appropriate. An example of this in action can be seen here: https://fosstodon.org/@slp/109545849296546767 Signed-off-by: Sergio Lopez Reviewed-by: Marc-Andr=C3=A9 Lureau --- ui/gtk.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index fd82e9b1ca..3a667bfba6 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -130,6 +130,13 @@ typedef struct VCChardev VCChardev; DECLARE_INSTANCE_CHECKER(VCChardev, VC_CHARDEV, TYPE_CHARDEV_VC) =20 +struct touch_slot { + int x; + int y; + int tracking_id; +}; +static struct touch_slot touch_slots[INPUT_EVENT_SLOTS_MAX]; + bool gtk_use_gl_area; =20 static void gd_grab_pointer(VirtualConsole *vc, const char *reason); @@ -1058,6 +1065,82 @@ static gboolean gd_scroll_event(GtkWidget *widget, G= dkEventScroll *scroll, } =20 =20 +static gboolean gd_touch_event(GtkWidget *widget, GdkEventTouch *touch, + void *opaque) +{ + VirtualConsole *vc =3D opaque; + struct touch_slot *slot; + uint64_t num_slot =3D GPOINTER_TO_UINT(touch->sequence); + bool needs_sync =3D false; + int update; + int type =3D -1; + int i; + + if (num_slot >=3D INPUT_EVENT_SLOTS_MAX) { + fprintf(stderr, "%s: unexpected touch slot number: %ld >=3D %d\n", + __func__, num_slot, INPUT_EVENT_SLOTS_MAX); + return FALSE; + } + + slot =3D &touch_slots[num_slot]; + slot->x =3D touch->x; + slot->y =3D touch->y; + + switch (touch->type) { + case GDK_TOUCH_BEGIN: + type =3D INPUT_MULTITOUCH_TYPE_BEGIN; + slot->tracking_id =3D num_slot; + break; + case GDK_TOUCH_UPDATE: + type =3D INPUT_MULTITOUCH_TYPE_UPDATE; + break; + case GDK_TOUCH_END: + case GDK_TOUCH_CANCEL: + type =3D INPUT_MULTITOUCH_TYPE_END; + break; + default: + fprintf(stderr, "%s: unexpected touch event\n", __func__); + } + + for (i =3D 0; i < INPUT_EVENT_SLOTS_MAX; ++i) { + if (i =3D=3D num_slot) { + update =3D type; + } else { + update =3D INPUT_MULTITOUCH_TYPE_UPDATE; + } + + slot =3D &touch_slots[i]; + + if (slot->tracking_id =3D=3D -1) { + continue; + } + + if (update =3D=3D INPUT_MULTITOUCH_TYPE_END) { + slot->tracking_id =3D -1; + qemu_input_queue_mtt(vc->gfx.dcl.con, update, i, slot->trackin= g_id); + needs_sync =3D true; + } else { + qemu_input_queue_mtt(vc->gfx.dcl.con, update, i, slot->trackin= g_id); + qemu_input_queue_btn(vc->gfx.dcl.con, INPUT_BUTTON_TOUCH, true= ); + qemu_input_queue_mtt_abs(vc->gfx.dcl.con, + INPUT_AXIS_X, (int) slot->x, + 0, surface_width(vc->gfx.ds), + i, slot->tracking_id); + qemu_input_queue_mtt_abs(vc->gfx.dcl.con, + INPUT_AXIS_Y, (int) slot->y, + 0, surface_height(vc->gfx.ds), + i, slot->tracking_id); + needs_sync =3D true; + } + } + + if (needs_sync) { + qemu_input_event_sync(); + } + + return TRUE; +} + static const guint16 *gd_get_keymap(size_t *maplen) { GdkDisplay *dpy =3D gdk_display_get_default(); @@ -1977,6 +2060,8 @@ static void gd_connect_vc_gfx_signals(VirtualConsole = *vc) G_CALLBACK(gd_key_event), vc); g_signal_connect(vc->gfx.drawing_area, "key-release-event", G_CALLBACK(gd_key_event), vc); + g_signal_connect(vc->gfx.drawing_area, "touch-event", + G_CALLBACK(gd_touch_event), vc); =20 g_signal_connect(vc->gfx.drawing_area, "enter-notify-event", G_CALLBACK(gd_enter_event), vc); @@ -2086,6 +2171,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, GSList *group, GtkWidget *view_menu) { bool zoom_to_fit =3D false; + int i; =20 vc->label =3D qemu_console_get_label(con); vc->s =3D s; @@ -2133,6 +2219,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK | + GDK_TOUCH_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_SCROLL_MASK | @@ -2168,6 +2255,11 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vi= rtualConsole *vc, s->free_scale =3D true; } =20 + for (i =3D 0; i < INPUT_EVENT_SLOTS_MAX; i++) { + struct touch_slot *slot =3D &touch_slots[i]; + slot->tracking_id =3D -1; + } + return group; } =20 --=20 2.38.1