16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 01:59:19 +02:00

Remember which modifiers were present on key press and use them on key release

This fixes an issue where a triggered command stays indefinitely active
when the user releases the modifier before releasing the triggering key.
This commit is contained in:
Sebastian Krzyszkowiak
2026-06-29 23:19:39 +02:00
parent bb69986962
commit 6435c3d850
2 changed files with 12 additions and 1 deletions

View File

@@ -308,11 +308,21 @@ keyboard_input::key( int const Key, int const Action ) {
}
// include active modifiers for currently pressed key, except if the key is a modifier itself
auto const key =
auto key =
Key
| ( modifier ? 0 : ( input::key_shift ? keymodifier::shift : 0 ) )
| ( modifier ? 0 : ( input::key_ctrl ? keymodifier::control : 0 ) );
if( Action == GLFW_RELEASE ) {
auto const stored = m_modsforkeys.find( Key );
if( stored != m_modsforkeys.end() ) {
key = stored->second;
}
m_modsforkeys.erase( Key );
} else {
m_modsforkeys[ Key ] = key;
}
auto const lookup = m_bindings.find( key );
if( lookup == m_bindings.end() ) {
// no binding for this key