Add support for right control key on OS X

Related to #401
This commit is contained in:
Marco Antognini 2013-06-28 12:48:18 +02:00
parent 8ecdd3ae8c
commit f92c0cbe7e
2 changed files with 15 additions and 21 deletions

View File

@ -37,12 +37,8 @@ namespace sf {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Keyboard Modifiers Helper /// Keyboard Modifiers Helper
/// ///
/// Handle modifiers (cmd, ctrl, alt, shift) events and send /// Handle left & right modifiers (cmd, ctrl, alt, shift)
/// them back to the requester. /// events and send them back to the requester.
///
/// As I don't have the right control keycode I cannot
/// implement left-right recognition for this key.
/// (See SFKeyboardModifiersHelper.mm for more info.)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -32,13 +32,8 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Here are define the mask value for the 'modifiers' keys (cmd, ctrl, alt, shift) /// Here are define the mask value for the 'modifiers'
/// /// keys (cmd, ctrl, alt, shift)
/// As I don't have the right control keycode I cannot implement left-right
/// recognition for this key.
#warning Missing keycode for right control key.
/// #define NSRightControlKeyMask 0x...
/// #define NSLeftControlKeyMask 0x40101
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#define NSRightShiftKeyMask 0x020004 #define NSRightShiftKeyMask 0x020004
@ -47,6 +42,8 @@
#define NSLeftCommandKeyMask 0x100008 #define NSLeftCommandKeyMask 0x100008
#define NSRightAlternateKeyMask 0x080040 #define NSRightAlternateKeyMask 0x080040
#define NSLeftAlternateKeyMask 0x080020 #define NSLeftAlternateKeyMask 0x080020
#define NSRightControlKeyMask 0x042000
#define NSLeftControlKeyMask 0x040001
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -62,8 +59,8 @@ struct ModifiersState
BOOL leftCommandWasDown; BOOL leftCommandWasDown;
BOOL rightAlternateWasDown; BOOL rightAlternateWasDown;
BOOL leftAlternateWasDown; BOOL leftAlternateWasDown;
BOOL controlWasDown; BOOL leftControlWasDown;
// Left & right control keys not yet supported. See the note above. BOOL rightControlWasDown;
}; };
@ -167,10 +164,11 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req
); );
// Handle control // Handle control
// Currently only the left control key will be used in SFML (see note above). processLeftRightModifiers(
processOneModifier( modifiers,
modifiers, NSControlKeyMask, NSLeftControlKeyMask, NSRightControlKeyMask,
state.controlWasDown, sf::Keyboard::LControl, state.leftControlWasDown, state.rightControlWasDown,
sf::Keyboard::LControl, sf::Keyboard::RControl,
requester requester
); );
} }
@ -200,8 +198,8 @@ void ensureModifiersStateIsInitilized()
state.rightCommandWasDown = isKeyMaskActive(modifiers, NSRightCommandKeyMask); state.rightCommandWasDown = isKeyMaskActive(modifiers, NSRightCommandKeyMask);
state.leftAlternateWasDown = isKeyMaskActive(modifiers, NSLeftAlternateKeyMask); state.leftAlternateWasDown = isKeyMaskActive(modifiers, NSLeftAlternateKeyMask);
state.rightAlternateWasDown = isKeyMaskActive(modifiers, NSRightAlternateKeyMask); state.rightAlternateWasDown = isKeyMaskActive(modifiers, NSRightAlternateKeyMask);
state.controlWasDown = isKeyMaskActive(modifiers, NSControlKeyMask); state.leftControlWasDown = isKeyMaskActive(modifiers, NSLeftControlKeyMask);
// Currently only the left control key will be used in SFML (see note above). state.rightControlWasDown = isKeyMaskActive(modifiers, NSRightControlKeyMask);
isStateInitialized = YES; isStateInitialized = YES;
} }