Changeset 7211 for trunk/src/user32/oslibmsgtranslate.cpp
- Timestamp:
- Oct 26, 2001, 11:10:57 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/oslibmsgtranslate.cpp
r7205 r7211 1 /* $Id: oslibmsgtranslate.cpp,v 1.6 8 2001-10-25 15:35:53phaller Exp $ */1 /* $Id: oslibmsgtranslate.cpp,v 1.69 2001-10-26 09:10:12 phaller Exp $ */ 2 2 /* 3 3 * Window message translation functions for OS/2 … … 166 166 167 167 168 // Note: 169 // For a "lonekey"-press of AltGr, we only receive WM_KEYUP 170 // messages. If the key is pressed longer and starts to repeat, 171 // WM_KEYDOWN messages come in properly. 172 static BOOL fKeyAltGrDown = FALSE; 173 168 174 //****************************************************************************** 169 175 //****************************************************************************** … … 684 690 685 691 dprintf(("PM: WM_CHAR: %x %x rep=%d scancode=%x", SHORT1FROMMP(os2Msg->mp2), SHORT2FROMMP(os2Msg->mp2), repeatCount, scanCode)); 686 dprintf(("PM: WM_CHAR: hwnd %x flags %x mp1 %x, mp2 %x ", win32wnd->getWindowHandle(), flags, os2Msg->mp1, os2Msg->mp2));692 dprintf(("PM: WM_CHAR: hwnd %x flags %x mp1 %x, mp2 %x, time=%08xh", win32wnd->getWindowHandle(), flags, os2Msg->mp1, os2Msg->mp2, os2Msg->time)); 687 693 688 694 // vitali add begin … … 805 811 // check if additional messages have to be recorded 806 812 // ------------------------------------------------ 813 #if 0 807 814 { 808 815 MSG extramsg; … … 813 820 switch (scanCode) 814 821 { 815 case PMSCAN_ESC:816 {817 // Note: ESC generates a WM_CHAR for WINWM_KEYDOWN818 // under Windows, not under PM819 // so we've got to post it to ourself here!820 // WM_CHAR(0x0000001bh, 00010001h)821 if (winMsg->message == WINWM_KEYDOWN)822 {823 extramsg.message = WINWM_CHAR;824 extramsg.wParam = VK_ESCAPE_W;825 extramsg.lParam = winMsg->lParam;826 setThreadQueueExtraCharMessage(teb, &extramsg);827 }828 }829 break;830 831 #if 0832 822 case PMSCAN_PRINT: 833 823 // Note: PRINT generates a WM_KEYUP under Windows … … 841 831 setThreadQueueExtraCharMessage(teb, &extramsg); 842 832 break; 843 #endif844 833 834 #define WIN_KEY_EXTENDED 0x01000000 835 #define WIN_KEY_DONTCARE 0x02000000 836 #define WIN_KEY_ALTHELD 0x20000000 837 #define WIN_KEY_PREVSTATE 0x40000000 845 838 case PMSCAN_ALTRIGHT: 846 839 { 847 840 // we need very special treatment here for the 848 841 // poor, crippled AltGr key 849 if (keyWasPressed) 842 // Note: see fKeyAltGrDown above! 843 844 if ( (keyWasPressed) || (fKeyAltGrDown == FALSE) ) 850 845 { 846 fKeyAltGrDown = TRUE; 847 851 848 // 1 - generate a virtual LCONTROL-keypress 852 849 // 2 - send LMENU-keypress (NT emulates ALtGr w/ Ctrl-AltGr!) 853 850 // 0xfe000000: mask out extended-key, scancode, repeatcount 851 // Note: Win sends a WINWM_SYSKEYDOWN to the hooks, 852 // the queue gets a WM_KEYDOWN only! (wrong impl. here) 854 853 extramsg.message = WINWM_KEYDOWN; 855 854 extramsg.wParam = VK_RMENU_W; 856 855 extramsg.lParam = (winMsg->lParam & 0xfe000000) 856 | WIN_KEY_EXTENDED 857 | (keyWasPressed ? WIN_KEY_PREVSTATE : 0) 858 | WIN_KEY_ALTHELD 857 859 | repeatCount 858 | (WINSCAN_ALTRIGHT << 24);860 | (WINSCAN_ALTRIGHT << 16); 859 861 winMsg->message = WINWM_KEYDOWN; 860 862 winMsg->wParam = VK_LCONTROL_W; 861 863 winMsg->lParam = (winMsg->lParam & 0xfe000000) 864 | WIN_KEY_DONTCARE 865 | (keyWasPressed ? WIN_KEY_PREVSTATE : 0) 866 | WIN_KEY_ALTHELD 862 867 | repeatCount 863 | (WINSCAN_CTRLLEFT << 24);868 | (WINSCAN_CTRLLEFT << 16); 864 869 } 865 870 else 866 871 { 872 // OK, now we can release it! 873 fKeyAltGrDown = FALSE; 874 867 875 // key up 868 876 // 1 - generate a virtual LCONTROL-keypress 869 877 // 2 - send LMENU-keypress (NT emulates ALtGr w/ Ctrl-Alt!) 870 extramsg.message = WINWM_KEY DOWN;878 extramsg.message = WINWM_KEYUP; 871 879 extramsg.wParam = VK_RMENU_W; 872 880 extramsg.lParam = (winMsg->lParam & 0xfe000000) 881 | WIN_KEY_EXTENDED 873 882 | repeatCount 874 | (WINSCAN_ALTRIGHT << 24);883 | (WINSCAN_ALTRIGHT << 16); 875 884 winMsg->message = WINWM_SYSKEYUP; 876 885 winMsg->wParam = VK_LCONTROL_W; 877 886 winMsg->lParam = (winMsg->lParam & 0xfe000000) 887 | WIN_KEY_ALTHELD 878 888 | repeatCount 879 | (WINSCAN_CTRLLEFT << 24);889 | (WINSCAN_CTRLLEFT << 16); 880 890 } 881 891 892 // @@@PH 893 // unknown: this leads to an infinite loop 894 // because the OS/2 WM_CHAR_SPECIAL message is never 895 // removed from the queue?! 882 896 setThreadQueueExtraCharMessage(teb, &extramsg); 883 } 897 898 if ( (keyWasPressed) || (fKeyAltGrDown == FALSE) ) 899 { 900 fKeyAltGrDown = TRUE; 901 902 // 1 - generate a virtual LCONTROL-keypress 903 // 2 - send LMENU-keypress (NT emulates ALtGr w/ Ctrl-AltGr!) 904 // 0xfe000000: mask out extended-key, scancode, repeatcount 905 // Note: Win sends a WINWM_SYSKEYDOWN to the hooks, 906 // the queue gets a WM_KEYDOWN only! (wrong impl. here) 907 winMsg->message = WINWM_KEYDOWN; 908 winMsg->wParam = VK_RMENU_W; 909 winMsg->lParam = (winMsg->lParam & 0xfe000000) 910 | WIN_KEY_EXTENDED 911 | (keyWasPressed ? WIN_KEY_PREVSTATE : 0) 912 | WIN_KEY_ALTHELD 913 | repeatCount 914 | (WINSCAN_ALTRIGHT << 16); 915 } 916 else 917 { 918 // OK, now we can release it! 919 fKeyAltGrDown = FALSE; 920 921 // key up 922 // 1 - generate a virtual LCONTROL-keypress 923 // 2 - send LMENU-keypress (NT emulates ALtGr w/ Ctrl-Alt!) 924 winMsg->message = WINWM_KEYUP; 925 winMsg->wParam = VK_RMENU_W; 926 winMsg->lParam = (winMsg->lParam & 0xfe000000) 927 | WIN_KEY_EXTENDED 928 | repeatCount 929 | (WINSCAN_ALTRIGHT << 16); 930 } 931 } 932 break; 884 933 } /* switch */ 885 934 } 886 935 #endif 887 936 888 937 if (ISKDB_CAPTURED()) … … 1046 1095 // the newly generated WM_CHAR message. 1047 1096 if(!teb->o.odin.fTranslated && teb->o.odin.os2msg.msg == WM_CHAR && !((SHORT1FROMMP(teb->o.odin.os2msg.mp1) & KC_KEYUP) == KC_KEYUP)) 1048 {//TranslatedMessage was called before DispatchMessage, so queue WM_CHAR message 1049 ULONG fl = SHORT1FROMMP(teb->o.odin.os2msg.mp1); 1050 MSG extramsg; 1051 1052 memcpy(&extramsg, msg, sizeof(MSG)); 1053 extramsg.wParam = SHORT1FROMMP(teb->o.odin.os2msg.mp2); 1054 extramsg.lParam = 0; 1055 1056 if(!(fl & KC_CHAR) && msg->message < WINWM_SYSKEYDOWN) { 1057 return FALSE; 1058 } 1059 1060 if(fl & KC_VIRTUALKEY) { 1061 if(msg->wParam) { 1062 if ((msg->wParam >= VK_NUMPAD0_W) && (msg->wParam <= VK_NUMPAD9_W)) 1063 extramsg.wParam = msg->wParam - 0x30; 1064 else 1065 extramsg.wParam = msg->wParam; 1066 } 1067 else extramsg.wParam = SHORT2FROMMP(teb->o.odin.os2msg.mp2); 1068 } 1069 1070 1071 if(msg->message >= WINWM_SYSKEYDOWN) { 1072 extramsg.message = WINWM_SYSCHAR; 1073 } 1074 else extramsg.message = WINWM_CHAR; 1075 1076 if(fl & KC_DEADKEY) { 1077 extramsg.message++; //WM_DEADCHAR/WM_SYSDEADCHAR 1078 } 1079 1080 extramsg.lParam = msg->lParam & 0x00FFFFFF; 1081 if(fl & KC_ALT) 1082 extramsg.lParam |= (1<<29); 1083 if(fl & KC_PREVDOWN) 1084 extramsg.lParam |= (1<<30); 1085 if(fl & KC_KEYUP) 1086 extramsg.lParam |= (1<<31); 1087 1088 // insert message into the queue 1089 setThreadQueueExtraCharMessage(teb, &extramsg); 1090 return TRUE; 1097 { 1098 //TranslatedMessage was called before DispatchMessage, so queue WM_CHAR message 1099 ULONG fl = SHORT1FROMMP(teb->o.odin.os2msg.mp1); 1100 MSG extramsg; 1101 1102 memcpy(&extramsg, msg, sizeof(MSG)); 1103 extramsg.wParam = SHORT1FROMMP(teb->o.odin.os2msg.mp2); 1104 extramsg.lParam = 0; 1105 1106 // ESCAPE generates a WM_CHAR under windows, so take 1107 // special care for this here. 1108 UCHAR ucPMScanCode = CHAR4FROMMP(teb->o.odin.os2msg.mp1); 1109 switch (ucPMScanCode) 1110 { 1111 case PMSCAN_ESC: 1112 extramsg.wParam = VK_ESCAPE_W; 1113 fl |= KC_CHAR; 1114 break; 1115 } 1116 1117 if(!(fl & KC_CHAR) && msg->message < WINWM_SYSKEYDOWN) 1118 { 1119 return FALSE; 1120 } 1121 1122 if(fl & KC_VIRTUALKEY) 1123 { 1124 if(msg->wParam) 1125 { 1126 if ((msg->wParam >= VK_NUMPAD0_W) && 1127 (msg->wParam <= VK_NUMPAD9_W)) 1128 extramsg.wParam = msg->wParam - 0x30; 1129 else 1130 extramsg.wParam = msg->wParam; 1131 } 1132 else 1133 extramsg.wParam = SHORT2FROMMP(teb->o.odin.os2msg.mp2); 1134 } 1135 1136 1137 if(msg->message >= WINWM_SYSKEYDOWN) 1138 extramsg.message = WINWM_SYSCHAR; 1139 else 1140 extramsg.message = WINWM_CHAR; 1141 1142 if(fl & KC_DEADKEY) 1143 extramsg.message++; //WM_DEADCHAR/WM_SYSDEADCHAR 1144 1145 1146 extramsg.lParam = msg->lParam & 0x00FFFFFF; 1147 if(fl & KC_ALT) 1148 extramsg.lParam |= (1<<29); 1149 if(fl & KC_PREVDOWN) 1150 extramsg.lParam |= (1<<30); 1151 if(fl & KC_KEYUP) 1152 extramsg.lParam |= (1<<31); 1153 1154 // insert message into the queue 1155 setThreadQueueExtraCharMessage(teb, &extramsg); 1156 return TRUE; 1091 1157 } 1092 1158 return FALSE;
Note:
See TracChangeset
for help on using the changeset viewer.