Fixed sf::Keyboard on Mac OS X

This commit is contained in:
Marco Antognini 2012-07-16 16:27:27 +02:00
parent 3e2c3b8c95
commit 68494d0dbb
3 changed files with 14 additions and 14 deletions

View File

@ -108,7 +108,7 @@ public :
////////////////////////////////////////////////////////////
/// Try to convert a character into a SFML key code.
///
/// Return sf::Keyboard::KeyCount if it doesn't match any 'localized' keys.
/// Return sf::Keyboard::Unknown if it doesn't match any 'localized' keys.
///
/// By 'localized' I mean keys that depend on the keyboard layout
/// and might not be the same as the US keycode in some country
@ -121,7 +121,7 @@ public :
////////////////////////////////////////////////////////////
/// Try to convert a virtual keycode into a SFML key code.
///
/// Return sf::Keyboard::KeyCount if the keycode is unknown.
/// Return sf::Keyboard::Unknown if the keycode is unknown.
///
////////////////////////////////////////////////////////////
static Keyboard::Key nonLocalizedKeys(UniChar virtualKeycode);

View File

@ -415,7 +415,7 @@ void HIDInputManager::loadKey(IOHIDElementRef key)
// Translation went fine
// The corresponding SFML key code
Keyboard::Key code = Keyboard::KeyCount; // KeyCound means 'none'
Keyboard::Key code = Keyboard::Unknown; // KeyCound means 'none'
// First we look if the key down is from a list of characters
// that depend on keyboard localization
@ -425,12 +425,12 @@ void HIDInputManager::loadKey(IOHIDElementRef key)
// The key is not a localized one so we try to find a
// corresponding code through virtual key code
if (code == Keyboard::KeyCount) {
if (code == Keyboard::Unknown) {
code = nonLocalizedKeys(virtualCode);
}
// A code was found, wonderful!
if (code != Keyboard::KeyCount) {
if (code != Keyboard::Unknown) {
// Ok, everything went fine. Now we have a unique
// corresponding sf::Keyboard::Key to one IOHIDElementRef
@ -455,7 +455,7 @@ void HIDInputManager::loadKey(IOHIDElementRef key)
// 0x51 | 0x67 | Keypad Equal
// 0x4c | 0x77 | Select
//if (code == Keyboard::KeyCount) { // The key is unknown.
//if (code == Keyboard::Unknown) { // The key is unknown.
// sf::err() << "This is an unknow key. Virtual key code is 0x"
// << std::hex
// << (UInt32)virtualCode
@ -847,7 +847,7 @@ Keyboard::Key HIDInputManager::localizedKeys(UniChar ch)
case 'Z': return sf::Keyboard::Z;
// The key is not 'localized'.
default: return sf::Keyboard::KeyCount;
default: return sf::Keyboard::Unknown;
}
}

View File

@ -97,7 +97,7 @@ NSUInteger keepOnlyMaskFromData(NSUInteger data, NSUInteger mask);
/// Convert a key down/up NSEvent into an SFML key event.
/// Based on localizedKeys and nonLocalizedKeys function.
///
/// Return sf::Keyboard::KeyCount as Code if the key is unknown.
/// Return sf::Keyboard::Unknown as Code if the key is unknown.
///
////////////////////////////////////////////////////////////
+(sf::Event::KeyEvent)convertNSKeyEventToSFMLEvent:(NSEvent *)anEvent;
@ -532,7 +532,7 @@ NSUInteger keepOnlyMaskFromData(NSUInteger data, NSUInteger mask);
if (m_useKeyRepeat || ![theEvent isARepeat]) {
sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
if (key.code != sf::Keyboard::KeyCount) { // The key is recognized.
if (key.code != sf::Keyboard::Unknown) { // The key is recognized.
m_requester->keyDown(key);
}
}
@ -608,7 +608,7 @@ NSUInteger keepOnlyMaskFromData(NSUInteger data, NSUInteger mask);
sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
if (key.code != sf::Keyboard::KeyCount) { // The key is recognized.
if (key.code != sf::Keyboard::Unknown) { // The key is recognized.
m_requester->keyUp(key);
}
}
@ -626,7 +626,7 @@ NSUInteger keepOnlyMaskFromData(NSUInteger data, NSUInteger mask);
// Setup a potential event key.
sf::Event::KeyEvent key;
key.code = sf::Keyboard::KeyCount;
key.code = sf::Keyboard::Unknown;
key.alt = modifiers & NSAlternateKeyMask;
key.control = modifiers & NSControlKeyMask;
key.shift = modifiers & NSShiftKeyMask;
@ -1049,7 +1049,7 @@ NSUInteger keepOnlyMaskFromData(NSUInteger data, NSUInteger mask);
key.system = modifierFlags & NSCommandKeyMask;
// Key code.
key.code = sf::Keyboard::KeyCount;
key.code = sf::Keyboard::Unknown;
// First we look if the key down is from a list of caracter
// that depend on keyboard localization.
@ -1060,12 +1060,12 @@ NSUInteger keepOnlyMaskFromData(NSUInteger data, NSUInteger mask);
// The key is not a localized one, so we try to find a corresponding code
// through virtual key code.
if (key.code == sf::Keyboard::KeyCount) {
if (key.code == sf::Keyboard::Unknown) {
key.code = sf::priv::HIDInputManager::nonLocalizedKeys([anEvent keyCode]);
}
//#ifdef SFML_DEBUG // Don't bother the final customers with annoying messages.
// if (key.code == sf::Keyboard::KeyCount) { // The key is unknown.
// if (key.code == sf::Keyboard::Unknown) { // The key is unknown.
// sf::err() << "This is an unknow key. Virtual key code is 0x"
// << std::hex
// << [anEvent keyCode]