Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenkeyboard.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Boot Loader 00003 * LICENSE: BSD - See COPYING.ARM in the top level directory 00004 * FILE: boot/armllb/hw/keyboard.c 00005 * PURPOSE: LLB Keyboard Routines 00006 * PROGRAMMERS: ReactOS Portable Systems Group 00007 */ 00008 00009 #include "precomp.h" 00010 00011 #define E0_KPENTER 96 00012 #define E0_RCTRL 97 00013 #define E0_KPSLASH 98 00014 #define E0_PRSCR 99 00015 #define E0_RALT 100 00016 #define E0_BREAK 101 00017 #define E0_HOME 102 00018 #define E0_UP 103 00019 #define E0_PGUP 104 00020 #define E0_LEFT 105 00021 #define E0_RIGHT 106 00022 #define E0_END 107 00023 #define E0_DOWN 108 00024 #define E0_PGDN 109 00025 #define E0_INS 110 00026 #define E0_DEL 111 00027 #define E1_PAUSE 119 00028 #define E0_MACRO 112 00029 #define E0_F13 113 00030 #define E0_F14 114 00031 #define E0_HELP 115 00032 #define E0_DO 116 00033 #define E0_F17 117 00034 #define E0_KPMINPLUS 118 00035 #define E0_OK 124 00036 #define E0_MSLW 125 00037 #define E0_MSRW 126 00038 #define E0_MSTM 127 00039 00040 /* US 101 KEYBOARD LAYOUT *****************************************************/ 00041 00042 CHAR LlbHwScanCodeToAsciiTable[58][2] = 00043 { 00044 { 0,0 } , 00045 { 27, 27 } , 00046 { '1','!' } , 00047 { '2','@' } , 00048 { '3','#' } , 00049 { '4','$' } , 00050 { '5','%' } , 00051 { '6','^' } , 00052 { '7','&' } , 00053 { '8','*' } , 00054 { '9','(' } , 00055 { '0',')' } , 00056 { '-','_' } , 00057 { '=','+' } , 00058 { 8,8 } , 00059 { 9,9 } , 00060 { 'q','Q' } , 00061 { 'w','W' } , 00062 { 'e','E' } , 00063 { 'r','R' } , 00064 { 't','T' } , 00065 { 'y','Y' } , 00066 { 'u','U' } , 00067 { 'i','I' } , 00068 { 'o','O' } , 00069 { 'p','P' } , 00070 { '[','{' } , 00071 { ']','}' } , 00072 { 13,13 } , 00073 { 0,0 } , 00074 { 'a','A' } , 00075 { 's','S' } , 00076 { 'd','D' } , 00077 { 'f','F' } , 00078 { 'g','G' } , 00079 { 'h','H' } , 00080 { 'j','J' } , 00081 { 'k','K' } , 00082 { 'l','L' } , 00083 { ';',':' } , 00084 { 39,34 } , 00085 { '`','~' } , 00086 { 0,0 } , 00087 { '\\','|'} , 00088 { 'z','Z' } , 00089 { 'x','X' } , 00090 { 'c','C' } , 00091 { 'v','V' } , 00092 { 'b','B' } , 00093 { 'n','N' } , 00094 { 'm','M' } , 00095 { ',','<' } , 00096 { '.','>' } , 00097 { '/','?' } , 00098 { 0,0 } , 00099 { 0,0 } , 00100 { 0,0 } , 00101 { ' ',' ' } , 00102 }; 00103 00104 /* EXTENDED KEY TABLE *********************************************************/ 00105 00106 UCHAR LlbHwExtendedScanCodeTable[128] = 00107 { 00108 0, 0, 0, 0, 00109 0, 0, 0, 0, 00110 0, 0, 0, 0, 00111 0, 0, 0, 0, 00112 0, 0, 0, 0, 00113 0, 0, 0, 0, 00114 0, 0, 0, 0, 00115 E0_KPENTER, E0_RCTRL, 0, 0, 00116 0, 0, 0, 0, 00117 0, 0, 0, 0, 00118 0, 0, 0, 0, 00119 0, 0, 0, 0, 00120 0, 0, 0, 0, 00121 0, E0_KPSLASH, 0, E0_PRSCR, 00122 E0_RALT, 0, 0, 0, 00123 0, E0_F13, E0_F14, E0_HELP, 00124 E0_DO, E0_F17, 0, 0, 00125 0, 0, E0_BREAK, E0_HOME, 00126 E0_UP, E0_PGUP, 0, E0_LEFT, 00127 E0_OK, E0_RIGHT, E0_KPMINPLUS, E0_END, 00128 E0_DOWN, E0_PGDN, E0_INS, E0_DEL, 00129 0, 0, 0, 0, 00130 0, 0, 0, E0_MSLW, 00131 E0_MSRW, E0_MSTM, 0, 0, 00132 0, 0, 0, 0, 00133 0, 0, 0, 0, 00134 0, 0, 0, 0, 00135 0, 0, 0, E0_MACRO, 00136 0, 0, 0, 0, 00137 0, 0, 0, 0, 00138 0, 0, 0, 0, 00139 0, 0, 0, 0 00140 }; 00141 00142 00143 /* FUNCTIONS ******************************************************************/ 00144 00145 USHORT LlbKbdLastScanCode; 00146 00147 UCHAR 00148 NTAPI 00149 LlbKbdTranslateScanCode(IN USHORT ScanCode, 00150 IN PUCHAR KeyCode) 00151 { 00152 ULONG LastScanCode; 00153 00154 /* Check for extended scan codes */ 00155 if ((ScanCode == 0xE0) || (ScanCode == 0xE1)) 00156 { 00157 /* We'll get these on the next scan */ 00158 LlbKbdLastScanCode = ScanCode; 00159 return 0; 00160 } 00161 00162 /* Check for bogus scan codes */ 00163 if ((ScanCode == 0x00) || (ScanCode == 0xFF)) 00164 { 00165 /* Reset */ 00166 LlbKbdLastScanCode = 0; 00167 return 0; 00168 } 00169 00170 /* Only act on the break, not the make */ 00171 if (ScanCode > 0x80) return 0; 00172 00173 /* Keep only simple scan codes */ 00174 ScanCode &= 0x7F; 00175 00176 /* Check if this was part of an extended sequence */ 00177 if (LlbKbdLastScanCode) 00178 { 00179 /* Save the last scan code and clear it, since we've consumed it now */ 00180 LastScanCode = LlbKbdLastScanCode; 00181 LlbKbdLastScanCode = 0; 00182 switch (LastScanCode) 00183 { 00184 /* E0 extended codes */ 00185 case 0xE0: 00186 00187 /* Skip bogus codes */ 00188 if ((ScanCode == 0x2A) || (ScanCode == 0x36)) return 0; 00189 00190 /* Lookup the code for it */ 00191 if (!LlbHwExtendedScanCodeTable[ScanCode]) return 0; 00192 *KeyCode = LlbHwExtendedScanCodeTable[ScanCode]; 00193 break; 00194 00195 /* E1 extended codes */ 00196 case 0xE1: 00197 00198 /* Only recognize one (the SYSREQ/PAUSE sequence) */ 00199 if (ScanCode != 0x1D) return 0; 00200 LlbKbdLastScanCode = 0x100; 00201 break; 00202 00203 /* PAUSE sequence */ 00204 case 0x100: 00205 00206 /* Make sure it's the one */ 00207 if (ScanCode != 0x45) return 0; 00208 *KeyCode = E1_PAUSE; 00209 break; 00210 } 00211 } 00212 else 00213 { 00214 /* Otherwise, the scancode is the key code */ 00215 LlbKbdLastScanCode = 0; 00216 *KeyCode = ScanCode; 00217 } 00218 00219 /* Translation success */ 00220 return 1; 00221 } 00222 00223 CHAR 00224 NTAPI 00225 LlbKeyboardGetChar(VOID) 00226 { 00227 UCHAR ScanCode, KeyCode; 00228 00229 do 00230 { 00231 /* Read the scan code and convert it to a virtual key code */ 00232 ScanCode = LlbHwKbdRead(); 00233 } while (!LlbKbdTranslateScanCode(ScanCode, &KeyCode)); 00234 00235 /* Is this ASCII? */ 00236 if (KeyCode > 96) return ScanCode; 00237 00238 /* Return the ASCII character */ 00239 return LlbHwScanCodeToAsciiTable[KeyCode][0]; 00240 } 00241 00242 /* EOF */ Generated on Sun May 27 2012 04:18:59 for ReactOS by
1.7.6.1
|