committed by
Daan De Meyer
parent
efc529cfbd
commit
e9f9ddbfa8
+5
-5
@@ -35,15 +35,13 @@ static void event_closep(EFI_EVENT *event) {
|
||||
* will replace ConInEx permanently if it ever reports a key press.
|
||||
* Lastly, a timer event allows us to provide a input timeout without having to call into
|
||||
* any input functions that can freeze on us or using a busy/stall loop. */
|
||||
EFI_STATUS console_key_read(uint64_t *key, uint64_t timeout_usec) {
|
||||
EFI_STATUS console_key_read(uint64_t *ret_key, uint64_t timeout_usec) {
|
||||
static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *conInEx = NULL, *extraInEx = NULL;
|
||||
static bool checked = false;
|
||||
size_t index;
|
||||
EFI_STATUS err;
|
||||
_cleanup_(event_closep) EFI_EVENT timer = NULL;
|
||||
|
||||
assert(key);
|
||||
|
||||
if (!checked) {
|
||||
/* Get the *first* TextInputEx device. */
|
||||
err = BS->LocateProtocol(
|
||||
@@ -148,7 +146,8 @@ EFI_STATUS console_key_read(uint64_t *key, uint64_t timeout_usec) {
|
||||
}
|
||||
|
||||
/* 32 bit modifier keys + 16 bit scan code + 16 bit unicode */
|
||||
*key = KEYPRESS(shift, keydata.Key.ScanCode, keydata.Key.UnicodeChar);
|
||||
if (ret_key)
|
||||
*ret_key = KEYPRESS(shift, keydata.Key.ScanCode, keydata.Key.UnicodeChar);
|
||||
return EFI_SUCCESS;
|
||||
} else if (BS->CheckEvent(ST->ConIn->WaitForKey) == EFI_SUCCESS) {
|
||||
EFI_INPUT_KEY k;
|
||||
@@ -157,7 +156,8 @@ EFI_STATUS console_key_read(uint64_t *key, uint64_t timeout_usec) {
|
||||
if (err != EFI_SUCCESS)
|
||||
return err;
|
||||
|
||||
*key = KEYPRESS(0, k.ScanCode, k.UnicodeChar);
|
||||
if (ret_key)
|
||||
*ret_key = KEYPRESS(0, k.ScanCode, k.UnicodeChar);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,8 +94,7 @@ EFI_STATUS secure_boot_enroll_at(EFI_FILE *root_dir, const char16_t *path, bool
|
||||
for (;;) {
|
||||
printf("\rEnrolling in %2u s, press any key to abort.", timeout_sec);
|
||||
|
||||
uint64_t key;
|
||||
err = console_key_read(&key, 1000 * 1000);
|
||||
err = console_key_read(/* ret_key= */ NULL, /* timeout_usec= */ 1000 * 1000);
|
||||
if (err == EFI_NOT_READY)
|
||||
continue;
|
||||
if (err == EFI_TIMEOUT) {
|
||||
|
||||
Reference in New Issue
Block a user