Generate key events for caps lock when the modifier state changes

This is not accurate because modifier state and key state are not the
same thing for caps lock, but at least some events are generated
instead of nothing.
This commit is contained in:
kimci86 2022-12-17 14:48:21 +01:00 committed by Lukas Dürrenberger
parent 1cbd6e9d12
commit 722838d590

View File

@ -69,6 +69,7 @@ struct ModifiersState
BOOL leftAlternateWasDown; BOOL leftAlternateWasDown;
BOOL leftControlWasDown; BOOL leftControlWasDown;
BOOL rightControlWasDown; BOOL rightControlWasDown;
BOOL capsLockWasOn;
}; };
@ -140,6 +141,7 @@ void initialiseKeyboardHelper(void)
state.rightAlternateWasDown = isKeyMaskActive(modifiers, NSRightAlternateKeyMask); state.rightAlternateWasDown = isKeyMaskActive(modifiers, NSRightAlternateKeyMask);
state.leftControlWasDown = isKeyMaskActive(modifiers, NSLeftControlKeyMask); state.leftControlWasDown = isKeyMaskActive(modifiers, NSLeftControlKeyMask);
state.rightControlWasDown = isKeyMaskActive(modifiers, NSRightControlKeyMask); state.rightControlWasDown = isKeyMaskActive(modifiers, NSRightControlKeyMask);
state.capsLockWasOn = isKeyMaskActive(modifiers, NSEventModifierFlagCapsLock);
isStateInitialized = YES; isStateInitialized = YES;
} }
@ -202,6 +204,16 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req
sf::Keyboard::Scan::LControl, sf::Keyboard::Scan::RControl, sf::Keyboard::Scan::LControl, sf::Keyboard::Scan::RControl,
requester requester
); );
// Handle caps lock
processOneModifier(
modifiers,
NSEventModifierFlagCapsLock,
state.capsLockWasOn,
sf::Keyboard::Unknown,
sf::Keyboard::Scan::CapsLock,
requester
);
} }