From nobody Mon Apr 29 03:26:59 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 1507198113743958.5529968087311; Thu, 5 Oct 2017 03:08:33 -0700 (PDT) Received: from localhost ([::1]:38815 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e034l-0001nr-VJ for importer@patchew.org; Thu, 05 Oct 2017 06:08:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e02xw-00054F-6e for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e02xt-0005QS-Hb for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53540) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e02xt-0005P5-9F for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:13 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A9FE7E454 for ; Thu, 5 Oct 2017 10:01:12 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id B52DE60603; Thu, 5 Oct 2017 10:01:08 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id BFF634057F; Thu, 5 Oct 2017 12:01:06 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1A9FE7E454 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 12:01:01 +0200 Message-Id: <20171005100106.30118-2-kraxel@redhat.com> In-Reply-To: <20171005100106.30118-1-kraxel@redhat.com> References: <20171005100106.30118-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 05 Oct 2017 10:01:12 +0000 (UTC) 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] [PULL 1/6] build: automatically handle GIT submodule checkout for dtc 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Currently if DTC is required by configure and not available in the host OS install, we exit with an error message telling the user to checkout a git submodule or install the library. This introduces automatic handling of the git submodule checkout process and enables it for dtc. This only runs if building from GIT, so users of release tarballs still need the system library install. The current state of the git checkout is stashed in .git-submodule-status, and a helper program is used to determine if this state matches the desired submodule state. A dependency against 'Makefile' ensures that the submodule state is refreshed at the start of the build process Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-2-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- configure | 46 ++++++++++++++++++++++++++------------------= -- Makefile | 25 ++++++++++++++++++++++++- .gitignore | 1 + MAINTAINERS | 6 ++++++ scripts/git-submodule.sh | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 21 deletions(-) create mode 100755 scripts/git-submodule.sh diff --git a/configure b/configure index 6587e8014b..38f1710c80 100755 --- a/configure +++ b/configure @@ -264,6 +264,7 @@ cc_i386=3Di386-pc-linux-gnu-gcc libs_qga=3D"" debug_info=3D"yes" stack_protector=3D"" +git_submodules=3D"" =20 # Don't accept a target_list environment variable. unset target_list @@ -3584,27 +3585,30 @@ EOF if compile_prog "" "$fdt_libs" ; then # system DTC is good - use it fdt=3Dyes - elif test -d ${source_path}/dtc/libfdt ; then - # have submodule DTC - use it - fdt=3Dyes - dtc_internal=3D"yes" - mkdir -p dtc - if [ "$pwd_is_source_path" !=3D "y" ] ; then - symlink "$source_path/dtc/Makefile" "dtc/Makefile" - symlink "$source_path/dtc/scripts" "dtc/scripts" - fi - fdt_cflags=3D"-I\$(SRC_PATH)/dtc/libfdt" - fdt_libs=3D"-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs" - elif test "$fdt" =3D "yes" ; then - # have neither and want - prompt for system/submodule install - error_exit "DTC (libfdt) version >=3D 1.4.2 not present. Your options:= " \ - " (1) Preferred: Install the DTC (libfdt) devel package" \ - " (2) Fetch the DTC submodule, using:" \ - " git submodule update --init dtc" else - # don't have and don't want - fdt_libs=3D - fdt=3Dno + # have GIT checkout, so activate dtc submodule + if test -e "${source_path}/.git" ; then + git_submodules=3D"${git_submodules} dtc" + fi + if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.g= it" ; then + fdt=3Dyes + dtc_internal=3D"yes" + mkdir -p dtc + if [ "$pwd_is_source_path" !=3D "y" ] ; then + symlink "$source_path/dtc/Makefile" "dtc/Makefile" + symlink "$source_path/dtc/scripts" "dtc/scripts" + fi + fdt_cflags=3D"-I\$(SRC_PATH)/dtc/libfdt" + fdt_libs=3D"-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs" + elif test "$fdt" =3D "yes" ; then + # Not a git build & no libfdt found, prompt for system install + error_exit "DTC (libfdt) version >=3D 1.4.2 not present." \ + "Please install the DTC (libfdt) devel package" + else + # don't have and don't want + fdt_libs=3D + fdt=3Dno + fi fi fi =20 @@ -5295,6 +5299,7 @@ echo "local state directory queried at runtime" echo "Windows SDK $win_sdk" fi echo "Source path $source_path" +echo "GIT submodules $git_submodules" echo "C compiler $cc" echo "Host C compiler $host_cc" echo "C++ compiler $cxx" @@ -5483,6 +5488,7 @@ echo "extra_cxxflags=3D$EXTRA_CXXFLAGS" >> $config_ho= st_mak echo "extra_ldflags=3D$EXTRA_LDFLAGS" >> $config_host_mak echo "qemu_localedir=3D$qemu_localedir" >> $config_host_mak echo "libs_softmmu=3D$libs_softmmu" >> $config_host_mak +echo "GIT_SUBMODULES=3D$git_submodules" >> $config_host_mak =20 echo "ARCH=3D$ARCH" >> $config_host_mak =20 diff --git a/Makefile b/Makefile index cee6e28659..cec0f44374 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,29 @@ ifneq ($(wildcard config-host.mak),) all: include config-host.mak =20 +git-submodule-update: + +.PHONY: git-submodule-update + +ifeq (0,$(MAKELEVEL)) + git_module_status :=3D $(shell \ + cd '$(SRC_PATH)' && \ + ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \ + echo $$?; \ + ) + +ifeq (1,$(git_module_status)) +git-submodule-update: + $(call quiet-command, \ + (cd $(SRC_PATH) && ./scripts/git-submodule.sh update $(GIT_SUBMO= DULES)), \ + "GIT","$(GIT_SUBMODULES)") +endif +endif + +.git-submodule-status: git-submodule-update + +Makefile: .git-submodule-status + # Check that we're not trying to do an out-of-tree build from # a tree that's been used for an in-tree build. ifneq ($(realpath $(SRC_PATH)),$(realpath .)) @@ -330,7 +353,7 @@ DTC_MAKE_ARGS=3D-I$(SRC_PATH)/dtc VPATH=3D$(SRC_PATH)/d= tc -C dtc V=3D"$(V)" LIBFDT_src DTC_CFLAGS=3D$(CFLAGS) $(QEMU_CFLAGS) DTC_CPPFLAGS=3D-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libf= dt =20 -subdir-dtc:dtc/libfdt dtc/tests +subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests $(call quiet-command,$(MAKE) $(DTC_MAKE_ARGS) CPPFLAGS=3D"$(DTC_CPPFLAGS)= " CFLAGS=3D"$(DTC_CFLAGS)" LDFLAGS=3D"$(LDFLAGS)" ARFLAGS=3D"$(ARFLAGS)" CC= =3D"$(CC)" AR=3D"$(AR)" LD=3D"$(LD)" $(SUBDIR_MAKEFLAGS) libfdt/libfdt.a,) =20 dtc/%: diff --git a/.gitignore b/.gitignore index 3a7e01dc6a..b5e115d96b 100644 --- a/.gitignore +++ b/.gitignore @@ -113,6 +113,7 @@ /docs/version.texi *.tps .stgit-* +.git-submodule-status cscope.* tags TAGS diff --git a/MAINTAINERS b/MAINTAINERS index 932443df41..7708bbb21d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1947,3 +1947,9 @@ M: Daniel P. Berrange S: Odd Fixes F: docs/devel/build-system.txt =20 +Build System +------------ +GIT submodules +M: Daniel P. Berrange +S: Odd Fixes +F: scripts/git-submodule.sh diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh new file mode 100755 index 0000000000..9f73f0e6e3 --- /dev/null +++ b/scripts/git-submodule.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# This code is licensed under the GPL version 2 or later. See +# the COPYING file in the top-level directory. + +set -e + +substat=3D".git-submodule-status" + +command=3D$1 +shift +modules=3D"$@" + +if test -z "$modules" +then + test -e $substat || touch $substat + exit 0 +fi + +if ! test -e ".git" +then + echo "$0: unexpectedly called with submodules but no git checkout exis= ts" + exit 1 +fi + +case "$command" in +status) + test -f "$substat" || exit 1 + trap "rm -f ${substat}.tmp" EXIT + git submodule status $modules > "${substat}.tmp" + diff "${substat}" "${substat}.tmp" >/dev/null + exit $? + ;; +update) + git submodule update --init $modules 1>/dev/null 2>&1 + git submodule status $modules > "${substat}" + ;; +esac --=20 2.9.3 From nobody Mon Apr 29 03:26:59 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507198037732760.2845310208568; Thu, 5 Oct 2017 03:07:17 -0700 (PDT) Received: from localhost ([::1]:38811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e033e-0001G0-1P for importer@patchew.org; Thu, 05 Oct 2017 06:07:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e02xw-00054U-Ib for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e02xu-0005SJ-1U for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57752) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e02xt-0005Q3-QK for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA20BC04AC41 for ; Thu, 5 Oct 2017 10:01:12 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDECD5D9C0; Thu, 5 Oct 2017 10:01:08 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C724166; Thu, 5 Oct 2017 12:01:06 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CA20BC04AC41 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 12:01:02 +0200 Message-Id: <20171005100106.30118-3-kraxel@redhat.com> In-Reply-To: <20171005100106.30118-1-kraxel@redhat.com> References: <20171005100106.30118-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 05 Oct 2017 10:01:12 +0000 (UTC) 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] [PULL 2/6] docker: don't rely on submodules existing in the main checkout 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" When building the tarball to pass into the docker/vm test image, the code relies on the git submodules being checked out in the main checkout. ie if the developer has not run 'git submodule update --init dtc' many of the docker tests will fail due to the libfdt package not being present in the test images. Patchew manually checks out the dtc submodule in the main git checkout, but this is a bad idea. When running tests we want to have a predictable set of submodules included in the source that's tested. The build environment is completely independent of the developers host OS, so the submodules the developer has checked out should not be considered relevant for the tests. This changes the archive-source.sh script so that it clones the current git checkout into a temporary directory, checks out a fixed set of submodules, builds the tarball and finally removes the temporary git clone. Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-3-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- scripts/archive-source.sh | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index c4e7d98f4d..4029de7b20 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -18,15 +18,37 @@ if test $# -lt 1; then error "Usage: $0 " fi =20 -tar_file=3D"$1" -list_file=3D"$1.list" -submodules=3D$(git submodule foreach --recursive --quiet 'echo $name') +tar_file=3D`realpath "$1"` +list_file=3D"${tar_file}.list" +vroot_dir=3D"${tar_file}.vroot" =20 -if test $? -ne 0; then - error "git submodule command failed" +# We want a predictable list of submodules for builds, that is +# independent of what the developer currently has initialized +# in their checkout, because the build environment is completely +# different to the host OS. +submodules=3D"dtc" + +trap "status=3D$?; rm -rf \"$list_file\" \"$vroot_dir\"; exit \$status" 0 = 1 2 3 15 + +if git diff-index --quiet HEAD -- &>/dev/null +then + HEAD=3DHEAD +else + HEAD=3D`git stash create` fi +git clone --shared . "$vroot_dir" +test $? -ne 0 && error "failed to clone into '$vroot_dir'" =20 -trap "status=3D$?; rm -f \"$list_file\"; exit \$status" 0 1 2 3 15 +cd "$vroot_dir" +test $? -ne 0 && error "failed to change into '$vroot_dir'" + +git checkout $HEAD +test $? -ne 0 && error "failed to checkout $HEAD revision" + +for sm in $submodules; do + git submodule update --init $sm + test $? -ne 0 && error "failed to init submodule $sm" +done =20 if test -n "$submodules"; then { --=20 2.9.3 From nobody Mon Apr 29 03:26:59 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 1507197802395518.4775951659432; Thu, 5 Oct 2017 03:03:22 -0700 (PDT) Received: from localhost ([::1]:38754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e02zu-0006ew-Kh for importer@patchew.org; Thu, 05 Oct 2017 06:03:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e02xx-00054u-CR for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e02xt-0005Pj-4i for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42184) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e02xs-0005O9-T9 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:13 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E5CC37F402 for ; Thu, 5 Oct 2017 10:01:11 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7BBF62690; Thu, 5 Oct 2017 10:01:08 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D2E0417531; Thu, 5 Oct 2017 12:01:06 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E5CC37F402 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 12:01:03 +0200 Message-Id: <20171005100106.30118-4-kraxel@redhat.com> In-Reply-To: <20171005100106.30118-1-kraxel@redhat.com> References: <20171005100106.30118-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 05 Oct 2017 10:01:12 +0000 (UTC) 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] [PULL 3/6] ui: add keycodemapdb repository as a GIT submodule 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The https://gitlab.com/keycodemap/keycodemapdb/ repo contains a data file mapping between all the different scancode/keycode/keysym sets that are known, and a tool to auto-generate lookup tables for different combinations. It is used by GTK-VNC, SPICE-GTK and libvirt for mapping keys. Using it in QEMU will let us replace many hand written lookup tables with auto-generated tables from a master data source, reducing bugs. Adding new QKeyCodes will now only require the master table to be updated, all ~20 other tables will be automatically updated to follow. Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-4-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- configure | 8 +++++++- Makefile | 18 ++++++++++++++++++ .gitignore | 1 + .gitmodules | 3 +++ scripts/archive-source.sh | 2 +- ui/keycodemapdb | 1 + 6 files changed, 31 insertions(+), 2 deletions(-) create mode 160000 ui/keycodemapdb diff --git a/configure b/configure index 38f1710c80..06f18ea9af 100755 --- a/configure +++ b/configure @@ -264,7 +264,13 @@ cc_i386=3Di386-pc-linux-gnu-gcc libs_qga=3D"" debug_info=3D"yes" stack_protector=3D"" -git_submodules=3D"" + +if test -e "$source_path/.git" +then + git_submodules=3D"ui/keycodemapdb" +else + git_submodules=3D"" +fi =20 # Don't accept a target_list environment variable. unset target_list diff --git a/Makefile b/Makefile index cec0f44374..d2bada4d8b 100644 --- a/Makefile +++ b/Makefile @@ -214,6 +214,24 @@ trace-dtrace-root.h: trace-dtrace-root.dtrace =20 trace-dtrace-root.o: trace-dtrace-root.dtrace =20 +KEYCODEMAP_GEN =3D $(SRC_PATH)/ui/keycodemapdb/tools/keymap-gen +KEYCODEMAP_CSV =3D $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv + +KEYCODEMAP_FILES =3D \ + $(NULL) + +GENERATED_FILES +=3D $(KEYCODEMAP_FILES) + +ui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) $(SRC_PATH)/ui/Ma= kefile.objs .git-submodule-status + $(call quiet-command,\ + src=3D$$(echo $@ | sed -E -e "s,^ui/input-keymap-(.+)-to-(.+)\.c$$,\1= ,") && \ + dst=3D$$(echo $@ | sed -E -e "s,^ui/input-keymap-(.+)-to-(.+)\.c$$,\2= ,") && \ + $(PYTHON) $(KEYCODEMAP_GEN) \ + --lang glib2 \ + --varname qemu_input_map_$${src}_to_$${dst} \ + code-map $(KEYCODEMAP_CSV) $${src} $${dst} \ + > $@ || rm $@, "GEN", "$@") + # Don't try to regenerate Makefile or configure # We don't generate any of them Makefile: ; diff --git a/.gitignore b/.gitignore index b5e115d96b..620eec6b47 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ /trace/generated-tcg-tracers.h /ui/shader/texture-blit-frag.h /ui/shader/texture-blit-vert.h +/ui/input-keymap-*.c *-timestamp /*-softmmu /*-darwin-user diff --git a/.gitmodules b/.gitmodules index 84c54cdc49..f3bbc01f82 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,3 +34,6 @@ [submodule "roms/QemuMacDrivers"] path =3D roms/QemuMacDrivers url =3D git://git.qemu.org/QemuMacDrivers.git +[submodule "ui/keycodemapdb"] + path =3D ui/keycodemapdb + url =3D https://gitlab.com/keycodemap/keycodemapdb.git diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index 4029de7b20..4e63774f9a 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -26,7 +26,7 @@ vroot_dir=3D"${tar_file}.vroot" # independent of what the developer currently has initialized # in their checkout, because the build environment is completely # different to the host OS. -submodules=3D"dtc" +submodules=3D"dtc ui/keycodemapdb" =20 trap "status=3D$?; rm -rf \"$list_file\" \"$vroot_dir\"; exit \$status" 0 = 1 2 3 15 =20 diff --git a/ui/keycodemapdb b/ui/keycodemapdb new file mode 160000 index 0000000000..56ce5650d2 --- /dev/null +++ b/ui/keycodemapdb @@ -0,0 +1 @@ +Subproject commit 56ce5650d2c6ea216b4580df44b9a6dd3bc92c3b --=20 2.9.3 From nobody Mon Apr 29 03:26:59 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507197945221903.546762861177; Thu, 5 Oct 2017 03:05:45 -0700 (PDT) Received: from localhost ([::1]:38789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0327-0000Ag-Ak for importer@patchew.org; Thu, 05 Oct 2017 06:05:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e02xy-00055X-Lb for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e02xt-0005Qd-IY for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52834) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e02xt-0005P7-9U for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:13 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A8A513A42 for ; Thu, 5 Oct 2017 10:01:12 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id E41735EE02; Thu, 5 Oct 2017 10:01:08 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E20D23F116; Thu, 5 Oct 2017 12:01:06 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4A8A513A42 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=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 12:01:04 +0200 Message-Id: <20171005100106.30118-5-kraxel@redhat.com> In-Reply-To: <20171005100106.30118-1-kraxel@redhat.com> References: <20171005100106.30118-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 05 Oct 2017 10:01:12 +0000 (UTC) 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] [PULL 4/6] ui: convert common input code to keycodemapdb 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Replace the number_to_qcode, qcode_to_number and linux_to_qcode tables with automatically generated tables. Missing entries in linux_to_qcode now fixed: KEY_LINEFEED -> Q_KEY_CODE_LF KEY_KPEQUAL -> Q_KEY_CODE_KP_EQUALS KEY_COMPOSE -> Q_KEY_CODE_COMPOSE KEY_AGAIN -> Q_KEY_CODE_AGAIN KEY_PROPS -> Q_KEY_CODE_PROPS KEY_UNDO -> Q_KEY_CODE_UNDO KEY_FRONT -> Q_KEY_CODE_FRONT KEY_COPY -> Q_KEY_CODE_COPY KEY_OPEN -> Q_KEY_CODE_OPEN KEY_PASTE -> Q_KEY_CODE_PASTE KEY_CUT -> Q_KEY_CODE_CUT KEY_HELP -> Q_KEY_CODE_HELP KEY_MEDIA -> Q_KEY_CODE_MEDIASELECT In addition, some fixes: - KEY_PLAYPAUSE now maps to Q_KEY_CODE_AUDIOPLAY, instead of KEY_PLAYCD. KEY_PLAYPAUSE is defined across almost all scancodes sets, while KEY_PLAYCD only appears in AT set1, so the former is a more useful mapping. Missing entries in qcode_to_number now fixed: Q_KEY_CODE_AGAIN -> 0x85 Q_KEY_CODE_PROPS -> 0x86 Q_KEY_CODE_UNDO -> 0x87 Q_KEY_CODE_FRONT -> 0x8c Q_KEY_CODE_COPY -> 0xf8 Q_KEY_CODE_OPEN -> 0x64 Q_KEY_CODE_PASTE -> 0x65 Q_KEY_CODE_CUT -> 0xbc Q_KEY_CODE_LF -> 0x5b Q_KEY_CODE_HELP -> 0xf5 Q_KEY_CODE_COMPOSE -> 0xdd Q_KEY_CODE_KP_EQUALS -> 0x59 Q_KEY_CODE_MEDIASELECT -> 0xed In addition, some fixes: - Q_KEY_CODE_MENU was incorrectly mapped to the compose scancode (0xdd) and is now mapped to 0x9e - Q_KEY_CODE_FIND was mapped to 0xe065 (Search) instead of to 0xe041 (Find) - Q_KEY_CODE_HIRAGANA was mapped to 0x70 (Katakanahiragana) instead of of 0x77 (Hirigana) - Q_KEY_CODE_PRINT was mapped to 0xb7 which is not a defined scan code in AT set 1, it is now mapped to 0x54 (sysrq) Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-5-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- Makefile | 3 + include/ui/input.h | 11 +- ui/input-keymap.c | 336 ++++---------------------------------------------= ---- 3 files changed, 33 insertions(+), 317 deletions(-) diff --git a/Makefile b/Makefile index d2bada4d8b..1d3b31f074 100644 --- a/Makefile +++ b/Makefile @@ -218,6 +218,9 @@ KEYCODEMAP_GEN =3D $(SRC_PATH)/ui/keycodemapdb/tools/ke= ymap-gen KEYCODEMAP_CSV =3D $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv =20 KEYCODEMAP_FILES =3D \ + ui/input-keymap-linux-to-qcode.c \ + ui/input-keymap-qcode-to-qnum.c \ + ui/input-keymap-qnum-to-qcode.c \ $(NULL) =20 GENERATED_FILES +=3D $(KEYCODEMAP_FILES) diff --git a/include/ui/input.h b/include/ui/input.h index c488585def..479cc46cfc 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -43,7 +43,7 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue= *key, bool down); void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down= ); void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool do= wn); void qemu_input_event_send_key_delay(uint32_t delay_ms); -int qemu_input_key_number_to_qcode(uint8_t nr); +int qemu_input_key_number_to_qcode(unsigned int nr); int qemu_input_key_value_to_number(const KeyValue *value); int qemu_input_key_value_to_qcode(const KeyValue *value); int qemu_input_key_value_to_scancode(const KeyValue *value, bool down, @@ -69,4 +69,13 @@ void qemu_input_check_mode_change(void); void qemu_add_mouse_mode_change_notifier(Notifier *notify); void qemu_remove_mouse_mode_change_notifier(Notifier *notify); =20 +extern const guint qemu_input_map_linux_to_qcode_len; +extern const guint16 qemu_input_map_linux_to_qcode[]; + +extern const guint qemu_input_map_qcode_to_qnum_len; +extern const guint16 qemu_input_map_qcode_to_qnum[]; + +extern const guint qemu_input_map_qnum_to_qcode_len; +extern const guint16 qemu_input_map_qnum_to_qcode[]; + #endif /* INPUT_H */ diff --git a/ui/input-keymap.c b/ui/input-keymap.c index cf979c2ce9..3a19a169f5 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -5,333 +5,37 @@ =20 #include "standard-headers/linux/input.h" =20 -static int linux_to_qcode[KEY_CNT] =3D { - [KEY_ESC] =3D Q_KEY_CODE_ESC, - [KEY_1] =3D Q_KEY_CODE_1, - [KEY_2] =3D Q_KEY_CODE_2, - [KEY_3] =3D Q_KEY_CODE_3, - [KEY_4] =3D Q_KEY_CODE_4, - [KEY_5] =3D Q_KEY_CODE_5, - [KEY_6] =3D Q_KEY_CODE_6, - [KEY_7] =3D Q_KEY_CODE_7, - [KEY_8] =3D Q_KEY_CODE_8, - [KEY_9] =3D Q_KEY_CODE_9, - [KEY_0] =3D Q_KEY_CODE_0, - [KEY_MINUS] =3D Q_KEY_CODE_MINUS, - [KEY_EQUAL] =3D Q_KEY_CODE_EQUAL, - [KEY_BACKSPACE] =3D Q_KEY_CODE_BACKSPACE, - [KEY_TAB] =3D Q_KEY_CODE_TAB, - [KEY_Q] =3D Q_KEY_CODE_Q, - [KEY_W] =3D Q_KEY_CODE_W, - [KEY_E] =3D Q_KEY_CODE_E, - [KEY_R] =3D Q_KEY_CODE_R, - [KEY_T] =3D Q_KEY_CODE_T, - [KEY_Y] =3D Q_KEY_CODE_Y, - [KEY_U] =3D Q_KEY_CODE_U, - [KEY_I] =3D Q_KEY_CODE_I, - [KEY_O] =3D Q_KEY_CODE_O, - [KEY_P] =3D Q_KEY_CODE_P, - [KEY_LEFTBRACE] =3D Q_KEY_CODE_BRACKET_LEFT, - [KEY_RIGHTBRACE] =3D Q_KEY_CODE_BRACKET_RIGHT, - [KEY_ENTER] =3D Q_KEY_CODE_RET, - [KEY_LEFTCTRL] =3D Q_KEY_CODE_CTRL, - [KEY_A] =3D Q_KEY_CODE_A, - [KEY_S] =3D Q_KEY_CODE_S, - [KEY_D] =3D Q_KEY_CODE_D, - [KEY_F] =3D Q_KEY_CODE_F, - [KEY_G] =3D Q_KEY_CODE_G, - [KEY_H] =3D Q_KEY_CODE_H, - [KEY_J] =3D Q_KEY_CODE_J, - [KEY_K] =3D Q_KEY_CODE_K, - [KEY_L] =3D Q_KEY_CODE_L, - [KEY_SEMICOLON] =3D Q_KEY_CODE_SEMICOLON, - [KEY_APOSTROPHE] =3D Q_KEY_CODE_APOSTROPHE, - [KEY_GRAVE] =3D Q_KEY_CODE_GRAVE_ACCENT, - [KEY_LEFTSHIFT] =3D Q_KEY_CODE_SHIFT, - [KEY_BACKSLASH] =3D Q_KEY_CODE_BACKSLASH, - [KEY_102ND] =3D Q_KEY_CODE_LESS, - [KEY_Z] =3D Q_KEY_CODE_Z, - [KEY_X] =3D Q_KEY_CODE_X, - [KEY_C] =3D Q_KEY_CODE_C, - [KEY_V] =3D Q_KEY_CODE_V, - [KEY_B] =3D Q_KEY_CODE_B, - [KEY_N] =3D Q_KEY_CODE_N, - [KEY_M] =3D Q_KEY_CODE_M, - [KEY_COMMA] =3D Q_KEY_CODE_COMMA, - [KEY_DOT] =3D Q_KEY_CODE_DOT, - [KEY_SLASH] =3D Q_KEY_CODE_SLASH, - [KEY_RIGHTSHIFT] =3D Q_KEY_CODE_SHIFT_R, - [KEY_LEFTALT] =3D Q_KEY_CODE_ALT, - [KEY_SPACE] =3D Q_KEY_CODE_SPC, - [KEY_CAPSLOCK] =3D Q_KEY_CODE_CAPS_LOCK, - [KEY_F1] =3D Q_KEY_CODE_F1, - [KEY_F2] =3D Q_KEY_CODE_F2, - [KEY_F3] =3D Q_KEY_CODE_F3, - [KEY_F4] =3D Q_KEY_CODE_F4, - [KEY_F5] =3D Q_KEY_CODE_F5, - [KEY_F6] =3D Q_KEY_CODE_F6, - [KEY_F7] =3D Q_KEY_CODE_F7, - [KEY_F8] =3D Q_KEY_CODE_F8, - [KEY_F9] =3D Q_KEY_CODE_F9, - [KEY_F10] =3D Q_KEY_CODE_F10, - [KEY_NUMLOCK] =3D Q_KEY_CODE_NUM_LOCK, - [KEY_SCROLLLOCK] =3D Q_KEY_CODE_SCROLL_LOCK, - [KEY_KP0] =3D Q_KEY_CODE_KP_0, - [KEY_KP1] =3D Q_KEY_CODE_KP_1, - [KEY_KP2] =3D Q_KEY_CODE_KP_2, - [KEY_KP3] =3D Q_KEY_CODE_KP_3, - [KEY_KP4] =3D Q_KEY_CODE_KP_4, - [KEY_KP5] =3D Q_KEY_CODE_KP_5, - [KEY_KP6] =3D Q_KEY_CODE_KP_6, - [KEY_KP7] =3D Q_KEY_CODE_KP_7, - [KEY_KP8] =3D Q_KEY_CODE_KP_8, - [KEY_KP9] =3D Q_KEY_CODE_KP_9, - [KEY_KPMINUS] =3D Q_KEY_CODE_KP_SUBTRACT, - [KEY_KPPLUS] =3D Q_KEY_CODE_KP_ADD, - [KEY_KPDOT] =3D Q_KEY_CODE_KP_DECIMAL, - [KEY_KPENTER] =3D Q_KEY_CODE_KP_ENTER, - [KEY_KPSLASH] =3D Q_KEY_CODE_KP_DIVIDE, - [KEY_KPASTERISK] =3D Q_KEY_CODE_KP_MULTIPLY, - [KEY_F11] =3D Q_KEY_CODE_F11, - [KEY_F12] =3D Q_KEY_CODE_F12, - [KEY_RO] =3D Q_KEY_CODE_RO, - [KEY_HIRAGANA] =3D Q_KEY_CODE_HIRAGANA, - [KEY_HENKAN] =3D Q_KEY_CODE_HENKAN, - [KEY_RIGHTCTRL] =3D Q_KEY_CODE_CTRL_R, - [KEY_SYSRQ] =3D Q_KEY_CODE_SYSRQ, - [KEY_RIGHTALT] =3D Q_KEY_CODE_ALT_R, - [KEY_HOME] =3D Q_KEY_CODE_HOME, - [KEY_UP] =3D Q_KEY_CODE_UP, - [KEY_PAGEUP] =3D Q_KEY_CODE_PGUP, - [KEY_LEFT] =3D Q_KEY_CODE_LEFT, - [KEY_RIGHT] =3D Q_KEY_CODE_RIGHT, - [KEY_END] =3D Q_KEY_CODE_END, - [KEY_DOWN] =3D Q_KEY_CODE_DOWN, - [KEY_PAGEDOWN] =3D Q_KEY_CODE_PGDN, - [KEY_INSERT] =3D Q_KEY_CODE_INSERT, - [KEY_DELETE] =3D Q_KEY_CODE_DELETE, - [KEY_POWER] =3D Q_KEY_CODE_POWER, - [KEY_KPCOMMA] =3D Q_KEY_CODE_KP_COMMA, - [KEY_YEN] =3D Q_KEY_CODE_YEN, - [KEY_LEFTMETA] =3D Q_KEY_CODE_META_L, - [KEY_RIGHTMETA] =3D Q_KEY_CODE_META_R, - [KEY_MENU] =3D Q_KEY_CODE_MENU, - [KEY_PAUSE] =3D Q_KEY_CODE_PAUSE, - - [KEY_SLEEP] =3D Q_KEY_CODE_SLEEP, - [KEY_WAKEUP] =3D Q_KEY_CODE_WAKE, - [KEY_CALC] =3D Q_KEY_CODE_CALCULATOR, - [KEY_MAIL] =3D Q_KEY_CODE_MAIL, - [KEY_COMPUTER] =3D Q_KEY_CODE_COMPUTER, - - [KEY_STOP] =3D Q_KEY_CODE_STOP, - [KEY_BOOKMARKS] =3D Q_KEY_CODE_AC_BOOKMARKS, - [KEY_BACK] =3D Q_KEY_CODE_AC_BACK, - [KEY_FORWARD] =3D Q_KEY_CODE_AC_FORWARD, - [KEY_HOMEPAGE] =3D Q_KEY_CODE_AC_HOME, - [KEY_REFRESH] =3D Q_KEY_CODE_AC_REFRESH, - [KEY_FIND] =3D Q_KEY_CODE_FIND, - - [KEY_NEXTSONG] =3D Q_KEY_CODE_AUDIONEXT, - [KEY_PREVIOUSSONG] =3D Q_KEY_CODE_AUDIOPREV, - [KEY_STOPCD] =3D Q_KEY_CODE_AUDIOSTOP, - [KEY_PLAYCD] =3D Q_KEY_CODE_AUDIOPLAY, - [KEY_MUTE] =3D Q_KEY_CODE_AUDIOMUTE, - [KEY_VOLUMEDOWN] =3D Q_KEY_CODE_VOLUMEDOWN, - [KEY_VOLUMEUP] =3D Q_KEY_CODE_VOLUMEUP, -}; - -static const int qcode_to_number[] =3D { - [Q_KEY_CODE_SHIFT] =3D 0x2a, - [Q_KEY_CODE_SHIFT_R] =3D 0x36, - - [Q_KEY_CODE_ALT] =3D 0x38, - [Q_KEY_CODE_ALT_R] =3D 0xb8, - [Q_KEY_CODE_CTRL] =3D 0x1d, - [Q_KEY_CODE_CTRL_R] =3D 0x9d, - - [Q_KEY_CODE_META_L] =3D 0xdb, - [Q_KEY_CODE_META_R] =3D 0xdc, - [Q_KEY_CODE_MENU] =3D 0xdd, - - [Q_KEY_CODE_ESC] =3D 0x01, - - [Q_KEY_CODE_1] =3D 0x02, - [Q_KEY_CODE_2] =3D 0x03, - [Q_KEY_CODE_3] =3D 0x04, - [Q_KEY_CODE_4] =3D 0x05, - [Q_KEY_CODE_5] =3D 0x06, - [Q_KEY_CODE_6] =3D 0x07, - [Q_KEY_CODE_7] =3D 0x08, - [Q_KEY_CODE_8] =3D 0x09, - [Q_KEY_CODE_9] =3D 0x0a, - [Q_KEY_CODE_0] =3D 0x0b, - [Q_KEY_CODE_MINUS] =3D 0x0c, - [Q_KEY_CODE_EQUAL] =3D 0x0d, - [Q_KEY_CODE_BACKSPACE] =3D 0x0e, - - [Q_KEY_CODE_TAB] =3D 0x0f, - [Q_KEY_CODE_Q] =3D 0x10, - [Q_KEY_CODE_W] =3D 0x11, - [Q_KEY_CODE_E] =3D 0x12, - [Q_KEY_CODE_R] =3D 0x13, - [Q_KEY_CODE_T] =3D 0x14, - [Q_KEY_CODE_Y] =3D 0x15, - [Q_KEY_CODE_U] =3D 0x16, - [Q_KEY_CODE_I] =3D 0x17, - [Q_KEY_CODE_O] =3D 0x18, - [Q_KEY_CODE_P] =3D 0x19, - [Q_KEY_CODE_BRACKET_LEFT] =3D 0x1a, - [Q_KEY_CODE_BRACKET_RIGHT] =3D 0x1b, - [Q_KEY_CODE_RET] =3D 0x1c, - - [Q_KEY_CODE_A] =3D 0x1e, - [Q_KEY_CODE_S] =3D 0x1f, - [Q_KEY_CODE_D] =3D 0x20, - [Q_KEY_CODE_F] =3D 0x21, - [Q_KEY_CODE_G] =3D 0x22, - [Q_KEY_CODE_H] =3D 0x23, - [Q_KEY_CODE_J] =3D 0x24, - [Q_KEY_CODE_K] =3D 0x25, - [Q_KEY_CODE_L] =3D 0x26, - [Q_KEY_CODE_SEMICOLON] =3D 0x27, - [Q_KEY_CODE_APOSTROPHE] =3D 0x28, - [Q_KEY_CODE_GRAVE_ACCENT] =3D 0x29, - - [Q_KEY_CODE_BACKSLASH] =3D 0x2b, - [Q_KEY_CODE_Z] =3D 0x2c, - [Q_KEY_CODE_X] =3D 0x2d, - [Q_KEY_CODE_C] =3D 0x2e, - [Q_KEY_CODE_V] =3D 0x2f, - [Q_KEY_CODE_B] =3D 0x30, - [Q_KEY_CODE_N] =3D 0x31, - [Q_KEY_CODE_M] =3D 0x32, - [Q_KEY_CODE_COMMA] =3D 0x33, - [Q_KEY_CODE_DOT] =3D 0x34, - [Q_KEY_CODE_SLASH] =3D 0x35, - - [Q_KEY_CODE_ASTERISK] =3D 0x37, - - [Q_KEY_CODE_SPC] =3D 0x39, - [Q_KEY_CODE_CAPS_LOCK] =3D 0x3a, - [Q_KEY_CODE_F1] =3D 0x3b, - [Q_KEY_CODE_F2] =3D 0x3c, - [Q_KEY_CODE_F3] =3D 0x3d, - [Q_KEY_CODE_F4] =3D 0x3e, - [Q_KEY_CODE_F5] =3D 0x3f, - [Q_KEY_CODE_F6] =3D 0x40, - [Q_KEY_CODE_F7] =3D 0x41, - [Q_KEY_CODE_F8] =3D 0x42, - [Q_KEY_CODE_F9] =3D 0x43, - [Q_KEY_CODE_F10] =3D 0x44, - [Q_KEY_CODE_NUM_LOCK] =3D 0x45, - [Q_KEY_CODE_SCROLL_LOCK] =3D 0x46, - - [Q_KEY_CODE_KP_DIVIDE] =3D 0xb5, - [Q_KEY_CODE_KP_MULTIPLY] =3D 0x37, - [Q_KEY_CODE_KP_SUBTRACT] =3D 0x4a, - [Q_KEY_CODE_KP_ADD] =3D 0x4e, - [Q_KEY_CODE_KP_ENTER] =3D 0x9c, - [Q_KEY_CODE_KP_DECIMAL] =3D 0x53, - [Q_KEY_CODE_SYSRQ] =3D 0x54, - [Q_KEY_CODE_PAUSE] =3D 0xc6, - - [Q_KEY_CODE_KP_0] =3D 0x52, - [Q_KEY_CODE_KP_1] =3D 0x4f, - [Q_KEY_CODE_KP_2] =3D 0x50, - [Q_KEY_CODE_KP_3] =3D 0x51, - [Q_KEY_CODE_KP_4] =3D 0x4b, - [Q_KEY_CODE_KP_5] =3D 0x4c, - [Q_KEY_CODE_KP_6] =3D 0x4d, - [Q_KEY_CODE_KP_7] =3D 0x47, - [Q_KEY_CODE_KP_8] =3D 0x48, - [Q_KEY_CODE_KP_9] =3D 0x49, - - [Q_KEY_CODE_LESS] =3D 0x56, - - [Q_KEY_CODE_F11] =3D 0x57, - [Q_KEY_CODE_F12] =3D 0x58, - - [Q_KEY_CODE_PRINT] =3D 0xb7, - - [Q_KEY_CODE_HOME] =3D 0xc7, - [Q_KEY_CODE_PGUP] =3D 0xc9, - [Q_KEY_CODE_PGDN] =3D 0xd1, - [Q_KEY_CODE_END] =3D 0xcf, - - [Q_KEY_CODE_LEFT] =3D 0xcb, - [Q_KEY_CODE_UP] =3D 0xc8, - [Q_KEY_CODE_DOWN] =3D 0xd0, - [Q_KEY_CODE_RIGHT] =3D 0xcd, - - [Q_KEY_CODE_INSERT] =3D 0xd2, - [Q_KEY_CODE_DELETE] =3D 0xd3, - - [Q_KEY_CODE_RO] =3D 0x73, - [Q_KEY_CODE_HIRAGANA] =3D 0x70, - [Q_KEY_CODE_HENKAN] =3D 0x79, - [Q_KEY_CODE_POWER] =3D 0xde, - [Q_KEY_CODE_YEN] =3D 0x7d, - [Q_KEY_CODE_KP_COMMA] =3D 0x7e, - - [Q_KEY_CODE_SLEEP] =3D 0xdf, - [Q_KEY_CODE_WAKE] =3D 0xe3, - [Q_KEY_CODE_CALCULATOR] =3D 0xa1, - [Q_KEY_CODE_MAIL] =3D 0xec, - [Q_KEY_CODE_COMPUTER] =3D 0xeb, - - [Q_KEY_CODE_STOP] =3D 0xe8, - [Q_KEY_CODE_AC_BOOKMARKS] =3D 0xe6, - [Q_KEY_CODE_AC_BACK] =3D 0xea, - [Q_KEY_CODE_AC_FORWARD] =3D 0xe9, - [Q_KEY_CODE_AC_HOME] =3D 0xb2, - [Q_KEY_CODE_AC_REFRESH] =3D 0xe7, - [Q_KEY_CODE_FIND] =3D 0xe5, - - [Q_KEY_CODE_AUDIONEXT] =3D 0x99, - [Q_KEY_CODE_AUDIOPREV] =3D 0x90, - [Q_KEY_CODE_AUDIOSTOP] =3D 0xa4, - [Q_KEY_CODE_AUDIOPLAY] =3D 0xa2, - [Q_KEY_CODE_AUDIOMUTE] =3D 0xa0, - [Q_KEY_CODE_VOLUMEDOWN] =3D 0xae, - [Q_KEY_CODE_VOLUMEUP] =3D 0xb0, - - [Q_KEY_CODE__MAX] =3D 0, -}; - -static int number_to_qcode[0x100]; +#include "ui/input-keymap-linux-to-qcode.c" +#include "ui/input-keymap-qcode-to-qnum.c" +#include "ui/input-keymap-qnum-to-qcode.c" =20 int qemu_input_linux_to_qcode(unsigned int lnx) { - assert(lnx < KEY_CNT); - return linux_to_qcode[lnx]; + if (lnx >=3D qemu_input_map_linux_to_qcode_len) { + return 0; + } + return qemu_input_map_linux_to_qcode[lnx]; } =20 int qemu_input_key_value_to_number(const KeyValue *value) { if (value->type =3D=3D KEY_VALUE_KIND_QCODE) { - return qcode_to_number[value->u.qcode.data]; - } else { - assert(value->type =3D=3D KEY_VALUE_KIND_NUMBER); - return value->u.number.data; - } -} - -int qemu_input_key_number_to_qcode(uint8_t nr) -{ - static int first =3D true; - - if (first) { - int qcode, number; - first =3D false; - for (qcode =3D 0; qcode < Q_KEY_CODE__MAX; qcode++) { - number =3D qcode_to_number[qcode]; - assert(number < ARRAY_SIZE(number_to_qcode)); - number_to_qcode[number] =3D qcode; + if (value->u.qcode.data >=3D qemu_input_map_qcode_to_qnum_len) { + return 0; } + return qemu_input_map_qcode_to_qnum[value->u.qcode.data]; + } else { + assert(value->type =3D=3D KEY_VALUE_KIND_NUMBER); + return value->u.number.data; } +} =20 - return number_to_qcode[nr]; +int qemu_input_key_number_to_qcode(unsigned int nr) +{ + if (nr >=3D qemu_input_map_qnum_to_qcode_len) { + return 0; + } + return qemu_input_map_qnum_to_qcode[nr]; } =20 int qemu_input_key_value_to_qcode(const KeyValue *value) --=20 2.9.3 From nobody Mon Apr 29 03:26:59 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 15071978063976.180274503983128; Thu, 5 Oct 2017 03:03:26 -0700 (PDT) Received: from localhost ([::1]:38755 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e02zv-0006fL-Kd for importer@patchew.org; Thu, 05 Oct 2017 06:03:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e02y1-00057W-K7 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e02xu-0005Sl-I8 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42240) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e02xu-0005Rn-Aa for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A18381E04 for ; Thu, 5 Oct 2017 10:01:13 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8C185EE02; Thu, 5 Oct 2017 10:01:12 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E922B42293; Thu, 5 Oct 2017 12:01:06 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5A18381E04 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 12:01:05 +0200 Message-Id: <20171005100106.30118-6-kraxel@redhat.com> In-Reply-To: <20171005100106.30118-1-kraxel@redhat.com> References: <20171005100106.30118-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 05 Oct 2017 10:01:13 +0000 (UTC) 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] [PULL 5/6] ui: convert key events to QKeyCodes immediately 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Always use QKeyCode in the InputKeyEvent struct, by converting key numbers to QKeyCode at the time the event is created. This allows the code processing / consuming key events to assume QKeyCode is used. The only place we accept a key number in the InputKeyEvent struct is with QMP commands sent by the user. Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-6-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/input.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ui/input.c b/ui/input.c index 3422d4a8ef..4b241aa823 100644 --- a/ui/input.c +++ b/ui/input.c @@ -157,9 +157,16 @@ void qmp_input_send_event(bool has_device, const char = *device, } =20 for (e =3D events; e !=3D NULL; e =3D e->next) { - InputEvent *event =3D e->value; + InputEvent *evt =3D e->value; =20 - qemu_input_event_send(con, event); + if (evt->type =3D=3D INPUT_EVENT_KIND_KEY && + evt->u.key.data->key->type =3D=3D KEY_VALUE_KIND_NUMBER) { + KeyValue *key =3D evt->u.key.data->key; + QKeyCode code =3D qemu_input_key_number_to_qcode(key->u.qcode.= data); + qemu_input_event_send_key_qcode(con, code, evt->u.key.data->do= wn); + } else { + qemu_input_event_send(con, evt); + } } =20 qemu_input_event_sync(); @@ -341,6 +348,11 @@ void qemu_input_event_send_impl(QemuConsole *src, Inpu= tEvent *evt) =20 void qemu_input_event_send(QemuConsole *src, InputEvent *evt) { + /* Expect all parts of QEMU to send events with QCodes exclusively. + * Key numbers are only supported as end-user input via QMP */ + assert(!(evt->type =3D=3D INPUT_EVENT_KIND_KEY && + evt->u.key.data->key->type =3D=3D KEY_VALUE_KIND_NUMBER)); + if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { return; } @@ -400,10 +412,8 @@ void qemu_input_event_send_key(QemuConsole *src, KeyVa= lue *key, bool down) =20 void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) { - KeyValue *key =3D g_new0(KeyValue, 1); - key->type =3D KEY_VALUE_KIND_NUMBER; - key->u.number.data =3D num; - qemu_input_event_send_key(src, key, down); + QKeyCode code =3D qemu_input_key_number_to_qcode(num); + qemu_input_event_send_key_qcode(src, code, down); } =20 void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool do= wn) --=20 2.9.3 From nobody Mon Apr 29 03:26:59 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 1507197847843805.602724601047; Thu, 5 Oct 2017 03:04:07 -0700 (PDT) Received: from localhost ([::1]:38756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e030d-0007HD-4p for importer@patchew.org; Thu, 05 Oct 2017 06:04:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e02y1-00057Y-Qy for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e02xw-0005VF-Bk for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35280) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e02xw-0005US-6R for qemu-devel@nongnu.org; Thu, 05 Oct 2017 06:01:16 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38FF7356F2 for ; Thu, 5 Oct 2017 10:01:15 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id C544B5C88F; Thu, 5 Oct 2017 10:01:12 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F1150422E0; Thu, 5 Oct 2017 12:01:06 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 38FF7356F2 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 12:01:06 +0200 Message-Id: <20171005100106.30118-7-kraxel@redhat.com> In-Reply-To: <20171005100106.30118-1-kraxel@redhat.com> References: <20171005100106.30118-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 05 Oct 2017 10:01:15 +0000 (UTC) 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] [PULL 6/6] ui: don't export qemu_input_event_new_key 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" All public code should use qemu_input_event_send_key* functions instead of creating an event directly. Signed-off-by: Daniel P. Berrange Message-id: 20170929101201.21039-7-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- include/ui/input.h | 1 - ui/input.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/ui/input.h b/include/ui/input.h index 479cc46cfc..f8cee43f65 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -38,7 +38,6 @@ void qemu_input_event_send_impl(QemuConsole *src, InputEv= ent *evt); void qemu_input_event_sync(void); void qemu_input_event_sync_impl(void); =20 -InputEvent *qemu_input_event_new_key(KeyValue *key, bool down); void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down); void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down= ); void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool do= wn); diff --git a/ui/input.c b/ui/input.c index 4b241aa823..290b47354a 100644 --- a/ui/input.c +++ b/ui/input.c @@ -386,7 +386,7 @@ void qemu_input_event_sync(void) replay_input_sync_event(); } =20 -InputEvent *qemu_input_event_new_key(KeyValue *key, bool down) +static InputEvent *qemu_input_event_new_key(KeyValue *key, bool down) { InputEvent *evt =3D g_new0(InputEvent, 1); evt->u.key.data =3D g_new0(InputKeyEvent, 1); --=20 2.9.3