Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jOfFo-0006pw-Sn for mharc-grub-devel@gnu.org; Wed, 15 Apr 2020 06:26:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43647) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOfFm-0006lP-LO for grub-devel@gnu.org; Wed, 15 Apr 2020 06:26:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jOfFl-0005hN-HF for grub-devel@gnu.org; Wed, 15 Apr 2020 06:26:46 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47002 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 1jOfFl-0005hF-Db for grub-devel@gnu.org; Wed, 15 Apr 2020 06:26:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586946405; 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=8tEi5fQJ6DFJ63o28qsw+yTjjuaPVH3o0e1vLCOfYF4=; b=KxpS87ReKQSL3IcJ3oyuUN4IZgiZY3opE0aO2NoJZVzYmACUMjrOk6DqdT8jb8I2Egvxn5 ixdnsK52Ng6Wk+BwQrG1VC+zPjSIfxPcl9Aupc65Jco4aXge/s0ZZbriFiLhTN4MohbN6R 7GXKDSSkxAKf5dH4vAhO3HmXedAZV6A= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-1-bN1JTPtNOFm4Ng6HxZU26Q-1; Wed, 15 Apr 2020 06:26:43 -0400 X-MC-Unique: bN1JTPtNOFm4Ng6HxZU26Q-1 Received: by mail-wr1-f71.google.com with SMTP id j22so10396360wrb.4 for ; Wed, 15 Apr 2020 03:26:43 -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=FyyJCNvtoCakHmMKoSGJpn4KC8Rws5cnLU6eJUOmCHc=; b=EJZ6sVTXPIvn6cBatNOsBgaFBlGR+87YhJqGgOot48rbkO/T3hvyIvpBtXjCz+ALpz j0XtpHcfhVlECIjljvOpSAgNBZaT1H3pd+ZrBU+l/N4a7NmolTs1F+CbcKa8v40PI1YB HjBJJweQ1CUTiuxCm0e5TiUHh7wyA04JY3jKmnhtfOFfoQb3YO225ZDcpgnm7DQgxltw zP6/hVUHBnLSxA7y/86YJ9MWugTdQveCUA/NKWnpN7Gjk1NkPpZegyy9iRrfCE8/ICQp 8BP34BhHduxYDaPcOq0MBIQJM2hK50WmW6xDflKXl675wMzGbR0TbNQ7p2ktyIk6Tvub G5rw== X-Gm-Message-State: AGi0PuaPf44eiJ94xj2jMBD16lZ2uCh0k65WnMSinY1x6zf3g/ELUeUu 5GVKJ/GjA6+7TsHdqCmJE0mPxvxotBcl6O/z13HSHX4pq+wt9lz4F+Jh6YffVBz/Fq8pAJXn3Ow PB/zogWX/TCk= X-Received: by 2002:a1c:4b0a:: with SMTP id y10mr4403437wma.24.1586946401822; Wed, 15 Apr 2020 03:26:41 -0700 (PDT) X-Google-Smtp-Source: APiQypKk0Rc5omNbQ2F7smmKaJcI1RFJJGjHWPPBMi01lbueROY9XQEqshoGkqHEf80RcpaFKgC1Iw== X-Received: by 2002:a1c:4b0a:: with SMTP id y10mr4403422wma.24.1586946401627; Wed, 15 Apr 2020 03:26:41 -0700 (PDT) Received: from minerva.redhat.com ([2a01:c50f:ab80:6700:527f:85b3:5615:ff0b]) by smtp.gmail.com with ESMTPSA id n124sm22803517wma.11.2020.04.15.03.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2020 03:26:41 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Hans de Goede , Daniel Kiper , Javier Martinez Canillas Subject: [PATCH v3 4/6] efi/console: Implement getkeystatus() support Date: Wed, 15 Apr 2020 12:26:20 +0200 Message-Id: <20200415102622.1890550-5-javierm@redhat.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200415102622.1890550-1-javierm@redhat.com> References: <20200415102622.1890550-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] [fuzzy] X-Received-From: 207.211.31.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: Wed, 15 Apr 2020 10:26:47 -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 Reviewed-by: Daniel Kiper --- Changes in v3: None 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 0cb965a9931..64591b90aad 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -260,6 +260,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) { @@ -372,6 +405,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