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

kbd101b.c

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

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