From 7faf5857ec5f0e5906cb188616b70e7174f395dc Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Mon, 9 Jul 2012 23:26:37 +0200 Subject: [PATCH] Added a sf::Key::Unknown key code for unsupported keys --- include/SFML/Window/Keyboard.hpp | 3 ++- src/SFML/Window/Linux/WindowImplX11.cpp | 2 +- src/SFML/Window/OSX/HIDInputManager.mm | 2 +- src/SFML/Window/Win32/WindowImplWin32.cpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/SFML/Window/Keyboard.hpp b/include/SFML/Window/Keyboard.hpp index 9bd92575d..d008fc44b 100644 --- a/include/SFML/Window/Keyboard.hpp +++ b/include/SFML/Window/Keyboard.hpp @@ -47,7 +47,8 @@ public : //////////////////////////////////////////////////////////// enum Key { - A, ///< The A key + Unknown = -1, ///< Unhandled key + A = 0, ///< The A key B, ///< The B key C, ///< The C key D, ///< The D key diff --git a/src/SFML/Window/Linux/WindowImplX11.cpp b/src/SFML/Window/Linux/WindowImplX11.cpp index abeecedbf..c6f8391e1 100644 --- a/src/SFML/Window/Linux/WindowImplX11.cpp +++ b/src/SFML/Window/Linux/WindowImplX11.cpp @@ -939,7 +939,7 @@ Keyboard::Key WindowImplX11::keysymToSF(KeySym symbol) case XK_9 : return Keyboard::Num9; } - return Keyboard::Key(0); + return Keyboard::Unknown; } } // namespace priv diff --git a/src/SFML/Window/OSX/HIDInputManager.mm b/src/SFML/Window/OSX/HIDInputManager.mm index 153365a2f..a23f431b7 100644 --- a/src/SFML/Window/OSX/HIDInputManager.mm +++ b/src/SFML/Window/OSX/HIDInputManager.mm @@ -1019,7 +1019,7 @@ Keyboard::Key HIDInputManager::nonLocalizedKeys(UniChar virtualKeycode) // This key is ' on CH-FR, ) on FR and - on US layouts. // An unknown key. - default: return sf::Keyboard::KeyCount; + default: return sf::Keyboard::Unknown; } } diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 77dd0f9ad..b68ba57ae 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -820,7 +820,7 @@ Keyboard::Key WindowImplWin32::virtualKeyCodeToSF(WPARAM key, LPARAM flags) case '9' : return Keyboard::Num9; } - return Keyboard::Key(0); + return Keyboard::Unknown; }