Changeset 21916 for trunk/src/user32/winkeyboard.cpp
- Timestamp:
- Dec 18, 2011, 10:28:22 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 bin 2 Makefile.inc 1 env.cmd 2 LocalConfig.kmk
-
-
Property svn:mergeinfo
set to
/branches/gcc-kmk merged eligible
- Property svn:ignore
-
trunk/src/user32/winkeyboard.cpp
r21344 r21916 55 55 56 56 57 BYTE abPMScanToWinVKey[256][2] =57 static UCHAR auchPMScanToWinVKey[256][2] = 58 58 /****************************************************************************/ 59 59 /* PM Scancode * Win32 vkey Extended Key */ … … 320 320 { 321 321 /* index is the VKey value */ 322 BYTE bPMScanCode;323 LP STR lpstrName;322 UCHAR uchPMScanCode; 323 LPCSTR lpstrName; 324 324 } WINVKEYTOPMSCAN, *PWINVKEYTOPMSCAN; 325 325 326 static WINVKEYTOPMSCAN a bWinVKeyToPMScan[256] =326 static WINVKEYTOPMSCAN auchWinVKeyToPMScan[256] = 327 327 /**********************************************************************/ 328 328 /* Vkey * Scancode * Name */ … … 587 587 588 588 // @@PF reflect Num Enter key 589 LP STR lpstrNumEnter = "Num Enter";589 LPCSTR lpstrNumEnter = "Num Enter"; 590 590 591 591 // @@@PH 592 592 // Note: windows uses different scancodes if numlock is pressed 593 593 // This is not (yet) reflected here! 594 static BYTE a bPMScanToWinScan[256][2] =594 static BYTE auchPMScanToWinScan[256][2] = 595 595 /****************************************************************************/ 596 596 /* PM Scancode * Win32 Scancode Extended Key */ … … 858 858 //****************************************************************************** 859 859 860 VOID WIN32API KeyTranslatePMToWinBuf( BYTE *pmkey, BYTE *winkey,860 VOID WIN32API KeyTranslatePMToWinBuf(PUCHAR pmkey, PUCHAR winkey, 861 861 int nrkeys) 862 862 { … … 871 871 872 872 for(int i=1;i<nrkeys;i++) { 873 if(a bWinVKeyToPMScan[i].bPMScanCode) {874 pmvkey = OSLibWinTranslateChar(a bWinVKeyToPMScan[i].bPMScanCode, TC_SCANCODETOVIRTUALKEY, 0);873 if(auchWinVKeyToPMScan[i].uchPMScanCode) { 874 pmvkey = OSLibWinTranslateChar(auchWinVKeyToPMScan[i].uchPMScanCode, TC_SCANCODETOVIRTUALKEY, 0); 875 875 if(pmvkey == 0) { 876 dprintf2(("WinTranslateChar %x (%x) FAILED!!", i, a bWinVKeyToPMScan[i].bPMScanCode));876 dprintf2(("WinTranslateChar %x (%x) FAILED!!", i, auchWinVKeyToPMScan[i].uchPMScanCode)); 877 877 } 878 878 winkey[i] = pmkey[pmvkey]; … … 886 886 //****************************************************************************** 887 887 //****************************************************************************** 888 BYTE KeyTranslateWinVKeyToPMScan(BYTE bWinVKey, BOOL fExtended)888 UCHAR KeyTranslateWinVKeyToPMScan(UCHAR uchWinVKey, BOOL fExtended) 889 889 { 890 890 // if the extended bit didn't match, this is 891 891 // the closest hit 892 BYTE bAlmost = 0;892 UCHAR uchAlmost = 0; 893 893 894 894 // experiment 895 895 896 896 #if 0 897 bAlmost = a bWinVKeyToPMScan[bWinVKey].bPMScanCode;897 bAlmost = auchWinVKeyToPMScan[bWinVKey].uchPMScanCode; 898 898 #else 899 899 for(int i = 0; 900 i < 256; // sizeof(row of a bPMScanToWinVKey)900 i < 256; // sizeof(row of auchPMScanToWinVKey) 901 901 i++) 902 902 { 903 if (a bPMScanToWinVKey[i][0] == bWinVKey)903 if (auchPMScanToWinVKey[i][0] == uchWinVKey) 904 904 { 905 905 // this represents the PMScan code which is used as index 906 bAlmost = i;906 uchAlmost = i; 907 907 908 908 // exact match! 909 if (a bPMScanToWinVKey[i][1] == fExtended)909 if (auchPMScanToWinVKey[i][1] == fExtended) 910 910 break; 911 911 } … … 914 914 915 915 dprintf(("KeyTranslateWinVKeyToPMScan(%02xh,%d) = %02xh", 916 bWinVKey,916 uchWinVKey, 917 917 fExtended, 918 bAlmost));918 uchAlmost)); 919 919 920 920 // almost a match or no match at all. 921 return bAlmost;922 } 923 //****************************************************************************** 924 //****************************************************************************** 925 void KeyTranslatePMScanToWinVKey( BYTE bPMScan,921 return uchAlmost; 922 } 923 //****************************************************************************** 924 //****************************************************************************** 925 void KeyTranslatePMScanToWinVKey(UCHAR uchPMScan, 926 926 BOOL bNumLock, 927 P BYTE pbWinVKey,928 WORD *pwWinScan,927 PUCHAR puchWinVKey, 928 WORD *pwWinScan, 929 929 PBOOL pfExtended) 930 930 { 931 931 // @@@PH numlock is currently ignored 932 if (p bWinVKey)933 *p bWinVKey = abPMScanToWinVKey[bPMScan][0];932 if (puchWinVKey) 933 *puchWinVKey = auchPMScanToWinVKey[uchPMScan][0]; 934 934 935 935 if (pfExtended) 936 *pfExtended = a bPMScanToWinVKey[bPMScan][1];936 *pfExtended = auchPMScanToWinVKey[uchPMScan][1]; 937 937 938 938 if (pwWinScan) 939 *pwWinScan = a bPMScanToWinScan[bPMScan][0];940 } 941 //****************************************************************************** 942 //****************************************************************************** 943 BYTE KeyTranslateWinScanToPMScan(BYTE bWinScan, BOOL fExtended)939 *pwWinScan = auchPMScanToWinScan[uchPMScan][0]; 940 } 941 //****************************************************************************** 942 //****************************************************************************** 943 UCHAR KeyTranslateWinScanToPMScan(UCHAR uchWinScan, BOOL fExtended) 944 944 { 945 945 // Note: … … 949 949 // if the extended bit didn't match, this is 950 950 // the closest hit 951 BYTE bAlmost = 0;951 UCHAR uchAlmost = 0; 952 952 953 953 for(int i = 0; 954 i < 256; // sizeof(row of a bPMScanToWinVKey)954 i < 256; // sizeof(row of auchPMScanToWinVKey) 955 955 i++) 956 956 { 957 if (a bPMScanToWinScan[i][0] == bWinScan)957 if (auchPMScanToWinScan[i][0] == uchWinScan) 958 958 { 959 959 // this represents the PMScan code which is used as index 960 bAlmost = i;960 uchAlmost = i; 961 961 962 962 // exact match! 963 if (a bPMScanToWinVKey[i][1] == fExtended)963 if (auchPMScanToWinVKey[i][1] == fExtended) 964 964 break; 965 965 } … … 967 967 968 968 dprintf(("KeyTranslateWinScanToPMScan(%02xh,%d) = %02xh", 969 bWinScan,969 uchWinScan, 970 970 fExtended, 971 bAlmost));971 uchAlmost)); 972 972 973 973 // almost a match or no match at all. 974 return bAlmost;975 976 } 977 //****************************************************************************** 978 //****************************************************************************** 979 BYTE KeyTranslatePMScanToWinScan(BYTEbPMScan)974 return uchAlmost; 975 976 } 977 //****************************************************************************** 978 //****************************************************************************** 979 UCHAR KeyTranslatePMScanToWinScan(UCHAR bPMScan) 980 980 { 981 981 // Note: … … 983 983 // O32_MapVirtualKeyA uses PM Scancodes only! 984 984 985 return a bPMScanToWinScan[bPMScan][0];985 return auchPMScanToWinScan[bPMScan][0]; 986 986 } 987 987 //****************************************************************************** … … 1026 1026 } 1027 1027 for(int i=0;i<256;i++) { 1028 if(a bWinVKeyToPMScan[i].bPMScanCode) {1029 lpKeyState[i] = PMScanState[a bWinVKeyToPMScan[i].bPMScanCode];1028 if(auchWinVKeyToPMScan[i].uchPMScanCode) { 1029 lpKeyState[i] = PMScanState[auchWinVKeyToPMScan[i].uchPMScanCode]; 1030 1030 } 1031 1031 if(lpKeyState[i] & 0x80) { … … 1335 1335 } 1336 1336 1337 extern "C" 1337 1338 int WINAPI ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyState, 1338 1339 LPWSTR lpwStr, int size, UINT flags, HKL hkl) … … 1371 1372 BOOL fDontCare = (lParam & WIN_KEY_DONTCARE) != 0; 1372 1373 BOOL fExtended = (lParam & WIN_KEY_EXTENDED) != 0,PMExtended; 1373 UCHAR uc WinScan = (lParam & 0x00ff0000) >> 16;1374 UCHAR uc WinVKey;1375 UCHAR uc PMScan;1374 UCHAR uchWinScan = (lParam & 0x00ff0000) >> 16; 1375 UCHAR uchWinVKey; 1376 UCHAR uchPMScan; 1376 1377 int result; 1377 1378 … … 1388 1389 // Note: Open32 expects PM Scancodes, NOT Winscancodes. 1389 1390 // Note: this is the only way of loss-less conversion! 1390 uc PMScan = KeyTranslateWinScanToPMScan(ucWinScan, fExtended);1391 uchPMScan = KeyTranslateWinScanToPMScan(uchWinScan, fExtended); 1391 1392 dprintf(("ucWinScan=%02xh, fExtended=%d translated to PMscan=%02xh\n", 1392 uc WinScan,1393 uchWinScan, 1393 1394 fExtended, 1394 uc PMScan));1395 uc WinVKey = abPMScanToWinVKey[ucPMScan][0];1396 PMExtended = a bPMScanToWinVKey[ucPMScan][1];1395 uchPMScan)); 1396 uchWinVKey = auchPMScanToWinVKey[uchPMScan][0]; 1397 PMExtended = auchPMScanToWinVKey[uchPMScan][1]; 1397 1398 1398 1399 dprintf(("ucPMScan=%02xh translated to ucWinVKey=%02xh PMExtended=%d\n", 1399 uc PMScan,1400 uc WinVKey,PMExtended));1400 uchPMScan, 1401 uchWinVKey,PMExtended)); 1401 1402 1402 1403 // Bug in Open32: … … 1408 1409 memset(lpString, 0, nSize); 1409 1410 1410 LP STR lpstrKey;1411 lpstrKey = a bWinVKeyToPMScan[ucWinVKey].lpstrName;1411 LPCSTR lpstrKey; 1412 lpstrKey = auchWinVKeyToPMScan[uchWinVKey].lpstrName; 1412 1413 1413 1414 // handle Enter on Numeric Keypad here 1414 1415 if (PMExtended) 1415 1416 { 1416 if (uc WinVKey==VK_RETURN) lpstrKey = lpstrNumEnter;1417 if (uchWinVKey==VK_RETURN) lpstrKey = lpstrNumEnter; 1417 1418 } 1418 1419 … … 1420 1421 { 1421 1422 dprintf(("ERROR: keyname for winscan=%02xh winvkey=%02xh, fExtended=%d not found.\n", 1422 uc WinScan, ucWinVKey, fExtended & !fDontCare));1423 uchWinScan, uchWinVKey, fExtended & !fDontCare)); 1423 1424 1424 1425 // build artificial name … … 1427 1428 sprintf(szName, 1428 1429 "VKey%02x%c", 1429 uc WinScan,1430 uchWinScan, 1430 1431 fExtended ? '+' : 0); 1431 1432 memcpy(lpString, szName, nSize); … … 1504 1505 //O32_GetKeyState converts windows virtual keys to PM virtual keys and there 1505 1506 //are far fewer PM vkeys. (e.g. 0-9, A-Z will fail) 1506 if(nVirtKey < 256 && a bWinVKeyToPMScan[nVirtKey].bPMScanCode)1507 if(nVirtKey < 256 && auchWinVKeyToPMScan[nVirtKey].uchPMScanCode) 1507 1508 { 1508 1509 INT nVirtKey2 = 0; … … 1511 1512 if (nVirtKey == VK_CONTROL || nVirtKey == VK_LCONTROL) 1512 1513 {//if AltGr is down, then pretend VK_LCONTROL is down too 1513 result = OSLibWinGetScanState(a bWinVKeyToPMScan[VK_RMENU].bPMScanCode);1514 result = OSLibWinGetScanState(auchWinVKeyToPMScan[VK_RMENU].uchPMScanCode); 1514 1515 if(result & 0x8000) { 1515 1516 return result; … … 1520 1521 if ((nVirtKey >= VK_PRIOR) && (nVirtKey <= VK_DELETE)) 1521 1522 { 1522 WORD numState = OSLibWinGetScanState(a bWinVKeyToPMScan[VK_NUMLOCK].bPMScanCode) & 1;1523 WORD numState = OSLibWinGetScanState(auchWinVKeyToPMScan[VK_NUMLOCK].uchPMScanCode) & 1; 1523 1524 1524 1525 if(!numState) { … … 1544 1545 nVirtKey2 = VK_RSHIFT; 1545 1546 } 1546 result = OSLibWinGetScanState(a bWinVKeyToPMScan[nVirtKey].bPMScanCode);1547 result = OSLibWinGetScanState(auchWinVKeyToPMScan[nVirtKey].uchPMScanCode); 1547 1548 if(nVirtKey2) { 1548 result |= OSLibWinGetScanState(a bWinVKeyToPMScan[nVirtKey2].bPMScanCode);1549 result |= OSLibWinGetScanState(auchWinVKeyToPMScan[nVirtKey2].uchPMScanCode); 1549 1550 } 1550 1551 return result; … … 1576 1577 //O32_GetAsyncKeyState converts windows virtual keys to PM virtual keys and there 1577 1578 //are far fewer PM vkeys. (e.g. 0-9, A-Z will fail) 1578 if(nVirtKey < 256 && a bWinVKeyToPMScan[nVirtKey].bPMScanCode)1579 if(nVirtKey < 256 && auchWinVKeyToPMScan[nVirtKey].uchPMScanCode) 1579 1580 { 1580 1581 INT nVirtKey2 = 0; … … 1583 1584 if (nVirtKey == VK_CONTROL || nVirtKey == VK_LCONTROL) 1584 1585 {//if AltGr is down, then pretend VK_LCONTROL is down too 1585 result = OSLibWinGetPhysKeyState(a bWinVKeyToPMScan[VK_RMENU].bPMScanCode);1586 result = OSLibWinGetPhysKeyState(auchWinVKeyToPMScan[VK_RMENU].uchPMScanCode); 1586 1587 if(result & 0x8000) { 1587 1588 return result; … … 1592 1593 if ((nVirtKey >= VK_PRIOR) && (nVirtKey <= VK_DELETE)) 1593 1594 { 1594 WORD numState = OSLibWinGetScanState(a bWinVKeyToPMScan[VK_NUMLOCK].bPMScanCode) & 1;1595 WORD numState = OSLibWinGetScanState(auchWinVKeyToPMScan[VK_NUMLOCK].uchPMScanCode) & 1; 1595 1596 1596 1597 if(!numState) { … … 1617 1618 } 1618 1619 1619 result = OSLibWinGetPhysKeyState(a bWinVKeyToPMScan[nVirtKey].bPMScanCode);1620 result = OSLibWinGetPhysKeyState(auchWinVKeyToPMScan[nVirtKey].uchPMScanCode); 1620 1621 if(nVirtKey2) { 1621 result |= OSLibWinGetPhysKeyState(a bWinVKeyToPMScan[nVirtKey2].bPMScanCode);1622 result |= OSLibWinGetPhysKeyState(auchWinVKeyToPMScan[nVirtKey2].uchPMScanCode); 1622 1623 } 1623 1624 return result;
Note:
See TracChangeset
for help on using the changeset viewer.