From: <sag...@us...> - 2014-02-16 15:11:01
|
Revision: 3723 http://sourceforge.net/p/modplug/code/3723 Author: saga-games Date: 2014-02-16 15:10:50 +0000 (Sun, 16 Feb 2014) Log Message: ----------- [Fix] Scroll/num/caps lock keys should now work better with toggle-able shortcuts (http://bugs.openmpt.org/view.php?id=13) [Mod] OpenMPT: Version is now 1.22.07.22 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/InputHandler.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-02-16 00:45:51 UTC (rev 3722) +++ trunk/OpenMPT/common/versionNumber.h 2014-02-16 15:10:50 UTC (rev 3723) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 07 -#define VER_MINORMINOR 21 +#define VER_MINORMINOR 22 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2014-02-16 00:45:51 UTC (rev 3722) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2014-02-16 15:10:50 UTC (rev 3723) @@ -39,8 +39,8 @@ // 1. Try to load keybindings from the path saved in the settings. // 2. If the setting doesn't exist or the loading fails, try to load from default location. // 3. If neither one of these worked, load default keybindings from resources. - // 4. If there were no keybinging setting already, create a keybinding file to default location - // and set it's path to settings. + // 4. If there were no keybinding setting already, create a keybinding file to default location + // and set its path to settings. if (bNoExistingKbdFileSetting || !(activeCommandSet->LoadFile(TrackerSettings::Instance().m_szKbdFile))) { @@ -49,7 +49,7 @@ bool bSuccess = false; if (PathFileExistsW(sDefaultPath.AsNative().c_str()) == TRUE) bSuccess = activeCommandSet->LoadFile(sDefaultPath); - if (bSuccess == false) + if (!bSuccess) { // Load keybindings from resources. Log("Loading keybindings from resources\n"); @@ -59,7 +59,7 @@ activeCommandSet->SaveFile(TrackerSettings::Instance().m_szKbdFile); } } - if (bSuccess == false) + if (!bSuccess) ErrorBox(IDS_UNABLE_TO_LOAD_KEYBINDINGS); } // We will only overwrite the default Keybindings.mkb file from now on. @@ -68,7 +68,6 @@ //Get Keymap activeCommandSet->GenKeyMap(keyMap); SetupSpecialKeyInterception(); // Feature: use Windows keys as modifier keys, intercept special keys - m_nSkipGeneratedKeypresses = 0; m_bBypass = false; modifierMask=0; @@ -84,8 +83,8 @@ } -CommandID CInputHandler::GeneralKeyEvent(InputTargetContext context, int code, WPARAM wParam , LPARAM lParam) -//----------------------------------------------------------------------------------------------------------- +CommandID CInputHandler::GeneralKeyEvent(InputTargetContext context, int code, WPARAM wParam, LPARAM lParam) +//---------------------------------------------------------------------------------------------------------- { KeyMap::const_iterator cmd = keyMap.end(); KeyEventType keyEventType; @@ -113,7 +112,7 @@ CatchModifierChange(wParam, keyEventType, scancode); } - if(!InterceptSpecialKeys( wParam, lParam ) && !IsBypassed()) + if(!InterceptSpecialKeys(wParam, lParam, true) && !IsBypassed()) { // only execute command when the input handler is not locked // and the input is not a consequence of special key interception. @@ -140,9 +139,11 @@ } -CommandID CInputHandler::KeyEvent(InputTargetContext context, UINT &nChar, UINT &/*nRepCnt*/, UINT &/*nFlags*/, KeyEventType keyEventType, CWnd* pSourceWnd) +CommandID CInputHandler::KeyEvent(InputTargetContext context, UINT &nChar, UINT &/*nRepCnt*/, UINT &nFlags, KeyEventType keyEventType, CWnd* pSourceWnd) //---------------------------------------------------------------------------------------------------------------------------------------------------------- { + if(InterceptSpecialKeys(nChar, nFlags, false)) + return kcNull; KeyMap::const_iterator cmd = keyMap.find(KeyCombination(context, modifierMask, nChar, keyEventType)); CommandID executeCommand = kcNull; @@ -164,51 +165,51 @@ // Feature: use Windows keys as modifier keys, intercept special keys -bool CInputHandler::InterceptSpecialKeys(UINT nChar, UINT nFlags) -//--------------------------------------------------------------- +bool CInputHandler::InterceptSpecialKeys(UINT nChar, UINT nFlags, bool generateMsg) +//--------------------------------------------------------------------------------- { - KeyEventType keyEventType = GetKeyEventType( HIWORD(nFlags) ); + KeyEventType keyEventType = GetKeyEventType(HIWORD(nFlags)); enum { VK_NonExistentKey = VK_F24+1 }; - if( nChar == VK_NonExistentKey ) + if(nChar == VK_NonExistentKey) { return true; - } else if( m_bInterceptWindowsKeys && ( nChar == VK_LWIN || nChar == VK_RWIN ) ) + } else if(m_bInterceptWindowsKeys && (nChar == VK_LWIN || nChar == VK_RWIN)) { - if( keyEventType == kKeyEventDown ) + if(keyEventType == kKeyEventDown) { INPUT inp[2]; inp[0].type = inp[1].type = INPUT_KEYBOARD; inp[0].ki.time = inp[1].ki.time = 0; - inp[0].ki.dwExtraInfo = inp[0].ki.dwExtraInfo = 0; + inp[0].ki.dwExtraInfo = inp[1].ki.dwExtraInfo = 0; inp[0].ki.wVk = inp[1].ki.wVk = VK_NonExistentKey; inp[0].ki.wScan = inp[1].ki.wScan = 0; inp[0].ki.dwFlags = 0; inp[1].ki.dwFlags = KEYEVENTF_KEYUP; - SendInput( 2, inp, sizeof(INPUT) ); + SendInput(2, inp, sizeof(INPUT)); } } - if( ( nChar == VK_NUMLOCK && m_bInterceptNumLock ) || - ( nChar == VK_CAPITAL && m_bInterceptCapsLock ) || - ( nChar == VK_SCROLL && m_bInterceptScrollLock ) ) + if((nChar == VK_NUMLOCK && m_bInterceptNumLock) + || (nChar == VK_CAPITAL && m_bInterceptCapsLock) + || (nChar == VK_SCROLL && m_bInterceptScrollLock)) { - if( m_nSkipGeneratedKeypresses > 0 ) + if(GetMessageExtraInfo() == 0xC0FFEE) { - m_nSkipGeneratedKeypresses -- ; + SetMessageExtraInfo(0); return true; - } else if( keyEventType == kKeyEventDown ) + } else if(keyEventType == kKeyEventDown && generateMsg) { - m_nSkipGeneratedKeypresses = 2; + // Prevent keys from lighting up by simulating a second press. INPUT inp[2]; inp[0].type = inp[1].type = INPUT_KEYBOARD; inp[0].ki.time = inp[1].ki.time = 0; - inp[0].ki.dwExtraInfo = inp[0].ki.dwExtraInfo = 0; + inp[0].ki.dwExtraInfo = inp[1].ki.dwExtraInfo = 0xC0FFEE; inp[0].ki.wVk = inp[1].ki.wVk = static_cast<WORD>(nChar); inp[0].ki.wScan = inp[1].ki.wScan = 0; inp[0].ki.dwFlags = KEYEVENTF_KEYUP; inp[1].ki.dwFlags = 0; - SendInput( 2, inp, sizeof(INPUT) ); + SendInput(2, inp, sizeof(INPUT)); } } return false; Modified: trunk/OpenMPT/mptrack/InputHandler.h =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.h 2014-02-16 00:45:51 UTC (rev 3722) +++ trunk/OpenMPT/mptrack/InputHandler.h 2014-02-16 15:10:50 UTC (rev 3723) @@ -41,8 +41,7 @@ bool m_bNoAltMenu; bool CatchModifierChange(WPARAM wParam, KeyEventType keyEventType, int scancode); bool m_bInterceptWindowsKeys, m_bInterceptNumLock, m_bInterceptCapsLock, m_bInterceptScrollLock; - int m_nSkipGeneratedKeypresses; - bool InterceptSpecialKeys( UINT nChar , UINT nFlags ); + bool InterceptSpecialKeys(UINT nChar , UINT nFlags, bool generateMsg); void SetupSpecialKeyInterception(); public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |