|
|
d9d99f |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
d9d99f |
From: Hans de Goede <hdegoede@redhat.com>
|
|
|
d9d99f |
Date: Wed, 6 Jun 2018 16:16:47 +0200
|
|
|
d9d99f |
Subject: [PATCH] EFI: console: Implement getkeystatus() support
|
|
|
d9d99f |
|
|
|
d9d99f |
Implement getkeystatus() support.
|
|
|
d9d99f |
|
|
|
d9d99f |
Note that if a non-modifier key gets pressed and repeated calls to
|
|
|
d9d99f |
getkeystatus() are made then it will return the modifier status at the
|
|
|
d9d99f |
time of the non-modifier key, until that key-press gets consumed by a
|
|
|
d9d99f |
getkey() call.
|
|
|
d9d99f |
|
|
|
d9d99f |
This is a side-effect of how the EFI simple-text-input protocol works
|
|
|
d9d99f |
and cannot be avoided.
|
|
|
d9d99f |
|
|
|
d9d99f |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
d9d99f |
---
|
|
|
d9d99f |
grub-core/term/efi/console.c | 34 ++++++++++++++++++++++++++++++++++
|
|
|
d9d99f |
1 file changed, 34 insertions(+)
|
|
|
d9d99f |
|
|
|
d9d99f |
diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
|
|
|
b71686 |
index 3d36c5c70..92dd4996b 100644
|
|
|
d9d99f |
--- a/grub-core/term/efi/console.c
|
|
|
d9d99f |
+++ b/grub-core/term/efi/console.c
|
|
|
d9d99f |
@@ -223,6 +223,39 @@ grub_console_getkey_ex(struct grub_term_input *term)
|
|
|
d9d99f |
return key;
|
|
|
d9d99f |
}
|
|
|
d9d99f |
|
|
|
d9d99f |
+static int
|
|
|
d9d99f |
+grub_console_getkeystatus(struct grub_term_input *term)
|
|
|
d9d99f |
+{
|
|
|
d9d99f |
+ grub_efi_key_data_t key_data;
|
|
|
d9d99f |
+ grub_efi_uint32_t kss;
|
|
|
d9d99f |
+ int key, mods = 0;
|
|
|
d9d99f |
+
|
|
|
d9d99f |
+ if (grub_efi_is_finished)
|
|
|
d9d99f |
+ return 0;
|
|
|
d9d99f |
+
|
|
|
d9d99f |
+ if (grub_console_read_key_stroke (term->data, &key_data, &key, 0))
|
|
|
d9d99f |
+ return 0;
|
|
|
d9d99f |
+
|
|
|
d9d99f |
+ kss = key_data.key_state.key_shift_state;
|
|
|
d9d99f |
+ if (kss & GRUB_EFI_SHIFT_STATE_VALID)
|
|
|
d9d99f |
+ {
|
|
|
d9d99f |
+ if (kss & GRUB_EFI_LEFT_SHIFT_PRESSED)
|
|
|
d9d99f |
+ mods |= GRUB_TERM_STATUS_LSHIFT;
|
|
|
d9d99f |
+ if (kss & GRUB_EFI_RIGHT_SHIFT_PRESSED)
|
|
|
d9d99f |
+ mods |= GRUB_TERM_STATUS_RSHIFT;
|
|
|
d9d99f |
+ if (kss & GRUB_EFI_LEFT_ALT_PRESSED)
|
|
|
d9d99f |
+ mods |= GRUB_TERM_STATUS_LALT;
|
|
|
d9d99f |
+ if (kss & GRUB_EFI_RIGHT_ALT_PRESSED)
|
|
|
d9d99f |
+ mods |= GRUB_TERM_STATUS_RALT;
|
|
|
d9d99f |
+ if (kss & GRUB_EFI_LEFT_CONTROL_PRESSED)
|
|
|
d9d99f |
+ mods |= GRUB_TERM_STATUS_LCTRL;
|
|
|
d9d99f |
+ if (kss & GRUB_EFI_RIGHT_CONTROL_PRESSED)
|
|
|
d9d99f |
+ mods |= GRUB_TERM_STATUS_RCTRL;
|
|
|
d9d99f |
+ }
|
|
|
d9d99f |
+
|
|
|
d9d99f |
+ return mods;
|
|
|
d9d99f |
+}
|
|
|
d9d99f |
+
|
|
|
d9d99f |
static grub_err_t
|
|
|
d9d99f |
grub_efi_console_input_init (struct grub_term_input *term)
|
|
|
d9d99f |
{
|
|
|
d9d99f |
@@ -403,6 +436,7 @@ static struct grub_term_input grub_console_term_input =
|
|
|
d9d99f |
{
|
|
|
d9d99f |
.name = "console",
|
|
|
d9d99f |
.getkey = grub_console_getkey,
|
|
|
d9d99f |
+ .getkeystatus = grub_console_getkeystatus,
|
|
|
d9d99f |
.init = grub_efi_console_input_init,
|
|
|
d9d99f |
};
|
|
|
d9d99f |
|