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

fekbd.c

Go to the documentation of this file.
00001 /****************************** Module Header ******************************\ 00002 * Module Name: fekbd.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * OEM-specific tables and routines for FarEast keyboards. 00007 * 00008 * History: 00009 * 16-07-96 hideyukn Created. 00010 \***************************************************************************/ 00011 00012 #include "precomp.h" 00013 #pragma hdrstop 00014 00015 /* 00016 * This macro will clear Virtual key code. 00017 */ 00018 #define NLS_CLEAR_VK(Vk) \ 00019 ((Vk) &= (KBDEXT|KBDMULTIVK|KBDSPECIAL|KBDNUMPAD|KBDBREAK)) 00020 00021 /* 00022 * This macro will clear Virtual key code and 'make'/'break' bit. 00023 */ 00024 #define NLS_CLEAR_VK_AND_ATTR(Vk) \ 00025 ((Vk) &= (KBDEXT|KBDMULTIVK|KBDSPECIAL|KBDNUMPAD)) 00026 00027 /* 00028 * VK_DBE_xxx tables. 00029 */ 00030 BYTE NlsAlphaNumMode[] = {VK_DBE_ALPHANUMERIC,VK_DBE_HIRAGANA,VK_DBE_KATAKANA,0}; 00031 BYTE NlsSbcsDbcsMode[] = {VK_DBE_SBCSCHAR,VK_DBE_DBCSCHAR,0}; 00032 BYTE NlsRomanMode[] = {VK_DBE_NOROMAN,VK_DBE_ROMAN,0}; 00033 BYTE NlsCodeInputMode[] = {VK_DBE_NOCODEINPUT,VK_DBE_CODEINPUT,0}; 00034 00035 /* 00036 * Modifiers for generate NLS Virtual Key. 00037 */ 00038 VK_TO_BIT aVkToBits_NLSKBD[] = { 00039 { VK_SHIFT, KBDSHIFT}, 00040 { VK_CONTROL, KBDCTRL}, 00041 { VK_MENU, KBDALT}, 00042 { 0, 0} 00043 }; 00044 00045 MODIFIERS Modifiers_NLSKBD = { 00046 &aVkToBits_NLSKBD[0], 00047 7, 00048 { 00049 0, // modifier keys (VK modification number 0) 00050 1, // modifier keys (VK modification number 1) 00051 2, // modifier keys (VK modification number 2) 00052 3, // modifier keys (VK modification number 3) 00053 4, // modifier keys (VK modification number 4) 00054 5, // modifier keys (VK modification number 5) 00055 6, // modifier keys (VK modification number 6) 00056 7, // modifier keys (VK modification number 7) 00057 } 00058 }; 00059 00060 /* 00061 * For PC-9800 Series configuration. 00062 */ 00063 #define GEN_KANA_AWARE 0x1 // Switch generation for VK_END/VK_HELP based on Kana On/Off. 00064 #define GEN_VK_END 0x2 // Generate VK_END, otherwise VK_HELP. 00065 #define GEN_VK_HOME 0x4 // Generate VK_HOME, otherwise VK_CLEAR. 00066 00067 #define IS_KANA_AWARE() (fNlsKbdConfiguration & GEN_KANA_AWARE) 00068 #define IS_SEND_VK_END() (fNlsKbdConfiguration & GEN_VK_END) 00069 #define IS_SEND_VK_HOME() (fNlsKbdConfiguration & GEN_VK_HOME) 00070 00071 BYTE fNlsKbdConfiguration = GEN_KANA_AWARE | GEN_VK_END | GEN_VK_HOME; 00072 00073 /***************************************************************************\ 00074 * NlsTestKeyStateToggle() 00075 * 00076 * History: 00077 * 16-07-96 hideyukn Created. 00078 \***************************************************************************/ 00079 00080 BOOL NlsTestKeyStateToggle(BYTE Vk) 00081 { 00082 if (gpqForeground) { 00083 return (TestKeyStateToggle(gpqForeground,Vk)); 00084 } else { 00085 return (TestAsyncKeyStateToggle(Vk)); 00086 } 00087 } 00088 00089 /***************************************************************************\ 00090 * NlsSetKeyStateToggle(BYTE Vk) 00091 * 00092 * History: 00093 * 27-09-96 hideyukn Created. 00094 \***************************************************************************/ 00095 00096 VOID NlsSetKeyStateToggle(BYTE Vk) 00097 { 00098 if (gpqForeground) 00099 SetKeyStateToggle(gpqForeground,Vk); 00100 SetAsyncKeyStateToggle(Vk); 00101 } 00102 00103 /***************************************************************************\ 00104 * NlsClearKeyStateToggle() 00105 * 00106 * History: 00107 * 16-07-96 hideyukn Created. 00108 \***************************************************************************/ 00109 00110 VOID NlsClearKeyStateToggle(BYTE Vk) 00111 { 00112 if (gpqForeground) 00113 ClearKeyStateToggle(gpqForeground,Vk); 00114 ClearAsyncKeyStateToggle(Vk); 00115 } 00116 00117 /***************************************************************************\ 00118 * NlsGetCurrentInputMode() 00119 * 00120 * History: 00121 * 16-07-96 hideyukn Created. 00122 \***************************************************************************/ 00123 00124 BYTE NlsGetCurrentInputMode(BYTE *QueryMode) 00125 { 00126 BYTE *VkTable = QueryMode; 00127 BYTE VkDefault; 00128 /* 00129 * Get VkDefault, we will return this, if no bit is toggled. 00130 */ 00131 VkDefault = *VkTable; 00132 00133 while (*VkTable) { 00134 if (NlsTestKeyStateToggle(*VkTable)) { 00135 return *VkTable; 00136 } 00137 VkTable++; 00138 } 00139 00140 /* Something error */ 00141 return VkDefault; 00142 } 00143 00144 /***************************************************************************\ 00145 * NlsNullProc() - nothing to do 00146 * 00147 * History: 00148 * 16-07-96 hideyukn Created. 00149 \***************************************************************************/ 00150 00151 BOOL NlsNullProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00152 { 00153 UNREFERENCED_PARAMETER(pKe); 00154 UNREFERENCED_PARAMETER(dwExtraInfo); 00155 UNREFERENCED_PARAMETER(dwParam); 00156 00157 /* 00158 * Actually we should not get here... 00159 */ 00160 return TRUE; 00161 } 00162 00163 /***************************************************************************\ 00164 * NlsSendBaseVk() - nothing to do 00165 * 00166 * History: 00167 * 16-07-96 hideyukn Created. 00168 \***************************************************************************/ 00169 00170 BOOL NlsSendBaseVk(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00171 { 00172 UNREFERENCED_PARAMETER(pKe); 00173 UNREFERENCED_PARAMETER(dwExtraInfo); 00174 UNREFERENCED_PARAMETER(dwParam); 00175 00176 /* 00177 * We don't need to modify Original data. 00178 */ 00179 return TRUE; 00180 } 00181 00182 /***************************************************************************\ 00183 * NlsSendParamVk() - Replace original message with parameter 00184 * 00185 * History: 00186 * 16-07-96 hideyukn Created. 00187 \***************************************************************************/ 00188 00189 BOOL NlsSendParamVk(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00190 { 00191 UNREFERENCED_PARAMETER(dwExtraInfo); 00192 00193 /* 00194 * Clear Virtual code. 00195 */ 00196 NLS_CLEAR_VK(pKe->usFlaggedVk); 00197 /* 00198 * Set parameter as new VK key. 00199 */ 00200 pKe->usFlaggedVk |= (BYTE)dwParam; 00201 return TRUE; 00202 } 00203 00204 /***************************************************************************\ 00205 * NlsLapseProc() - Lapse handle (Locale dependent) 00206 * 00207 * History: 00208 * 16-07-96 hideyukn Created. 00209 \***************************************************************************/ 00210 00211 BOOL NlsLapseProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00212 { 00213 UNREFERENCED_PARAMETER(pKe); 00214 UNREFERENCED_PARAMETER(dwExtraInfo); 00215 UNREFERENCED_PARAMETER(dwParam); 00216 00217 /* 00218 * Just throw away this event. 00219 */ 00220 return FALSE; 00221 } 00222 00223 /***************************************************************************\ 00224 * AlphanumericModeProc() - handle special case Alphanumeric key 00225 * 00226 * History: 00227 * 16-07-96 hideyukn Created. 00228 \***************************************************************************/ 00229 00230 BOOL NlsAlphanumericModeProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00231 { 00232 if (!(pKe->usFlaggedVk & KBDBREAK)) { 00233 /* 00234 * We are in 'make' sequence. 00235 */ 00236 /* 00237 * Clear Virtual code. 00238 */ 00239 NLS_CLEAR_VK(pKe->usFlaggedVk); 00240 00241 if (!NlsTestKeyStateToggle(VK_DBE_ALPHANUMERIC)) { 00242 /* 00243 * Query current mode. 00244 */ 00245 BYTE CurrentMode = NlsGetCurrentInputMode(NlsAlphaNumMode); 00246 /* 00247 * Off toggle for previous key mode. 00248 */ 00249 NlsClearKeyStateToggle(CurrentMode); 00250 /* 00251 * We are not in 'AlphaNumeric' mode, before enter 'AlphaNumeric' 00252 * mode, we should send 'break' for previous key mode. 00253 */ 00254 xxxKeyEvent((USHORT)(pKe->usFlaggedVk | CurrentMode | KBDBREAK), 00255 pKe->bScanCode, pKe->dwTime, dwExtraInfo, FALSE); 00256 } 00257 /* 00258 * Switch to 'AlphaNumeric' mode. 00259 */ 00260 pKe->usFlaggedVk |= VK_DBE_ALPHANUMERIC; 00261 00262 /* 00263 * Call i/o control. 00264 */ 00265 if ((!gdwIMEOpenStatus) && NlsTestKeyStateToggle(VK_KANA)) { 00266 NlsKbdSendIMEProc(TRUE, IME_CMODE_KATAKANA); 00267 } 00268 } else { 00269 return NlsLapseProc(pKe,dwExtraInfo,dwParam); 00270 } 00271 return TRUE; 00272 } 00273 00274 /***************************************************************************\ 00275 * KatakanaModeProc() - handle special case Katakana key 00276 * 00277 * History: 00278 * 16-07-96 hideyukn Created. 00279 \***************************************************************************/ 00280 00281 BOOL NlsKatakanaModeProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00282 { 00283 if (!(pKe->usFlaggedVk & KBDBREAK)) { 00284 /* 00285 * We are in 'make' sequence. 00286 */ 00287 /* 00288 * Clear Virtual code. 00289 */ 00290 NLS_CLEAR_VK(pKe->usFlaggedVk); 00291 00292 if (!NlsTestKeyStateToggle(VK_DBE_KATAKANA)) { 00293 /* 00294 * Query current mode. 00295 */ 00296 BYTE CurrentMode = NlsGetCurrentInputMode(NlsAlphaNumMode); 00297 /* 00298 * Off toggle for previous key mode. 00299 */ 00300 NlsClearKeyStateToggle(CurrentMode); 00301 /* 00302 * We are not in 'Katakana' mode, yet. Before enter 'Katakana' 00303 * mode, we should make 'break key' for previous mode. 00304 */ 00305 xxxKeyEvent((USHORT)(pKe->usFlaggedVk | CurrentMode | KBDBREAK), 00306 pKe->bScanCode, pKe->dwTime, dwExtraInfo, FALSE); 00307 } 00308 /* 00309 * Switch to 'Katakana' mode. 00310 */ 00311 pKe->usFlaggedVk |= VK_DBE_KATAKANA; 00312 00313 /* 00314 * Call i/o control. 00315 */ 00316 if ((!gdwIMEOpenStatus) && (!(NlsTestKeyStateToggle(VK_KANA)))) { 00317 NlsKbdSendIMEProc(FALSE, IME_CMODE_ALPHANUMERIC); 00318 } 00319 } else { 00320 return(NlsLapseProc(pKe,dwExtraInfo,dwParam)); 00321 } 00322 return TRUE; 00323 } 00324 00325 /***************************************************************************\ 00326 * HiraganaModeProc() - handle special case Hiragana key (Locale dependent) 00327 * 00328 * History: 00329 * 16-07-96 hideyukn Created. 00330 \***************************************************************************/ 00331 00332 BOOL NlsHiraganaModeProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00333 { 00334 if (!(pKe->usFlaggedVk & KBDBREAK)) { 00335 /* 00336 * We are in 'make' sequence. 00337 */ 00338 /* 00339 * Clear Virtual code. 00340 */ 00341 NLS_CLEAR_VK(pKe->usFlaggedVk); 00342 00343 if (!NlsTestKeyStateToggle(VK_DBE_HIRAGANA)) { 00344 /* 00345 * Query current mode. 00346 */ 00347 BYTE CurrentMode = NlsGetCurrentInputMode(NlsAlphaNumMode); 00348 /* 00349 * Off toggle for previous key mode. 00350 */ 00351 NlsClearKeyStateToggle(CurrentMode); 00352 /* 00353 * We are not in 'Hiragana' mode, yet. Before enter 'Hiragana' 00354 * mode, we should make 'break key' for previous key. 00355 */ 00356 xxxKeyEvent((USHORT)(pKe->usFlaggedVk | CurrentMode | KBDBREAK), 00357 pKe->bScanCode, pKe->dwTime, dwExtraInfo, FALSE); 00358 } 00359 /* 00360 * Switch to 'Hiragana' mode. 00361 */ 00362 pKe->usFlaggedVk |= VK_DBE_HIRAGANA; 00363 00364 /* 00365 * Call i/o control. 00366 */ 00367 if ((!gdwIMEOpenStatus) && (!(NlsTestKeyStateToggle(VK_KANA)))) { 00368 NlsKbdSendIMEProc(FALSE, IME_CMODE_ALPHANUMERIC); 00369 } 00370 } else { 00371 return(NlsLapseProc(pKe,dwExtraInfo,dwParam)); 00372 } 00373 return TRUE; 00374 } 00375 00376 /***************************************************************************\ 00377 * SbcsDbcsToggleProc() - handle special case SBCS/DBCS key 00378 * 00379 * History: 00380 * 16-07-96 hideyukn Created. 00381 \***************************************************************************/ 00382 00383 BOOL NlsSbcsDbcsToggleProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00384 { 00385 if (!(pKe->usFlaggedVk & KBDBREAK)) { 00386 /* 00387 * We are in 'make' sequence. 00388 */ 00389 /* 00390 * Query current 'Sbcs'/'Dbcs' mode. 00391 */ 00392 BYTE CurrentMode = NlsGetCurrentInputMode(NlsSbcsDbcsMode); 00393 /* 00394 * Clear Virtual code. 00395 */ 00396 NLS_CLEAR_VK(pKe->usFlaggedVk); 00397 /* 00398 * Off toggle for previous key mode. 00399 */ 00400 NlsClearKeyStateToggle(CurrentMode); 00401 00402 switch (CurrentMode) { 00403 case VK_DBE_SBCSCHAR: 00404 /* 00405 * We are in 'SbcsChar' mode, let us send 'break key' for that. 00406 */ 00407 xxxKeyEvent((USHORT)(pKe->usFlaggedVk|VK_DBE_SBCSCHAR|KBDBREAK), 00408 pKe->bScanCode, pKe->dwTime, dwExtraInfo, FALSE); 00409 /* 00410 * Then, switch to 'DbcsChar' mode. 00411 */ 00412 pKe->usFlaggedVk |= VK_DBE_DBCSCHAR; 00413 break; 00414 case VK_DBE_DBCSCHAR: 00415 /* 00416 * We are in 'DbcsChar' mode, let us send 'break key' for that. 00417 */ 00418 xxxKeyEvent((USHORT)(pKe->usFlaggedVk|VK_DBE_DBCSCHAR|KBDBREAK), 00419 pKe->bScanCode, pKe->dwTime, dwExtraInfo, FALSE); 00420 /* 00421 * Then, switch to 'SbcsChar' mode. 00422 */ 00423 pKe->usFlaggedVk |= VK_DBE_SBCSCHAR; 00424 break; 00425 } 00426 } else { 00427 return(NlsLapseProc(pKe,dwExtraInfo,dwParam)); 00428 } 00429 return TRUE; 00430 } 00431 00432 /***************************************************************************\ 00433 * RomanToggleProc() - handle special case Roman key (Locale dependent) 00434 * 00435 * History: 00436 * 16-07-96 hideyukn Created. 00437 \***************************************************************************/ 00438 00439 BOOL NlsRomanToggleProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00440 { 00441 if (!(pKe->usFlaggedVk & KBDBREAK)) { 00442 /* 00443 * We are in 'make' sequence. 00444 */ 00445 /* 00446 * Query current 'Roman'/'NoRoman' mode. 00447 */ 00448 BYTE CurrentMode = NlsGetCurrentInputMode(NlsRomanMode); 00449 /* 00450 * Clear Virtual code. 00451 */ 00452 NLS_CLEAR_VK(pKe->usFlaggedVk); 00453 /* 00454 * Off toggle for previous key mode. 00455 */ 00456 NlsClearKeyStateToggle(CurrentMode); 00457 00458 switch (CurrentMode) { 00459 case VK_DBE_NOROMAN: 00460 /* 00461 * We are in 'NoRoman' mode, let us send 'break key' for that. 00462 */ 00463 xxxKeyEvent((USHORT)(pKe->usFlaggedVk|VK_DBE_NOROMAN|KBDBREAK), 00464 pKe->bScanCode, pKe->dwTime, dwExtraInfo, FALSE); 00465 /* 00466 * Then, switch to 'Roman' mode. 00467 */ 00468 pKe->usFlaggedVk |= VK_DBE_ROMAN; 00469 break; 00470 case VK_DBE_ROMAN: 00471 /* 00472 * We are in 'Roman' mode, let us send 'break key' for that. 00473 */ 00474 xxxKeyEvent((USHORT)(pKe->usFlaggedVk|VK_DBE_ROMAN|KBDBREAK), 00475 pKe->bScanCode, pKe->dwTime, dwExtraInfo, FALSE); 00476 /* 00477 * Then, switch to 'NoRoman' mode. 00478 */ 00479 pKe->usFlaggedVk |= VK_DBE_NOROMAN; 00480 break; 00481 } 00482 } else { 00483 return(NlsLapseProc(pKe,dwExtraInfo,dwParam)); 00484 } 00485 return TRUE; 00486 } 00487 00488 /***************************************************************************\ 00489 * CodeInputToggleProc() - handle special case Code Input key 00490 * 00491 * History: 00492 * 16-07-96 hideyukn Created. 00493 \***************************************************************************/ 00494 00495 BOOL NlsCodeInputToggleProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00496 { 00497 if (!(pKe->usFlaggedVk & KBDBREAK)) { 00498 /* 00499 * We are in 'make' sequence. 00500 */ 00501 /* 00502 * Query current 'CodeInput'/'NoCodeInput' mode. 00503 */ 00504 BYTE CurrentMode = NlsGetCurrentInputMode(NlsCodeInputMode); 00505 /* 00506 * Clear Virtual code. 00507 */ 00508 NLS_CLEAR_VK(pKe->usFlaggedVk); 00509 /* 00510 * Off toggle for previous key mode. 00511 */ 00512 NlsClearKeyStateToggle(CurrentMode); 00513 00514 switch (CurrentMode) { 00515 case VK_DBE_NOCODEINPUT: 00516 /* 00517 * We are in 'NoCodeInput' mode, let us send 'break key' for that. 00518 */ 00519 xxxKeyEvent((USHORT)(pKe->usFlaggedVk|VK_DBE_NOCODEINPUT|KBDBREAK), 00520 pKe->bScanCode, pKe->dwTime, dwExtraInfo, FALSE); 00521 /* 00522 * Then, switch to 'CodeInput' mode. 00523 */ 00524 pKe->usFlaggedVk |= VK_DBE_CODEINPUT; 00525 break; 00526 case VK_DBE_CODEINPUT: 00527 /* 00528 * We are in 'CodeInput' mode, let us send 'break key' for that. 00529 */ 00530 xxxKeyEvent((USHORT)(pKe->usFlaggedVk|VK_DBE_CODEINPUT|KBDBREAK), 00531 pKe->bScanCode, pKe->dwTime, dwExtraInfo, FALSE); 00532 /* 00533 * Then, switch to 'NoCodeInput' mode. 00534 */ 00535 pKe->usFlaggedVk |= VK_DBE_NOCODEINPUT; 00536 break; 00537 } 00538 } else { 00539 return(NlsLapseProc(pKe,dwExtraInfo,dwParam)); 00540 } 00541 return TRUE; 00542 } 00543 00544 /***************************************************************************\ 00545 * KanaToggleProc() - handle special case Kana key (Locale dependent) 00546 * 00547 * History: 00548 * 16-07-96 hideyukn Created. 00549 \***************************************************************************/ 00550 00551 BOOL NlsKanaModeToggleProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00552 { 00553 /* 00554 * Check this is 'make' or 'break'. 00555 */ 00556 BOOL bMake = !(pKe->usFlaggedVk & KBDBREAK); 00557 /* 00558 * Check we are in 'kana' mode or not. 00559 */ 00560 BOOL bKana = NlsTestKeyStateToggle(VK_KANA); 00561 /* 00562 * Clear virtual code and key attributes. 00563 */ 00564 NLS_CLEAR_VK_AND_ATTR(pKe->usFlaggedVk); 00565 00566 if (bMake) { 00567 /* 00568 * We are in 'make' sequence. 00569 */ 00570 if (bKana) { 00571 /* 00572 * Make 'break' for VK_KANA. 00573 */ 00574 pKe->usFlaggedVk |= (VK_KANA|KBDBREAK); 00575 } else { 00576 /* 00577 * Not yet in 'kana' mode, Let generate 'make' for VK_KANA... 00578 */ 00579 pKe->usFlaggedVk |= VK_KANA; 00580 } 00581 return TRUE; 00582 } else { 00583 /* 00584 * We will keep 'down' & 'toggled' in 'kana' mode, 00585 * then don't need to generate 'break' for VK_KANA. 00586 * when next time generate 'make' for this, we will generate 00587 * 'break' for this. 00588 */ 00589 return(NlsLapseProc(pKe,dwExtraInfo,dwParam)); 00590 } 00591 } 00592 00593 /**********************************************************************\ 00594 * NlsHelpOrEndProc() 00595 * 00596 * History: 00597 * 26-09-96 hideyukn Ported from NEC code. 00598 \**********************************************************************/ 00599 00600 BOOL NlsHelpOrEndProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00601 { 00602 UNREFERENCED_PARAMETER(dwExtraInfo); 00603 UNREFERENCED_PARAMETER(dwParam); 00604 00605 if (!(pKe->usFlaggedVk & KBDNUMPAD)) { 00606 /* 00607 * Clear Virtual code. 00608 */ 00609 NLS_CLEAR_VK(pKe->usFlaggedVk); 00610 00611 if (!IS_KANA_AWARE()) { 00612 /* 00613 * We don't care 'kana' status. just check VK_END or VK_HELP. 00614 */ 00615 if (IS_SEND_VK_END()) { 00616 pKe->usFlaggedVk |= VK_END; 00617 } else { 00618 pKe->usFlaggedVk |= VK_HELP; 00619 } 00620 } else { 00621 /* 00622 * We care 'kana' status. 00623 */ 00624 if (IS_SEND_VK_END()) { 00625 if (NlsTestKeyStateToggle(VK_KANA)) { 00626 pKe->usFlaggedVk |= VK_HELP; 00627 } else { 00628 pKe->usFlaggedVk |= VK_END; 00629 } 00630 } else { 00631 if (NlsTestKeyStateToggle(VK_KANA)) { 00632 pKe->usFlaggedVk |= VK_END; 00633 } else { 00634 pKe->usFlaggedVk |= VK_HELP; 00635 } 00636 } 00637 } 00638 } 00639 return TRUE; 00640 } 00641 00642 /**********************************************************************\ 00643 * NlsHelpOrEndProc() 00644 * 00645 * History: 00646 * 26-09-96 hideyukn Ported from NEC code. 00647 \**********************************************************************/ 00648 00649 BOOL NlsHomeOrClearProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00650 { 00651 UNREFERENCED_PARAMETER(dwExtraInfo); 00652 UNREFERENCED_PARAMETER(dwParam); 00653 00654 if (!(pKe->usFlaggedVk & KBDNUMPAD)) { 00655 /* 00656 * Clear virtual code. 00657 */ 00658 NLS_CLEAR_VK(pKe->usFlaggedVk); 00659 00660 if (IS_SEND_VK_HOME()) { 00661 pKe->usFlaggedVk |= VK_HOME; 00662 } else { 00663 pKe->usFlaggedVk |= VK_CLEAR; 00664 } 00665 } 00666 return TRUE; 00667 } 00668 00669 /**********************************************************************\ 00670 * NlsNumpadModeProc() 00671 * 00672 * History: 00673 * 26-09-96 hideyukn Ported from NEC code. 00674 \**********************************************************************/ 00675 00676 BOOL NlsNumpadModeProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00677 { 00678 /* 00679 * Get current Virtual key. 00680 */ 00681 BYTE Vk = LOBYTE(pKe->usFlaggedVk); 00682 00683 UNREFERENCED_PARAMETER(dwExtraInfo); 00684 UNREFERENCED_PARAMETER(dwParam); 00685 00686 if(!NlsTestKeyStateToggle(VK_NUMLOCK)) { 00687 /* 00688 * Clear virtual code. 00689 */ 00690 NLS_CLEAR_VK(pKe->usFlaggedVk); 00691 00692 switch (Vk) { 00693 case VK_NUMPAD0: 00694 pKe->usFlaggedVk |= VK_INSERT; 00695 break; 00696 case VK_NUMPAD1: 00697 pKe->usFlaggedVk |= VK_END; 00698 break; 00699 case VK_NUMPAD2: 00700 pKe->usFlaggedVk |= VK_DOWN; 00701 break; 00702 case VK_NUMPAD3: 00703 pKe->usFlaggedVk |= VK_NEXT; 00704 break; 00705 case VK_NUMPAD4: 00706 pKe->usFlaggedVk |= VK_LEFT; 00707 break; 00708 case VK_NUMPAD5: 00709 pKe->usFlaggedVk |= VK_CLEAR; 00710 break; 00711 case VK_NUMPAD6: 00712 pKe->usFlaggedVk |= VK_RIGHT; 00713 break; 00714 case VK_NUMPAD7: 00715 pKe->usFlaggedVk |= VK_HOME; 00716 break; 00717 case VK_NUMPAD8: 00718 pKe->usFlaggedVk |= VK_UP; 00719 break; 00720 case VK_NUMPAD9: 00721 pKe->usFlaggedVk |= VK_PRIOR; 00722 break; 00723 case VK_DECIMAL: 00724 pKe->usFlaggedVk |= VK_DELETE; 00725 break; 00726 } 00727 00728 } else if (TestRawKeyDown(VK_SHIFT)) { 00729 /* 00730 * Clear virtual code. 00731 */ 00732 NLS_CLEAR_VK(pKe->usFlaggedVk); 00733 00734 switch (Vk) { 00735 case VK_NUMPAD0: 00736 pKe->usFlaggedVk |= VK_INSERT; 00737 break; 00738 case VK_NUMPAD1: 00739 pKe->usFlaggedVk |= VK_END; 00740 break; 00741 case VK_NUMPAD2: 00742 pKe->usFlaggedVk |= VK_DOWN; 00743 break; 00744 case VK_NUMPAD3: 00745 pKe->usFlaggedVk |= VK_NEXT; 00746 break; 00747 case VK_NUMPAD4: 00748 pKe->usFlaggedVk |= VK_LEFT; 00749 break; 00750 case VK_NUMPAD5: 00751 pKe->usFlaggedVk |= VK_CLEAR; 00752 break; 00753 case VK_NUMPAD6: 00754 pKe->usFlaggedVk |= VK_RIGHT; 00755 break; 00756 case VK_NUMPAD7: 00757 pKe->usFlaggedVk |= VK_HOME; 00758 break; 00759 case VK_NUMPAD8: 00760 pKe->usFlaggedVk |= VK_UP; 00761 break; 00762 case VK_NUMPAD9: 00763 pKe->usFlaggedVk |= VK_PRIOR; 00764 break; 00765 case VK_DECIMAL: 00766 pKe->usFlaggedVk |= VK_DELETE; 00767 break; 00768 } 00769 } else { 00770 /* 00771 * Otherwise, just pass through... 00772 */ 00773 } 00774 return TRUE; 00775 } 00776 00777 /**********************************************************************\ 00778 * NlsKanaEventProc() - Fujitsu FMV oyayubi shift keyboard use only. 00779 * 00780 * History: 00781 * 10-10-96 v-kazuta Created. 00782 \**********************************************************************/ 00783 BOOL NlsKanaEventProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00784 { 00785 UNREFERENCED_PARAMETER(dwExtraInfo); 00786 /* 00787 * Clear Virtual code. 00788 */ 00789 NLS_CLEAR_VK(pKe->usFlaggedVk); 00790 00791 /* 00792 * Set parameter as new VK key. 00793 */ 00794 pKe->usFlaggedVk |= (BYTE)dwParam; 00795 00796 /* 00797 * Send notification to kernel mode keyboard driver. 00798 */ 00799 if (!(pKe->usFlaggedVk & KBDBREAK)) { 00800 if (NlsTestKeyStateToggle(VK_KANA)) { 00801 /* 00802 * Call i/o control. 00803 */ 00804 NlsKbdSendIMEProc(FALSE, IME_CMODE_ALPHANUMERIC); 00805 } else { 00806 /* 00807 * Call i/o control. 00808 */ 00809 NlsKbdSendIMEProc(TRUE, IME_CMODE_KATAKANA); 00810 } 00811 } 00812 return TRUE; 00813 } 00814 00815 /**********************************************************************\ 00816 * NlsConvOrNonConvProc() - Fujitsu FMV oyayubi shift keyboard only. 00817 * 00818 * History: 00819 * 10-10-96 v-kazuta Created. 00820 \**********************************************************************/ 00821 BOOL NlsConvOrNonConvProc(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam) 00822 { 00823 UNREFERENCED_PARAMETER(pKe); 00824 UNREFERENCED_PARAMETER(dwExtraInfo); 00825 UNREFERENCED_PARAMETER(dwParam); 00826 /* 00827 * 00828 */ 00829 if ((!gdwIMEOpenStatus) && (!(NlsTestKeyStateToggle(VK_KANA)))) { 00830 NlsKbdSendIMEProc(FALSE, IME_CMODE_ALPHANUMERIC); 00831 } 00832 /* 00833 * We don't need to modify Original data. 00834 */ 00835 return TRUE; 00836 } 00837 00838 /**********************************************************************\ 00839 * Index to function body dispatcher table 00840 * 00841 * History: 00842 * 16-07-96 hideyukn Created. 00843 \**********************************************************************/ 00844 00845 NLSKEPROC aNLSKEProc[] = { 00846 NlsNullProc, // KBDNLS_NULL (Invalid function) 00847 NlsLapseProc, // KBDNLS_NOEVENT (Drop keyevent) 00848 NlsSendBaseVk, // KBDNLS_SEND_BASE_VK (Send Base VK_xxx) 00849 NlsSendParamVk, // KBDNLS_SEND_PARAM_VK (Send Parameter VK_xxx) 00850 NlsKanaModeToggleProc, // KBDNLS_KANAMODE (VK_KANA (Special case)) 00851 NlsAlphanumericModeProc, // KBDNLS_ALPHANUM (VK_DBE_ALPHANUMERIC) 00852 NlsHiraganaModeProc, // KBDNLS_HIRAGANA (VK_DBE_HIRAGANA) 00853 NlsKatakanaModeProc, // KBDNLS_KATAKANA (VK_DBE_KATAKANA) 00854 NlsSbcsDbcsToggleProc, // KBDNLS_SBCSDBCS (VK_DBE_SBCSCHAR/VK_DBE_DBCSCHAR) 00855 NlsRomanToggleProc, // KBDNLS_ROMAN (VK_DBE_ROMAN/VK_DBE_NOROMAN) 00856 NlsCodeInputToggleProc, // KBDNLS_CODEINPUT (VK_DBE_CODEINPUT/VK_DBE_NOCODEINPUT) 00857 NlsHelpOrEndProc, // KBDNLS_HELP_OR_END (VK_HELP or VK_END) [NEC PC-9800 Only] 00858 NlsHomeOrClearProc, // KBDNLS_HOME_OR_CLEAR (VK_HOME or VK_CLEAR) [NEC PC-9800 Only] 00859 NlsNumpadModeProc, // KBDNLS_NUMPAD (VK_xxx for Numpad) [NEC PC-9800 Only] 00860 NlsKanaEventProc, // KBDNLS_KANAEVENT (VK_KANA) [Fujitsu FMV oyayubi Only] 00861 NlsConvOrNonConvProc, // KBDNLS_CONV_OR_NONCONV (VK_CONVERT and VK_NONCONVERT) [Fujitsu FMV oyayubi Only] 00862 }; 00863 00864 BOOL GenerateNlsVkKey(PVK_F pVkToF, WORD nMod, PKE pKe, ULONG_PTR dwExtraInfo) 00865 { 00866 BYTE iFuncIndex; 00867 DWORD dwParam; 00868 00869 iFuncIndex = pVkToF->NLSFEProc[nMod].NLSFEProcIndex; 00870 dwParam = pVkToF->NLSFEProc[nMod].NLSFEProcParam; 00871 00872 return((aNLSKEProc[iFuncIndex])(pKe, dwExtraInfo, dwParam)); 00873 } 00874 00875 BOOL GenerateNlsVkAltKey(PVK_F pVkToF, WORD nMod, PKE pKe, ULONG_PTR dwExtraInfo) 00876 { 00877 BYTE iFuncIndex; 00878 DWORD dwParam; 00879 00880 iFuncIndex = pVkToF->NLSFEProcAlt[nMod].NLSFEProcIndex; 00881 dwParam = pVkToF->NLSFEProcAlt[nMod].NLSFEProcParam; 00882 00883 return((aNLSKEProc[iFuncIndex])(pKe,dwExtraInfo,dwParam)); 00884 } 00885 00886 /***************************************************************************\ 00887 * KbdNlsFuncTypeDummy() - KBDNLS_FUNC_TYPE_NULL 00888 * 00889 * History: 00890 * 16-07-96 hideyukn Created. 00891 \***************************************************************************/ 00892 00893 BOOL KbdNlsFuncTypeDummy(PVK_F pVkToF, PKE pKe, ULONG_PTR dwExtraInfo) 00894 { 00895 UNREFERENCED_PARAMETER(pVkToF); 00896 UNREFERENCED_PARAMETER(pKe); 00897 UNREFERENCED_PARAMETER(dwExtraInfo); 00898 00899 /* 00900 * We don't need to modify Original data. 00901 */ 00902 return TRUE; 00903 } 00904 00905 /***************************************************************************\ 00906 * KbdNlsFuncTypeNormal - KBDNLS_FUNC_TYPE_NORMAL 00907 * 00908 * History: 00909 * 16-07-96 hideyukn Created. 00910 \***************************************************************************/ 00911 00912 BOOL KbdNlsFuncTypeNormal(PVK_F pVkToF, PKE pKe, ULONG_PTR dwExtraInfo) 00913 { 00914 WORD nMod; 00915 00916 if (pKe == NULL) { 00917 /* 00918 * Clear state and deactivate this key processor 00919 */ 00920 return FALSE; 00921 } 00922 00923 nMod = GetModificationNumber(&Modifiers_NLSKBD, 00924 GetModifierBits(&Modifiers_NLSKBD, 00925 gafRawKeyState)); 00926 00927 if (nMod != SHFT_INVALID) { 00928 return(GenerateNlsVkKey(pVkToF, nMod, pKe, dwExtraInfo)); 00929 } 00930 return FALSE; 00931 } 00932 00933 /***************************************************************************\ 00934 * KbdNlsFuncTypeAlt - KBDNLS_FUNC_TYPE_ALT 00935 * 00936 * History: 00937 * 16-07-96 hideyukn Created. 00938 \***************************************************************************/ 00939 00940 BOOL KbdNlsFuncTypeAlt(PVK_F pVkToF, PKE pKe, ULONG_PTR dwExtraInfo) 00941 { 00942 WORD nMod; 00943 BOOL fRet = FALSE; 00944 00945 if (pKe == NULL) { 00946 /* 00947 * Clear state and deactivate this key processor 00948 */ 00949 return FALSE; 00950 } 00951 00952 nMod = GetModificationNumber(&Modifiers_NLSKBD, 00953 GetModifierBits(&Modifiers_NLSKBD, 00954 gafRawKeyState)); 00955 00956 if (nMod != SHFT_INVALID) { 00957 if (!(pKe->usFlaggedVk & KBDBREAK)) { 00958 if (pVkToF->NLSFEProcCurrent == KBDNLS_INDEX_ALT) { 00959 fRet = GenerateNlsVkAltKey(pVkToF, nMod, pKe, dwExtraInfo); 00960 } else { 00961 fRet = GenerateNlsVkKey(pVkToF, nMod, pKe, dwExtraInfo); 00962 } 00963 if (pVkToF->NLSFEProcSwitch & (1 << nMod)) { 00964 TAGMSG0(DBGTAG_IMM, "USERKM:FEKBD Switching Alt table\n"); 00965 /* 00966 * Switch to "alt". 00967 */ 00968 pVkToF->NLSFEProcCurrent = KBDNLS_INDEX_ALT; 00969 } 00970 } else { 00971 if (pVkToF->NLSFEProcCurrent == KBDNLS_INDEX_ALT) { 00972 fRet = GenerateNlsVkAltKey(pVkToF, nMod, pKe, dwExtraInfo); 00973 /* 00974 * Back to "normal" 00975 */ 00976 pVkToF->NLSFEProcCurrent = KBDNLS_INDEX_NORMAL; 00977 } else { 00978 fRet = GenerateNlsVkKey(pVkToF, nMod, pKe, dwExtraInfo); 00979 } 00980 } 00981 } 00982 return fRet; 00983 } 00984 00985 /***************************************************************************\ 00986 * KENLSProcs() 00987 * 00988 * History: 00989 * 16-07-96 hideyukn Created. 00990 \***************************************************************************/ 00991 00992 NLSVKFPROC aNLSVKFProc[] = { 00993 KbdNlsFuncTypeDummy, // KBDNLS_INDEX_NULL 0 00994 KbdNlsFuncTypeNormal, // KBDNLS_INDEX_NORMAL 1 00995 KbdNlsFuncTypeAlt // KBDNLS_INDEX_ALT 2 00996 }; 00997 00998 /* 00999 * Returning FALSE means the Key Event has been deleted by a special-case 01000 * KeyEvent processor. 01001 * Returning TRUE means the Key Event should be passed on (although it may 01002 * have been altered. 01003 */ 01004 BOOL xxxKENLSProcs(PKE pKe, ULONG_PTR dwExtraInfo) 01005 { 01006 01007 CheckCritIn(); 01008 01009 if (gpKbdNlsTbl != NULL) { 01010 PVK_F pVkToF = gpKbdNlsTbl->pVkToF; 01011 UINT iNumVk = gpKbdNlsTbl->NumOfVkToF; 01012 01013 while(iNumVk) { 01014 if (pVkToF[iNumVk-1].Vk == LOBYTE(pKe->usFlaggedVk)) { 01015 return((aNLSVKFProc[pVkToF[iNumVk-1].NLSFEProcType]) 01016 (&(pVkToF[iNumVk-1]),pKe,dwExtraInfo)); 01017 } 01018 iNumVk--; 01019 } 01020 } 01021 /* 01022 * Other special Key Event processors 01023 */ 01024 return TRUE; 01025 } 01026 01027 /***************************************************************************\ 01028 * NlsKbdSendIMENotification() 01029 * 01030 * History: 01031 * 10-09-96 hideyukn Created. 01032 \***************************************************************************/ 01033 01034 VOID NlsKbdSendIMENotification(DWORD dwImeOpen, DWORD dwImeConversion) 01035 { 01036 PKBDNLSTABLES pKbdNlsTable = gpKbdNlsTbl; 01037 01038 if (pKbdNlsTable == NULL) { 01039 /* 01040 * 'Active' layout driver does not have NLSKBD table. 01041 */ 01042 return; 01043 } 01044 01045 /* 01046 * Let us send notification to kernel mode keyboard driver, if nessesary. 01047 */ 01048 if ((pKbdNlsTable->LayoutInformation) & NLSKBD_INFO_SEND_IME_NOTIFICATION) { 01049 PDEVICEINFO pDeviceInfo; 01050 01051 /* 01052 * Fill up the KEYBOARD_IME_STATUS structure. 01053 */ 01054 gKbdImeStatus.UnitId = 0; 01055 gKbdImeStatus.ImeOpen = dwImeOpen; 01056 gKbdImeStatus.ImeConvMode = dwImeConversion; 01057 01058 EnterDeviceInfoListCrit(); 01059 BEGINATOMICDEVICEINFOLISTCHECK(); 01060 for (pDeviceInfo = gpDeviceInfoList; pDeviceInfo; pDeviceInfo = pDeviceInfo->pNext) { 01061 if ((pDeviceInfo->type == DEVICE_TYPE_KEYBOARD) && (pDeviceInfo->handle)) { 01062 RequestDeviceChange(pDeviceInfo, GDIAF_IME_STATUS, TRUE); 01063 } 01064 } 01065 ENDATOMICDEVICEINFOLISTCHECK(); 01066 LeaveDeviceInfoListCrit(); 01067 } 01068 return; 01069 } 01070 01071 VOID NlsKbdSendIMEProc(DWORD dwImeOpen, DWORD dwImeConversion) 01072 { 01073 if (gpqForeground != NULL && gpqForeground->ptiKeyboard != NULL && 01074 (!(GetAppImeCompatFlags(gpqForeground->ptiKeyboard) & IMECOMPAT_HYDRACLIENT))) { 01075 NlsKbdSendIMENotification(dwImeOpen, dwImeConversion); 01076 } 01077 } 01078 01079 /* 01080 * Compatibility for Windows NT 3.xx and Windows 3.x for NEC PC-9800 Series 01081 */ 01082 #define NLSKBD_CONFIG_PATH \ 01083 L"WOW\\keyboard" 01084 01085 /***************************************************************************\ 01086 * NlsKbdInitializePerSystem() 01087 * 01088 * History: 01089 * 26-09-96 hideyukn Created. 01090 \***************************************************************************/ 01091 01092 VOID NlsKbdInitializePerSystem(VOID) 01093 { 01094 RTL_QUERY_REGISTRY_TABLE QueryTable[4]; 01095 01096 UNICODE_STRING EndString, HelpString; 01097 UNICODE_STRING YesString, NoString; 01098 UNICODE_STRING HomeString, ClearString; 01099 01100 UNICODE_STRING HelpKeyString; 01101 UNICODE_STRING KanaHelpString; 01102 UNICODE_STRING ClearKeyString; 01103 01104 NTSTATUS status; 01105 01106 // 01107 // Set default VK_DBE_xxx status. 01108 // 01109 // 01110 // AlphaNumeric input mode. 01111 // 01112 NlsSetKeyStateToggle(VK_DBE_ALPHANUMERIC); 01113 // 01114 // Single byte character input mode. 01115 // 01116 NlsSetKeyStateToggle(VK_DBE_SBCSCHAR); 01117 // 01118 // No roman input mode. 01119 // 01120 NlsSetKeyStateToggle(VK_DBE_NOROMAN); 01121 // 01122 // No code input mode. 01123 // 01124 NlsSetKeyStateToggle(VK_DBE_NOCODEINPUT); 01125 01126 // 01127 // From Here, below code is for compatibility for Windows NT 3.xx 01128 // for NEC PC-9800 verion. 01129 // 01130 01131 // 01132 // Initialize default strings. 01133 // 01134 RtlInitUnicodeString(&EndString, L"end"); 01135 RtlInitUnicodeString(&HelpString,L"help"); 01136 01137 RtlInitUnicodeString(&YesString,L"yes"); 01138 RtlInitUnicodeString(&NoString, L"no"); 01139 01140 RtlInitUnicodeString(&HomeString, L"home"); 01141 RtlInitUnicodeString(&ClearString,L"clear"); 01142 01143 // 01144 // Initialize recieve buffer. 01145 // 01146 RtlInitUnicodeString(&HelpKeyString,NULL); 01147 RtlInitUnicodeString(&KanaHelpString,NULL); 01148 RtlInitUnicodeString(&ClearKeyString,NULL); 01149 01150 // 01151 // Initalize query tables. 01152 // 01153 // ValueName : "helpkey" 01154 // ValueData : if "end" VK_END, otherwise VK_HELP 01155 // 01156 QueryTable[0].QueryRoutine = NULL; 01157 QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; 01158 QueryTable[0].Name = (PWSTR) L"helpkey", 01159 QueryTable[0].EntryContext = (PVOID) &HelpKeyString; 01160 QueryTable[0].DefaultType = REG_SZ; 01161 QueryTable[0].DefaultData = &EndString; 01162 QueryTable[0].DefaultLength = 0; 01163 01164 // 01165 // ValueName : "KanaHelpKey" 01166 // ValueData : if "yes" if kana on switch VK_HELP and VK_END 01167 // 01168 QueryTable[1].QueryRoutine = NULL; 01169 QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT; 01170 QueryTable[1].Name = (PWSTR) L"KanaHelpKey", 01171 QueryTable[1].EntryContext = (PVOID) &KanaHelpString; 01172 QueryTable[1].DefaultType = REG_SZ; 01173 QueryTable[1].DefaultData = &YesString; 01174 QueryTable[1].DefaultLength = 0; 01175 01176 // 01177 // ValueName : "clrkey" 01178 // ValueData : if "home" VK_HOME, otherwise VK_CLEAR 01179 // 01180 QueryTable[2].QueryRoutine = NULL; 01181 QueryTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT; 01182 QueryTable[2].Name = (PWSTR) L"clrkey", 01183 QueryTable[2].EntryContext = (PVOID) &ClearKeyString; 01184 QueryTable[2].DefaultType = REG_SZ; 01185 QueryTable[2].DefaultData = &HomeString; 01186 QueryTable[2].DefaultLength = 0; 01187 01188 QueryTable[3].QueryRoutine = NULL; 01189 QueryTable[3].Flags = 0; 01190 QueryTable[3].Name = NULL; 01191 01192 status = RtlQueryRegistryValues( 01193 RTL_REGISTRY_WINDOWS_NT, 01194 NLSKBD_CONFIG_PATH, 01195 QueryTable, NULL, NULL); 01196 01197 if (!NT_SUCCESS(status)) { 01198 RIPMSG1(RIP_WARNING, "FEKBD:RtlQueryRegistryValues fails (%x)\n", status); 01199 return; 01200 } 01201 01202 if (RtlEqualUnicodeString(&HelpKeyString,&HelpString,TRUE)) { 01203 /* 01204 * Generate VK_HELP, when NLSKBD_HELP_OR_END is called. 01205 */ 01206 fNlsKbdConfiguration &= ~GEN_VK_END; 01207 } 01208 01209 if (RtlEqualUnicodeString(&KanaHelpString,&NoString,TRUE)) { 01210 /* 01211 * In case of "yes": 01212 * If 'kana' is on, when NLSKBD_HELP_OR_END is called, switch VK_END and VK_HELP. 01213 * Else, in case of "no": 01214 * Doesn't generate by 'kana' toggle state. 01215 */ 01216 fNlsKbdConfiguration &= ~GEN_KANA_AWARE; 01217 } 01218 01219 if (RtlEqualUnicodeString(&ClearKeyString,&ClearString,TRUE)) { 01220 /* 01221 * Generate VK_CLEAR, when KBDNLS_HOME_OR_CLEAR is called. 01222 */ 01223 fNlsKbdConfiguration &= ~GEN_VK_HOME; 01224 } 01225 01226 return; 01227 }

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