ReactOS 0.4.15-dev-7958-gcd0bb1a
keyboard.c File Reference
#include "precomp.h"
Include dependency graph for keyboard.c:

Go to the source code of this file.

Macros

#define E0_KPENTER   96
 
#define E0_RCTRL   97
 
#define E0_KPSLASH   98
 
#define E0_PRSCR   99
 
#define E0_RALT   100
 
#define E0_BREAK   101
 
#define E0_HOME   102
 
#define E0_UP   103
 
#define E0_PGUP   104
 
#define E0_LEFT   105
 
#define E0_RIGHT   106
 
#define E0_END   107
 
#define E0_DOWN   108
 
#define E0_PGDN   109
 
#define E0_INS   110
 
#define E0_DEL   111
 
#define E1_PAUSE   119
 
#define E0_MACRO   112
 
#define E0_F13   113
 
#define E0_F14   114
 
#define E0_HELP   115
 
#define E0_DO   116
 
#define E0_F17   117
 
#define E0_KPMINPLUS   118
 
#define E0_OK   124
 
#define E0_MSLW   125
 
#define E0_MSRW   126
 
#define E0_MSTM   127
 

Functions

UCHAR NTAPI LlbKbdTranslateScanCode (IN USHORT ScanCode, IN PUCHAR KeyCode)
 
CHAR NTAPI LlbKeyboardGetChar (VOID)
 

Variables

CHAR LlbHwScanCodeToAsciiTable [58][2]
 
UCHAR LlbHwExtendedScanCodeTable [128]
 
USHORT LlbKbdLastScanCode
 

Macro Definition Documentation

◆ E0_BREAK

#define E0_BREAK   101

Definition at line 16 of file keyboard.c.

◆ E0_DEL

#define E0_DEL   111

Definition at line 26 of file keyboard.c.

◆ E0_DO

#define E0_DO   116

Definition at line 32 of file keyboard.c.

◆ E0_DOWN

#define E0_DOWN   108

Definition at line 23 of file keyboard.c.

◆ E0_END

#define E0_END   107

Definition at line 22 of file keyboard.c.

◆ E0_F13

#define E0_F13   113

Definition at line 29 of file keyboard.c.

◆ E0_F14

#define E0_F14   114

Definition at line 30 of file keyboard.c.

◆ E0_F17

#define E0_F17   117

Definition at line 33 of file keyboard.c.

◆ E0_HELP

#define E0_HELP   115

Definition at line 31 of file keyboard.c.

◆ E0_HOME

#define E0_HOME   102

Definition at line 17 of file keyboard.c.

◆ E0_INS

#define E0_INS   110

Definition at line 25 of file keyboard.c.

◆ E0_KPENTER

#define E0_KPENTER   96

Definition at line 11 of file keyboard.c.

◆ E0_KPMINPLUS

#define E0_KPMINPLUS   118

Definition at line 34 of file keyboard.c.

◆ E0_KPSLASH

#define E0_KPSLASH   98

Definition at line 13 of file keyboard.c.

◆ E0_LEFT

#define E0_LEFT   105

Definition at line 20 of file keyboard.c.

◆ E0_MACRO

#define E0_MACRO   112

Definition at line 28 of file keyboard.c.

◆ E0_MSLW

#define E0_MSLW   125

Definition at line 36 of file keyboard.c.

◆ E0_MSRW

#define E0_MSRW   126

Definition at line 37 of file keyboard.c.

◆ E0_MSTM

#define E0_MSTM   127

Definition at line 38 of file keyboard.c.

◆ E0_OK

#define E0_OK   124

Definition at line 35 of file keyboard.c.

◆ E0_PGDN

#define E0_PGDN   109

Definition at line 24 of file keyboard.c.

◆ E0_PGUP

#define E0_PGUP   104

Definition at line 19 of file keyboard.c.

◆ E0_PRSCR

#define E0_PRSCR   99

Definition at line 14 of file keyboard.c.

◆ E0_RALT

#define E0_RALT   100

Definition at line 15 of file keyboard.c.

◆ E0_RCTRL

#define E0_RCTRL   97

Definition at line 12 of file keyboard.c.

◆ E0_RIGHT

#define E0_RIGHT   106

Definition at line 21 of file keyboard.c.

◆ E0_UP

#define E0_UP   103

