Skip to content

Commit

Permalink
Generate key events for caps lock when the modifier state changes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kimci86 committed Dec 17, 2022
1 parent 79363f1 commit 7ca9c73
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
BOOL leftAlternateWasDown;
BOOL leftControlWasDown;
BOOL rightControlWasDown;
BOOL capsLockWasOn;
};


Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
);
}


Expand Down

0 comments on commit 7ca9c73

Please sign in to comment.