Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jLk9X-0007el-6z for mharc-grub-devel@gnu.org; Tue, 07 Apr 2020 05:04:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55342) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLk9T-0007bV-7E for grub-devel@gnu.org; Tue, 07 Apr 2020 05:04:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLk9S-0005hE-36 for grub-devel@gnu.org; Tue, 07 Apr 2020 05:04:11 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:45409 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLk9R-0005gp-Vr for grub-devel@gnu.org; Tue, 07 Apr 2020 05:04:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586250249; 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=rxnijn5NkOIDjajzom/v6reFzXnI5zSZeT8czujJAf0=; b=C39zpgkZyiCqYed0EzXRxE5JpKPkQa3GIBRmONecLp6IWG334uuPYdRVt1VrJr8BwCXUsK 0nBRLVS3YPHsh/PZD6XO5Y6yfNib8LAIyhyWlBtcTiDKupQfLSBRuTvVwUJSZp6U5AqSOO LuLCATtWXPpV/evhqn8fQJwV0pCl29s= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-236-3vPgv0DCMFGzM-mjTeaJRQ-1; Tue, 07 Apr 2020 05:04:08 -0400 X-MC-Unique: 3vPgv0DCMFGzM-mjTeaJRQ-1 Received: by mail-wm1-f70.google.com with SMTP id a4so442073wmb.3 for ; Tue, 07 Apr 2020 02:04:07 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=5sq46MWMTxG11JxhmwjIlnvy/CyvKML1+aulOU13M1E=; b=RdgIHk+Zdmgd0EFrRJebDXz7S//EDsGapQVnDBq0xWUMpfIdwQIFoekiIDpzhH4fOR QubVE4eQASYEgNWnNOMTxBl03XXzBE3mz3P7sU7LctN8cpL0QJ98NgfyfYb6otxZySzV KJqxAtbInfB4dvh6MmkZwvcE6+UlvCAUa+kdqRradMB9PgVAp+1vW8sIQ+i+3XeuYCr1 aDBb9kUV/09q3lrQaBCM6UlFzJxoBp7RnoLx6DypJgwHPp+tj5LlxinUYHX3O+0/hrh3 IdlS7g68E2rpdKIeAR5UK5zjGHp0TaTr/T7SYeW9P4EV6TG38O4il3ctfbo19bRmWWzX AR7Q== X-Gm-Message-State: AGi0PuYQXSIRzknRaoHaS0VIzUtGd2rQaGwgv2Ka7+1tcJyQRLXfmiKa opQZqfajvB77tDCGbzug/yDZl0BpgVr8kMrZEUYxGXvuDUwceZxqgvNw6tWOZKxIERN+3Me4q5o XXoPn/oU/Plc= X-Received: by 2002:adf:aacc:: with SMTP id i12mr1725897wrc.116.1586250246496; Tue, 07 Apr 2020 02:04:06 -0700 (PDT) X-Google-Smtp-Source: APiQypKxjDEOBJfXEddjw59Yx31w54+2Qap2xErPzLKKBTqBo4VkK+bXNTVdIYPaLG/lMXQEpKtP+Q== X-Received: by 2002:adf:aacc:: with SMTP id i12mr1725864wrc.116.1586250246188; Tue, 07 Apr 2020 02:04:06 -0700 (PDT) Received: from minerva.home ([2a01:c50f:ab80:6700:527f:85b3:5615:ff0b]) by smtp.gmail.com with ESMTPSA id o13sm7805444wrm.74.2020.04.07.02.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 02:04:05 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Hans de Goede , Daniel Kiper , Javier Martinez Canillas Subject: [PATCH v2 4/6] efi/console: Implement getkeystatus() support Date: Tue, 7 Apr 2020 11:03:49 +0200 Message-Id: <20200407090351.50921-5-javierm@redhat.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200407090351.50921-1-javierm@redhat.com> References: <20200407090351.50921-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Apr 2020 09:04:13 -0000 From: Hans de Goede Implement getkeystatus() support in the EFI console driver. This is needed because the logic to determine if a key was pressed to make the menu countdown stop will be changed by a later patch to also take into account the SHIFT key being held down. For this reason the EFI console driver has to support getkeystatus() to allow detecting that event. Note that if a non-modifier key gets pressed and repeated calls to getkeystatus() are made then it will return the modifier status at the time of the non-modifier key, until that key-press gets consumed by a getkey() call. This is a side-effect of how the EFI simple-text-input protocol works and cannot be avoided. Signed-off-by: Hans de Goede Signed-off-by: Javier Martinez Canillas --- Changes in v2: - Explain why the getkeystatus() handler is needed for the EFI console driv= er. - Code style cleanups. grub-core/term/efi/console.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c index 2145f33c32a..9c32ca60a1d 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -259,6 +259,39 @@ grub_console_getkey_ex (struct grub_term_input *term) return key; } =20 +static int +grub_console_getkeystatus (struct grub_term_input *term) +{ + grub_efi_key_data_t key_data; + grub_efi_uint32_t kss; + int key, mods =3D 0; + + if (grub_efi_is_finished) + return 0; + + if (grub_console_read_key_stroke (term->data, &key_data, &key, 0)) + return 0; + + kss =3D key_data.key_state.key_shift_state; + if (kss & GRUB_EFI_SHIFT_STATE_VALID) + { + if (kss & GRUB_EFI_LEFT_SHIFT_PRESSED) + mods |=3D GRUB_TERM_STATUS_LSHIFT; + if (kss & GRUB_EFI_RIGHT_SHIFT_PRESSED) + mods |=3D GRUB_TERM_STATUS_RSHIFT; + if (kss & GRUB_EFI_LEFT_ALT_PRESSED) + mods |=3D GRUB_TERM_STATUS_LALT; + if (kss & GRUB_EFI_RIGHT_ALT_PRESSED) + mods |=3D GRUB_TERM_STATUS_RALT; + if (kss & GRUB_EFI_LEFT_CONTROL_PRESSED) + mods |=3D GRUB_TERM_STATUS_LCTRL; + if (kss & GRUB_EFI_RIGHT_CONTROL_PRESSED) + mods |=3D GRUB_TERM_STATUS_RCTRL; + } + + return mods; +} + static grub_err_t grub_efi_console_input_init (struct grub_term_input *term) { @@ -371,6 +404,7 @@ static struct grub_term_input grub_console_term_input = =3D { .name =3D "console", .getkey =3D grub_console_getkey, + .getkeystatus =3D grub_console_getkeystatus, .init =3D grub_efi_console_input_init, }; =20 --=20 2.25.1