OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
KeyTester.c
Go to the documentation of this file.
1
15#include <Uefi.h>
16#include <Library/UefiLib.h>
17#include <Library/DebugLib.h>
18#include <Library/BaseMemoryLib.h>
19#include <Library/UefiBootServicesTableLib.h>
20#include <Library/UefiApplicationEntryPoint.h>
21
22EFI_STATUS
23EFIAPI
25 IN EFI_HANDLE ImageHandle,
26 IN EFI_SYSTEM_TABLE *SystemTable
27 )
28{
29 EFI_STATUS Status;
30 UINTN EventIndex;
31 EFI_INPUT_KEY Key;
32
33 STATIC CHAR16 Output[] = L"Received symbol: \r\n";
34
35 do {
36 //
37 // Read a key
38 //
39 gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
40 ZeroMem (&Key, sizeof (Key));
41 Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
42 if (EFI_ERROR (Status)) {
43 if (Status == EFI_NOT_READY) {
44 continue;
45 }
46
47 break;
48 }
49
50 Output[ARRAY_SIZE (Output) - 4] = Key.UnicodeChar;
51 gST->ConOut->OutputString (gST->ConOut, Output);
52 DEBUG ((DEBUG_INFO, "KKT: Received %X %X\n", Key.ScanCode, Key.UnicodeChar));
53 } while (TRUE);
54
55 return EFI_SUCCESS;
56}
#define ARRAY_SIZE(Array)
Definition AppleMacEfi.h:34
EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition KeyTester.c:24
EFI_SYSTEM_TABLE * gST
EFI_BOOT_SERVICES * gBS
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)