-
Notifications
You must be signed in to change notification settings - Fork 265
fix(input): Prevent modified key releases from firing plain hotkeys #3233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5470941
02e7cdb
5907158
e52d4a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,6 @@ | |
| //----------------------------------------------------------------------------- | ||
| #include "GameClient/HotKey.h" | ||
| #include "GameClient/KeyDefs.h" | ||
| #include "GameClient/MetaEvent.h" | ||
| #include "GameClient/GameWindow.h" | ||
| #include "GameClient/GameWindowManager.h" | ||
| #include "GameClient/Keyboard.h" | ||
|
|
@@ -72,35 +71,17 @@ GameMessageDisposition HotKeyTranslator::translateGameMessage(const GameMessage | |
| GameMessageDisposition disp = KEEP_MESSAGE; | ||
| GameMessage::Type t = msg->getType(); | ||
|
|
||
| if ( t == GameMessage::MSG_RAW_KEY_UP) | ||
| // TheSuperHackers @fix Run hotkeys on press so releasing a modifier first cannot trigger a plain hotkey. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Run hotkeys on press instead of release ..." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can also say that the press is consistent with the typical meta event key mappings. |
||
| if ( t == GameMessage::MSG_RAW_KEY_DOWN) | ||
|
greptile-apps[bot] marked this conversation as resolved.
xezon marked this conversation as resolved.
|
||
| { | ||
|
|
||
| //char key = msg->getArgument(0)->integer; | ||
| Int keyState = msg->getArgument(1)->integer; | ||
|
|
||
| // for our purposes here, we don't care to distinguish between right and left keys, | ||
| // so just fudge a little to simplify things. | ||
| Int newModState = 0; | ||
|
|
||
| if( keyState & KEY_STATE_CONTROL ) | ||
| { | ||
| newModState |= CTRL; | ||
| } | ||
|
|
||
| if( keyState & KEY_STATE_SHIFT ) | ||
| { | ||
| newModState |= SHIFT; | ||
| } | ||
|
|
||
| if( keyState & KEY_STATE_ALT ) | ||
| { | ||
| newModState |= ALT; | ||
| } | ||
| if(newModState != 0) | ||
| const KeyDefType key = (KeyDefType)msg->getArgument(0)->integer; | ||
| const KeyState keyState = (KeyState)msg->getArgument(1)->integer; | ||
|
xezon marked this conversation as resolved.
|
||
| if( keyState & (KEY_STATE_MODIFIERS | KEY_STATE_AUTOREPEAT) ) | ||
| return disp; | ||
| WideChar key = TheKeyboard->getPrintableKey((KeyDefType)msg->getArgument(0)->integer, 0); | ||
|
|
||
| WideChar printableKey = TheKeyboard->getPrintableKey(key, 0); | ||
| UnicodeString uKey; | ||
| uKey.concat(key); | ||
| uKey.concat(printableKey); | ||
| AsciiString aKey; | ||
| aKey.translate(uKey); | ||
| if(TheHotKeyManager && TheHotKeyManager->executeHotKey(aKey)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,8 +286,9 @@ void GameClient::init() | |
|
|
||
| // since we only allocate one of each, don't bother pooling 'em | ||
| m_translators[ m_numTranslators++ ] = TheMessageStream->attachTranslator( MSGNEW("GameClientSubsystem") WindowTranslator, 10 ); | ||
| // TheSuperHackers @fix Let active GUI hotkeys handle keys before MetaEventTranslator consumes overlapping bindings. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How did you come to the conclusion that this is the right thing to do? If a unit has a button mapped on key "E", then pressing "E" will no longer select matching units for the selection: a deviation of the original, possibly confusing the player. |
||
| m_translators[ m_numTranslators++ ] = TheMessageStream->attachTranslator( MSGNEW("GameClientSubsystem") HotKeyTranslator, 15 ); | ||
|
xezon marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you give an example what concrete button conflict this solves now or would solve on a conflict? |
||
| m_translators[ m_numTranslators++ ] = TheMessageStream->attachTranslator( MSGNEW("GameClientSubsystem") MetaEventTranslator, 20 ); | ||
| m_translators[ m_numTranslators++ ] = TheMessageStream->attachTranslator( MSGNEW("GameClientSubsystem") HotKeyTranslator, 25 ); | ||
| m_translators[ m_numTranslators++ ] = TheMessageStream->attachTranslator( MSGNEW("GameClientSubsystem") PlaceEventTranslator, 30 ); | ||
| m_translators[ m_numTranslators++ ] = TheMessageStream->attachTranslator( MSGNEW("GameClientSubsystem") GUICommandTranslator, 40 ); | ||
| m_translators[ m_numTranslators++ ] = TheMessageStream->attachTranslator( MSGNEW("GameClientSubsystem") SelectionTranslator, 50 ); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.