-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.c
28 lines (21 loc) · 828 Bytes
/
input.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <uefi.h>
int main(int argc, char **argv) {
(void) argc;
(void) argv;
// Reset current input state
efi_status_t input_status = ST->ConIn->Reset(ST->ConIn, 0);
if(EFI_ERROR(input_status)) return input_status;
efi_input_key_t current_key;
// Wait for input initialization
while((input_status = ST->ConIn->ReadKeyStroke(ST->ConIn, ¤t_key)) == EFI_NOT_READY);
while(1) {
// Print previous typed character
ST->ConOut->OutputString(ST->ConOut, ¤t_key.UnicodeChar);
// Read new pressed key
input_status = ST->ConIn->ReadKeyStroke(ST->ConIn, ¤t_key);
// Exit if [ESC] pressed
if (current_key.ScanCode == 0x17) return 0;
// Sleep prevents cursor blinking and useless CPU usage
usleep(50 * 1000);
}
}