diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2011-03-10 21:56:19 +0300 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2011-03-10 21:56:19 +0300 |
commit | d6b43fed313b60bb6a269680b3c5622955b8a690 (patch) | |
tree | 0455b40d67f534632d48971fe01f88e39c41452e /intern | |
parent | efc697b481d19a957b1a302c8ed92ad3e6c85142 (diff) |
Fix [#26446] Quick extrude (Ctrl+LMB) works only one time
Reported by Michael R
This was one thing I didn't test when accepting patch [#26364]. It is important to not
send repeats of modifier keys.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.cpp | 64 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.h | 35 |
2 files changed, 98 insertions, 1 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index db53e97705b..b940823534a 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -454,8 +454,71 @@ GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, WPARAM wParam, LPAR if (ri.header.dwType == RIM_TYPEKEYBOARD) { + GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem(); + + GHOST_ModifierKeys modifiers; + system->retrieveModifierKeys(modifiers); + *keyDown = !(ri.data.keyboard.Flags & RI_KEY_BREAK); key = this->convertKey(window, ri.data.keyboard.VKey, ri.data.keyboard.MakeCode, (ri.data.keyboard.Flags&(RI_KEY_E1|RI_KEY_E0))); + + // extra handling of modifier keys: don't send repeats out from GHOST + if(key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt) + { + bool changed = false; + GHOST_TModifierKeyMask modifier; + switch(key) { + case GHOST_kKeyLeftShift: + { + changed = (modifiers.get(GHOST_kModifierKeyLeftShift) != *keyDown); + modifier = GHOST_kModifierKeyLeftShift; + } + break; + case GHOST_kKeyRightShift: + { + changed = (modifiers.get(GHOST_kModifierKeyRightShift) != *keyDown); + modifier = GHOST_kModifierKeyRightShift; + } + break; + case GHOST_kKeyLeftControl: + { + changed = (modifiers.get(GHOST_kModifierKeyLeftControl) != *keyDown); + modifier = GHOST_kModifierKeyLeftControl; + } + break; + case GHOST_kKeyRightControl: + { + changed = (modifiers.get(GHOST_kModifierKeyRightControl) != *keyDown); + modifier = GHOST_kModifierKeyRightControl; + } + break; + case GHOST_kKeyLeftAlt: + { + changed = (modifiers.get(GHOST_kModifierKeyLeftAlt) != *keyDown); + modifier = GHOST_kModifierKeyLeftAlt; + } + break; + case GHOST_kKeyRightAlt: + { + changed = (modifiers.get(GHOST_kModifierKeyRightAlt) != *keyDown); + modifier = GHOST_kModifierKeyRightAlt; + } + break; + default: break; + } + + if(changed) + { + modifiers.set(modifier, *keyDown); + system->storeModifierKeys(modifiers); + } + else + { + key = GHOST_kKeyUnknown; + } + } + + if(vk) *vk = ri.data.keyboard.VKey; }; @@ -586,6 +649,7 @@ GHOST_TKey GHOST_SystemWin32::convertKey(GHOST_IWindow *window, short vKey, shor break; } } + return key; } diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h index ca1297adfc5..602c4545da4 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.h +++ b/intern/ghost/intern/GHOST_SystemWin32.h @@ -322,6 +322,14 @@ protected: */ virtual GHOST_TKey hardKey(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam, int * keyDown, char * vk); + /** + * Creates modifier key event(s) and updates the key data stored locally (m_modifierKeys). + * With the modifier keys, we want to distinguish left and right keys. + * Sometimes this is not possible (Windows ME for instance). Then, we want + * events generated for both keys. + * @param window The window receiving the event (the active window). + */ + GHOST_EventKey* processModifierKeys(GHOST_IWindow *window); /** * Creates mouse button event. @@ -381,6 +389,19 @@ protected: static void processMinMaxInfo(MINMAXINFO * minmax); /** + * Returns the local state of the modifier keys (from the message queue). + * @param keys The state of the keys. + */ + inline virtual void retrieveModifierKeys(GHOST_ModifierKeys& keys) const; + + /** + * Stores the state of the modifier keys locally. + * For internal use only! + * @param keys The new state of the modifier keys. + */ + inline virtual void storeModifierKeys(const GHOST_ModifierKeys& keys); + + /** * Check current key layout for AltGr */ inline virtual void handleKeyboardChange(void); @@ -394,7 +415,9 @@ protected: * Initiates WM_INPUT messages from keyboard */ GHOST_TInt32 initKeyboardRawInput(void); - + + /** The current state of the modifier keys. */ + GHOST_ModifierKeys m_modifierKeys; /** State variable set at initialization. */ bool m_hasPerformanceCounter; /** High frequency timer variable. */ @@ -418,6 +441,16 @@ protected: #endif }; +inline void GHOST_SystemWin32::retrieveModifierKeys(GHOST_ModifierKeys& keys) const +{ + keys = m_modifierKeys; +} + +inline void GHOST_SystemWin32::storeModifierKeys(const GHOST_ModifierKeys& keys) +{ + m_modifierKeys = keys; +} + inline void GHOST_SystemWin32::handleKeyboardChange(void) { m_keylayout = GetKeyboardLayout(0); // get keylayout for current thread |