16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 22:39:17 +02:00

Merge pull request #117 from dos1/keyboard-mod-release

Remember which modifiers were present on key press and use them on key release
This commit is contained in:
2026-06-29 23:54:12 +02:00
committed by GitHub
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

View File

@@ -106,6 +106,7 @@ private:
// members
user_command m_command { user_command::none }; // last, if any, issued command
usercommand_map m_bindings;
std::unordered_map<int, int> m_modsforkeys; // modifiers that were used with the active keys
command_relay m_relay;
bindings_cache m_bindingscache;
glm::vec2 m_movementhorizontal { 0.f };