Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

kbd101a.c

Go to the documentation of this file.
00001 /***************************************************************************\ 00002 * Module Name: kbd101a.c (Type A) 00003 * 00004 * Copyright (c) 1985-92, Microsoft Corporation 00005 * 00006 * Keyboard Type A : Hangeul Toggle : Right Alt 00007 * Junja Toggle : Left Alt + '=' 00008 * Hanja Toggle : Right Ctrl 00009 \***************************************************************************/ 00010 00011 #include <windows.h> 00012 #include <ime.h> 00013 #include "vkoem.h" 00014 #include "kbd101a.h" 00015 00016 #if defined(_M_IA64) 00017 #pragma section(".data") 00018 #define ALLOC_SECTION_LDATA __declspec(allocate(".data")) 00019 #else 00020 #pragma data_seg(".data") 00021 #define ALLOC_SECTION_LDATA 00022 #endif 00023 00024 /***************************************************************************\ 00025 * ausVK[] - Virtual Scan Code to Virtual Key conversion table for 101 00026 \***************************************************************************/ 00027 00028 static ALLOC_SECTION_LDATA USHORT ausVK[] = { 00029 T00, T01, T02, T03, T04, T05, T06, T07, 00030 T08, T09, T0A, T0B, T0C, 00031 00032 /* 00033 * '='/'+' key must have KBDSPECIAL bit set (NLS key) 00034 */ 00035 T0D | KBDSPECIAL, 00036 00037 T0E, T0F, 00038 T10, T11, T12, T13, T14, T15, T16, T17, 00039 T18, T19, T1A, T1B, T1C, T1D, T1E, T1F, 00040 T20, T21, T22, T23, T24, T25, T26, T27, 00041 T28, T29, T2A, T2B, T2C, T2D, T2E, T2F, 00042 T30, T31, T32, T33, T34, T35, 00043 00044 /* 00045 * Right-hand Shift key must have KBDEXT bit set. 00046 */ 00047 T36 | KBDEXT, 00048 00049 /* 00050 * numpad_* + Shift/Alt -> SnapShot 00051 */ 00052 T37 | KBDMULTIVK, 00053 00054 T38, T39, T3A, T3B, T3C, T3D, T3E, T3F, 00055 T40, T41, T42, T43, T44, 00056 00057 /* 00058 * NumLock Key: 00059 * KBDEXT - VK_NUMLOCK is an Extended key 00060 * KBDMULTIVK - VK_NUMLOCK or VK_PAUSE (without or with CTRL) 00061 */ 00062 T45 | KBDEXT | KBDMULTIVK, 00063 00064 T46 | KBDMULTIVK, 00065 00066 /* 00067 * Number Pad keys: 00068 * KBDNUMPAD - digits 0-9 and decimal point. 00069 * KBDSPECIAL - require special processing by Windows 00070 */ 00071 T47 | KBDNUMPAD | KBDSPECIAL, // Numpad 7 (Home) 00072 T48 | KBDNUMPAD | KBDSPECIAL, // Numpad 8 (Up), 00073 T49 | KBDNUMPAD | KBDSPECIAL, // Numpad 9 (PgUp), 00074 T4A, 00075 T4B | KBDNUMPAD | KBDSPECIAL, // Numpad 4 (Left), 00076 T4C | KBDNUMPAD | KBDSPECIAL, // Numpad 5 (Clear), 00077 T4D | KBDNUMPAD | KBDSPECIAL, // Numpad 6 (Right), 00078 T4E, 00079 T4F | KBDNUMPAD | KBDSPECIAL, // Numpad 1 (End), 00080 T50 | KBDNUMPAD | KBDSPECIAL, // Numpad 2 (Down), 00081 T51 | KBDNUMPAD | KBDSPECIAL, // Numpad 3 (PgDn), 00082 T52 | KBDNUMPAD | KBDSPECIAL, // Numpad 0 (Ins), 00083 T53 | KBDNUMPAD | KBDSPECIAL, // Numpad . (Del), 00084 00085 T54, T55, T56, T57, T58, T59, T5A, T5B, 00086 T5C, T5D, T5E, T5F, T60, T61, T62, T63, 00087 T64, T65, T66, T67, T68, T69, T6A, T6B, 00088 T6C, T6D, T6E, T6F, T70, T71, T72, T73, 00089 T74, T75, T76, T77, T78, T79, T7A, T7B, 00090 T7C, T7D, T7E, T7F 00091 }; 00092 00093 static ALLOC_SECTION_LDATA VSC_VK aE0VscToVk[] = { 00094 { 0x10, X10 | KBDEXT }, // Speedracer: Previous Track 00095 { 0x19, X19 | KBDEXT }, // Speedracer: Next Track 00096 { 0x1C, X1C | KBDEXT }, // Numpad Enter 00097 { 0x1D, X1D | KBDEXT | KBDSPECIAL }, // RControl // Hanja NLS key 00098 { 0x20, X20 | KBDEXT }, // Speedracer: Volume Mute 00099 { 0x21, X21 | KBDEXT }, // Speedracer: Launch App 2 00100 { 0x22, X22 | KBDEXT }, // Speedracer: Media Play/Pause 00101 { 0x24, X24 | KBDEXT }, // Speedracer: Media Stop 00102 { 0x2E, X2E | KBDEXT }, // Speedracer: Volume Down 00103 { 0x30, X30 | KBDEXT }, // Speedracer: Volume Up 00104 { 0x32, X32 | KBDEXT }, // Speedracer: Browser Home 00105 { 0x35, X35 | KBDEXT }, // Numpad Divide 00106 { 0x37, X37 | KBDEXT }, // Snapshot 00107 { 0x38, X38 | KBDEXT | KBDSPECIAL }, // RMenu // Hangeul NLS key 00108 { 0x46, X46 | KBDEXT }, // Break (Ctrl + Pause) 00109 { 0x47, X47 | KBDEXT }, // Home 00110 { 0x48, X48 | KBDEXT }, // Up 00111 { 0x49, X49 | KBDEXT }, // Prior 00112 { 0x4B, X4B | KBDEXT }, // Left 00113 { 0x4D, X4D | KBDEXT }, // Right 00114 { 0x4F, X4F | KBDEXT }, // End 00115 { 0x50, X50 | KBDEXT }, // Down 00116 { 0x51, X51 | KBDEXT }, // Next 00117 { 0x52, X52 | KBDEXT }, // Insert 00118 { 0x53, X53 | KBDEXT }, // Delete 00119 { 0x5B, X5B | KBDEXT }, // Left Win 00120 { 0x5C, X5C | KBDEXT }, // Right Win 00121 { 0x5D, X5D | KBDEXT }, // Applications 00122 { 0x5F, X5F | KBDEXT }, // Speedracer: Sleep 00123 { 0x65, X65 | KBDEXT }, // Speedracer: Browser Search 00124 { 0x66, X66 | KBDEXT }, // Speedracer: Browser Favorites 00125 { 0x67, X67 | KBDEXT }, // Speedracer: Browser Refresh 00126 { 0x68, X68 | KBDEXT }, // Speedracer: Browser Stop 00127 { 0x69, X69 | KBDEXT }, // Speedracer: Browser Forward 00128 { 0x6A, X6A | KBDEXT }, // Speedracer: Browser Back 00129 { 0x6B, X6B | KBDEXT }, // Speedracer: Launch App 1 00130 { 0x6C, X6C | KBDEXT }, // Speedracer: Launch Mail 00131 { 0x6D, X6D | KBDEXT }, // Speedracer: Launch Media Selector 00132 { 0xF1, XF1 | KBDEXT | KBDSPECIAL }, // Hanja 00133 { 0xF2, XF2 | KBDEXT | KBDSPECIAL }, // Hangeul 00134 { 0, 0 } 00135 }; 00136 00137 static ALLOC_SECTION_LDATA VSC_VK aE1VscToVk[] = { 00138 { 0x1D, Y1D }, // Pause 00139 { 0 , 0 } 00140 }; 00141 00142 /***************************************************************************\ 00143 * aVkToBits[] - map Virtual Keys to Modifier Bits 00144 * 00145 * See kbd.h for a full description. 00146 * 00147 * US Keyboard has only three shifter keys: 00148 * SHIFT (L & R) affects alphabnumeric keys, 00149 * CTRL (L & R) is used to generate control characters 00150 * ALT (L & R) used for generating characters by number with numpad 00151 \***************************************************************************/ 00152 00153 static ALLOC_SECTION_LDATA VK_TO_BIT aVkToBits[] = { 00154 { VK_SHIFT, KBDSHIFT }, 00155 { VK_CONTROL, KBDCTRL }, 00156 { VK_MENU, KBDALT }, 00157 { 0, 0 } 00158 }; 00159 00160 /***************************************************************************\ 00161 * aModification[] - map character modifier bits to modification number 00162 * 00163 * See kbd.h for a full description. 00164 * 00165 \***************************************************************************/ 00166 00167 static ALLOC_SECTION_LDATA MODIFIERS CharModifiers = { 00168 &aVkToBits[0], 00169 3, 00170 { 00171 // Modification# // Keys Pressed : Explanation 00172 // ============= // ============== : ============================= 00173 0, // : unshifted characters 00174 1, // SHIFT : capitals, ~!@#$%^&*()_+{}:"<>? etc. 00175 2, // CTRL : control characters 00176 3, // CTRL SHIFT : 00177 // ALT : invalid 00178 // ALT SHIFT : invalid 00179 // ALT CTRL : invalid 00180 // ALT CTRL SHIFT : invalid 00181 } 00182 }; 00183 00184 /***************************************************************************\ 00185 * 00186 * aVkToWch2[] - Virtual Key to WCHAR translation for 2 shift states 00187 * aVkToWch3[] - Virtual Key to WCHAR translation for 3 shift states 00188 * aVkToWch4[] - Virtual Key to WCHAR translation for 4 shift states 00189 * 00190 * Table attributes: Unordered Scan, null-terminated 00191 * 00192 * Search this table for an entry with a matching Virtual Key to find the 00193 * corresponding unshifted and shifted WCHAR characters. 00194 * 00195 * Reserved VirtualKey values (first column) 00196 * -1 - this line contains dead characters (diacritic) 00197 * 0 - terminator 00198 * 00199 * Reserved Attribute values (second column) 00200 * CAPLOK - CapsLock affects this key like Shift 00201 * 00202 * Reserved character values (third through last column) 00203 * WCH_NONE - No character 00204 * WCH_DEAD - Dead character (diacritic) value is in next line 00205 * 00206 \***************************************************************************/ 00207 00208 static ALLOC_SECTION_LDATA VK_TO_WCHARS2 aVkToWch2[] = { 00209 {'0' , 0 ,'0' ,')' }, 00210 {'1' , 0 ,'1' ,'!' }, 00211 {'3' , 0 ,'3' ,'#' }, 00212 {'4' , 0 ,'4' ,'$' }, 00213 {'5' , 0 ,'5' ,'%' }, 00214 {'7' , 0 ,'7' ,'&' }, 00215 {'8' , 0 ,'8' ,'*' }, 00216 {'9' , 0 ,'9' ,'(' }, 00217 {'A' , CAPLOK ,'a' ,'A' }, 00218 {'B' , CAPLOK ,'b' ,'B' }, 00219 {'C' , CAPLOK ,'c' ,'C' }, 00220 {'D' , CAPLOK ,'d' ,'D' }, 00221 {'E' , CAPLOK ,'e' ,'E' }, 00222 {'F' , CAPLOK ,'f' ,'F' }, 00223 {'G' , CAPLOK ,'g' ,'G' }, 00224 {'H' , CAPLOK ,'h' ,'H' }, 00225 {'I' , CAPLOK ,'i' ,'I' }, 00226 {'J' , CAPLOK ,'j' ,'J' }, 00227 {'K' , CAPLOK ,'k' ,'K' }, 00228 {'L' , CAPLOK ,'l' ,'L' }, 00229 {'M' , CAPLOK ,'m' ,'M' }, 00230 {'N' , CAPLOK ,'n' ,'N' }, 00231 {'O' , CAPLOK ,'o' ,'O' }, 00232 {'P' , CAPLOK ,'p' ,'P' }, 00233 {'Q' , CAPLOK ,'q' ,'Q' }, 00234 {'R' , CAPLOK ,'r' ,'R' }, 00235 {'S' , CAPLOK ,'s' ,'S' }, 00236 {'T' , CAPLOK ,'t' ,'T' }, 00237 {'U' , CAPLOK ,'u' ,'U' }, 00238 {'V' , CAPLOK ,'v' ,'V' }, 00239 {'W' , CAPLOK ,'w' ,'W' }, 00240 {'X' , CAPLOK ,'x' ,'X' }, 00241 {'Y' , CAPLOK ,'y' ,'Y' }, 00242 {'Z' , CAPLOK ,'z' ,'Z' }, 00243 {VK_OEM_1 , 0 ,';' ,':' }, 00244 {VK_OEM_2 , 0 ,'/' ,'?' }, 00245 {VK_OEM_3 , 0 ,'`' ,'~' }, 00246 {VK_OEM_7 , 0 ,0x27 ,'"' }, 00247 {VK_OEM_8 , 0 ,WCH_NONE ,WCH_NONE }, 00248 {VK_OEM_COMMA , 0 ,',' ,'<' }, 00249 {VK_OEM_PERIOD, 0 ,'.' ,'>' }, 00250 {VK_OEM_PLUS , 0 ,'=' ,'+' }, 00251 {VK_TAB , 0 ,'\t' ,'\t' }, 00252 {VK_ADD , 0 ,'+' ,'+' }, 00253 {VK_DECIMAL , 0 ,'.' ,'.' }, 00254 {VK_DIVIDE , 0 ,'/' ,'/' }, 00255 {VK_MULTIPLY , 0 ,'*' ,'*' }, 00256 {VK_SUBTRACT , 0 ,'-' ,'-' }, 00257 {0 , 0 ,0 ,0 } 00258 }; 00259 00260 static ALLOC_SECTION_LDATA VK_TO_WCHARS3 aVkToWch3[] = { 00261 // | | SHIFT | CONTROL | 00262 // | |==========|===========| 00263 {VK_BACK , 0 ,'\b' ,'\b' , 0x7f }, 00264 {VK_CANCEL , 0 ,0x03 ,0x03 , 0x03 }, 00265 {VK_ESCAPE , 0 ,0x1b ,0x1b , 0x1b }, 00266 {VK_OEM_4 , 0 ,'[' ,'{' , 0x1b }, 00267 {VK_OEM_5 , 0 ,'\\' ,'|' , 0x1c }, 00268 {VK_OEM_102 , 0 ,'\\' ,'|' , 0x1c }, 00269 {VK_OEM_6 , 0 ,']' ,'}' , 0x1d }, 00270 {VK_RETURN , 0 ,'\r' ,'\r' , '\n' }, 00271 {VK_SPACE , 0 ,' ' ,' ' , 0x20 }, 00272 {0 , 0 ,0 ,0 , 0 } 00273 }; 00274 00275 static ALLOC_SECTION_LDATA VK_TO_WCHARS4 aVkToWch4[] = { 00276 // | | SHIFT | CONTROL | SHFT+CTRL | 00277 // | |==========|===========|===========| 00278 {'2' , 0 ,'2' ,'@' , WCH_NONE , 0x00 }, 00279 {'6' , 0 ,'6' ,'^' , WCH_NONE , 0x1e }, 00280 {VK_OEM_MINUS , 0 ,'-' ,'_' , WCH_NONE , 0x1f }, 00281 {0 , 0 ,0 ,0 , 0 , 0 } 00282 }; 00283 00284 // Put this last so that VkKeyScan interprets number characters 00285 // as coming from the main section of the kbd (aVkToWch2 and 00286 // aVkToWch4) before considering the numpad (aVkToWch1). 00287 00288 static ALLOC_SECTION_LDATA VK_TO_WCHARS1 aVkToWch1[] = { 00289 { VK_NUMPAD0 , 0 , '0' }, 00290 { VK_NUMPAD1 , 0 , '1' }, 00291 { VK_NUMPAD2 , 0 , '2' }, 00292 { VK_NUMPAD3 , 0 , '3' }, 00293 { VK_NUMPAD4 , 0 , '4' }, 00294 { VK_NUMPAD5 , 0 , '5' }, 00295 { VK_NUMPAD6 , 0 , '6' }, 00296 { VK_NUMPAD7 , 0 , '7' }, 00297 { VK_NUMPAD8 , 0 , '8' }, 00298 { VK_NUMPAD9 , 0 , '9' }, 00299 { 0 , 0 , '\0' } //null terminator 00300 }; 00301 00302 /***************************************************************************\ 00303 * aVkToWcharTable: table of pointers to Character Tables 00304 * 00305 * Describes the character tables and the order they should be searched. 00306 * 00307 * Note: the order determines the behavior of VkKeyScan() : this function 00308 * takes a character and attempts to find a Virtual Key and character- 00309 * modifier key combination that produces that character. The table 00310 * containing the numeric keypad (aVkToWch1) must appear last so that 00311 * VkKeyScan('0') will be interpreted as one of keys from the main 00312 * section, not the numpad. etc. 00313 \***************************************************************************/ 00314 00315 static ALLOC_SECTION_LDATA VK_TO_WCHAR_TABLE aVkToWcharTable[] = { 00316 { (PVK_TO_WCHARS1)aVkToWch3, 3, sizeof(aVkToWch3[0]) }, 00317 { (PVK_TO_WCHARS1)aVkToWch4, 4, sizeof(aVkToWch4[0]) }, 00318 { (PVK_TO_WCHARS1)aVkToWch2, 2, sizeof(aVkToWch2[0]) }, 00319 { (PVK_TO_WCHARS1)aVkToWch1, 1, sizeof(aVkToWch1[0]) }, // must come last 00320 { NULL, 0, 0 } 00321 }; 00322 00323 /***************************************************************************\ 00324 * aKeyNames[], aKeyNamesExt[] - Scan Code -> Key Name tables 00325 * 00326 * For the GetKeyNameText() API function 00327 * 00328 * Tables for non-extended and extended (KBDEXT) keys. 00329 * (Keys producing printable characters are named by the character itself) 00330 \***************************************************************************/ 00331 00332 static ALLOC_SECTION_LDATA VSC_LPWSTR aKeyNames[] = { 00333 0x01, L"Esc", 00334 0x0e, L"Backspace", 00335 0x0f, L"Tab", 00336 0x1c, L"Enter", 00337 0x1d, L"Ctrl", 00338 0x2a, L"Shift", 00339 0x36, L"Right Shift", 00340 0x37, L"Num *", 00341 0x38, L"Alt", 00342 0x39, L"Space", 00343 0x3a, L"Caps Lock", 00344 0x3b, L"F1", 00345 0x3c, L"F2", 00346 0x3d, L"F3", 00347 0x3e, L"F4", 00348 0x3f, L"F5", 00349 0x40, L"F6", 00350 0x41, L"F7", 00351 0x42, L"F8", 00352 0x43, L"F9", 00353 0x44, L"F10", 00354 0x45, L"Pause", 00355 0x46, L"Scroll Lock", 00356 0x47, L"Num 7", 00357 0x48, L"Num 8", 00358 0x49, L"Num 9", 00359 0x4a, L"Num -", 00360 0x4b, L"Num 4", 00361 0x4c, L"Num 5", 00362 0x4d, L"Num 6", 00363 0x4e, L"Num +", 00364 0x4f, L"Num 1", 00365 0x50, L"Num 2", 00366 0x51, L"Num 3", 00367 0x52, L"Num 0", 00368 0x53, L"Num Del", 00369 0x54, L"Sys Req", 00370 0x57, L"F11", 00371 0x58, L"F12", 00372 0x7C, L"F13", 00373 0x7D, L"F14", 00374 0x7E, L"F15", 00375 0x7F, L"F16", 00376 0x80, L"F17", 00377 0x81, L"F18", 00378 0x82, L"F19", 00379 0x83, L"F20", 00380 0x84, L"F21", 00381 0x85, L"F22", 00382 0x86, L"F23", 00383 0x87, L"F24", 00384 0 , NULL 00385 }; 00386 00387 static ALLOC_SECTION_LDATA VSC_LPWSTR aKeyNamesExt[] = { 00388 0x1c, L"Num Enter", 00389 0x1d, L"Right Control", 00390 0x35, L"Num /", 00391 0x37, L"Prnt Scrn", 00392 0x38, L"Right Alt", 00393 0x45, L"Num Lock", 00394 0x46, L"Break", 00395 0x47, L"Home", 00396 0x48, L"Up", 00397 0x49, L"Page Up", 00398 0x4b, L"Left", 00399 0x4d, L"Right", 00400 0x4f, L"End", 00401 0x50, L"Down", 00402 0x51, L"Page Down", 00403 0x52, L"Insert", 00404 0x53, L"Delete", 00405 0x5B, L"Left Windows", 00406 0x5C, L"Right Windows", 00407 0x5D, L"Application", 00408 0xF1, L"Hanja", 00409 0xF2, L"Hangeul", 00410 0 , NULL 00411 }; 00412 00413 static ALLOC_SECTION_LDATA KBDTABLES KbdTables = { 00414 /* 00415 * Modifier keys 00416 */ 00417 &CharModifiers, 00418 00419 /* 00420 * Characters tables 00421 */ 00422 aVkToWcharTable, 00423 00424 /* 00425 * Diacritics (none for US English) 00426 */ 00427 NULL, 00428 00429 /* 00430 * Names of Keys (no dead keys) 00431 */ 00432 aKeyNames, 00433 aKeyNamesExt, 00434 NULL, 00435 00436 /* 00437 * Scan codes to Virtual Keys 00438 */ 00439 ausVK, 00440 sizeof(ausVK) / sizeof(ausVK[0]), 00441 aE0VscToVk, 00442 aE1VscToVk, 00443 00444 /* 00445 * No Locale-specific special processing 00446 */ 00447 0 00448 }; 00449 00450 PKBDTABLES KbdLayerDescriptor(VOID) 00451 { 00452 return &KbdTables; 00453 } 00454 00455 /***********************************************************************\ 00456 * VkToFuncTable_101a[] 00457 * 00458 \***********************************************************************/ 00459 00460 static ALLOC_SECTION_LDATA VK_F VkToFuncTable_101a[] = { 00461 { 00462 VK_OEM_PLUS, // Base Vk 00463 KBDNLS_TYPE_NORMAL, // NLSFEProcType 00464 KBDNLS_INDEX_NORMAL, // NLSFEProcCurrent 00465 0x0, // NLSFEProcSwitch 00466 { // NLSFEProcIndex 00467 {KBDNLS_SEND_BASE_VK,0}, // Base 00468 {KBDNLS_SEND_BASE_VK,0}, // Shift 00469 {KBDNLS_SEND_BASE_VK,0}, // Control 00470 {KBDNLS_SEND_BASE_VK,0}, // Shift+Control 00471 {KBDNLS_SEND_PARAM_VK,VK_JUNJA}, // Alt 00472 {KBDNLS_SEND_BASE_VK,0}, // Shift+Alt 00473 {KBDNLS_SEND_BASE_VK,0}, // Control+Alt 00474 {KBDNLS_SEND_BASE_VK,0} // Shift+Control+Alt 00475 }, 00476 { // NLSFEProcIndexAlt 00477 {KBDNLS_NULL,0}, // Base 00478 {KBDNLS_NULL,0}, // Shift 00479 {KBDNLS_NULL,0}, // Control 00480 {KBDNLS_NULL,0}, // Shift+Control 00481 {KBDNLS_NULL,0}, // Alt 00482 {KBDNLS_NULL,0}, // Shift+Alt 00483 {KBDNLS_NULL,0}, // Control+Alt 00484 {KBDNLS_NULL,0} // Shift+Control+Alt 00485 } 00486 } 00487 }; 00488 00489 /***********************************************************************\ 00490 * KbdNlsTables 00491 * 00492 \***********************************************************************/ 00493 00494 static ALLOC_SECTION_LDATA KBDNLSTABLES KbdNlsTables = { 00495 0, // OEM ID (0 = Microsoft) 00496 0, // Information 00497 1, // Number of VK_F entry 00498 VkToFuncTable_101a, // Pointer to VK_F array 00499 0, // Number of MouseVk entry 00500 NULL // Pointer to MouseVk array 00501 }; 00502 00503 PKBDNLSTABLES KbdNlsLayerDescriptor(VOID) 00504 { 00505 return &KbdNlsTables; 00506 }

Generated on Sat May 15 19:40:32 2004 for test by doxygen 1.3.7