Changeset 21885 for branches/gcc-kmk/src
- Timestamp:
- Dec 15, 2011, 11:24:47 AM (14 years ago)
- Location:
- branches/gcc-kmk/src/user32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gcc-kmk/src/user32/oslibmsgtranslate.cpp
r21811 r21885 95 95 { 96 96 ULONG ret; 97 BYTEwinKey;97 UCHAR winKey; 98 98 99 99 switch (pmScan) … … 113 113 } 114 114 115 KeyTranslatePMScanToWinVKey(ret, FALSE, (PBYTE)&winKey, NULL, NULL);115 KeyTranslatePMScanToWinVKey(ret, FALSE, &winKey, NULL, NULL); 116 116 return winKey; 117 117 … … 760 760 761 761 BOOL fWinExtended; 762 BYTE bWinVKey;762 UCHAR uchWinVKey; 763 763 WORD wWinScan; 764 764 … … 775 775 // for Korean 776 776 case VK_DBE_HANJA : 777 bWinVKey = 0x19;777 uchWinVKey = 0x19; 778 778 break; 779 779 780 780 case VK_DBE_HANGEUL : 781 bWinVKey = 0x15;781 uchWinVKey = 0x15; 782 782 break; 783 783 784 784 case VK_DBE_JAMO : 785 bWinVKey = 0;785 uchWinVKey = 0; 786 786 break; 787 787 788 788 // for Japan 789 789 case VK_DBE_KATAKANA : 790 bWinVKey = 0;790 uchWinVKey = 0; 791 791 break; 792 792 793 793 case VK_DBE_HIRAGANA : 794 bWinVKey = 0;794 uchWinVKey = 0; 795 795 break; 796 796 797 797 case VK_DBE_SBCSCHAR : 798 bWinVKey = 0;798 uchWinVKey = 0; 799 799 break; 800 800 801 801 case VK_DBE_DBCSCHAR : 802 bWinVKey = 0;802 uchWinVKey = 0; 803 803 break; 804 804 805 805 case VK_DBE_SBCSDBCSCHAR : 806 bWinVKey = 0;806 uchWinVKey = 0; 807 807 break; 808 808 809 809 case VK_DBE_ROMAN : 810 bWinVKey = 0;810 uchWinVKey = 0; 811 811 break; 812 812 813 813 // for PRC-Chinese 814 814 case VK_DBE_HANZI : 815 bWinVKey = 0;815 uchWinVKey = 0; 816 816 break; 817 817 818 818 // for Taiwan 819 819 case VK_DBE_TSANGJYE : 820 bWinVKey = 0;820 uchWinVKey = 0; 821 821 break; 822 822 823 823 case VK_DBE_PHONETIC : 824 bWinVKey = 0;824 uchWinVKey = 0; 825 825 break; 826 826 827 827 case VK_DBE_CONV : 828 bWinVKey = 0;828 uchWinVKey = 0; 829 829 break; 830 830 831 831 case VK_DBE_NOCONV : 832 bWinVKey = 0;832 uchWinVKey = 0; 833 833 break; 834 834 … … 838 838 case 949 : // Korea 839 839 case 1361 : 840 bWinVKey = 0x15;840 uchWinVKey = 0x15; 841 841 break; 842 842 … … 850 850 case 950 : // Taiwan 851 851 default : 852 bWinVKey = 0;852 uchWinVKey = 0; 853 853 } 854 854 break; … … 857 857 KeyTranslatePMScanToWinVKey(usPMScanCode, 858 858 FALSE, 859 & bWinVKey,859 &uchWinVKey, 860 860 &wWinScan, 861 861 &fWinExtended); 862 862 } 863 863 864 winMsg->wParam = bWinVKey;864 winMsg->wParam = uchWinVKey; 865 865 } 866 866 else -
branches/gcc-kmk/src/user32/winkeyboard.cpp
r21808 r21885 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;322 UCHAR uchPMScanCode; 323 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 */ … … 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) { … … 1372 1372 BOOL fDontCare = (lParam & WIN_KEY_DONTCARE) != 0; 1373 1373 BOOL fExtended = (lParam & WIN_KEY_EXTENDED) != 0,PMExtended; 1374 UCHAR uc WinScan = (lParam & 0x00ff0000) >> 16;1375 UCHAR uc WinVKey;1376 UCHAR uc PMScan;1374 UCHAR uchWinScan = (lParam & 0x00ff0000) >> 16; 1375 UCHAR uchWinVKey; 1376 UCHAR uchPMScan; 1377 1377 int result; 1378 1378 … … 1389 1389 // Note: Open32 expects PM Scancodes, NOT Winscancodes. 1390 1390 // Note: this is the only way of loss-less conversion! 1391 uc PMScan = KeyTranslateWinScanToPMScan(ucWinScan, fExtended);1391 uchPMScan = KeyTranslateWinScanToPMScan(uchWinScan, fExtended); 1392 1392 dprintf(("ucWinScan=%02xh, fExtended=%d translated to PMscan=%02xh\n", 1393 uc WinScan,1393 uchWinScan, 1394 1394 fExtended, 1395 uc PMScan));1396 uc WinVKey = abPMScanToWinVKey[ucPMScan][0];1397 PMExtended = a bPMScanToWinVKey[ucPMScan][1];1395 uchPMScan)); 1396 uchWinVKey = auchPMScanToWinVKey[uchPMScan][0]; 1397 PMExtended = auchPMScanToWinVKey[uchPMScan][1]; 1398 1398 1399 1399 dprintf(("ucPMScan=%02xh translated to ucWinVKey=%02xh PMExtended=%d\n", 1400 uc PMScan,1401 uc WinVKey,PMExtended));1400 uchPMScan, 1401 uchWinVKey,PMExtended)); 1402 1402 1403 1403 // Bug in Open32: … … 1410 1410 1411 1411 LPCSTR lpstrKey; 1412 lpstrKey = a bWinVKeyToPMScan[ucWinVKey].lpstrName;1412 lpstrKey = auchWinVKeyToPMScan[uchWinVKey].lpstrName; 1413 1413 1414 1414 // handle Enter on Numeric Keypad here 1415 1415 if (PMExtended) 1416 1416 { 1417 if (uc WinVKey==VK_RETURN) lpstrKey = lpstrNumEnter;1417 if (uchWinVKey==VK_RETURN) lpstrKey = lpstrNumEnter; 1418 1418 } 1419 1419 … … 1421 1421 { 1422 1422 dprintf(("ERROR: keyname for winscan=%02xh winvkey=%02xh, fExtended=%d not found.\n", 1423 uc WinScan, ucWinVKey, fExtended & !fDontCare));1423 uchWinScan, uchWinVKey, fExtended & !fDontCare)); 1424 1424 1425 1425 // build artificial name … … 1428 1428 sprintf(szName, 1429 1429 "VKey%02x%c", 1430 uc WinScan,1430 uchWinScan, 1431 1431 fExtended ? '+' : 0); 1432 1432 memcpy(lpString, szName, nSize); … … 1505 1505 //O32_GetKeyState converts windows virtual keys to PM virtual keys and there 1506 1506 //are far fewer PM vkeys. (e.g. 0-9, A-Z will fail) 1507 if(nVirtKey < 256 && a bWinVKeyToPMScan[nVirtKey].bPMScanCode)1507 if(nVirtKey < 256 && auchWinVKeyToPMScan[nVirtKey].uchPMScanCode) 1508 1508 { 1509 1509 INT nVirtKey2 = 0; … … 1512 1512 if (nVirtKey == VK_CONTROL || nVirtKey == VK_LCONTROL) 1513 1513 {//if AltGr is down, then pretend VK_LCONTROL is down too 1514 result = OSLibWinGetScanState(a bWinVKeyToPMScan[VK_RMENU].bPMScanCode);1514 result = OSLibWinGetScanState(auchWinVKeyToPMScan[VK_RMENU].uchPMScanCode); 1515 1515 if(result & 0x8000) { 1516 1516 return result; … … 1521 1521 if ((nVirtKey >= VK_PRIOR) && (nVirtKey <= VK_DELETE)) 1522 1522 { 1523 WORD numState = OSLibWinGetScanState(a bWinVKeyToPMScan[VK_NUMLOCK].bPMScanCode) & 1;1523 WORD numState = OSLibWinGetScanState(auchWinVKeyToPMScan[VK_NUMLOCK].uchPMScanCode) & 1; 1524 1524 1525 1525 if(!numState) { … … 1545 1545 nVirtKey2 = VK_RSHIFT; 1546 1546 } 1547 result = OSLibWinGetScanState(a bWinVKeyToPMScan[nVirtKey].bPMScanCode);1547 result = OSLibWinGetScanState(auchWinVKeyToPMScan[nVirtKey].uchPMScanCode); 1548 1548 if(nVirtKey2) { 1549 result |= OSLibWinGetScanState(a bWinVKeyToPMScan[nVirtKey2].bPMScanCode);1549 result |= OSLibWinGetScanState(auchWinVKeyToPMScan[nVirtKey2].uchPMScanCode); 1550 1550 } 1551 1551 return result; … … 1577 1577 //O32_GetAsyncKeyState converts windows virtual keys to PM virtual keys and there 1578 1578 //are far fewer PM vkeys. (e.g. 0-9, A-Z will fail) 1579 if(nVirtKey < 256 && a bWinVKeyToPMScan[nVirtKey].bPMScanCode)1579 if(nVirtKey < 256 && auchWinVKeyToPMScan[nVirtKey].uchPMScanCode) 1580 1580 { 1581 1581 INT nVirtKey2 = 0; … … 1584 1584 if (nVirtKey == VK_CONTROL || nVirtKey == VK_LCONTROL) 1585 1585 {//if AltGr is down, then pretend VK_LCONTROL is down too 1586 result = OSLibWinGetPhysKeyState(a bWinVKeyToPMScan[VK_RMENU].bPMScanCode);1586 result = OSLibWinGetPhysKeyState(auchWinVKeyToPMScan[VK_RMENU].uchPMScanCode); 1587 1587 if(result & 0x8000) { 1588 1588 return result; … … 1593 1593 if ((nVirtKey >= VK_PRIOR) && (nVirtKey <= VK_DELETE)) 1594 1594 { 1595 WORD numState = OSLibWinGetScanState(a bWinVKeyToPMScan[VK_NUMLOCK].bPMScanCode) & 1;1595 WORD numState = OSLibWinGetScanState(auchWinVKeyToPMScan[VK_NUMLOCK].uchPMScanCode) & 1; 1596 1596 1597 1597 if(!numState) { … … 1618 1618 } 1619 1619 1620 result = OSLibWinGetPhysKeyState(a bWinVKeyToPMScan[nVirtKey].bPMScanCode);1620 result = OSLibWinGetPhysKeyState(auchWinVKeyToPMScan[nVirtKey].uchPMScanCode); 1621 1621 if(nVirtKey2) { 1622 result |= OSLibWinGetPhysKeyState(a bWinVKeyToPMScan[nVirtKey2].bPMScanCode);1622 result |= OSLibWinGetPhysKeyState(auchWinVKeyToPMScan[nVirtKey2].uchPMScanCode); 1623 1623 } 1624 1624 return result;
Note:
See TracChangeset
for help on using the changeset viewer.