From 7db80584da9a50653b0a164d296f033f13ba17cc Mon Sep 17 00:00:00 2001 From: Ihar Hubchyk Date: Sun, 24 Dec 2023 19:33:26 +0800 Subject: [PATCH] Take into an account SHIFT and CAPS LOCK being used at the same time relates to #8098 If a user has active CAPS LOCK and uses SHIFT while typing, the letters must be non-capital. --- src/engine/localevent.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/localevent.cpp b/src/engine/localevent.cpp index 4d362dbc87f..17c3d5ca43e 100644 --- a/src/engine/localevent.cpp +++ b/src/engine/localevent.cpp @@ -340,8 +340,12 @@ namespace return modifier; } - char getCharacterFromPressedKey( const fheroes2::Key key, const int32_t mod ) + char getCharacterFromPressedKey( const fheroes2::Key key, int32_t mod ) { + if ( ( mod & fheroes2::KeyModifier::KEY_MODIFIER_SHIFT ) && ( mod & fheroes2::KeyModifier::KEY_MODIFIER_CAPS ) ) { + mod = mod & ~( fheroes2::KeyModifier::KEY_MODIFIER_SHIFT | fheroes2::KeyModifier::KEY_MODIFIER_CAPS ); + } + switch ( key ) { case fheroes2::Key::KEY_1: return ( fheroes2::KeyModifier::KEY_MODIFIER_SHIFT & mod ? '!' : '1' );