From nobody Sat May 4 00:37:45 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.zoho.com; dkim=fail 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 1493991806758440.778067630746; Fri, 5 May 2017 06:43:26 -0700 (PDT) Received: from localhost ([::1]:47176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6dW0-0003Vd-Cz for importer@patchew.org; Fri, 05 May 2017 09:43:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6dVH-0003Ep-6y for qemu-devel@nongnu.org; Fri, 05 May 2017 09:42:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6dVE-00048b-4c for qemu-devel@nongnu.org; Fri, 05 May 2017 09:42:39 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35854) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d6dVD-00048I-Tp for qemu-devel@nongnu.org; Fri, 05 May 2017 09:42:36 -0400 Received: by mail-wm0-x242.google.com with SMTP id u65so1431745wmu.3 for ; Fri, 05 May 2017 06:42:35 -0700 (PDT) Received: from tupw.localdomain (pub082136102096.dh-hfc.datazug.ch. [82.136.102.96]) by smtp.gmail.com with ESMTPSA id t57sm2875787edb.28.2017.05.05.06.42.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 May 2017 06:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=DZfEAmMdysmcZZHZIV5mHznWuoTYk0bOWHTfINSbLGY=; b=AHOwcQXRFBDWis3CldfV2wy8/v2cOM//T8OmWog/HcwWU/sxyU5/Dz2Tlokt67SAtF 6D70yPNhr+cHUTua9AIiImhhZH+x1Ezp8ESE52zCDjDh1M9pLf2TATAlD2F6KsDi5IOe t3DUtD63sDiNSK9Dj5yKnJbiY9lxirO7hmKof8N0qekN2cpwz+A/uBpsFpDH7gdmX2Ah 6i1LucfOMbr1csj5IgR7xjvtAhddQHlMDZawP00MNcei34tiiW9TKMRaI/hqysEMN2IY /sh/lDY9lPhLC0UMxE/ei0t7ti0R/hBy6d7DCWFhhpglSwUHWoPlh027PF9jP3r3M/sm XKSA== 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=DZfEAmMdysmcZZHZIV5mHznWuoTYk0bOWHTfINSbLGY=; b=i0tsaqMKUBH69wACTnnNtqbYaVCW1u2R5xrTU/oVaLeR6QVhBepbXHFq+sgV2vNezF eBEXgKpFLbHts8bxU+Ws8aG8ncHvi2l1usea+67C6kGwljKzt8gcycHAMq5yHV9Iv/qA Er+jVIkuJQUCfdvdgnQ7jhsnyhRKZl/Y9lLjJyAqmP9x8AYnnMZX8HSQDU0hGtunq4L+ MZ+0Jsd7kUSxoJMVSahCVPibJuSMhZqHXfcKRuduYIHerQyQY6jbJdiu73ABSPifT1RS TG3Fk0XeGkpxZicT8awz12pT2QMwIqQnfEh8JiEjvKAl8vsZq4CTZwP3c4Qq+PkI1GkW DyMQ== X-Gm-Message-State: AN3rC/7ftIyI9ZOIwrWSyNUwmxwgmGHsR5DwwN0ir1W04FIyHlWx/fAg 5AdWXOIljyQwGw== X-Received: by 10.80.183.146 with SMTP id h18mr34381750ede.39.1493991754876; Fri, 05 May 2017 06:42:34 -0700 (PDT) From: Philippe Voinov To: qemu-devel@nongnu.org Date: Fri, 5 May 2017 15:42:31 +0200 Message-Id: <20170505134231.30210-1-philippevoinov@gmail.com> X-Mailer: git-send-email 2.12.2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH v3] ui: input-linux: Add absolute event support 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: Gerd Hoffmann , Philippe Voinov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This depends on: [PATCH] ui: Support non-zero minimum values for absolute input axes This patch adds support for absolute pointer events to the input-linux subsystem. This support was omitted from the original input-linux patch, however most of the code required for it is already in place. Support for absolute events is especially useful for guests with vga passthrough. Since they have a physical monitor, none of normal channels for sending video output (vnc, etc) are used, meaning they also can't be used to send absolute input events. This leaves QMP as the only option to send absolute input into vga passthrough guests, which is not its intended use and is not efficient. This patch allows, for example, uinput to be used to create virtual absolute input devices. This lets you build external systems which share physical input devices between guests. Without absolute input capability, such external systems can't seamlessly share pointer devices between guests. Signed-off-by: Philippe Voinov --- ui/input-linux.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ui/input-linux.c b/ui/input-linux.c index dc0613c..49d52a6 100644 --- a/ui/input-linux.c +++ b/ui/input-linux.c @@ -169,6 +169,10 @@ struct InputLinux { bool has_abs_x; int num_keys; int num_btns; + int abs_x_min; + int abs_x_max; + int abs_y_min; + int abs_y_max; struct input_event event; int read_offset; =20 @@ -314,6 +318,18 @@ static void input_linux_handle_mouse(InputLinux *il, s= truct input_event *event) break; } break; + case EV_ABS: + switch (event->code) { + case ABS_X: + qemu_input_queue_abs(NULL, INPUT_AXIS_X, event->value, + il->abs_x_min, il->abs_x_max); + break; + case ABS_Y: + qemu_input_queue_abs(NULL, INPUT_AXIS_Y, event->value, + il->abs_y_min, il->abs_y_max); + break; + } + break; case EV_SYN: qemu_input_event_sync(); if (il->wheel !=3D 0) { @@ -351,7 +367,7 @@ static void input_linux_event(void *opaque) if (il->num_keys) { input_linux_handle_keyboard(il, &il->event); } - if (il->has_rel_x && il->num_btns) { + if ((il->has_rel_x || il->has_abs_x) && il->num_btns) { input_linux_handle_mouse(il, &il->event); } } @@ -364,6 +380,7 @@ static void input_linux_complete(UserCreatable *uc, Err= or **errp) uint8_t keymap[KEY_CNT / 8], keystate[KEY_CNT / 8]; unsigned int i; int rc, ver; + struct input_absinfo absinfo; =20 if (!il->evdev) { error_setg(errp, "no input device specified"); @@ -402,6 +419,12 @@ static void input_linux_complete(UserCreatable *uc, Er= ror **errp) rc =3D ioctl(il->fd, EVIOCGBIT(EV_ABS, sizeof(absmap)), &absmap); if (absmap & (1 << ABS_X)) { il->has_abs_x =3D true; + rc =3D ioctl(il->fd, EVIOCGABS(ABS_X), &absinfo); + il->abs_x_min =3D absinfo.minimum; + il->abs_x_max =3D absinfo.maximum; + rc =3D ioctl(il->fd, EVIOCGABS(ABS_Y), &absinfo); + il->abs_y_min =3D absinfo.minimum; + il->abs_y_max =3D absinfo.maximum; } } =20 --=20 2.12.2