Changeset 9810 for trunk/src/user32/winkeyboard.cpp
- Timestamp:
- Feb 16, 2003, 4:31:12 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/winkeyboard.cpp
r9689 r9810 1 /* $Id: winkeyboard.cpp,v 1.3 8 2003-01-17 16:35:38sandervl Exp $ */1 /* $Id: winkeyboard.cpp,v 1.39 2003-02-16 15:31:12 sandervl Exp $ */ 2 2 /* 3 3 * Win32 <-> PM key translation … … 17 17 #include <stdio.h> 18 18 #include <winkeyboard.h> 19 #include "oslib win.h"19 #include "oslibkbd.h" 20 20 #include <heapstring.h> 21 21 #include <pmscan.h> … … 415 415 /* 0x55 VK_U */ , PMSCAN_U , "U" 416 416 /* 0x56 VK_V */ , PMSCAN_V , "V" 417 /* 0x57 VK 417 /* 0x57 VK_W */ , PMSCAN_W , "W" 418 418 /* 0x58 VK_X */ , PMSCAN_X , "X" 419 419 /* 0x59 VK_Y */ , PMSCAN_Y , "Y" … … 861 861 int nrkeys) 862 862 { 863 int pmvkey; 864 865 #ifdef DEBUG 866 for(int j=1;j<nrkeys;j++) { 867 if(pmkey[j]) 868 dprintf2(("PM vkey %x state %x", j, pmkey[j])); 869 } 870 #endif 871 863 872 for(int i=1;i<nrkeys;i++) { 864 873 if(abWinVKeyToPMScan[i].bPMScanCode) { 865 winkey[i] = pmkey[OSLibWinTranslateChar(abWinVKeyToPMScan[i].bPMScanCode, TC_SCANCODETOVIRTUALKEY, 0)]; 874 pmvkey = OSLibWinTranslateChar(abWinVKeyToPMScan[i].bPMScanCode, TC_SCANCODETOVIRTUALKEY, 0); 875 if(pmvkey == 0) { 876 dprintf2(("WinTranslateChar %x (%x) FAILED!!", i, abWinVKeyToPMScan[i].bPMScanCode)); 877 } 878 winkey[i] = pmkey[pmvkey]; 866 879 } 880 else dprintf2(("key %x has no PM scancode", i)); 867 881 } 868 882 winkey[VK_SHIFT] = winkey[VK_LSHIFT] | winkey[VK_RSHIFT]; … … 970 984 BOOL WIN32API GetKeyboardState(PBYTE lpKeyState) 971 985 { 986 #if 1 987 int state; 988 for(int i=0;i<256;i++) { 989 state = GetKeyState(i); 990 lpKeyState[i] = ((state & 0x8000) >> 8) | (state & 1); 991 if(lpKeyState[i] & 0x80) { 992 dprintf2(("Win key 0x%0x = %x", i, lpKeyState[i])); 993 } 994 } 995 return TRUE; 996 #if 1 997 #else 998 BYTE PMScanState[256]; 999 BOOL rc; 1000 int state; 1001 1002 memset(PMScanState, 0, sizeof(PMScanState)); 1003 memset(lpKeyState, 0, 256); 1004 1005 // 1006 //OSLibWinGetKeyboardStateTable returns the state of PM virtual keys only and 1007 //there are far fewer PM vkeys. (e.g. 0-9, A-Z are not included) 1008 //So we need to use OSLibWinGetScanStateTable (WinSetScanState) 1009 // 1010 rc = OSLibWinGetScanStateTable((PBYTE)&PMScanState[0] ); 1011 if(!rc) { 1012 // DebugInt3(); 1013 dprintf(("OSLibWinGetScanStateTable FAILED")); 1014 return FALSE; 1015 } 1016 for(int i=0;i<256;i++) { 1017 if(abWinVKeyToPMScan[i].bPMScanCode) { 1018 lpKeyState[i] = PMScanState[abWinVKeyToPMScan[i].bPMScanCode]; 1019 } 1020 if(lpKeyState[i] & 0x80) { 1021 dprintf2(("Win key 0x%0x = %x", i, lpKeyState[i])); 1022 } 1023 } 1024 //now process the mouse buttons (left, middle, right) 1025 state = GetKeyState(VK_LBUTTON); 1026 lpKeyState[VK_LBUTTON] = ((state & 0x8000) >> 8) | (state & 1); 1027 state = GetKeyState(VK_MBUTTON); 1028 lpKeyState[VK_MBUTTON] = ((state & 0x8000) >> 8) | (state & 1); 1029 state = GetKeyState(VK_RBUTTON); 1030 lpKeyState[VK_RBUTTON] = ((state & 0x8000) >> 8) | (state & 1); 1031 #ifdef DEBUG 1032 if(lpKeyState[VK_LBUTTON]) { 1033 dprintf2(("Win key 0x%0x = %x", VK_LBUTTON, lpKeyState[VK_LBUTTON])); 1034 } 1035 if(lpKeyState[VK_MBUTTON]) { 1036 dprintf2(("Win key 0x%0x = %x", VK_MBUTTON, lpKeyState[VK_MBUTTON])); 1037 } 1038 if(lpKeyState[VK_RBUTTON]) { 1039 dprintf2(("Win key 0x%0x = %x", VK_RBUTTON, lpKeyState[VK_RBUTTON])); 1040 } 1041 #endif 1042 return TRUE; 1043 #endif 1044 #else 972 1045 BYTE PMKeyState[256]; 973 1046 BOOL rc; … … 999 1072 } 1000 1073 return FALSE; 1074 #endif 1001 1075 } 1002 1076 //****************************************************************************** … … 1152 1226 if(lpbKeyState[VK_LSHIFT] & 0x80) shiftstate |= TCF_LSHIFT; 1153 1227 if(lpbKeyState[VK_RSHIFT] & 0x80) shiftstate |= TCF_RSHIFT; 1154 if(lpbKeyState[VK_SHIFT] & 0x80) shiftstate |= TCF_SHIFT;1155 1228 if(lpbKeyState[VK_LCONTROL] & 0x80) shiftstate |= TCF_LCONTROL; 1156 1229 if(lpbKeyState[VK_RCONTROL] & 0x80) shiftstate |= TCF_RCONTROL; 1157 if(lpbKeyState[VK_CONTROL] & 0x80) shiftstate |= TCF_CONTROL;1158 1230 if(lpbKeyState[VK_LMENU] & 0x80) shiftstate |= TCF_ALT; 1159 1231 if(lpbKeyState[VK_RMENU] & 0x80) shiftstate |= TCF_ALTGR; 1160 if(lpbKeyState[VK_MENU] & 0x80) shiftstate |= TCF_ALT;1161 1232 if(lpbKeyState[VK_CAPITAL] & 1) shiftstate |= TCF_CAPSLOCK; 1162 1233 if(lpbKeyState[VK_NUMLOCK] & 1) shiftstate |= TCF_NUMLOCK; … … 1397 1468 return 0x0000; 1398 1469 } 1399 if (nVirtKey == VK_MENU) return O32_GetKeyState(VK_LMENU) | O32_GetKeyState(VK_RMENU); 1470 1471 //If there's a PM scancode for this virtual key, then call WinGetScanState 1472 //O32_GetKeyState converts windows virtual keys to PM virtual keys and there 1473 //are far fewer PM vkeys. (e.g. 0-9, A-Z will fail) 1474 if(nVirtKey < 256 && abWinVKeyToPMScan[nVirtKey].bPMScanCode) 1475 { 1476 INT nVirtKey2 = 0; 1477 WORD result; 1478 1479 if (nVirtKey == VK_MENU) { 1480 nVirtKey = VK_LMENU; 1481 nVirtKey2 = VK_RMENU; 1482 } 1483 else 1484 if (nVirtKey == VK_CONTROL) { 1485 nVirtKey = VK_LCONTROL; 1486 nVirtKey2 = VK_RCONTROL; 1487 } 1488 else 1489 if (nVirtKey == VK_SHIFT) { 1490 nVirtKey = VK_LSHIFT; 1491 nVirtKey2 = VK_RSHIFT; 1492 } 1493 result = OSLibWinGetScanState(abWinVKeyToPMScan[nVirtKey].bPMScanCode); 1494 if(nVirtKey2) { 1495 result |= OSLibWinGetScanState(abWinVKeyToPMScan[nVirtKey2].bPMScanCode); 1496 } 1497 return result; 1498 } 1499 1400 1500 return O32_GetKeyState(nVirtKey); 1401 1501 } … … 1419 1519 return 0x0000; 1420 1520 } 1421 if (nVirtKey == VK_MENU) return O32_GetAsyncKeyState(VK_LMENU) | O32_GetAsyncKeyState(VK_RMENU); 1521 1522 //If there's a PM scancode for this virtual key, then call WinGetPhysKeyState 1523 //O32_GetAsyncKeyState converts windows virtual keys to PM virtual keys and there 1524 //are far fewer PM vkeys. (e.g. 0-9, A-Z will fail) 1525 if(nVirtKey < 256 && abWinVKeyToPMScan[nVirtKey].bPMScanCode) 1526 { 1527 INT nVirtKey2 = 0; 1528 WORD result; 1529 1530 if (nVirtKey == VK_MENU) { 1531 nVirtKey = VK_LMENU; 1532 nVirtKey2 = VK_RMENU; 1533 } 1534 else 1535 if (nVirtKey == VK_CONTROL) { 1536 nVirtKey = VK_LCONTROL; 1537 nVirtKey2 = VK_RCONTROL; 1538 } 1539 else 1540 if (nVirtKey == VK_SHIFT) { 1541 nVirtKey = VK_LSHIFT; 1542 nVirtKey2 = VK_RSHIFT; 1543 } 1544 1545 result = OSLibWinGetPhysKeyState(abWinVKeyToPMScan[nVirtKey].bPMScanCode); 1546 if(nVirtKey2) { 1547 result |= OSLibWinGetPhysKeyState(abWinVKeyToPMScan[nVirtKey2].bPMScanCode); 1548 } 1549 return result; 1550 } 1551 1422 1552 return O32_GetAsyncKeyState(nVirtKey); 1423 1553 } … … 1426 1556 UINT WIN32API MapVirtualKeyA(UINT uCode, UINT uMapType) 1427 1557 { 1428 dprintf(("i mcompletely implemented"));1558 dprintf(("incompletely implemented")); 1429 1559 1430 1560 /* A quick fix for Commandos, very incomplete */ … … 1451 1581 UINT WIN32API MapVirtualKeyW(UINT uCode, UINT uMapType) 1452 1582 { 1453 dprintf(("incorrectly implemented \n"));1583 dprintf(("incorrectly implemented")); 1454 1584 1455 1585 // NOTE: This will not work as is (needs UNICODE support) 1456 return O32_MapVirtualKey(uCode,uMapType);1586 return MapVirtualKeyA(uCode,uMapType); 1457 1587 } 1458 1588 /*****************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.