2 * PROJECT: ReactOS Boot Loader
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: boot/armllb/hw/keyboard.c
5 * PURPOSE: LLB Keyboard Routines
6 * PROGRAMMERS: ReactOS Portable Systems Group
34 #define E0_KPMINPLUS 118
40 /* US 101 KEYBOARD LAYOUT *****************************************************/
42 CHAR LlbHwScanCodeToAsciiTable
[58][2] =
104 /* EXTENDED KEY TABLE *********************************************************/
106 UCHAR LlbHwExtendedScanCodeTable
[128] =
115 E0_KPENTER
, E0_RCTRL
, 0, 0,
121 0, E0_KPSLASH
, 0, E0_PRSCR
,
123 0, E0_F13
, E0_F14
, E0_HELP
,
125 0, 0, E0_BREAK
, E0_HOME
,
126 E0_UP
, E0_PGUP
, 0, E0_LEFT
,
127 E0_OK
, E0_RIGHT
, E0_KPMINPLUS
, E0_END
,
128 E0_DOWN
, E0_PGDN
, E0_INS
, E0_DEL
,
131 E0_MSRW
, E0_MSTM
, 0, 0,
143 /* FUNCTIONS ******************************************************************/
145 USHORT LlbKbdLastScanCode
;
149 LlbKbdTranslateScanCode(IN USHORT ScanCode
,
154 /* Check for extended scan codes */
155 if ((ScanCode
== 0xE0) || (ScanCode
== 0xE1))
157 /* We'll get these on the next scan */
158 LlbKbdLastScanCode
= ScanCode
;
162 /* Check for bogus scan codes */
163 if ((ScanCode
== 0x00) || (ScanCode
== 0xFF))
166 LlbKbdLastScanCode
= 0;
170 /* Only act on the break, not the make */
171 if (ScanCode
> 0x80) return 0;
173 /* Keep only simple scan codes */
176 /* Check if this was part of an extended sequence */
177 if (LlbKbdLastScanCode
)
179 /* Save the last scan code and clear it, since we've consumed it now */
180 LastScanCode
= LlbKbdLastScanCode
;
181 LlbKbdLastScanCode
= 0;
182 switch (LastScanCode
)
184 /* E0 extended codes */
187 /* Skip bogus codes */
188 if ((ScanCode
== 0x2A) || (ScanCode
== 0x36)) return 0;
190 /* Lookup the code for it */
191 if (!LlbHwExtendedScanCodeTable
[ScanCode
]) return 0;
192 *KeyCode
= LlbHwExtendedScanCodeTable
[ScanCode
];
195 /* E1 extended codes */
198 /* Only recognize one (the SYSREQ/PAUSE sequence) */
199 if (ScanCode
!= 0x1D) return 0;
200 LlbKbdLastScanCode
= 0x100;
206 /* Make sure it's the one */
207 if (ScanCode
!= 0x45) return 0;
214 /* Otherwise, the scancode is the key code */
215 LlbKbdLastScanCode
= 0;
219 /* Translation success */
225 LlbKeyboardGetChar(VOID
)
227 UCHAR ScanCode
, KeyCode
;
231 /* Read the scan code and convert it to a virtual key code */
232 ScanCode
= LlbHwKbdRead();
233 } while (!LlbKbdTranslateScanCode(ScanCode
, &KeyCode
));
236 if (KeyCode
> 96) return ScanCode
;
238 /* Return the ASCII character */
239 return LlbHwScanCodeToAsciiTable
[KeyCode
][0];