From 722838d590c01d1c0805a3bf290f4c3d83a39a91 Mon Sep 17 00:00:00 2001 From: kimci86 Date: Sat, 17 Dec 2022 14:48:21 +0100 Subject: [PATCH] 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. --- src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm b/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm index 87b3c96dc..0346f4046 100644 --- a/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm +++ b/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm @@ -69,6 +69,7 @@ struct ModifiersState BOOL leftAlternateWasDown; BOOL leftControlWasDown; BOOL rightControlWasDown; + BOOL capsLockWasOn; }; @@ -140,6 +141,7 @@ void initialiseKeyboardHelper(void) state.rightAlternateWasDown = isKeyMaskActive(modifiers, NSRightAlternateKeyMask); state.leftControlWasDown = isKeyMaskActive(modifiers, NSLeftControlKeyMask); state.rightControlWasDown = isKeyMaskActive(modifiers, NSRightControlKeyMask); + state.capsLockWasOn = isKeyMaskActive(modifiers, NSEventModifierFlagCapsLock); isStateInitialized = YES; } @@ -202,6 +204,16 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req sf::Keyboard::Scan::LControl, sf::Keyboard::Scan::RControl, requester ); + + // Handle caps lock + processOneModifier( + modifiers, + NSEventModifierFlagCapsLock, + state.capsLockWasOn, + sf::Keyboard::Unknown, + sf::Keyboard::Scan::CapsLock, + requester + ); }