[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 4/6] efi/console: Implement getkeystatus() support
From: |
Javier Martinez Canillas |
Subject: |
[PATCH v2 4/6] efi/console: Implement getkeystatus() support |
Date: |
Tue, 7 Apr 2020 11:03:49 +0200 |
From: Hans de Goede <address@hidden>
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 <address@hidden>
Signed-off-by: Javier Martinez Canillas <address@hidden>
---
Changes in v2:
- Explain why the getkeystatus() handler is needed for the EFI console driver.
- 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;
}
+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 = 0;
+
+ if (grub_efi_is_finished)
+ return 0;
+
+ if (grub_console_read_key_stroke (term->data, &key_data, &key, 0))
+ return 0;
+
+ kss = key_data.key_state.key_shift_state;
+ if (kss & GRUB_EFI_SHIFT_STATE_VALID)
+ {
+ if (kss & GRUB_EFI_LEFT_SHIFT_PRESSED)
+ mods |= GRUB_TERM_STATUS_LSHIFT;
+ if (kss & GRUB_EFI_RIGHT_SHIFT_PRESSED)
+ mods |= GRUB_TERM_STATUS_RSHIFT;
+ if (kss & GRUB_EFI_LEFT_ALT_PRESSED)
+ mods |= GRUB_TERM_STATUS_LALT;
+ if (kss & GRUB_EFI_RIGHT_ALT_PRESSED)
+ mods |= GRUB_TERM_STATUS_RALT;
+ if (kss & GRUB_EFI_LEFT_CONTROL_PRESSED)
+ mods |= GRUB_TERM_STATUS_LCTRL;
+ if (kss & GRUB_EFI_RIGHT_CONTROL_PRESSED)
+ mods |= 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 =
{
.name = "console",
.getkey = grub_console_getkey,
+ .getkeystatus = grub_console_getkeystatus,
.init = grub_efi_console_input_init,
};
--
2.25.1
- [PATCH v2 0/6] Improvements to EFI console and terminal drivers for Flicker Free Boot, Javier Martinez Canillas, 2020/04/07
- [PATCH v2 2/6] kern/term: Make grub_getkeystatus helper function available everywhere, Javier Martinez Canillas, 2020/04/07
- [PATCH v2 1/6] efi/console: Move grub_console_set{colorstate, cursor} higher in the file, Javier Martinez Canillas, 2020/04/07
- [PATCH v2 4/6] efi/console: Implement getkeystatus() support,
Javier Martinez Canillas <=
- [PATCH v2 3/6] efi/console: Add grub_console_read_key_stroke() helper function, Javier Martinez Canillas, 2020/04/07
- [PATCH v2 5/6] efi/console: Do not set text-mode until we actually need it, Javier Martinez Canillas, 2020/04/07
- [PATCH v2 6/6] kern/term: Accept ESC, F4 and holding SHIFT as user interrupt keys, Javier Martinez Canillas, 2020/04/07
- Re: [PATCH v2 0/6] Improvements to EFI console and terminal drivers for Flicker Free Boot, Daniel Kiper, 2020/04/14