Definition at line 18 of file keyboard.c.

◆ E1_PAUSE

#define E1_PAUSE   119

Definition at line 27 of file keyboard.c.

Function Documentation

◆ LlbKbdTranslateScanCode()

UCHAR NTAPI LlbKbdTranslateScanCode ( IN USHORT  ScanCode,
IN PUCHAR  KeyCode 
)

Definition at line 149 of file keyboard.c.

151{
152 ULONG LastScanCode;
153
154 /* Check for extended scan codes */
155 if ((ScanCode == 0xE0) || (ScanCode == 0xE1))
156 {
157 /* We'll get these on the next scan */
159 return 0;
160 }
161
162 /* Check for bogus scan codes */
163 if ((ScanCode == 0x00) || (ScanCode == 0xFF))
164 {
165 /* Reset */
167 return 0;
168 }
169
170 /* Only act on the break, not the make */
171 if (ScanCode > 0x80) return 0;
172
173 /* Keep only simple scan codes */
174 ScanCode &= 0x7F;
175
176 /* Check if this was part of an extended sequence */
178 {
179 /* Save the last scan code and clear it, since we've consumed it now */
180 LastScanCode = LlbKbdLastScanCode;
182 switch (LastScanCode)
183 {
184 /* E0 extended codes */
185 case 0xE0:
186
187 /* Skip bogus codes */
188 if ((ScanCode == 0x2A) || (ScanCode == 0x36)) return 0;
189
190 /* Lookup the code for it */
191 if (!LlbHwExtendedScanCodeTable[ScanCode]) return 0;
193 break;
194
195 /* E1 extended codes */
196 case 0xE1:
197
198 /* Only recognize one (the SYSREQ/PAUSE sequence) */
199 if (ScanCode != 0x1D) return 0;
200 LlbKbdLastScanCode = 0x100;
201 break;
202
203 /* PAUSE sequence */
204 case 0x100:
205
206 /* Make sure it's the one */
207 if (ScanCode != 0x45) return 0;
208 *KeyCode = E1_PAUSE;
209 break;
210 }
211 }
212 else
213 {
214 /* Otherwise, the scancode is the key code */
216 *KeyCode = ScanCode;
217 }
218
219 /* Translation success */
220 return 1;
221 }
UINT ScanCode
Definition: VirtualKey.c:24
UCHAR LlbHwExtendedScanCodeTable[128]
Definition: keyboard.c:106
USHORT LlbKbdLastScanCode
Definition: keyboard.c:145
#define E1_PAUSE
Definition: keyboard.c:27
uint32_t ULONG
Definition: typedefs.h:59

Referenced by LlbKeyboardGetChar().

◆ LlbKeyboardGetChar()

CHAR NTAPI LlbKeyboardGetChar ( VOID  )

Definition at line 225 of file keyboard.c.

226{
227 UCHAR ScanCode, KeyCode;
228
229 do
230 {
231 /* Read the scan code and convert it to a virtual key code */
233 } while (!LlbKbdTranslateScanCode(ScanCode, &KeyCode));
234
235 /* Is this ASCII? */
236 if (KeyCode > 96) return ScanCode;
237
238 /* Return the ASCII character */
239 return LlbHwScanCodeToAsciiTable[KeyCode][0];
240}
CHAR LlbHwScanCodeToAsciiTable[58][2]
Definition: keyboard.c:42
UCHAR NTAPI LlbKbdTranslateScanCode(IN USHORT ScanCode, IN PUCHAR KeyCode)
Definition: keyboard.c:149
INT NTAPI LlbHwKbdRead(VOID)
Definition: hwinfo.c:55
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by LlbFwGetCh().

Variable Documentation

◆ LlbHwExtendedScanCodeTable

UCHAR LlbHwExtendedScanCodeTable[128]

Definition at line 106 of file keyboard.c.

Referenced by LlbKbdTranslateScanCode().

◆ LlbHwScanCodeToAsciiTable

CHAR LlbHwScanCodeToAsciiTable[58][2]

Definition at line 42 of file keyboard.c.

Referenced by LlbKeyboardGetChar().

◆ LlbKbdLastScanCode

USHORT LlbKbdLastScanCode

Definition at line 145 of file keyboard.c.

Referenced by LlbKbdTranslateScanCode().