From nobody Sun Oct 26 01:41:55 2025 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; 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515363400926788.0332611208632; Sun, 7 Jan 2018 14:16:40 -0800 (PST) Received: from localhost ([::1]:44805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYJF5-00042y-0g for importer@patchew.org; Sun, 07 Jan 2018 17:16:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYJDb-0003Fz-Q7 for qemu-devel@nongnu.org; Sun, 07 Jan 2018 17:15:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eYJDa-0001KM-NZ for qemu-devel@nongnu.org; Sun, 07 Jan 2018 17:15:03 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35630) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eYJDa-0001Jn-HR for qemu-devel@nongnu.org; Sun, 07 Jan 2018 17:15:02 -0500 Received: by mail-pf0-x242.google.com with SMTP id t12so1815823pfg.2 for ; Sun, 07 Jan 2018 14:15:02 -0800 (PST) Received: from miku.meowdesu (node-1w7jr9qp2twqeku9s2tvm6w6f.ipv6.telus.net. [2001:569:7842:7200:4ecc:6aff:fe93:ea67]) by smtp.gmail.com with ESMTPSA id g17sm22892328pfj.66.2018.01.07.14.15.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Jan 2018 14:15:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NWLMbryDvINi505eyREsRdNUInVBfc0JFw6piWJzFLE=; b=fNnoz0sxaQsRMj2oPyL0DrqPfLsdKkewgBLTWEQ5mPAnQLTg1jbV3NghKv4IqrWI2r XxC3xz6zB2+Apw5x76uRUmcYPtiALVNWfBFb/qvN8TROvrktTi9awPLhQcg99g4f3nln b6hUiASBj8q2QXIgXERAVI4of4xzZZUCzLXSs/0aitv+DCM0EkFnL+rAPku7UWz+/cLD G/O6J2hYCBRyTKBm5wNvec+IJHuXIbOxuOxA3Z4pvA0zcK6ODAWtibOrfqUCeW3ogZWF PZJZrLJVnbEwatHZQcjwsdWnezv42mI00goYr+Su8xvcMCW7eUHV0RmRbesU0GgXo91U +o3A== 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; bh=NWLMbryDvINi505eyREsRdNUInVBfc0JFw6piWJzFLE=; b=j2UB/FY3oMooZBMVGOrtnOrVR0yZc7rrVY0LpSyEI0DStr0yCMm8M1M9z2eFHeWjqg viSB6lvOJUFLYIuldja5NDXuoAxvAc1b3omAOJ4OB6oyTxjgdrWcsSqOdS0odlg5wpLD vdm5wr6i/fxjsTKGKNZ68NNbL/vKbchBBgNXLBvXyXvcvg+o/c1+rJBcuvil1lrRts1i UR3yb3dP1YPOslOjBotcGd4SNnetrDIU/sEKeZ4TEydEosAGOkorzfUgkLhKTZnjrJfN aHxa6yvLAVOJYUiV/6G4YOwo5VosRWV/l4dvjgS/v25KbyxEFphrIicmy6DWpXWLrdmx NfCA== X-Gm-Message-State: AKGB3mJS4PSsOkpJ2OHD/M8rKFNSwmuJXm2OOniUKjTwiIBsZiybUw/A pqTpvqj3KOBr6x1KYa4Flc+UhC+j X-Google-Smtp-Source: ACJfBovl7iB36Nvi1LcNHBnmSnibGkzRNrRTZtVciHo8v1aMiDrlq9tyUxcQMvEhT6HgR58F5W6apQ== X-Received: by 10.99.145.66 with SMTP id l63mr3615812pge.273.1515363301462; Sun, 07 Jan 2018 14:15:01 -0800 (PST) From: byxk To: qemu-devel@nongnu.org Date: Sun, 7 Jan 2018 14:14:55 -0800 Message-Id: <20180107221455.25504-2-patricktsen@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180107221455.25504-1-patricktsen@gmail.com> References: <20180107221455.25504-1-patricktsen@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH 1/1] input-linux: provide hotkeys for evdev toggle 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: kraxel@redhat.com, byxk 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" --- ui/input-linux.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/ui/input-linux.c b/ui/input-linux.c index 9720333b2c..a553d2b4cc 100644 --- a/ui/input-linux.c +++ b/ui/input-linux.c @@ -5,6 +5,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "qemu-common.h" #include "qemu/config-file.h" @@ -62,6 +63,8 @@ struct InputLinux { int abs_y_max; struct input_event event; int read_offset; + long rhotkey; + long lhotkey; =20 QTAILQ_ENTRY(InputLinux) next; }; @@ -134,8 +137,8 @@ static void input_linux_handle_keyboard(InputLinux *il, } =20 /* hotkey -> record switch request ... */ - if (il->keydown[KEY_LEFTCTRL] && - il->keydown[KEY_RIGHTCTRL]) { + if (il->keydown[il->rhotkey] && + il->keydown[il->lhotkey]) { il->grab_request =3D true; } =20 @@ -274,6 +277,14 @@ static void input_linux_complete(UserCreatable *uc, Er= ror **errp) return; } =20 + if (!il->rhotkey) { + il->rhotkey =3D KEY_RIGHTCTRL; + } + + if (!il->lhotkey) { + il->lhotkey =3D KEY_LEFTCTRL; + } + il->fd =3D open(il->evdev, O_RDWR); if (il->fd < 0) { error_setg_file_open(errp, errno, il->evdev); @@ -395,6 +406,62 @@ static void input_linux_set_grab_all(Object *obj, bool= value, il->grab_all =3D value; } =20 +static void input_linux_set_rhotkey(Object *obj, const char *value, + Error **errp) +{ + InputLinux *il =3D INPUT_LINUX(obj); + InputLinux *item; + long rhotkey; + int res =3D qemu_strtol(value, NULL, 0, &rhotkey); + if (res !=3D 0) { + rhotkey =3D KEY_RIGHTCTRL; + } + il->rhotkey =3D rhotkey; + + QTAILQ_FOREACH(item, &inputs, next) { + if (item =3D=3D il || item->rhotkey) { + continue; + } + item->rhotkey =3D rhotkey; + } +} + +static char *input_linux_get_rhotkey(Object *obj, Error **errp) +{ + InputLinux *il =3D INPUT_LINUX(obj); + char buf[sizeof(int) * 4]; + sprintf(buf, "%ld", il->rhotkey); + return g_strdup(buf); +} + +static void input_linux_set_lhotkey(Object *obj, const char *value, + Error **errp) +{ + InputLinux *il =3D INPUT_LINUX(obj); + InputLinux *item; + long lhotkey =3D KEY_LEFTCTRL; + int res =3D qemu_strtol(value, NULL, 0, &lhotkey); + if (res !=3D 0) { + lhotkey =3D KEY_LEFTCTRL; + } + il->lhotkey =3D lhotkey; + + QTAILQ_FOREACH(item, &inputs, next) { + if (item =3D=3D il || item->lhotkey) { + continue; + } + item->lhotkey =3D lhotkey; + } +} + +static char *input_linux_get_lhotkey(Object *obj, Error **errp) +{ + InputLinux *il =3D INPUT_LINUX(obj); + char buf[sizeof(int) * 4]; + sprintf(buf, "%ld", il->lhotkey); + return g_strdup(buf); +} + static bool input_linux_get_repeat(Object *obj, Error **errp) { InputLinux *il =3D INPUT_LINUX(obj); @@ -421,6 +488,12 @@ static void input_linux_instance_init(Object *obj) object_property_add_bool(obj, "repeat", input_linux_get_repeat, input_linux_set_repeat, NULL); + object_property_add_str(obj, "rhotkey", + input_linux_get_rhotkey, + input_linux_set_rhotkey, NULL); + object_property_add_str(obj, "lhotkey", + input_linux_get_lhotkey, + input_linux_set_lhotkey, NULL); } =20 static void input_linux_class_init(ObjectClass *oc, void *data) --=20 2.15.1