ReactOS 0.4.16-dev-112-g52265ae
ueficon.c
Go to the documentation of this file.
1/*
2 * PROJECT: FreeLoader UEFI Support
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Console output
5 * COPYRIGHT: Copyright 2022 Justin Miller <justinmiller100@gmail.com>
6 */
7
8#include <uefildr.h>
9
10#define CHAR_WIDTH 8
11#define CHAR_HEIGHT 16
12
13/* GLOBALS ********************************************************************/
14
16static unsigned CurrentCursorX = 0;
17static unsigned CurrentCursorY = 0;
18static unsigned CurrentAttr = 0x0f;
21static char ExtendedScanCode = 0;
22
23/* FUNCTIONS ******************************************************************/
24
25VOID
27{
29 BOOLEAN NeedScroll;
30
32
33 NeedScroll = (CurrentCursorY >= Height);
34 if (NeedScroll)
35 {
38 }
39 if (c == '\r')
40 {
42 }
43 else if (c == '\n')
44 {
46
47 if (!NeedScroll)
49 }
50 else if (c == '\t')
51 {
52 CurrentCursorX = (CurrentCursorX + 8) & ~7;
53 }
54 else
55 {
58 }
59 if (CurrentCursorX >= Width)
60 {
63 }
64}
65
66static
69{
70 switch (KeyIn)
71 {
72 case SCAN_UP:
73 return KEY_UP;
74 case SCAN_DOWN:
75 return KEY_DOWN;
76 case SCAN_RIGHT:
77 return KEY_RIGHT;
78 case SCAN_LEFT:
79 return KEY_LEFT;
80 case SCAN_HOME:
81 return KEY_HOME;
82 case SCAN_END:
83 return KEY_END;
84
85 // case SCAN_INSERT:
86 // break;
87
88 case SCAN_DELETE:
89 return KEY_DELETE;
90
91 // case SCAN_PAGE_UP:
92 // case SCAN_PAGE_DOWN:
93 // break;
94
95 case SCAN_F1:
96 return KEY_F1;
97 case SCAN_F2:
98 return KEY_F2;
99 case SCAN_F3:
100 return KEY_F3;
101 case SCAN_F4:
102 return KEY_F4;
103 case SCAN_F5:
104 return KEY_F5;
105 case SCAN_F6:
106 return KEY_F6;
107 case SCAN_F7:
108 return KEY_F7;
109 case SCAN_F8:
110 return KEY_F8;
111 case SCAN_F9:
112 return KEY_F9;
113 case SCAN_F10:
114 return KEY_F10;
115 case SCAN_ESC:
116 return KEY_ESC;
117 }
118 return 0;
119}
120
123{
125}
126
127int
129{
130 UCHAR KeyOutput = 0;
131
132 /* If an extended key press was detected the last time we were called
133 * then return the scan code of that key. */
134 if (ExtendedKey)
135 {
137 return ExtendedScanCode;
138 }
139
140 if (Key.UnicodeChar != 0)
141 {
142 KeyOutput = Key.UnicodeChar;
143 }
144 else
145 {
148 KeyOutput = KEY_EXTENDED;
149 }
150
151 /* UEFI will stack input requests, we have to clear it */
152 Key.UnicodeChar = 0;
153 Key.ScanCode = 0;
154 return KeyOutput;
155}
unsigned char BOOLEAN
#define SCAN_F3
Definition: SimpleTextIn.h:71
#define SCAN_LEFT
Definition: SimpleTextIn.h:62
#define SCAN_HOME
Definition: SimpleTextIn.h:63
#define SCAN_F4
Definition: SimpleTextIn.h:72
#define SCAN_F6
Definition: SimpleTextIn.h:74
#define SCAN_RIGHT
Definition: SimpleTextIn.h:61
#define SCAN_F9
Definition: SimpleTextIn.h:77
#define SCAN_UP
Definition: SimpleTextIn.h:59
#define SCAN_F8
Definition: SimpleTextIn.h:76
#define SCAN_F5
Definition: SimpleTextIn.h:73
#define SCAN_F10
Definition: SimpleTextIn.h:78
#define SCAN_ESC
Definition: SimpleTextIn.h:79
#define SCAN_DELETE
Definition: SimpleTextIn.h:66
#define SCAN_DOWN
Definition: SimpleTextIn.h:60
#define SCAN_F1
Definition: SimpleTextIn.h:69
#define SCAN_END
Definition: SimpleTextIn.h:64
#define SCAN_F2
Definition: SimpleTextIn.h:70
#define SCAN_F7
Definition: SimpleTextIn.h:75
#define EFI_NOT_READY
Definition: UefiBaseType.h:126
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
const GLubyte * c
Definition: glext.h:8905
#define KEY_RIGHT
Definition: keycodes.h:48
#define KEY_DELETE
Definition: keycodes.h:41
#define KEY_DOWN
Definition: keycodes.h:46
#define KEY_F1
Definition: keycodes.h:51
#define KEY_F5
Definition: keycodes.h:55
#define KEY_F3
Definition: keycodes.h:53
#define KEY_F9
Definition: keycodes.h:59
#define KEY_EXTENDED
Definition: keycodes.h:38
#define KEY_F8
Definition: keycodes.h:58
#define KEY_F7
Definition: keycodes.h:57
#define KEY_ESC
Definition: keycodes.h:49
#define KEY_END
Definition: keycodes.h:64
#define KEY_F4
Definition: keycodes.h:54
#define KEY_F6
Definition: keycodes.h:56
#define KEY_F10
Definition: keycodes.h:60
#define KEY_F2
Definition: keycodes.h:52
#define KEY_LEFT
Definition: keycodes.h:47
#define KEY_HOME
Definition: keycodes.h:44
#define KEY_UP
Definition: keycodes.h:45
#define Unused(x)
Definition: atlwin.h:28
int UefiConsGetCh(void)
Definition: ueficon.c:128
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
Definition: UefiSpec.h:1932
EFI_INPUT_READ_KEY ReadKeyStroke
Definition: SimpleTextIn.h:125
uint32_t ULONG
Definition: typedefs.h:59
BOOLEAN UefiConsKbHit(VOID)
Definition: ueficon.c:122
static unsigned CurrentAttr
Definition: ueficon.c:18
static unsigned CurrentCursorX
Definition: ueficon.c:16
static UCHAR ConvertToBiosExtValue(UCHAR KeyIn)
Definition: ueficon.c:68
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
static unsigned CurrentCursorY
Definition: ueficon.c:17
static BOOLEAN ExtendedKey
Definition: ueficon.c:20
VOID UefiConsPutChar(int c)
Definition: ueficon.c:26
static EFI_INPUT_KEY Key
Definition: ueficon.c:19
static char ExtendedScanCode
Definition: ueficon.c:21
VOID UefiVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: uefivid.c:154
VOID UefiVideoScrollUp(VOID)
Definition: uefivid.c:191
VOID UefiVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: uefivid.c:142
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
unsigned char UCHAR
Definition: xmlstorage.h:181