Make Keyboard::Key a scoped enumeration

This commit is contained in:
kimci86 2023-12-19 23:45:33 +01:00 committed by Chris Thrasher
parent 82ee0f79ac
commit 39da2b829c
28 changed files with 1037 additions and 1037 deletions

View File

@ -121,7 +121,7 @@ int main(int argc, char* argv[])
window.close(); window.close();
break; break;
case sf::Event::KeyPressed: case sf::Event::KeyPressed:
if (event.key.code == sf::Keyboard::Escape) if (event.key.code == sf::Keyboard::Key::Escape)
window.close(); window.close();
break; break;
case sf::Event::Resized: case sf::Event::Resized:

View File

@ -159,10 +159,10 @@ struct SFMLmainWindow
// Scaling // Scaling
/* /!\ we do this at 60fps so choose low scaling factor! /!\ */ /* /!\ we do this at 60fps so choose low scaling factor! /!\ */
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up))
self.mainWindow->sprite.scale({1.01f, 1.01f}); self.mainWindow->sprite.scale({1.01f, 1.01f});
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down))
self.mainWindow->sprite.scale({0.99f, 0.99f}); self.mainWindow->sprite.scale({0.99f, 0.99f});
// Clear the window, display some stuff and display it into our view. // Clear the window, display some stuff and display it into our view.

View File

@ -182,7 +182,7 @@ int main()
{ {
// Window closed or escape key pressed: exit // Window closed or escape key pressed: exit
if ((event.type == sf::Event::Closed) || if ((event.type == sf::Event::Closed) ||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))) ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape)))
{ {
window.close(); window.close();
break; break;
@ -193,19 +193,19 @@ int main()
{ {
switch (event.key.code) switch (event.key.code)
{ {
case sf::Keyboard::Enter: case sf::Keyboard::Key::Enter:
generateTerrain(terrainStagingBuffer.data()); generateTerrain(terrainStagingBuffer.data());
break; break;
case sf::Keyboard::Down: case sf::Keyboard::Key::Down:
currentSetting = (currentSetting + 1) % settings.size(); currentSetting = (currentSetting + 1) % settings.size();
break; break;
case sf::Keyboard::Up: case sf::Keyboard::Key::Up:
currentSetting = (currentSetting + settings.size() - 1) % settings.size(); currentSetting = (currentSetting + settings.size() - 1) % settings.size();
break; break;
case sf::Keyboard::Left: case sf::Keyboard::Key::Left:
*(settings[currentSetting].value) -= 0.1f; *(settings[currentSetting].value) -= 0.1f;
break; break;
case sf::Keyboard::Right: case sf::Keyboard::Key::Right:
*(settings[currentSetting].value) += 0.1f; *(settings[currentSetting].value) += 0.1f;
break; break;
default: default:

View File

@ -162,7 +162,7 @@ int main()
{ {
// Window closed or escape key pressed: exit // Window closed or escape key pressed: exit
if ((event.type == sf::Event::Closed) || if ((event.type == sf::Event::Closed) ||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))) ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape)))
{ {
window.close(); window.close();
break; break;
@ -193,10 +193,10 @@ int main()
// Update threshold if the user wants to change it // Update threshold if the user wants to change it
float newThreshold = threshold; float newThreshold = threshold;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up))
newThreshold += 0.1f; newThreshold += 0.1f;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down))
newThreshold -= 0.1f; newThreshold -= 0.1f;
newThreshold = std::clamp(newThreshold, 0.1f, 100.0f); newThreshold = std::clamp(newThreshold, 0.1f, 100.0f);

View File

@ -213,14 +213,14 @@ int main()
} }
// Escape key: exit // Escape key: exit
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)) if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape))
{ {
exit = true; exit = true;
window.close(); window.close();
} }
// Return key: toggle mipmapping // Return key: toggle mipmapping
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Enter)) if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Key::Enter))
{ {
if (mipmapEnabled) if (mipmapEnabled)
{ {
@ -237,7 +237,7 @@ int main()
} }
// Space key: toggle sRGB conversion // Space key: toggle sRGB conversion
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space)) if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Key::Space))
{ {
sRgb = !sRgb; sRgb = !sRgb;
window.close(); window.close();

View File

@ -400,12 +400,12 @@ int main()
switch (event.key.code) switch (event.key.code)
{ {
// Escape key: exit // Escape key: exit
case sf::Keyboard::Escape: case sf::Keyboard::Key::Escape:
window.close(); window.close();
break; break;
// Left arrow key: previous shader // Left arrow key: previous shader
case sf::Keyboard::Left: case sf::Keyboard::Key::Left:
if (current == 0) if (current == 0)
current = effects.size() - 1; current = effects.size() - 1;
else else
@ -414,7 +414,7 @@ int main()
break; break;
// Right arrow key: next shader // Right arrow key: next shader
case sf::Keyboard::Right: case sf::Keyboard::Key::Right:
if (current == effects.size() - 1) if (current == effects.size() - 1)
current = 0; current = 0;
else else

View File

@ -114,14 +114,14 @@ int main()
{ {
// Window closed or escape key pressed: exit // Window closed or escape key pressed: exit
if ((event.type == sf::Event::Closed) || if ((event.type == sf::Event::Closed) ||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))) ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape)))
{ {
window.close(); window.close();
break; break;
} }
// Space key pressed: play // Space key pressed: play
if (((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space)) || if (((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Key::Space)) ||
(event.type == sf::Event::TouchBegan)) (event.type == sf::Event::TouchBegan))
{ {
if (!isPlaying) if (!isPlaying)
@ -159,11 +159,11 @@ int main()
const float deltaTime = clock.restart().asSeconds(); const float deltaTime = clock.restart().asSeconds();
// Move the player's paddle // Move the player's paddle
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) && (leftPaddle.getPosition().y - paddleSize.y / 2 > 5.f)) if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up) && (leftPaddle.getPosition().y - paddleSize.y / 2 > 5.f))
{ {
leftPaddle.move({0.f, -paddleSpeed * deltaTime}); leftPaddle.move({0.f, -paddleSpeed * deltaTime});
} }
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) && if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down) &&
(leftPaddle.getPosition().y + paddleSize.y / 2 < gameHeight - 5.f)) (leftPaddle.getPosition().y + paddleSize.y / 2 < gameHeight - 5.f))
{ {
leftPaddle.move({0.f, paddleSpeed * deltaTime}); leftPaddle.move({0.f, paddleSpeed * deltaTime});

View File

@ -2547,7 +2547,7 @@ public:
window.close(); window.close();
// Escape key: exit // Escape key: exit
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)) if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape))
window.close(); window.close();
// Re-create the swapchain when the window is resized // Re-create the swapchain when the window is resized

View File

@ -148,7 +148,7 @@ int main()
window.close(); window.close();
// Escape key: exit // Escape key: exit
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)) if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape))
window.close(); window.close();
// Resize event: adjust the viewport // Resize event: adjust the viewport

View File

@ -98,11 +98,11 @@ SFML_WINDOW_API void setString(const String& text);
/// if(event.type == sf::Event::KeyPressed) /// if(event.type == sf::Event::KeyPressed)
/// { /// {
/// // Using Ctrl + V to paste a string into SFML /// // Using Ctrl + V to paste a string into SFML
/// if(event.key.control && event.key.code == sf::Keyboard::V) /// if(event.key.control && event.key.code == sf::Keyboard::Key::V)
/// string = sf::Clipboard::getString(); /// string = sf::Clipboard::getString();
/// ///
/// // Using Ctrl + C to copy a string out of SFML /// // Using Ctrl + C to copy a string out of SFML
/// if(event.key.control && event.key.code == sf::Keyboard::C) /// if(event.key.control && event.key.code == sf::Keyboard::Key::C)
/// sf::Clipboard::setString("Hello World!"); /// sf::Clipboard::setString("Hello World!");
/// } /// }
/// } /// }

View File

@ -253,7 +253,7 @@ struct Event
/// window.close(); /// window.close();
/// ///
/// // The escape key was pressed /// // The escape key was pressed
/// if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)) /// if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape))
/// window.close(); /// window.close();
/// ///
/// // The window was resized /// // The window was resized

View File

@ -48,7 +48,7 @@ namespace Keyboard
/// to `Y` or `Z`. /// to `Y` or `Z`.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
enum Key enum class Key
{ {
Unknown = -1, //!< Unhandled key Unknown = -1, //!< Unhandled key
A = 0, //!< The A key A = 0, //!< The A key
@ -362,7 +362,7 @@ SFML_WINDOW_API bool isKeyPressed(Scancode code);
/// ///
/// \return The key corresponding to the scancode under the current /// \return The key corresponding to the scancode under the current
/// keyboard layout used by the operating system, or /// keyboard layout used by the operating system, or
/// sf::Keyboard::Unknown when the scancode cannot be mapped /// sf::Keyboard::Key::Unknown when the scancode cannot be mapped
/// to a Key. /// to a Key.
/// ///
/// \see delocalize /// \see delocalize
@ -398,7 +398,7 @@ SFML_WINDOW_API Scancode delocalize(Key key);
/// "Left Command" on macOS. /// "Left Command" on macOS.
/// ///
/// The current keyboard layout set by the operating system is used to /// The current keyboard layout set by the operating system is used to
/// interpret the scancode: for example, sf::Keyboard::Semicolon is /// interpret the scancode: for example, sf::Keyboard::Key::Semicolon is
/// mapped to ";" for layout and to "é" for others. /// mapped to ";" for layout and to "é" for others.
/// ///
/// \return The localized description of the code /// \return The localized description of the code
@ -444,15 +444,15 @@ SFML_WINDOW_API void setVirtualKeyboardVisible(bool visible);
/// ///
/// Usage example: /// Usage example:
/// \code /// \code
/// if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) /// if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Left))
/// { /// {
/// // move left... /// // move left...
/// } /// }
/// else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) /// else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Right))
/// { /// {
/// // move right... /// // move right...
/// } /// }
/// else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) /// else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape))
/// { /// {
/// // quit... /// // quit...
/// } /// }

View File

@ -58,7 +58,7 @@ bool isKeyPressed(Keyboard::Scancode /* codes */)
Keyboard::Key localize(Keyboard::Scancode /* code */) Keyboard::Key localize(Keyboard::Scancode /* code */)
{ {
// Not applicable // Not applicable
return Keyboard::Unknown; return Keyboard::Key::Unknown;
} }

View File

@ -590,20 +590,20 @@ Keyboard::Key WindowImplAndroid::androidKeyToSF(std::int32_t key)
case AKEYCODE_UNKNOWN: case AKEYCODE_UNKNOWN:
case AKEYCODE_SOFT_LEFT: case AKEYCODE_SOFT_LEFT:
case AKEYCODE_SOFT_RIGHT: case AKEYCODE_SOFT_RIGHT:
case AKEYCODE_HOME: return Keyboard::Unknown; case AKEYCODE_HOME: return Keyboard::Key::Unknown;
case AKEYCODE_BACK: return Keyboard::Escape; case AKEYCODE_BACK: return Keyboard::Key::Escape;
case AKEYCODE_CALL: case AKEYCODE_CALL:
case AKEYCODE_ENDCALL: return Keyboard::Unknown; case AKEYCODE_ENDCALL: return Keyboard::Key::Unknown;
case AKEYCODE_0: return Keyboard::Num0; case AKEYCODE_0: return Keyboard::Key::Num0;
case AKEYCODE_1: return Keyboard::Num1; case AKEYCODE_1: return Keyboard::Key::Num1;
case AKEYCODE_2: return Keyboard::Num2; case AKEYCODE_2: return Keyboard::Key::Num2;
case AKEYCODE_3: return Keyboard::Num3; case AKEYCODE_3: return Keyboard::Key::Num3;
case AKEYCODE_4: return Keyboard::Num4; case AKEYCODE_4: return Keyboard::Key::Num4;
case AKEYCODE_5: return Keyboard::Num5; case AKEYCODE_5: return Keyboard::Key::Num5;
case AKEYCODE_6: return Keyboard::Num6; case AKEYCODE_6: return Keyboard::Key::Num6;
case AKEYCODE_7: return Keyboard::Num7; case AKEYCODE_7: return Keyboard::Key::Num7;
case AKEYCODE_8: return Keyboard::Num8; case AKEYCODE_8: return Keyboard::Key::Num8;
case AKEYCODE_9: return Keyboard::Num9; case AKEYCODE_9: return Keyboard::Key::Num9;
case AKEYCODE_STAR: case AKEYCODE_STAR:
case AKEYCODE_POUND: case AKEYCODE_POUND:
case AKEYCODE_DPAD_UP: case AKEYCODE_DPAD_UP:
@ -615,56 +615,56 @@ Keyboard::Key WindowImplAndroid::androidKeyToSF(std::int32_t key)
case AKEYCODE_VOLUME_DOWN: case AKEYCODE_VOLUME_DOWN:
case AKEYCODE_POWER: case AKEYCODE_POWER:
case AKEYCODE_CAMERA: case AKEYCODE_CAMERA:
case AKEYCODE_CLEAR: return Keyboard::Unknown; case AKEYCODE_CLEAR: return Keyboard::Key::Unknown;
case AKEYCODE_A: return Keyboard::A; case AKEYCODE_A: return Keyboard::Key::A;
case AKEYCODE_B: return Keyboard::B; case AKEYCODE_B: return Keyboard::Key::B;
case AKEYCODE_C: return Keyboard::C; case AKEYCODE_C: return Keyboard::Key::C;
case AKEYCODE_D: return Keyboard::D; case AKEYCODE_D: return Keyboard::Key::D;
case AKEYCODE_E: return Keyboard::E; case AKEYCODE_E: return Keyboard::Key::E;
case AKEYCODE_F: return Keyboard::F; case AKEYCODE_F: return Keyboard::Key::F;
case AKEYCODE_G: return Keyboard::G; case AKEYCODE_G: return Keyboard::Key::G;
case AKEYCODE_H: return Keyboard::H; case AKEYCODE_H: return Keyboard::Key::H;
case AKEYCODE_I: return Keyboard::I; case AKEYCODE_I: return Keyboard::Key::I;
case AKEYCODE_J: return Keyboard::J; case AKEYCODE_J: return Keyboard::Key::J;
case AKEYCODE_K: return Keyboard::K; case AKEYCODE_K: return Keyboard::Key::K;
case AKEYCODE_L: return Keyboard::L; case AKEYCODE_L: return Keyboard::Key::L;
case AKEYCODE_M: return Keyboard::M; case AKEYCODE_M: return Keyboard::Key::M;
case AKEYCODE_N: return Keyboard::N; case AKEYCODE_N: return Keyboard::Key::N;
case AKEYCODE_O: return Keyboard::O; case AKEYCODE_O: return Keyboard::Key::O;
case AKEYCODE_P: return Keyboard::P; case AKEYCODE_P: return Keyboard::Key::P;
case AKEYCODE_Q: return Keyboard::Q; case AKEYCODE_Q: return Keyboard::Key::Q;
case AKEYCODE_R: return Keyboard::R; case AKEYCODE_R: return Keyboard::Key::R;
case AKEYCODE_S: return Keyboard::S; case AKEYCODE_S: return Keyboard::Key::S;
case AKEYCODE_T: return Keyboard::T; case AKEYCODE_T: return Keyboard::Key::T;
case AKEYCODE_U: return Keyboard::U; case AKEYCODE_U: return Keyboard::Key::U;
case AKEYCODE_V: return Keyboard::V; case AKEYCODE_V: return Keyboard::Key::V;
case AKEYCODE_W: return Keyboard::W; case AKEYCODE_W: return Keyboard::Key::W;
case AKEYCODE_X: return Keyboard::X; case AKEYCODE_X: return Keyboard::Key::X;
case AKEYCODE_Y: return Keyboard::Y; case AKEYCODE_Y: return Keyboard::Key::Y;
case AKEYCODE_Z: return Keyboard::Z; case AKEYCODE_Z: return Keyboard::Key::Z;
case AKEYCODE_COMMA: return Keyboard::Comma; case AKEYCODE_COMMA: return Keyboard::Key::Comma;
case AKEYCODE_PERIOD: return Keyboard::Period; case AKEYCODE_PERIOD: return Keyboard::Key::Period;
case AKEYCODE_ALT_LEFT: return Keyboard::LAlt; case AKEYCODE_ALT_LEFT: return Keyboard::Key::LAlt;
case AKEYCODE_ALT_RIGHT: return Keyboard::RAlt; case AKEYCODE_ALT_RIGHT: return Keyboard::Key::RAlt;
case AKEYCODE_SHIFT_LEFT: return Keyboard::LShift; case AKEYCODE_SHIFT_LEFT: return Keyboard::Key::LShift;
case AKEYCODE_SHIFT_RIGHT: return Keyboard::RShift; case AKEYCODE_SHIFT_RIGHT: return Keyboard::Key::RShift;
case AKEYCODE_TAB: return Keyboard::Tab; case AKEYCODE_TAB: return Keyboard::Key::Tab;
case AKEYCODE_SPACE: return Keyboard::Space; case AKEYCODE_SPACE: return Keyboard::Key::Space;
case AKEYCODE_SYM: case AKEYCODE_SYM:
case AKEYCODE_EXPLORER: case AKEYCODE_EXPLORER:
case AKEYCODE_ENVELOPE: return Keyboard::Unknown; case AKEYCODE_ENVELOPE: return Keyboard::Key::Unknown;
case AKEYCODE_ENTER: return Keyboard::Enter; case AKEYCODE_ENTER: return Keyboard::Key::Enter;
case AKEYCODE_DEL: return Keyboard::Backspace; case AKEYCODE_DEL: return Keyboard::Key::Backspace;
case AKEYCODE_FORWARD_DEL: return Keyboard::Delete; case AKEYCODE_FORWARD_DEL: return Keyboard::Key::Delete;
case AKEYCODE_GRAVE: return Keyboard::Grave; case AKEYCODE_GRAVE: return Keyboard::Key::Grave;
case AKEYCODE_MINUS: return Keyboard::Subtract; case AKEYCODE_MINUS: return Keyboard::Key::Subtract;
case AKEYCODE_EQUALS: return Keyboard::Equal; case AKEYCODE_EQUALS: return Keyboard::Key::Equal;
case AKEYCODE_LEFT_BRACKET: return Keyboard::LBracket; case AKEYCODE_LEFT_BRACKET: return Keyboard::Key::LBracket;
case AKEYCODE_RIGHT_BRACKET: return Keyboard::RBracket; case AKEYCODE_RIGHT_BRACKET: return Keyboard::Key::RBracket;
case AKEYCODE_BACKSLASH: return Keyboard::Backslash; case AKEYCODE_BACKSLASH: return Keyboard::Key::Backslash;
case AKEYCODE_SEMICOLON: return Keyboard::Semicolon; case AKEYCODE_SEMICOLON: return Keyboard::Key::Semicolon;
case AKEYCODE_APOSTROPHE: return Keyboard::Apostrophe; case AKEYCODE_APOSTROPHE: return Keyboard::Key::Apostrophe;
case AKEYCODE_SLASH: return Keyboard::Slash; case AKEYCODE_SLASH: return Keyboard::Key::Slash;
case AKEYCODE_AT: case AKEYCODE_AT:
case AKEYCODE_NUM: case AKEYCODE_NUM:
case AKEYCODE_HEADSETHOOK: case AKEYCODE_HEADSETHOOK:
@ -679,9 +679,9 @@ Keyboard::Key WindowImplAndroid::androidKeyToSF(std::int32_t key)
case AKEYCODE_MEDIA_PREVIOUS: case AKEYCODE_MEDIA_PREVIOUS:
case AKEYCODE_MEDIA_REWIND: case AKEYCODE_MEDIA_REWIND:
case AKEYCODE_MEDIA_FAST_FORWARD: case AKEYCODE_MEDIA_FAST_FORWARD:
case AKEYCODE_MUTE: return Keyboard::Unknown; case AKEYCODE_MUTE: return Keyboard::Key::Unknown;
case AKEYCODE_PAGE_UP: return Keyboard::PageUp; case AKEYCODE_PAGE_UP: return Keyboard::Key::PageUp;
case AKEYCODE_PAGE_DOWN: return Keyboard::PageDown; case AKEYCODE_PAGE_DOWN: return Keyboard::Key::PageDown;
case AKEYCODE_PICTSYMBOLS: case AKEYCODE_PICTSYMBOLS:
case AKEYCODE_SWITCH_CHARSET: case AKEYCODE_SWITCH_CHARSET:
case AKEYCODE_BUTTON_A: case AKEYCODE_BUTTON_A:
@ -699,7 +699,7 @@ Keyboard::Key WindowImplAndroid::androidKeyToSF(std::int32_t key)
case AKEYCODE_BUTTON_START: case AKEYCODE_BUTTON_START:
case AKEYCODE_BUTTON_SELECT: case AKEYCODE_BUTTON_SELECT:
case AKEYCODE_BUTTON_MODE: case AKEYCODE_BUTTON_MODE:
default: return Keyboard::Unknown; default: return Keyboard::Key::Unknown;
} }
// clang-format on // clang-format on
} }

View File

@ -76,19 +76,19 @@ termios newTerminalConfig, oldTerminalConfig; // Terminal configurations
bool altDown() bool altDown()
{ {
return keyMap[sf::Keyboard::LAlt] || keyMap[sf::Keyboard::RAlt]; return keyMap[sf::Keyboard::Key::LAlt] || keyMap[sf::Keyboard::Key::RAlt];
} }
bool controlDown() bool controlDown()
{ {
return keyMap[sf::Keyboard::LControl] || keyMap[sf::Keyboard::RControl]; return keyMap[sf::Keyboard::Key::LControl] || keyMap[sf::Keyboard::Key::RControl];
} }
bool shiftDown() bool shiftDown()
{ {
return keyMap[sf::Keyboard::LShift] || keyMap[sf::Keyboard::RShift]; return keyMap[sf::Keyboard::Key::LShift] || keyMap[sf::Keyboard::Key::RShift];
} }
bool systemDown() bool systemDown()
{ {
return keyMap[sf::Keyboard::LSystem] || keyMap[sf::Keyboard::RSystem]; return keyMap[sf::Keyboard::Key::LSystem] || keyMap[sf::Keyboard::Key::RSystem];
} }
void uninitFileDescriptors() void uninitFileDescriptors()
@ -192,108 +192,108 @@ sf::Keyboard::Key toKey(int code)
switch (code) switch (code)
{ {
// clang-format off // clang-format off
case KEY_ESC: return sf::Keyboard::Escape; case KEY_ESC: return sf::Keyboard::Key::Escape;
case KEY_1: return sf::Keyboard::Num1; case KEY_1: return sf::Keyboard::Key::Num1;
case KEY_2: return sf::Keyboard::Num2; case KEY_2: return sf::Keyboard::Key::Num2;
case KEY_3: return sf::Keyboard::Num3; case KEY_3: return sf::Keyboard::Key::Num3;
case KEY_4: return sf::Keyboard::Num4; case KEY_4: return sf::Keyboard::Key::Num4;
case KEY_5: return sf::Keyboard::Num5; case KEY_5: return sf::Keyboard::Key::Num5;
case KEY_6: return sf::Keyboard::Num6; case KEY_6: return sf::Keyboard::Key::Num6;
case KEY_7: return sf::Keyboard::Num7; case KEY_7: return sf::Keyboard::Key::Num7;
case KEY_8: return sf::Keyboard::Num8; case KEY_8: return sf::Keyboard::Key::Num8;
case KEY_9: return sf::Keyboard::Num9; case KEY_9: return sf::Keyboard::Key::Num9;
case KEY_0: return sf::Keyboard::Num0; case KEY_0: return sf::Keyboard::Key::Num0;
case KEY_MINUS: return sf::Keyboard::Hyphen; case KEY_MINUS: return sf::Keyboard::Key::Hyphen;
case KEY_EQUAL: return sf::Keyboard::Equal; case KEY_EQUAL: return sf::Keyboard::Key::Equal;
case KEY_BACKSPACE: return sf::Keyboard::Backspace; case KEY_BACKSPACE: return sf::Keyboard::Key::Backspace;
case KEY_TAB: return sf::Keyboard::Tab; case KEY_TAB: return sf::Keyboard::Key::Tab;
case KEY_Q: return sf::Keyboard::Q; case KEY_Q: return sf::Keyboard::Key::Q;
case KEY_W: return sf::Keyboard::W; case KEY_W: return sf::Keyboard::Key::W;
case KEY_E: return sf::Keyboard::E; case KEY_E: return sf::Keyboard::Key::E;
case KEY_R: return sf::Keyboard::R; case KEY_R: return sf::Keyboard::Key::R;
case KEY_T: return sf::Keyboard::T; case KEY_T: return sf::Keyboard::Key::T;
case KEY_Y: return sf::Keyboard::Y; case KEY_Y: return sf::Keyboard::Key::Y;
case KEY_U: return sf::Keyboard::U; case KEY_U: return sf::Keyboard::Key::U;
case KEY_I: return sf::Keyboard::I; case KEY_I: return sf::Keyboard::Key::I;
case KEY_O: return sf::Keyboard::O; case KEY_O: return sf::Keyboard::Key::O;
case KEY_P: return sf::Keyboard::P; case KEY_P: return sf::Keyboard::Key::P;
case KEY_LEFTBRACE: return sf::Keyboard::LBracket; case KEY_LEFTBRACE: return sf::Keyboard::Key::LBracket;
case KEY_RIGHTBRACE: return sf::Keyboard::RBracket; case KEY_RIGHTBRACE: return sf::Keyboard::Key::RBracket;
case KEY_KPENTER: case KEY_KPENTER:
case KEY_ENTER: return sf::Keyboard::Enter; case KEY_ENTER: return sf::Keyboard::Key::Enter;
case KEY_LEFTCTRL: return sf::Keyboard::LControl; case KEY_LEFTCTRL: return sf::Keyboard::Key::LControl;
case KEY_A: return sf::Keyboard::A; case KEY_A: return sf::Keyboard::Key::A;
case KEY_S: return sf::Keyboard::S; case KEY_S: return sf::Keyboard::Key::S;
case KEY_D: return sf::Keyboard::D; case KEY_D: return sf::Keyboard::Key::D;
case KEY_F: return sf::Keyboard::F; case KEY_F: return sf::Keyboard::Key::F;
case KEY_G: return sf::Keyboard::G; case KEY_G: return sf::Keyboard::Key::G;
case KEY_H: return sf::Keyboard::H; case KEY_H: return sf::Keyboard::Key::H;
case KEY_J: return sf::Keyboard::J; case KEY_J: return sf::Keyboard::Key::J;
case KEY_K: return sf::Keyboard::K; case KEY_K: return sf::Keyboard::Key::K;
case KEY_L: return sf::Keyboard::L; case KEY_L: return sf::Keyboard::Key::L;
case KEY_SEMICOLON: return sf::Keyboard::Semicolon; case KEY_SEMICOLON: return sf::Keyboard::Key::Semicolon;
case KEY_APOSTROPHE: return sf::Keyboard::Apostrophe; case KEY_APOSTROPHE: return sf::Keyboard::Key::Apostrophe;
case KEY_GRAVE: return sf::Keyboard::Grave; case KEY_GRAVE: return sf::Keyboard::Key::Grave;
case KEY_LEFTSHIFT: return sf::Keyboard::LShift; case KEY_LEFTSHIFT: return sf::Keyboard::Key::LShift;
case KEY_BACKSLASH: return sf::Keyboard::Backslash; case KEY_BACKSLASH: return sf::Keyboard::Key::Backslash;
case KEY_Z: return sf::Keyboard::Z; case KEY_Z: return sf::Keyboard::Key::Z;
case KEY_X: return sf::Keyboard::X; case KEY_X: return sf::Keyboard::Key::X;
case KEY_C: return sf::Keyboard::C; case KEY_C: return sf::Keyboard::Key::C;
case KEY_V: return sf::Keyboard::V; case KEY_V: return sf::Keyboard::Key::V;
case KEY_B: return sf::Keyboard::B; case KEY_B: return sf::Keyboard::Key::B;
case KEY_N: return sf::Keyboard::N; case KEY_N: return sf::Keyboard::Key::N;
case KEY_M: return sf::Keyboard::M; case KEY_M: return sf::Keyboard::Key::M;
case KEY_COMMA: return sf::Keyboard::Comma; case KEY_COMMA: return sf::Keyboard::Key::Comma;
case KEY_DOT: return sf::Keyboard::Period; case KEY_DOT: return sf::Keyboard::Key::Period;
case KEY_SLASH: return sf::Keyboard::Slash; case KEY_SLASH: return sf::Keyboard::Key::Slash;
case KEY_RIGHTSHIFT: return sf::Keyboard::RShift; case KEY_RIGHTSHIFT: return sf::Keyboard::Key::RShift;
case KEY_KPASTERISK: return sf::Keyboard::Multiply; case KEY_KPASTERISK: return sf::Keyboard::Key::Multiply;
case KEY_LEFTALT: return sf::Keyboard::LAlt; case KEY_LEFTALT: return sf::Keyboard::Key::LAlt;
case KEY_SPACE: return sf::Keyboard::Space; case KEY_SPACE: return sf::Keyboard::Key::Space;
case KEY_F1: return sf::Keyboard::F1; case KEY_F1: return sf::Keyboard::Key::F1;
case KEY_F2: return sf::Keyboard::F2; case KEY_F2: return sf::Keyboard::Key::F2;
case KEY_F3: return sf::Keyboard::F3; case KEY_F3: return sf::Keyboard::Key::F3;
case KEY_F4: return sf::Keyboard::F4; case KEY_F4: return sf::Keyboard::Key::F4;
case KEY_F5: return sf::Keyboard::F5; case KEY_F5: return sf::Keyboard::Key::F5;
case KEY_F6: return sf::Keyboard::F6; case KEY_F6: return sf::Keyboard::Key::F6;
case KEY_F7: return sf::Keyboard::F7; case KEY_F7: return sf::Keyboard::Key::F7;
case KEY_F8: return sf::Keyboard::F8; case KEY_F8: return sf::Keyboard::Key::F8;
case KEY_F9: return sf::Keyboard::F9; case KEY_F9: return sf::Keyboard::Key::F9;
case KEY_F10: return sf::Keyboard::F10; case KEY_F10: return sf::Keyboard::Key::F10;
case KEY_F11: return sf::Keyboard::F11; case KEY_F11: return sf::Keyboard::Key::F11;
case KEY_F12: return sf::Keyboard::F12; case KEY_F12: return sf::Keyboard::Key::F12;
case KEY_F13: return sf::Keyboard::F13; case KEY_F13: return sf::Keyboard::Key::F13;
case KEY_F14: return sf::Keyboard::F14; case KEY_F14: return sf::Keyboard::Key::F14;
case KEY_F15: return sf::Keyboard::F15; case KEY_F15: return sf::Keyboard::Key::F15;
case KEY_KP7: return sf::Keyboard::Numpad7; case KEY_KP7: return sf::Keyboard::Key::Numpad7;
case KEY_KP8: return sf::Keyboard::Numpad8; case KEY_KP8: return sf::Keyboard::Key::Numpad8;
case KEY_KP9: return sf::Keyboard::Numpad9; case KEY_KP9: return sf::Keyboard::Key::Numpad9;
case KEY_KPMINUS: return sf::Keyboard::Subtract; case KEY_KPMINUS: return sf::Keyboard::Key::Subtract;
case KEY_KP4: return sf::Keyboard::Numpad4; case KEY_KP4: return sf::Keyboard::Key::Numpad4;
case KEY_KP5: return sf::Keyboard::Numpad5; case KEY_KP5: return sf::Keyboard::Key::Numpad5;
case KEY_KP6: return sf::Keyboard::Numpad6; case KEY_KP6: return sf::Keyboard::Key::Numpad6;
case KEY_KPPLUS: return sf::Keyboard::Add; case KEY_KPPLUS: return sf::Keyboard::Key::Add;
case KEY_KP1: return sf::Keyboard::Numpad1; case KEY_KP1: return sf::Keyboard::Key::Numpad1;
case KEY_KP2: return sf::Keyboard::Numpad2; case KEY_KP2: return sf::Keyboard::Key::Numpad2;
case KEY_KP3: return sf::Keyboard::Numpad3; case KEY_KP3: return sf::Keyboard::Key::Numpad3;
case KEY_KP0: return sf::Keyboard::Numpad0; case KEY_KP0: return sf::Keyboard::Key::Numpad0;
case KEY_KPDOT: return sf::Keyboard::Delete; case KEY_KPDOT: return sf::Keyboard::Key::Delete;
case KEY_RIGHTCTRL: return sf::Keyboard::RControl; case KEY_RIGHTCTRL: return sf::Keyboard::Key::RControl;
case KEY_KPSLASH: return sf::Keyboard::Divide; case KEY_KPSLASH: return sf::Keyboard::Key::Divide;
case KEY_RIGHTALT: return sf::Keyboard::RAlt; case KEY_RIGHTALT: return sf::Keyboard::Key::RAlt;
case KEY_HOME: return sf::Keyboard::Home; case KEY_HOME: return sf::Keyboard::Key::Home;
case KEY_UP: return sf::Keyboard::Up; case KEY_UP: return sf::Keyboard::Key::Up;
case KEY_PAGEUP: return sf::Keyboard::PageUp; case KEY_PAGEUP: return sf::Keyboard::Key::PageUp;
case KEY_LEFT: return sf::Keyboard::Left; case KEY_LEFT: return sf::Keyboard::Key::Left;
case KEY_RIGHT: return sf::Keyboard::Right; case KEY_RIGHT: return sf::Keyboard::Key::Right;
case KEY_END: return sf::Keyboard::End; case KEY_END: return sf::Keyboard::Key::End;
case KEY_DOWN: return sf::Keyboard::Down; case KEY_DOWN: return sf::Keyboard::Key::Down;
case KEY_PAGEDOWN: return sf::Keyboard::PageDown; case KEY_PAGEDOWN: return sf::Keyboard::Key::PageDown;
case KEY_INSERT: return sf::Keyboard::Insert; case KEY_INSERT: return sf::Keyboard::Key::Insert;
case KEY_DELETE: return sf::Keyboard::Delete; case KEY_DELETE: return sf::Keyboard::Key::Delete;
case KEY_PAUSE: return sf::Keyboard::Pause; case KEY_PAUSE: return sf::Keyboard::Key::Pause;
case KEY_LEFTMETA: return sf::Keyboard::LSystem; case KEY_LEFTMETA: return sf::Keyboard::Key::LSystem;
case KEY_RIGHTMETA: return sf::Keyboard::RSystem; case KEY_RIGHTMETA: return sf::Keyboard::Key::RSystem;
case KEY_RESERVED: case KEY_RESERVED:
case KEY_SYSRQ: case KEY_SYSRQ:
@ -301,7 +301,7 @@ sf::Keyboard::Key toKey(int code)
case KEY_NUMLOCK: case KEY_NUMLOCK:
case KEY_SCROLLLOCK: case KEY_SCROLLLOCK:
default: default:
return sf::Keyboard::Unknown; return sf::Keyboard::Key::Unknown;
// clang-format on // clang-format on
} }
} }
@ -401,8 +401,8 @@ bool eventProcess(sf::Event& event)
const sf::Keyboard::Key kb = toKey(inputEvent.code); const sf::Keyboard::Key kb = toKey(inputEvent.code);
unsigned int special = 0; unsigned int special = 0;
if ((kb == sf::Keyboard::Delete) || (kb == sf::Keyboard::Backspace)) if ((kb == sf::Keyboard::Key::Delete) || (kb == sf::Keyboard::Key::Backspace))
special = (kb == sf::Keyboard::Delete) ? 127 : 8; special = (kb == sf::Keyboard::Key::Delete) ? 127 : 8;
if (inputEvent.value == 2) if (inputEvent.value == 2)
{ {
@ -415,7 +415,7 @@ bool eventProcess(sf::Event& event)
return true; return true;
} }
} }
else if (kb != sf::Keyboard::Unknown) else if (kb != sf::Keyboard::Key::Unknown)
{ {
// key down and key up events // key down and key up events
// //
@ -574,7 +574,7 @@ namespace sf::priv::InputImpl
bool isKeyPressed(Keyboard::Key key) bool isKeyPressed(Keyboard::Key key)
{ {
const std::lock_guard lock(inputMutex); const std::lock_guard lock(inputMutex);
if ((key < 0) || (key >= static_cast<int>(keyMap.size()))) if ((static_cast<int>(key) < 0) || (static_cast<int>(key) >= static_cast<int>(keyMap.size())))
return false; return false;
update(); update();
@ -596,7 +596,7 @@ Keyboard::Key localize(Keyboard::Scancode /* code */)
{ {
// TODO: not implemented // TODO: not implemented
err() << "sf::Keyboard::localize is not implemented for DRM." << std::endl; err() << "sf::Keyboard::localize is not implemented for DRM." << std::endl;
return Keyboard::Unknown; return Keyboard::Key::Unknown;
} }

View File

@ -38,111 +38,111 @@ Keyboard::Key keySymToKey(KeySym symbol)
// clang-format off // clang-format off
switch (symbol) switch (symbol)
{ {
case XK_Shift_L: return Keyboard::LShift; case XK_Shift_L: return Keyboard::Key::LShift;
case XK_Shift_R: return Keyboard::RShift; case XK_Shift_R: return Keyboard::Key::RShift;
case XK_Control_L: return Keyboard::LControl; case XK_Control_L: return Keyboard::Key::LControl;
case XK_Control_R: return Keyboard::RControl; case XK_Control_R: return Keyboard::Key::RControl;
case XK_Alt_L: return Keyboard::LAlt; case XK_Alt_L: return Keyboard::Key::LAlt;
case XK_ISO_Level3_Shift: case XK_ISO_Level3_Shift:
case XK_Alt_R: return Keyboard::RAlt; case XK_Alt_R: return Keyboard::Key::RAlt;
case XK_Super_L: return Keyboard::LSystem; case XK_Super_L: return Keyboard::Key::LSystem;
case XK_Super_R: return Keyboard::RSystem; case XK_Super_R: return Keyboard::Key::RSystem;
case XK_Menu: return Keyboard::Menu; case XK_Menu: return Keyboard::Key::Menu;
case XK_Escape: return Keyboard::Escape; case XK_Escape: return Keyboard::Key::Escape;
case XK_semicolon: return Keyboard::Semicolon; case XK_semicolon: return Keyboard::Key::Semicolon;
case XK_slash: return Keyboard::Slash; case XK_slash: return Keyboard::Key::Slash;
case XK_equal: return Keyboard::Equal; case XK_equal: return Keyboard::Key::Equal;
case XK_minus: return Keyboard::Hyphen; case XK_minus: return Keyboard::Key::Hyphen;
case XK_bracketleft: return Keyboard::LBracket; case XK_bracketleft: return Keyboard::Key::LBracket;
case XK_bracketright: return Keyboard::RBracket; case XK_bracketright: return Keyboard::Key::RBracket;
case XK_comma: return Keyboard::Comma; case XK_comma: return Keyboard::Key::Comma;
case XK_period: return Keyboard::Period; case XK_period: return Keyboard::Key::Period;
case XK_apostrophe: return Keyboard::Apostrophe; case XK_apostrophe: return Keyboard::Key::Apostrophe;
case XK_backslash: return Keyboard::Backslash; case XK_backslash: return Keyboard::Key::Backslash;
case XK_grave: return Keyboard::Grave; case XK_grave: return Keyboard::Key::Grave;
case XK_space: return Keyboard::Space; case XK_space: return Keyboard::Key::Space;
case XK_Return: return Keyboard::Enter; case XK_Return: return Keyboard::Key::Enter;
case XK_KP_Enter: return Keyboard::Enter; case XK_KP_Enter: return Keyboard::Key::Enter;
case XK_BackSpace: return Keyboard::Backspace; case XK_BackSpace: return Keyboard::Key::Backspace;
case XK_Tab: return Keyboard::Tab; case XK_Tab: return Keyboard::Key::Tab;
case XK_Prior: return Keyboard::PageUp; case XK_Prior: return Keyboard::Key::PageUp;
case XK_Next: return Keyboard::PageDown; case XK_Next: return Keyboard::Key::PageDown;
case XK_End: return Keyboard::End; case XK_End: return Keyboard::Key::End;
case XK_Home: return Keyboard::Home; case XK_Home: return Keyboard::Key::Home;
case XK_Insert: return Keyboard::Insert; case XK_Insert: return Keyboard::Key::Insert;
case XK_Delete: return Keyboard::Delete; case XK_Delete: return Keyboard::Key::Delete;
case XK_KP_Add: return Keyboard::Add; case XK_KP_Add: return Keyboard::Key::Add;
case XK_KP_Subtract: return Keyboard::Subtract; case XK_KP_Subtract: return Keyboard::Key::Subtract;
case XK_KP_Multiply: return Keyboard::Multiply; case XK_KP_Multiply: return Keyboard::Key::Multiply;
case XK_KP_Divide: return Keyboard::Divide; case XK_KP_Divide: return Keyboard::Key::Divide;
case XK_KP_Delete: return Keyboard::Period; case XK_KP_Delete: return Keyboard::Key::Period;
case XK_Pause: return Keyboard::Pause; case XK_Pause: return Keyboard::Key::Pause;
case XK_F1: return Keyboard::F1; case XK_F1: return Keyboard::Key::F1;
case XK_F2: return Keyboard::F2; case XK_F2: return Keyboard::Key::F2;
case XK_F3: return Keyboard::F3; case XK_F3: return Keyboard::Key::F3;
case XK_F4: return Keyboard::F4; case XK_F4: return Keyboard::Key::F4;
case XK_F5: return Keyboard::F5; case XK_F5: return Keyboard::Key::F5;
case XK_F6: return Keyboard::F6; case XK_F6: return Keyboard::Key::F6;
case XK_F7: return Keyboard::F7; case XK_F7: return Keyboard::Key::F7;
case XK_F8: return Keyboard::F8; case XK_F8: return Keyboard::Key::F8;
case XK_F9: return Keyboard::F9; case XK_F9: return Keyboard::Key::F9;
case XK_F10: return Keyboard::F10; case XK_F10: return Keyboard::Key::F10;
case XK_F11: return Keyboard::F11; case XK_F11: return Keyboard::Key::F11;
case XK_F12: return Keyboard::F12; case XK_F12: return Keyboard::Key::F12;
case XK_F13: return Keyboard::F13; case XK_F13: return Keyboard::Key::F13;
case XK_F14: return Keyboard::F14; case XK_F14: return Keyboard::Key::F14;
case XK_F15: return Keyboard::F15; case XK_F15: return Keyboard::Key::F15;
case XK_Left: return Keyboard::Left; case XK_Left: return Keyboard::Key::Left;
case XK_Right: return Keyboard::Right; case XK_Right: return Keyboard::Key::Right;
case XK_Up: return Keyboard::Up; case XK_Up: return Keyboard::Key::Up;
case XK_Down: return Keyboard::Down; case XK_Down: return Keyboard::Key::Down;
case XK_KP_Insert: return Keyboard::Numpad0; case XK_KP_Insert: return Keyboard::Key::Numpad0;
case XK_KP_End: return Keyboard::Numpad1; case XK_KP_End: return Keyboard::Key::Numpad1;
case XK_KP_Down: return Keyboard::Numpad2; case XK_KP_Down: return Keyboard::Key::Numpad2;
case XK_KP_Page_Down: return Keyboard::Numpad3; case XK_KP_Page_Down: return Keyboard::Key::Numpad3;
case XK_KP_Left: return Keyboard::Numpad4; case XK_KP_Left: return Keyboard::Key::Numpad4;
case XK_KP_Begin: return Keyboard::Numpad5; case XK_KP_Begin: return Keyboard::Key::Numpad5;
case XK_KP_Right: return Keyboard::Numpad6; case XK_KP_Right: return Keyboard::Key::Numpad6;
case XK_KP_Home: return Keyboard::Numpad7; case XK_KP_Home: return Keyboard::Key::Numpad7;
case XK_KP_Up: return Keyboard::Numpad8; case XK_KP_Up: return Keyboard::Key::Numpad8;
case XK_KP_Page_Up: return Keyboard::Numpad9; case XK_KP_Page_Up: return Keyboard::Key::Numpad9;
case XK_a: return Keyboard::A; case XK_a: return Keyboard::Key::A;
case XK_b: return Keyboard::B; case XK_b: return Keyboard::Key::B;
case XK_c: return Keyboard::C; case XK_c: return Keyboard::Key::C;
case XK_d: return Keyboard::D; case XK_d: return Keyboard::Key::D;
case XK_e: return Keyboard::E; case XK_e: return Keyboard::Key::E;
case XK_f: return Keyboard::F; case XK_f: return Keyboard::Key::F;
case XK_g: return Keyboard::G; case XK_g: return Keyboard::Key::G;
case XK_h: return Keyboard::H; case XK_h: return Keyboard::Key::H;
case XK_i: return Keyboard::I; case XK_i: return Keyboard::Key::I;
case XK_j: return Keyboard::J; case XK_j: return Keyboard::Key::J;
case XK_k: return Keyboard::K; case XK_k: return Keyboard::Key::K;
case XK_l: return Keyboard::L; case XK_l: return Keyboard::Key::L;
case XK_m: return Keyboard::M; case XK_m: return Keyboard::Key::M;
case XK_n: return Keyboard::N; case XK_n: return Keyboard::Key::N;
case XK_o: return Keyboard::O; case XK_o: return Keyboard::Key::O;
case XK_p: return Keyboard::P; case XK_p: return Keyboard::Key::P;
case XK_q: return Keyboard::Q; case XK_q: return Keyboard::Key::Q;
case XK_r: return Keyboard::R; case XK_r: return Keyboard::Key::R;
case XK_s: return Keyboard::S; case XK_s: return Keyboard::Key::S;
case XK_t: return Keyboard::T; case XK_t: return Keyboard::Key::T;
case XK_u: return Keyboard::U; case XK_u: return Keyboard::Key::U;
case XK_v: return Keyboard::V; case XK_v: return Keyboard::Key::V;
case XK_w: return Keyboard::W; case XK_w: return Keyboard::Key::W;
case XK_x: return Keyboard::X; case XK_x: return Keyboard::Key::X;
case XK_y: return Keyboard::Y; case XK_y: return Keyboard::Key::Y;
case XK_z: return Keyboard::Z; case XK_z: return Keyboard::Key::Z;
case XK_0: return Keyboard::Num0; case XK_0: return Keyboard::Key::Num0;
case XK_1: return Keyboard::Num1; case XK_1: return Keyboard::Key::Num1;
case XK_2: return Keyboard::Num2; case XK_2: return Keyboard::Key::Num2;
case XK_3: return Keyboard::Num3; case XK_3: return Keyboard::Key::Num3;
case XK_4: return Keyboard::Num4; case XK_4: return Keyboard::Key::Num4;
case XK_5: return Keyboard::Num5; case XK_5: return Keyboard::Key::Num5;
case XK_6: return Keyboard::Num6; case XK_6: return Keyboard::Key::Num6;
case XK_7: return Keyboard::Num7; case XK_7: return Keyboard::Key::Num7;
case XK_8: return Keyboard::Num8; case XK_8: return Keyboard::Key::Num8;
case XK_9: return Keyboard::Num9; case XK_9: return Keyboard::Key::Num9;
default: return Keyboard::Unknown; default: return Keyboard::Key::Unknown;
} }
// clang-format on // clang-format on
} }
@ -154,108 +154,108 @@ KeySym keyToKeySym(Keyboard::Key key)
// clang-format off // clang-format off
switch (key) switch (key)
{ {
case Keyboard::LShift: return XK_Shift_L; case Keyboard::Key::LShift: return XK_Shift_L;
case Keyboard::RShift: return XK_Shift_R; case Keyboard::Key::RShift: return XK_Shift_R;
case Keyboard::LControl: return XK_Control_L; case Keyboard::Key::LControl: return XK_Control_L;
case Keyboard::RControl: return XK_Control_R; case Keyboard::Key::RControl: return XK_Control_R;
case Keyboard::LAlt: return XK_Alt_L; case Keyboard::Key::LAlt: return XK_Alt_L;
case Keyboard::RAlt: return XK_Alt_R; case Keyboard::Key::RAlt: return XK_Alt_R;
case Keyboard::LSystem: return XK_Super_L; case Keyboard::Key::LSystem: return XK_Super_L;
case Keyboard::RSystem: return XK_Super_R; case Keyboard::Key::RSystem: return XK_Super_R;
case Keyboard::Menu: return XK_Menu; case Keyboard::Key::Menu: return XK_Menu;
case Keyboard::Escape: return XK_Escape; case Keyboard::Key::Escape: return XK_Escape;
case Keyboard::Semicolon: return XK_semicolon; case Keyboard::Key::Semicolon: return XK_semicolon;
case Keyboard::Slash: return XK_slash; case Keyboard::Key::Slash: return XK_slash;
case Keyboard::Equal: return XK_equal; case Keyboard::Key::Equal: return XK_equal;
case Keyboard::Hyphen: return XK_minus; case Keyboard::Key::Hyphen: return XK_minus;
case Keyboard::LBracket: return XK_bracketleft; case Keyboard::Key::LBracket: return XK_bracketleft;
case Keyboard::RBracket: return XK_bracketright; case Keyboard::Key::RBracket: return XK_bracketright;
case Keyboard::Comma: return XK_comma; case Keyboard::Key::Comma: return XK_comma;
case Keyboard::Period: return XK_period; case Keyboard::Key::Period: return XK_period;
case Keyboard::Apostrophe: return XK_apostrophe; case Keyboard::Key::Apostrophe: return XK_apostrophe;
case Keyboard::Backslash: return XK_backslash; case Keyboard::Key::Backslash: return XK_backslash;
case Keyboard::Grave: return XK_grave; case Keyboard::Key::Grave: return XK_grave;
case Keyboard::Space: return XK_space; case Keyboard::Key::Space: return XK_space;
case Keyboard::Enter: return XK_Return; case Keyboard::Key::Enter: return XK_Return;
case Keyboard::Backspace: return XK_BackSpace; case Keyboard::Key::Backspace: return XK_BackSpace;
case Keyboard::Tab: return XK_Tab; case Keyboard::Key::Tab: return XK_Tab;
case Keyboard::PageUp: return XK_Prior; case Keyboard::Key::PageUp: return XK_Prior;
case Keyboard::PageDown: return XK_Next; case Keyboard::Key::PageDown: return XK_Next;
case Keyboard::End: return XK_End; case Keyboard::Key::End: return XK_End;
case Keyboard::Home: return XK_Home; case Keyboard::Key::Home: return XK_Home;
case Keyboard::Insert: return XK_Insert; case Keyboard::Key::Insert: return XK_Insert;
case Keyboard::Delete: return XK_Delete; case Keyboard::Key::Delete: return XK_Delete;
case Keyboard::Add: return XK_KP_Add; case Keyboard::Key::Add: return XK_KP_Add;
case Keyboard::Subtract: return XK_KP_Subtract; case Keyboard::Key::Subtract: return XK_KP_Subtract;
case Keyboard::Multiply: return XK_KP_Multiply; case Keyboard::Key::Multiply: return XK_KP_Multiply;
case Keyboard::Divide: return XK_KP_Divide; case Keyboard::Key::Divide: return XK_KP_Divide;
case Keyboard::Pause: return XK_Pause; case Keyboard::Key::Pause: return XK_Pause;
case Keyboard::F1: return XK_F1; case Keyboard::Key::F1: return XK_F1;
case Keyboard::F2: return XK_F2; case Keyboard::Key::F2: return XK_F2;
case Keyboard::F3: return XK_F3; case Keyboard::Key::F3: return XK_F3;
case Keyboard::F4: return XK_F4; case Keyboard::Key::F4: return XK_F4;
case Keyboard::F5: return XK_F5; case Keyboard::Key::F5: return XK_F5;
case Keyboard::F6: return XK_F6; case Keyboard::Key::F6: return XK_F6;
case Keyboard::F7: return XK_F7; case Keyboard::Key::F7: return XK_F7;
case Keyboard::F8: return XK_F8; case Keyboard::Key::F8: return XK_F8;
case Keyboard::F9: return XK_F9; case Keyboard::Key::F9: return XK_F9;
case Keyboard::F10: return XK_F10; case Keyboard::Key::F10: return XK_F10;
case Keyboard::F11: return XK_F11; case Keyboard::Key::F11: return XK_F11;
case Keyboard::F12: return XK_F12; case Keyboard::Key::F12: return XK_F12;
case Keyboard::F13: return XK_F13; case Keyboard::Key::F13: return XK_F13;
case Keyboard::F14: return XK_F14; case Keyboard::Key::F14: return XK_F14;
case Keyboard::F15: return XK_F15; case Keyboard::Key::F15: return XK_F15;
case Keyboard::Left: return XK_Left; case Keyboard::Key::Left: return XK_Left;
case Keyboard::Right: return XK_Right; case Keyboard::Key::Right: return XK_Right;
case Keyboard::Up: return XK_Up; case Keyboard::Key::Up: return XK_Up;
case Keyboard::Down: return XK_Down; case Keyboard::Key::Down: return XK_Down;
case Keyboard::Numpad0: return XK_KP_Insert; case Keyboard::Key::Numpad0: return XK_KP_Insert;
case Keyboard::Numpad1: return XK_KP_End; case Keyboard::Key::Numpad1: return XK_KP_End;
case Keyboard::Numpad2: return XK_KP_Down; case Keyboard::Key::Numpad2: return XK_KP_Down;
case Keyboard::Numpad3: return XK_KP_Page_Down; case Keyboard::Key::Numpad3: return XK_KP_Page_Down;
case Keyboard::Numpad4: return XK_KP_Left; case Keyboard::Key::Numpad4: return XK_KP_Left;
case Keyboard::Numpad5: return XK_KP_Begin; case Keyboard::Key::Numpad5: return XK_KP_Begin;
case Keyboard::Numpad6: return XK_KP_Right; case Keyboard::Key::Numpad6: return XK_KP_Right;
case Keyboard::Numpad7: return XK_KP_Home; case Keyboard::Key::Numpad7: return XK_KP_Home;
case Keyboard::Numpad8: return XK_KP_Up; case Keyboard::Key::Numpad8: return XK_KP_Up;
case Keyboard::Numpad9: return XK_KP_Page_Up; case Keyboard::Key::Numpad9: return XK_KP_Page_Up;
case Keyboard::A: return XK_a; case Keyboard::Key::A: return XK_a;
case Keyboard::B: return XK_b; case Keyboard::Key::B: return XK_b;
case Keyboard::C: return XK_c; case Keyboard::Key::C: return XK_c;
case Keyboard::D: return XK_d; case Keyboard::Key::D: return XK_d;
case Keyboard::E: return XK_e; case Keyboard::Key::E: return XK_e;
case Keyboard::F: return XK_f; case Keyboard::Key::F: return XK_f;
case Keyboard::G: return XK_g; case Keyboard::Key::G: return XK_g;
case Keyboard::H: return XK_h; case Keyboard::Key::H: return XK_h;
case Keyboard::I: return XK_i; case Keyboard::Key::I: return XK_i;
case Keyboard::J: return XK_j; case Keyboard::Key::J: return XK_j;
case Keyboard::K: return XK_k; case Keyboard::Key::K: return XK_k;
case Keyboard::L: return XK_l; case Keyboard::Key::L: return XK_l;
case Keyboard::M: return XK_m; case Keyboard::Key::M: return XK_m;
case Keyboard::N: return XK_n; case Keyboard::Key::N: return XK_n;
case Keyboard::O: return XK_o; case Keyboard::Key::O: return XK_o;
case Keyboard::P: return XK_p; case Keyboard::Key::P: return XK_p;
case Keyboard::Q: return XK_q; case Keyboard::Key::Q: return XK_q;
case Keyboard::R: return XK_r; case Keyboard::Key::R: return XK_r;
case Keyboard::S: return XK_s; case Keyboard::Key::S: return XK_s;
case Keyboard::T: return XK_t; case Keyboard::Key::T: return XK_t;
case Keyboard::U: return XK_u; case Keyboard::Key::U: return XK_u;
case Keyboard::V: return XK_v; case Keyboard::Key::V: return XK_v;
case Keyboard::W: return XK_w; case Keyboard::Key::W: return XK_w;
case Keyboard::X: return XK_x; case Keyboard::Key::X: return XK_x;
case Keyboard::Y: return XK_y; case Keyboard::Key::Y: return XK_y;
case Keyboard::Z: return XK_z; case Keyboard::Key::Z: return XK_z;
case Keyboard::Num0: return XK_0; case Keyboard::Key::Num0: return XK_0;
case Keyboard::Num1: return XK_1; case Keyboard::Key::Num1: return XK_1;
case Keyboard::Num2: return XK_2; case Keyboard::Key::Num2: return XK_2;
case Keyboard::Num3: return XK_3; case Keyboard::Key::Num3: return XK_3;
case Keyboard::Num4: return XK_4; case Keyboard::Key::Num4: return XK_4;
case Keyboard::Num5: return XK_5; case Keyboard::Key::Num5: return XK_5;
case Keyboard::Num6: return XK_6; case Keyboard::Key::Num6: return XK_6;
case Keyboard::Num7: return XK_7; case Keyboard::Key::Num7: return XK_7;
case Keyboard::Num8: return XK_8; case Keyboard::Key::Num8: return XK_8;
case Keyboard::Num9: return XK_9; case Keyboard::Key::Num9: return XK_9;
default: return NoSymbol; default: return NoSymbol;
} }
// clang-format on // clang-format on
} }

View File

@ -560,7 +560,7 @@ KeyCode keyToKeyCode(sf::Keyboard::Key key)
} }
// Fallback for when XKeysymToKeycode cannot tell the KeyCode for XK_Alt_R // Fallback for when XKeysymToKeycode cannot tell the KeyCode for XK_Alt_R
if (key == sf::Keyboard::RAlt) if (key == sf::Keyboard::Key::RAlt)
return scancodeToKeycode[sf::Keyboard::Scan::RAlt]; return scancodeToKeycode[sf::Keyboard::Scan::RAlt];
return nullKeyCode; return nullKeyCode;
@ -805,11 +805,11 @@ Keyboard::Key KeyboardImpl::getKeyFromEvent(XKeyEvent& event)
// Get the SFML keyboard code from the keysym of the key that has been pressed // Get the SFML keyboard code from the keysym of the key that has been pressed
const KeySym keysym = XLookupKeysym(&event, i); const KeySym keysym = XLookupKeysym(&event, i);
const Keyboard::Key key = keySymToKey(keysym); const Keyboard::Key key = keySymToKey(keysym);
if (key != Keyboard::Unknown) if (key != Keyboard::Key::Unknown)
return key; return key;
} }
return Keyboard::Unknown; return Keyboard::Key::Unknown;
} }

View File

@ -42,108 +42,108 @@ sf::Keyboard::Key virtualKeyToSfKey(UINT virtualKey)
// clang-format off // clang-format off
switch (virtualKey) switch (virtualKey)
{ {
case 'A': return sf::Keyboard::A; case 'A': return sf::Keyboard::Key::A;
case 'B': return sf::Keyboard::B; case 'B': return sf::Keyboard::Key::B;
case 'C': return sf::Keyboard::C; case 'C': return sf::Keyboard::Key::C;
case 'D': return sf::Keyboard::D; case 'D': return sf::Keyboard::Key::D;
case 'E': return sf::Keyboard::E; case 'E': return sf::Keyboard::Key::E;
case 'F': return sf::Keyboard::F; case 'F': return sf::Keyboard::Key::F;
case 'G': return sf::Keyboard::G; case 'G': return sf::Keyboard::Key::G;
case 'H': return sf::Keyboard::H; case 'H': return sf::Keyboard::Key::H;
case 'I': return sf::Keyboard::I; case 'I': return sf::Keyboard::Key::I;
case 'J': return sf::Keyboard::J; case 'J': return sf::Keyboard::Key::J;
case 'K': return sf::Keyboard::K; case 'K': return sf::Keyboard::Key::K;
case 'L': return sf::Keyboard::L; case 'L': return sf::Keyboard::Key::L;
case 'M': return sf::Keyboard::M; case 'M': return sf::Keyboard::Key::M;
case 'N': return sf::Keyboard::N; case 'N': return sf::Keyboard::Key::N;
case 'O': return sf::Keyboard::O; case 'O': return sf::Keyboard::Key::O;
case 'P': return sf::Keyboard::P; case 'P': return sf::Keyboard::Key::P;
case 'Q': return sf::Keyboard::Q; case 'Q': return sf::Keyboard::Key::Q;
case 'R': return sf::Keyboard::R; case 'R': return sf::Keyboard::Key::R;
case 'S': return sf::Keyboard::S; case 'S': return sf::Keyboard::Key::S;
case 'T': return sf::Keyboard::T; case 'T': return sf::Keyboard::Key::T;
case 'U': return sf::Keyboard::U; case 'U': return sf::Keyboard::Key::U;
case 'V': return sf::Keyboard::V; case 'V': return sf::Keyboard::Key::V;
case 'W': return sf::Keyboard::W; case 'W': return sf::Keyboard::Key::W;
case 'X': return sf::Keyboard::X; case 'X': return sf::Keyboard::Key::X;
case 'Y': return sf::Keyboard::Y; case 'Y': return sf::Keyboard::Key::Y;
case 'Z': return sf::Keyboard::Z; case 'Z': return sf::Keyboard::Key::Z;
case '0': return sf::Keyboard::Num0; case '0': return sf::Keyboard::Key::Num0;
case '1': return sf::Keyboard::Num1; case '1': return sf::Keyboard::Key::Num1;
case '2': return sf::Keyboard::Num2; case '2': return sf::Keyboard::Key::Num2;
case '3': return sf::Keyboard::Num3; case '3': return sf::Keyboard::Key::Num3;
case '4': return sf::Keyboard::Num4; case '4': return sf::Keyboard::Key::Num4;
case '5': return sf::Keyboard::Num5; case '5': return sf::Keyboard::Key::Num5;
case '6': return sf::Keyboard::Num6; case '6': return sf::Keyboard::Key::Num6;
case '7': return sf::Keyboard::Num7; case '7': return sf::Keyboard::Key::Num7;
case '8': return sf::Keyboard::Num8; case '8': return sf::Keyboard::Key::Num8;
case '9': return sf::Keyboard::Num9; case '9': return sf::Keyboard::Key::Num9;
case VK_ESCAPE: return sf::Keyboard::Escape; case VK_ESCAPE: return sf::Keyboard::Key::Escape;
case VK_LCONTROL: return sf::Keyboard::LControl; case VK_LCONTROL: return sf::Keyboard::Key::LControl;
case VK_LSHIFT: return sf::Keyboard::LShift; case VK_LSHIFT: return sf::Keyboard::Key::LShift;
case VK_LMENU: return sf::Keyboard::LAlt; case VK_LMENU: return sf::Keyboard::Key::LAlt;
case VK_LWIN: return sf::Keyboard::LSystem; case VK_LWIN: return sf::Keyboard::Key::LSystem;
case VK_RCONTROL: return sf::Keyboard::RControl; case VK_RCONTROL: return sf::Keyboard::Key::RControl;
case VK_RSHIFT: return sf::Keyboard::RShift; case VK_RSHIFT: return sf::Keyboard::Key::RShift;
case VK_RMENU: return sf::Keyboard::RAlt; case VK_RMENU: return sf::Keyboard::Key::RAlt;
case VK_RWIN: return sf::Keyboard::RSystem; case VK_RWIN: return sf::Keyboard::Key::RSystem;
case VK_APPS: return sf::Keyboard::Menu; case VK_APPS: return sf::Keyboard::Key::Menu;
case VK_OEM_4: return sf::Keyboard::LBracket; case VK_OEM_4: return sf::Keyboard::Key::LBracket;
case VK_OEM_6: return sf::Keyboard::RBracket; case VK_OEM_6: return sf::Keyboard::Key::RBracket;
case VK_OEM_1: return sf::Keyboard::Semicolon; case VK_OEM_1: return sf::Keyboard::Key::Semicolon;
case VK_OEM_COMMA: return sf::Keyboard::Comma; case VK_OEM_COMMA: return sf::Keyboard::Key::Comma;
case VK_OEM_PERIOD: return sf::Keyboard::Period; case VK_OEM_PERIOD: return sf::Keyboard::Key::Period;
case VK_OEM_7: return sf::Keyboard::Apostrophe; case VK_OEM_7: return sf::Keyboard::Key::Apostrophe;
case VK_OEM_2: return sf::Keyboard::Slash; case VK_OEM_2: return sf::Keyboard::Key::Slash;
case VK_OEM_5: return sf::Keyboard::Backslash; case VK_OEM_5: return sf::Keyboard::Key::Backslash;
case VK_OEM_3: return sf::Keyboard::Grave; case VK_OEM_3: return sf::Keyboard::Key::Grave;
case VK_OEM_PLUS: return sf::Keyboard::Equal; case VK_OEM_PLUS: return sf::Keyboard::Key::Equal;
case VK_OEM_MINUS: return sf::Keyboard::Hyphen; case VK_OEM_MINUS: return sf::Keyboard::Key::Hyphen;
case VK_SPACE: return sf::Keyboard::Space; case VK_SPACE: return sf::Keyboard::Key::Space;
case VK_RETURN: return sf::Keyboard::Enter; case VK_RETURN: return sf::Keyboard::Key::Enter;
case VK_BACK: return sf::Keyboard::Backspace; case VK_BACK: return sf::Keyboard::Key::Backspace;
case VK_TAB: return sf::Keyboard::Tab; case VK_TAB: return sf::Keyboard::Key::Tab;
case VK_PRIOR: return sf::Keyboard::PageUp; case VK_PRIOR: return sf::Keyboard::Key::PageUp;
case VK_NEXT: return sf::Keyboard::PageDown; case VK_NEXT: return sf::Keyboard::Key::PageDown;
case VK_END: return sf::Keyboard::End; case VK_END: return sf::Keyboard::Key::End;
case VK_HOME: return sf::Keyboard::Home; case VK_HOME: return sf::Keyboard::Key::Home;
case VK_INSERT: return sf::Keyboard::Insert; case VK_INSERT: return sf::Keyboard::Key::Insert;
case VK_DELETE: return sf::Keyboard::Delete; case VK_DELETE: return sf::Keyboard::Key::Delete;
case VK_ADD: return sf::Keyboard::Add; case VK_ADD: return sf::Keyboard::Key::Add;
case VK_SUBTRACT: return sf::Keyboard::Subtract; case VK_SUBTRACT: return sf::Keyboard::Key::Subtract;
case VK_MULTIPLY: return sf::Keyboard::Multiply; case VK_MULTIPLY: return sf::Keyboard::Key::Multiply;
case VK_DIVIDE: return sf::Keyboard::Divide; case VK_DIVIDE: return sf::Keyboard::Key::Divide;
case VK_LEFT: return sf::Keyboard::Left; case VK_LEFT: return sf::Keyboard::Key::Left;
case VK_RIGHT: return sf::Keyboard::Right; case VK_RIGHT: return sf::Keyboard::Key::Right;
case VK_UP: return sf::Keyboard::Up; case VK_UP: return sf::Keyboard::Key::Up;
case VK_DOWN: return sf::Keyboard::Down; case VK_DOWN: return sf::Keyboard::Key::Down;
case VK_NUMPAD0: return sf::Keyboard::Numpad0; case VK_NUMPAD0: return sf::Keyboard::Key::Numpad0;
case VK_NUMPAD1: return sf::Keyboard::Numpad1; case VK_NUMPAD1: return sf::Keyboard::Key::Numpad1;
case VK_NUMPAD2: return sf::Keyboard::Numpad2; case VK_NUMPAD2: return sf::Keyboard::Key::Numpad2;
case VK_NUMPAD3: return sf::Keyboard::Numpad3; case VK_NUMPAD3: return sf::Keyboard::Key::Numpad3;
case VK_NUMPAD4: return sf::Keyboard::Numpad4; case VK_NUMPAD4: return sf::Keyboard::Key::Numpad4;
case VK_NUMPAD5: return sf::Keyboard::Numpad5; case VK_NUMPAD5: return sf::Keyboard::Key::Numpad5;
case VK_NUMPAD6: return sf::Keyboard::Numpad6; case VK_NUMPAD6: return sf::Keyboard::Key::Numpad6;
case VK_NUMPAD7: return sf::Keyboard::Numpad7; case VK_NUMPAD7: return sf::Keyboard::Key::Numpad7;
case VK_NUMPAD8: return sf::Keyboard::Numpad8; case VK_NUMPAD8: return sf::Keyboard::Key::Numpad8;
case VK_NUMPAD9: return sf::Keyboard::Numpad9; case VK_NUMPAD9: return sf::Keyboard::Key::Numpad9;
case VK_F1: return sf::Keyboard::F1; case VK_F1: return sf::Keyboard::Key::F1;
case VK_F2: return sf::Keyboard::F2; case VK_F2: return sf::Keyboard::Key::F2;
case VK_F3: return sf::Keyboard::F3; case VK_F3: return sf::Keyboard::Key::F3;
case VK_F4: return sf::Keyboard::F4; case VK_F4: return sf::Keyboard::Key::F4;
case VK_F5: return sf::Keyboard::F5; case VK_F5: return sf::Keyboard::Key::F5;
case VK_F6: return sf::Keyboard::F6; case VK_F6: return sf::Keyboard::Key::F6;
case VK_F7: return sf::Keyboard::F7; case VK_F7: return sf::Keyboard::Key::F7;
case VK_F8: return sf::Keyboard::F8; case VK_F8: return sf::Keyboard::Key::F8;
case VK_F9: return sf::Keyboard::F9; case VK_F9: return sf::Keyboard::Key::F9;
case VK_F10: return sf::Keyboard::F10; case VK_F10: return sf::Keyboard::Key::F10;
case VK_F11: return sf::Keyboard::F11; case VK_F11: return sf::Keyboard::Key::F11;
case VK_F12: return sf::Keyboard::F12; case VK_F12: return sf::Keyboard::Key::F12;
case VK_F13: return sf::Keyboard::F13; case VK_F13: return sf::Keyboard::Key::F13;
case VK_F14: return sf::Keyboard::F14; case VK_F14: return sf::Keyboard::Key::F14;
case VK_F15: return sf::Keyboard::F15; case VK_F15: return sf::Keyboard::Key::F15;
case VK_PAUSE: return sf::Keyboard::Pause; case VK_PAUSE: return sf::Keyboard::Key::Pause;
default: return sf::Keyboard::Unknown; default: return sf::Keyboard::Key::Unknown;
} }
// clang-format on // clang-format on
} }
@ -153,108 +153,108 @@ int sfKeyToVirtualKey(sf::Keyboard::Key key)
// clang-format off // clang-format off
switch (key) switch (key)
{ {
case sf::Keyboard::A: return 'A'; case sf::Keyboard::Key::A: return 'A';
case sf::Keyboard::B: return 'B'; case sf::Keyboard::Key::B: return 'B';
case sf::Keyboard::C: return 'C'; case sf::Keyboard::Key::C: return 'C';
case sf::Keyboard::D: return 'D'; case sf::Keyboard::Key::D: return 'D';
case sf::Keyboard::E: return 'E'; case sf::Keyboard::Key::E: return 'E';
case sf::Keyboard::F: return 'F'; case sf::Keyboard::Key::F: return 'F';
case sf::Keyboard::G: return 'G'; case sf::Keyboard::Key::G: return 'G';
case sf::Keyboard::H: return 'H'; case sf::Keyboard::Key::H: return 'H';
case sf::Keyboard::I: return 'I'; case sf::Keyboard::Key::I: return 'I';
case sf::Keyboard::J: return 'J'; case sf::Keyboard::Key::J: return 'J';
case sf::Keyboard::K: return 'K'; case sf::Keyboard::Key::K: return 'K';
case sf::Keyboard::L: return 'L'; case sf::Keyboard::Key::L: return 'L';
case sf::Keyboard::M: return 'M'; case sf::Keyboard::Key::M: return 'M';
case sf::Keyboard::N: return 'N'; case sf::Keyboard::Key::N: return 'N';
case sf::Keyboard::O: return 'O'; case sf::Keyboard::Key::O: return 'O';
case sf::Keyboard::P: return 'P'; case sf::Keyboard::Key::P: return 'P';
case sf::Keyboard::Q: return 'Q'; case sf::Keyboard::Key::Q: return 'Q';
case sf::Keyboard::R: return 'R'; case sf::Keyboard::Key::R: return 'R';
case sf::Keyboard::S: return 'S'; case sf::Keyboard::Key::S: return 'S';
case sf::Keyboard::T: return 'T'; case sf::Keyboard::Key::T: return 'T';
case sf::Keyboard::U: return 'U'; case sf::Keyboard::Key::U: return 'U';
case sf::Keyboard::V: return 'V'; case sf::Keyboard::Key::V: return 'V';
case sf::Keyboard::W: return 'W'; case sf::Keyboard::Key::W: return 'W';
case sf::Keyboard::X: return 'X'; case sf::Keyboard::Key::X: return 'X';
case sf::Keyboard::Y: return 'Y'; case sf::Keyboard::Key::Y: return 'Y';
case sf::Keyboard::Z: return 'Z'; case sf::Keyboard::Key::Z: return 'Z';
case sf::Keyboard::Num0: return '0'; case sf::Keyboard::Key::Num0: return '0';
case sf::Keyboard::Num1: return '1'; case sf::Keyboard::Key::Num1: return '1';
case sf::Keyboard::Num2: return '2'; case sf::Keyboard::Key::Num2: return '2';
case sf::Keyboard::Num3: return '3'; case sf::Keyboard::Key::Num3: return '3';
case sf::Keyboard::Num4: return '4'; case sf::Keyboard::Key::Num4: return '4';
case sf::Keyboard::Num5: return '5'; case sf::Keyboard::Key::Num5: return '5';
case sf::Keyboard::Num6: return '6'; case sf::Keyboard::Key::Num6: return '6';
case sf::Keyboard::Num7: return '7'; case sf::Keyboard::Key::Num7: return '7';
case sf::Keyboard::Num8: return '8'; case sf::Keyboard::Key::Num8: return '8';
case sf::Keyboard::Num9: return '9'; case sf::Keyboard::Key::Num9: return '9';
case sf::Keyboard::Escape: return VK_ESCAPE; case sf::Keyboard::Key::Escape: return VK_ESCAPE;
case sf::Keyboard::LControl: return VK_LCONTROL; case sf::Keyboard::Key::LControl: return VK_LCONTROL;
case sf::Keyboard::LShift: return VK_LSHIFT; case sf::Keyboard::Key::LShift: return VK_LSHIFT;
case sf::Keyboard::LAlt: return VK_LMENU; case sf::Keyboard::Key::LAlt: return VK_LMENU;
case sf::Keyboard::LSystem: return VK_LWIN; case sf::Keyboard::Key::LSystem: return VK_LWIN;
case sf::Keyboard::RControl: return VK_RCONTROL; case sf::Keyboard::Key::RControl: return VK_RCONTROL;
case sf::Keyboard::RShift: return VK_RSHIFT; case sf::Keyboard::Key::RShift: return VK_RSHIFT;
case sf::Keyboard::RAlt: return VK_RMENU; case sf::Keyboard::Key::RAlt: return VK_RMENU;
case sf::Keyboard::RSystem: return VK_RWIN; case sf::Keyboard::Key::RSystem: return VK_RWIN;
case sf::Keyboard::Menu: return VK_APPS; case sf::Keyboard::Key::Menu: return VK_APPS;
case sf::Keyboard::LBracket: return VK_OEM_4; case sf::Keyboard::Key::LBracket: return VK_OEM_4;
case sf::Keyboard::RBracket: return VK_OEM_6; case sf::Keyboard::Key::RBracket: return VK_OEM_6;
case sf::Keyboard::Semicolon: return VK_OEM_1; case sf::Keyboard::Key::Semicolon: return VK_OEM_1;
case sf::Keyboard::Comma: return VK_OEM_COMMA; case sf::Keyboard::Key::Comma: return VK_OEM_COMMA;
case sf::Keyboard::Period: return VK_OEM_PERIOD; case sf::Keyboard::Key::Period: return VK_OEM_PERIOD;
case sf::Keyboard::Apostrophe: return VK_OEM_7; case sf::Keyboard::Key::Apostrophe: return VK_OEM_7;
case sf::Keyboard::Slash: return VK_OEM_2; case sf::Keyboard::Key::Slash: return VK_OEM_2;
case sf::Keyboard::Backslash: return VK_OEM_5; case sf::Keyboard::Key::Backslash: return VK_OEM_5;
case sf::Keyboard::Grave: return VK_OEM_3; case sf::Keyboard::Key::Grave: return VK_OEM_3;
case sf::Keyboard::Equal: return VK_OEM_PLUS; case sf::Keyboard::Key::Equal: return VK_OEM_PLUS;
case sf::Keyboard::Hyphen: return VK_OEM_MINUS; case sf::Keyboard::Key::Hyphen: return VK_OEM_MINUS;
case sf::Keyboard::Space: return VK_SPACE; case sf::Keyboard::Key::Space: return VK_SPACE;
case sf::Keyboard::Enter: return VK_RETURN; case sf::Keyboard::Key::Enter: return VK_RETURN;
case sf::Keyboard::Backspace: return VK_BACK; case sf::Keyboard::Key::Backspace: return VK_BACK;
case sf::Keyboard::Tab: return VK_TAB; case sf::Keyboard::Key::Tab: return VK_TAB;
case sf::Keyboard::PageUp: return VK_PRIOR; case sf::Keyboard::Key::PageUp: return VK_PRIOR;
case sf::Keyboard::PageDown: return VK_NEXT; case sf::Keyboard::Key::PageDown: return VK_NEXT;
case sf::Keyboard::End: return VK_END; case sf::Keyboard::Key::End: return VK_END;
case sf::Keyboard::Home: return VK_HOME; case sf::Keyboard::Key::Home: return VK_HOME;
case sf::Keyboard::Insert: return VK_INSERT; case sf::Keyboard::Key::Insert: return VK_INSERT;
case sf::Keyboard::Delete: return VK_DELETE; case sf::Keyboard::Key::Delete: return VK_DELETE;
case sf::Keyboard::Add: return VK_ADD; case sf::Keyboard::Key::Add: return VK_ADD;
case sf::Keyboard::Subtract: return VK_SUBTRACT; case sf::Keyboard::Key::Subtract: return VK_SUBTRACT;
case sf::Keyboard::Multiply: return VK_MULTIPLY; case sf::Keyboard::Key::Multiply: return VK_MULTIPLY;
case sf::Keyboard::Divide: return VK_DIVIDE; case sf::Keyboard::Key::Divide: return VK_DIVIDE;
case sf::Keyboard::Left: return VK_LEFT; case sf::Keyboard::Key::Left: return VK_LEFT;
case sf::Keyboard::Right: return VK_RIGHT; case sf::Keyboard::Key::Right: return VK_RIGHT;
case sf::Keyboard::Up: return VK_UP; case sf::Keyboard::Key::Up: return VK_UP;
case sf::Keyboard::Down: return VK_DOWN; case sf::Keyboard::Key::Down: return VK_DOWN;
case sf::Keyboard::Numpad0: return VK_NUMPAD0; case sf::Keyboard::Key::Numpad0: return VK_NUMPAD0;
case sf::Keyboard::Numpad1: return VK_NUMPAD1; case sf::Keyboard::Key::Numpad1: return VK_NUMPAD1;
case sf::Keyboard::Numpad2: return VK_NUMPAD2; case sf::Keyboard::Key::Numpad2: return VK_NUMPAD2;
case sf::Keyboard::Numpad3: return VK_NUMPAD3; case sf::Keyboard::Key::Numpad3: return VK_NUMPAD3;
case sf::Keyboard::Numpad4: return VK_NUMPAD4; case sf::Keyboard::Key::Numpad4: return VK_NUMPAD4;
case sf::Keyboard::Numpad5: return VK_NUMPAD5; case sf::Keyboard::Key::Numpad5: return VK_NUMPAD5;
case sf::Keyboard::Numpad6: return VK_NUMPAD6; case sf::Keyboard::Key::Numpad6: return VK_NUMPAD6;
case sf::Keyboard::Numpad7: return VK_NUMPAD7; case sf::Keyboard::Key::Numpad7: return VK_NUMPAD7;
case sf::Keyboard::Numpad8: return VK_NUMPAD8; case sf::Keyboard::Key::Numpad8: return VK_NUMPAD8;
case sf::Keyboard::Numpad9: return VK_NUMPAD9; case sf::Keyboard::Key::Numpad9: return VK_NUMPAD9;
case sf::Keyboard::F1: return VK_F1; case sf::Keyboard::Key::F1: return VK_F1;
case sf::Keyboard::F2: return VK_F2; case sf::Keyboard::Key::F2: return VK_F2;
case sf::Keyboard::F3: return VK_F3; case sf::Keyboard::Key::F3: return VK_F3;
case sf::Keyboard::F4: return VK_F4; case sf::Keyboard::Key::F4: return VK_F4;
case sf::Keyboard::F5: return VK_F5; case sf::Keyboard::Key::F5: return VK_F5;
case sf::Keyboard::F6: return VK_F6; case sf::Keyboard::Key::F6: return VK_F6;
case sf::Keyboard::F7: return VK_F7; case sf::Keyboard::Key::F7: return VK_F7;
case sf::Keyboard::F8: return VK_F8; case sf::Keyboard::Key::F8: return VK_F8;
case sf::Keyboard::F9: return VK_F9; case sf::Keyboard::Key::F9: return VK_F9;
case sf::Keyboard::F10: return VK_F10; case sf::Keyboard::Key::F10: return VK_F10;
case sf::Keyboard::F11: return VK_F11; case sf::Keyboard::Key::F11: return VK_F11;
case sf::Keyboard::F12: return VK_F12; case sf::Keyboard::Key::F12: return VK_F12;
case sf::Keyboard::F13: return VK_F13; case sf::Keyboard::Key::F13: return VK_F13;
case sf::Keyboard::F14: return VK_F14; case sf::Keyboard::Key::F14: return VK_F14;
case sf::Keyboard::F15: return VK_F15; case sf::Keyboard::Key::F15: return VK_F15;
case sf::Keyboard::Pause: return VK_PAUSE; case sf::Keyboard::Key::Pause: return VK_PAUSE;
default: return 0; default: return 0;
} }
// clang-format on // clang-format on
} }
@ -530,7 +530,7 @@ void ensureMappings()
const auto scan = static_cast<sf::Keyboard::Scancode>(i); const auto scan = static_cast<sf::Keyboard::Scancode>(i);
const UINT virtualKey = sfScanToVirtualKey(scan); const UINT virtualKey = sfScanToVirtualKey(scan);
const sf::Keyboard::Key key = virtualKeyToSfKey(virtualKey); const sf::Keyboard::Key key = virtualKeyToSfKey(virtualKey);
if (key != sf::Keyboard::Unknown && keyToScancodeMapping[key] == sf::Keyboard::Scan::Unknown) if (key != sf::Keyboard::Key::Unknown && keyToScancodeMapping[key] == sf::Keyboard::Scan::Unknown)
keyToScancodeMapping[key] = scan; keyToScancodeMapping[key] = scan;
scancodeToKeyMapping[scan] = key; scancodeToKeyMapping[scan] = key;
} }
@ -545,7 +545,7 @@ bool isValidScancode(sf::Keyboard::Scancode code)
bool isValidKey(sf::Keyboard::Key key) bool isValidKey(sf::Keyboard::Key key)
{ {
return key > sf::Keyboard::Unknown && static_cast<unsigned int>(key) < sf::Keyboard::KeyCount; return key > sf::Keyboard::Key::Unknown && static_cast<unsigned int>(key) < sf::Keyboard::KeyCount;
} }
} // namespace } // namespace
@ -572,7 +572,7 @@ bool isKeyPressed(Keyboard::Scancode code)
Keyboard::Key localize(Keyboard::Scancode code) Keyboard::Key localize(Keyboard::Scancode code)
{ {
if (!isValidScancode(code)) if (!isValidScancode(code))
return Keyboard::Unknown; return Keyboard::Key::Unknown;
ensureMappings(); ensureMappings();

View File

@ -1189,115 +1189,115 @@ Keyboard::Key WindowImplWin32::virtualKeyCodeToSF(WPARAM key, LPARAM flags)
{ {
static const UINT lShift = MapVirtualKeyW(VK_LSHIFT, MAPVK_VK_TO_VSC); static const UINT lShift = MapVirtualKeyW(VK_LSHIFT, MAPVK_VK_TO_VSC);
const UINT scancode = static_cast<UINT>((flags & (0xFF << 16)) >> 16); const UINT scancode = static_cast<UINT>((flags & (0xFF << 16)) >> 16);
return scancode == lShift ? Keyboard::LShift : Keyboard::RShift; return scancode == lShift ? Keyboard::Key::LShift : Keyboard::Key::RShift;
} }
// Check the "extended" flag to distinguish between left and right alt // Check the "extended" flag to distinguish between left and right alt
case VK_MENU : return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::RAlt : Keyboard::LAlt; case VK_MENU : return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::Key::RAlt : Keyboard::Key::LAlt;
// Check the "extended" flag to distinguish between left and right control // Check the "extended" flag to distinguish between left and right control
case VK_CONTROL : return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::RControl : Keyboard::LControl; case VK_CONTROL : return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::Key::RControl : Keyboard::Key::LControl;
// Other keys are reported properly // Other keys are reported properly
case VK_LWIN: return Keyboard::LSystem; case VK_LWIN: return Keyboard::Key::LSystem;
case VK_RWIN: return Keyboard::RSystem; case VK_RWIN: return Keyboard::Key::RSystem;
case VK_APPS: return Keyboard::Menu; case VK_APPS: return Keyboard::Key::Menu;
case VK_OEM_1: return Keyboard::Semicolon; case VK_OEM_1: return Keyboard::Key::Semicolon;
case VK_OEM_2: return Keyboard::Slash; case VK_OEM_2: return Keyboard::Key::Slash;
case VK_OEM_PLUS: return Keyboard::Equal; case VK_OEM_PLUS: return Keyboard::Key::Equal;
case VK_OEM_MINUS: return Keyboard::Hyphen; case VK_OEM_MINUS: return Keyboard::Key::Hyphen;
case VK_OEM_4: return Keyboard::LBracket; case VK_OEM_4: return Keyboard::Key::LBracket;
case VK_OEM_6: return Keyboard::RBracket; case VK_OEM_6: return Keyboard::Key::RBracket;
case VK_OEM_COMMA: return Keyboard::Comma; case VK_OEM_COMMA: return Keyboard::Key::Comma;
case VK_OEM_PERIOD: return Keyboard::Period; case VK_OEM_PERIOD: return Keyboard::Key::Period;
case VK_OEM_7: return Keyboard::Apostrophe; case VK_OEM_7: return Keyboard::Key::Apostrophe;
case VK_OEM_5: return Keyboard::Backslash; case VK_OEM_5: return Keyboard::Key::Backslash;
case VK_OEM_3: return Keyboard::Grave; case VK_OEM_3: return Keyboard::Key::Grave;
case VK_ESCAPE: return Keyboard::Escape; case VK_ESCAPE: return Keyboard::Key::Escape;
case VK_SPACE: return Keyboard::Space; case VK_SPACE: return Keyboard::Key::Space;
case VK_RETURN: return Keyboard::Enter; case VK_RETURN: return Keyboard::Key::Enter;
case VK_BACK: return Keyboard::Backspace; case VK_BACK: return Keyboard::Key::Backspace;
case VK_TAB: return Keyboard::Tab; case VK_TAB: return Keyboard::Key::Tab;
case VK_PRIOR: return Keyboard::PageUp; case VK_PRIOR: return Keyboard::Key::PageUp;
case VK_NEXT: return Keyboard::PageDown; case VK_NEXT: return Keyboard::Key::PageDown;
case VK_END: return Keyboard::End; case VK_END: return Keyboard::Key::End;
case VK_HOME: return Keyboard::Home; case VK_HOME: return Keyboard::Key::Home;
case VK_INSERT: return Keyboard::Insert; case VK_INSERT: return Keyboard::Key::Insert;
case VK_DELETE: return Keyboard::Delete; case VK_DELETE: return Keyboard::Key::Delete;
case VK_ADD: return Keyboard::Add; case VK_ADD: return Keyboard::Key::Add;
case VK_SUBTRACT: return Keyboard::Subtract; case VK_SUBTRACT: return Keyboard::Key::Subtract;
case VK_MULTIPLY: return Keyboard::Multiply; case VK_MULTIPLY: return Keyboard::Key::Multiply;
case VK_DIVIDE: return Keyboard::Divide; case VK_DIVIDE: return Keyboard::Key::Divide;
case VK_PAUSE: return Keyboard::Pause; case VK_PAUSE: return Keyboard::Key::Pause;
case VK_F1: return Keyboard::F1; case VK_F1: return Keyboard::Key::F1;
case VK_F2: return Keyboard::F2; case VK_F2: return Keyboard::Key::F2;
case VK_F3: return Keyboard::F3; case VK_F3: return Keyboard::Key::F3;
case VK_F4: return Keyboard::F4; case VK_F4: return Keyboard::Key::F4;
case VK_F5: return Keyboard::F5; case VK_F5: return Keyboard::Key::F5;
case VK_F6: return Keyboard::F6; case VK_F6: return Keyboard::Key::F6;
case VK_F7: return Keyboard::F7; case VK_F7: return Keyboard::Key::F7;
case VK_F8: return Keyboard::F8; case VK_F8: return Keyboard::Key::F8;
case VK_F9: return Keyboard::F9; case VK_F9: return Keyboard::Key::F9;
case VK_F10: return Keyboard::F10; case VK_F10: return Keyboard::Key::F10;
case VK_F11: return Keyboard::F11; case VK_F11: return Keyboard::Key::F11;
case VK_F12: return Keyboard::F12; case VK_F12: return Keyboard::Key::F12;
case VK_F13: return Keyboard::F13; case VK_F13: return Keyboard::Key::F13;
case VK_F14: return Keyboard::F14; case VK_F14: return Keyboard::Key::F14;
case VK_F15: return Keyboard::F15; case VK_F15: return Keyboard::Key::F15;
case VK_LEFT: return Keyboard::Left; case VK_LEFT: return Keyboard::Key::Left;
case VK_RIGHT: return Keyboard::Right; case VK_RIGHT: return Keyboard::Key::Right;
case VK_UP: return Keyboard::Up; case VK_UP: return Keyboard::Key::Up;
case VK_DOWN: return Keyboard::Down; case VK_DOWN: return Keyboard::Key::Down;
case VK_NUMPAD0: return Keyboard::Numpad0; case VK_NUMPAD0: return Keyboard::Key::Numpad0;
case VK_NUMPAD1: return Keyboard::Numpad1; case VK_NUMPAD1: return Keyboard::Key::Numpad1;
case VK_NUMPAD2: return Keyboard::Numpad2; case VK_NUMPAD2: return Keyboard::Key::Numpad2;
case VK_NUMPAD3: return Keyboard::Numpad3; case VK_NUMPAD3: return Keyboard::Key::Numpad3;
case VK_NUMPAD4: return Keyboard::Numpad4; case VK_NUMPAD4: return Keyboard::Key::Numpad4;
case VK_NUMPAD5: return Keyboard::Numpad5; case VK_NUMPAD5: return Keyboard::Key::Numpad5;
case VK_NUMPAD6: return Keyboard::Numpad6; case VK_NUMPAD6: return Keyboard::Key::Numpad6;
case VK_NUMPAD7: return Keyboard::Numpad7; case VK_NUMPAD7: return Keyboard::Key::Numpad7;
case VK_NUMPAD8: return Keyboard::Numpad8; case VK_NUMPAD8: return Keyboard::Key::Numpad8;
case VK_NUMPAD9: return Keyboard::Numpad9; case VK_NUMPAD9: return Keyboard::Key::Numpad9;
case 'A': return Keyboard::A; case 'A': return Keyboard::Key::A;
case 'Z': return Keyboard::Z; case 'Z': return Keyboard::Key::Z;
case 'E': return Keyboard::E; case 'E': return Keyboard::Key::E;
case 'R': return Keyboard::R; case 'R': return Keyboard::Key::R;
case 'T': return Keyboard::T; case 'T': return Keyboard::Key::T;
case 'Y': return Keyboard::Y; case 'Y': return Keyboard::Key::Y;
case 'U': return Keyboard::U; case 'U': return Keyboard::Key::U;
case 'I': return Keyboard::I; case 'I': return Keyboard::Key::I;
case 'O': return Keyboard::O; case 'O': return Keyboard::Key::O;
case 'P': return Keyboard::P; case 'P': return Keyboard::Key::P;
case 'Q': return Keyboard::Q; case 'Q': return Keyboard::Key::Q;
case 'S': return Keyboard::S; case 'S': return Keyboard::Key::S;
case 'D': return Keyboard::D; case 'D': return Keyboard::Key::D;
case 'F': return Keyboard::F; case 'F': return Keyboard::Key::F;
case 'G': return Keyboard::G; case 'G': return Keyboard::Key::G;
case 'H': return Keyboard::H; case 'H': return Keyboard::Key::H;
case 'J': return Keyboard::J; case 'J': return Keyboard::Key::J;
case 'K': return Keyboard::K; case 'K': return Keyboard::Key::K;
case 'L': return Keyboard::L; case 'L': return Keyboard::Key::L;
case 'M': return Keyboard::M; case 'M': return Keyboard::Key::M;
case 'W': return Keyboard::W; case 'W': return Keyboard::Key::W;
case 'X': return Keyboard::X; case 'X': return Keyboard::Key::X;
case 'C': return Keyboard::C; case 'C': return Keyboard::Key::C;
case 'V': return Keyboard::V; case 'V': return Keyboard::Key::V;
case 'B': return Keyboard::B; case 'B': return Keyboard::Key::B;
case 'N': return Keyboard::N; case 'N': return Keyboard::Key::N;
case '0': return Keyboard::Num0; case '0': return Keyboard::Key::Num0;
case '1': return Keyboard::Num1; case '1': return Keyboard::Key::Num1;
case '2': return Keyboard::Num2; case '2': return Keyboard::Key::Num2;
case '3': return Keyboard::Num3; case '3': return Keyboard::Key::Num3;
case '4': return Keyboard::Num4; case '4': return Keyboard::Key::Num4;
case '5': return Keyboard::Num5; case '5': return Keyboard::Key::Num5;
case '6': return Keyboard::Num6; case '6': return Keyboard::Key::Num6;
case '7': return Keyboard::Num7; case '7': return Keyboard::Key::Num7;
case '8': return Keyboard::Num8; case '8': return Keyboard::Key::Num8;
case '9': return Keyboard::Num9; case '9': return Keyboard::Key::Num9;
} }
// clang-format on // clang-format on
return Keyboard::Unknown; return Keyboard::Key::Unknown;
} }

View File

@ -55,7 +55,7 @@ bool isKeyPressed(Keyboard::Scancode /* codes */)
Keyboard::Key localize(Keyboard::Scancode /* code */) Keyboard::Key localize(Keyboard::Scancode /* code */)
{ {
// Not applicable // Not applicable
return Keyboard::Unknown; return Keyboard::Key::Unknown;
} }

View File

@ -98,7 +98,7 @@ public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Try to convert a character into a SFML key code /// \brief Try to convert a character into a SFML key code
/// ///
/// Return sf::Keyboard::Unknown if it doesn't match any 'localized' keys. /// Return sf::Keyboard::Key::Unknown if it doesn't match any 'localized' keys.
/// ///
/// By 'localized' we mean keys that depend on the keyboard layout /// By 'localized' we mean keys that depend on the keyboard layout
/// and might not be the same as the US keycode for some countries /// and might not be the same as the US keycode for some countries

View File

@ -99,152 +99,152 @@ Keyboard::Key HIDInputManager::localizedKey(UniChar ch)
// clang-format off // clang-format off
switch (ch) switch (ch)
{ {
case 0x41: return Keyboard::A; // uppercase A case 0x41: return Keyboard::Key::A; // uppercase A
case 0x42: return Keyboard::B; case 0x42: return Keyboard::Key::B;
case 0x43: return Keyboard::C; case 0x43: return Keyboard::Key::C;
case 0x44: return Keyboard::D; case 0x44: return Keyboard::Key::D;
case 0x45: return Keyboard::E; case 0x45: return Keyboard::Key::E;
case 0x46: return Keyboard::F; case 0x46: return Keyboard::Key::F;
case 0x47: return Keyboard::G; case 0x47: return Keyboard::Key::G;
case 0x48: return Keyboard::H; case 0x48: return Keyboard::Key::H;
case 0x49: return Keyboard::I; case 0x49: return Keyboard::Key::I;
case 0x4a: return Keyboard::J; case 0x4a: return Keyboard::Key::J;
case 0x4b: return Keyboard::K; case 0x4b: return Keyboard::Key::K;
case 0x4c: return Keyboard::L; case 0x4c: return Keyboard::Key::L;
case 0x4d: return Keyboard::M; case 0x4d: return Keyboard::Key::M;
case 0x4e: return Keyboard::N; case 0x4e: return Keyboard::Key::N;
case 0x4f: return Keyboard::O; case 0x4f: return Keyboard::Key::O;
case 0x50: return Keyboard::P; case 0x50: return Keyboard::Key::P;
case 0x51: return Keyboard::Q; case 0x51: return Keyboard::Key::Q;
case 0x52: return Keyboard::R; case 0x52: return Keyboard::Key::R;
case 0x53: return Keyboard::S; case 0x53: return Keyboard::Key::S;
case 0x54: return Keyboard::T; case 0x54: return Keyboard::Key::T;
case 0x55: return Keyboard::U; case 0x55: return Keyboard::Key::U;
case 0x56: return Keyboard::V; case 0x56: return Keyboard::Key::V;
case 0x57: return Keyboard::W; case 0x57: return Keyboard::Key::W;
case 0x58: return Keyboard::X; case 0x58: return Keyboard::Key::X;
case 0x59: return Keyboard::Y; case 0x59: return Keyboard::Key::Y;
case 0x5a: return Keyboard::Z; case 0x5a: return Keyboard::Key::Z;
case 0x61: return Keyboard::A; // lowercase A case 0x61: return Keyboard::Key::A; // lowercase A
case 0x62: return Keyboard::B; case 0x62: return Keyboard::Key::B;
case 0x63: return Keyboard::C; case 0x63: return Keyboard::Key::C;
case 0x64: return Keyboard::D; case 0x64: return Keyboard::Key::D;
case 0x65: return Keyboard::E; case 0x65: return Keyboard::Key::E;
case 0x66: return Keyboard::F; case 0x66: return Keyboard::Key::F;
case 0x67: return Keyboard::G; case 0x67: return Keyboard::Key::G;
case 0x68: return Keyboard::H; case 0x68: return Keyboard::Key::H;
case 0x69: return Keyboard::I; case 0x69: return Keyboard::Key::I;
case 0x6a: return Keyboard::J; case 0x6a: return Keyboard::Key::J;
case 0x6b: return Keyboard::K; case 0x6b: return Keyboard::Key::K;
case 0x6c: return Keyboard::L; case 0x6c: return Keyboard::Key::L;
case 0x6d: return Keyboard::M; case 0x6d: return Keyboard::Key::M;
case 0x6e: return Keyboard::N; case 0x6e: return Keyboard::Key::N;
case 0x6f: return Keyboard::O; case 0x6f: return Keyboard::Key::O;
case 0x70: return Keyboard::P; case 0x70: return Keyboard::Key::P;
case 0x71: return Keyboard::Q; case 0x71: return Keyboard::Key::Q;
case 0x72: return Keyboard::R; case 0x72: return Keyboard::Key::R;
case 0x73: return Keyboard::S; case 0x73: return Keyboard::Key::S;
case 0x74: return Keyboard::T; case 0x74: return Keyboard::Key::T;
case 0x75: return Keyboard::U; case 0x75: return Keyboard::Key::U;
case 0x76: return Keyboard::V; case 0x76: return Keyboard::Key::V;
case 0x77: return Keyboard::W; case 0x77: return Keyboard::Key::W;
case 0x78: return Keyboard::X; case 0x78: return Keyboard::Key::X;
case 0x79: return Keyboard::Y; case 0x79: return Keyboard::Key::Y;
case 0x7a: return Keyboard::Z; case 0x7a: return Keyboard::Key::Z;
case 0x30: return Keyboard::Num0; case 0x30: return Keyboard::Key::Num0;
case 0x31: return Keyboard::Num1; case 0x31: return Keyboard::Key::Num1;
case 0x32: return Keyboard::Num2; case 0x32: return Keyboard::Key::Num2;
case 0x33: return Keyboard::Num3; case 0x33: return Keyboard::Key::Num3;
case 0x34: return Keyboard::Num4; case 0x34: return Keyboard::Key::Num4;
case 0x35: return Keyboard::Num5; case 0x35: return Keyboard::Key::Num5;
case 0x36: return Keyboard::Num6; case 0x36: return Keyboard::Key::Num6;
case 0x37: return Keyboard::Num7; case 0x37: return Keyboard::Key::Num7;
case 0x38: return Keyboard::Num8; case 0x38: return Keyboard::Key::Num8;
case 0x39: return Keyboard::Num9; case 0x39: return Keyboard::Key::Num9;
case 0x1b: return Keyboard::Escape; case 0x1b: return Keyboard::Key::Escape;
/* Those are not represented using Unicode. /* Those are not represented using Unicode.
* case 0x: return Keyboard::LControl; * case 0x: return Keyboard::Key::LControl;
* case 0x: return Keyboard::LShift; * case 0x: return Keyboard::Key::LShift;
* case 0x: return Keyboard::LAlt; * case 0x: return Keyboard::Key::LAlt;
* case 0x: return Keyboard::LSystem; * case 0x: return Keyboard::Key::LSystem;
* case 0x: return Keyboard::RControl; * case 0x: return Keyboard::Key::RControl;
* case 0x: return Keyboard::RShift; * case 0x: return Keyboard::Key::RShift;
* case 0x: return Keyboard::RAlt; * case 0x: return Keyboard::Key::RAlt;
* case 0x: return Keyboard::RSystem; * case 0x: return Keyboard::Key::RSystem;
*/ */
case NSMenuFunctionKey: return Keyboard::Menu; case NSMenuFunctionKey: return Keyboard::Key::Menu;
case 0x5b: return Keyboard::LBracket; case 0x5b: return Keyboard::Key::LBracket;
case 0x5d: return Keyboard::RBracket; case 0x5d: return Keyboard::Key::RBracket;
case 0x3b: return Keyboard::Semicolon; case 0x3b: return Keyboard::Key::Semicolon;
case 0x2c: return Keyboard::Comma; case 0x2c: return Keyboard::Key::Comma;
case 0x2e: return Keyboard::Period; case 0x2e: return Keyboard::Key::Period;
case 0x27: return Keyboard::Apostrophe; case 0x27: return Keyboard::Key::Apostrophe;
case 0x2f: return Keyboard::Slash; case 0x2f: return Keyboard::Key::Slash;
case 0x5c: return Keyboard::Backslash; case 0x5c: return Keyboard::Key::Backslash;
case 0x60: return Keyboard::Grave; case 0x60: return Keyboard::Key::Grave;
case 0x3d: return Keyboard::Equal; case 0x3d: return Keyboard::Key::Equal;
case 0x2d: return Keyboard::Hyphen; case 0x2d: return Keyboard::Key::Hyphen;
case 0x20: return Keyboard::Space; case 0x20: return Keyboard::Key::Space;
case 0x0d: return Keyboard::Enter; case 0x0d: return Keyboard::Key::Enter;
case 0x08: return Keyboard::Backspace; case 0x08: return Keyboard::Key::Backspace;
case 0x09: return Keyboard::Tab; case 0x09: return Keyboard::Key::Tab;
case NSPageUpFunctionKey: return Keyboard::PageUp; case NSPageUpFunctionKey: return Keyboard::Key::PageUp;
case NSPageDownFunctionKey: return Keyboard::PageDown; case NSPageDownFunctionKey: return Keyboard::Key::PageDown;
case NSEndFunctionKey: return Keyboard::End; case NSEndFunctionKey: return Keyboard::Key::End;
case NSHomeFunctionKey: return Keyboard::Home; case NSHomeFunctionKey: return Keyboard::Key::Home;
case NSInsertFunctionKey: return Keyboard::Insert; case NSInsertFunctionKey: return Keyboard::Key::Insert;
case NSDeleteFunctionKey: return Keyboard::Delete; case NSDeleteFunctionKey: return Keyboard::Key::Delete;
case 0x7f: return Keyboard::Delete; case 0x7f: return Keyboard::Key::Delete;
case 0x2b: return Keyboard::Add; case 0x2b: return Keyboard::Key::Add;
// case 0x: return Keyboard::Subtract; // collision with Keyboard::Hyphen // case 0x: return Keyboard::Key::Subtract; // collision with Keyboard::Key::Hyphen
case 0x2a: return Keyboard::Multiply; case 0x2a: return Keyboard::Key::Multiply;
// case 0x: return Keyboard::Divide; // collision with Keyboard::Slash // case 0x: return Keyboard::Key::Divide; // collision with Keyboard::Key::Slash
case NSLeftArrowFunctionKey: return Keyboard::Left; case NSLeftArrowFunctionKey: return Keyboard::Key::Left;
case NSRightArrowFunctionKey: return Keyboard::Right; case NSRightArrowFunctionKey: return Keyboard::Key::Right;
case NSUpArrowFunctionKey: return Keyboard::Up; case NSUpArrowFunctionKey: return Keyboard::Key::Up;
case NSDownArrowFunctionKey: return Keyboard::Down; case NSDownArrowFunctionKey: return Keyboard::Key::Down;
/* Those are not represented using Unicode. /* Those are not represented using Unicode.
* case 0x: return Keyboard::Numpad0; * case 0x: return Keyboard::Key::Numpad0;
* case 0x: return Keyboard::Numpad1; * case 0x: return Keyboard::Key::Numpad1;
* case 0x: return Keyboard::Numpad2; * case 0x: return Keyboard::Key::Numpad2;
* case 0x: return Keyboard::Numpad3; * case 0x: return Keyboard::Key::Numpad3;
* case 0x: return Keyboard::Numpad4; * case 0x: return Keyboard::Key::Numpad4;
* case 0x: return Keyboard::Numpad5; * case 0x: return Keyboard::Key::Numpad5;
* case 0x: return Keyboard::Numpad6; * case 0x: return Keyboard::Key::Numpad6;
* case 0x: return Keyboard::Numpad7; * case 0x: return Keyboard::Key::Numpad7;
* case 0x: return Keyboard::Numpad8; * case 0x: return Keyboard::Key::Numpad8;
* case 0x: return Keyboard::Numpad9; * case 0x: return Keyboard::Key::Numpad9;
*/ */
case NSF1FunctionKey: return Keyboard::F1; case NSF1FunctionKey: return Keyboard::Key::F1;
case NSF2FunctionKey: return Keyboard::F2; case NSF2FunctionKey: return Keyboard::Key::F2;
case NSF3FunctionKey: return Keyboard::F3; case NSF3FunctionKey: return Keyboard::Key::F3;
case NSF4FunctionKey: return Keyboard::F4; case NSF4FunctionKey: return Keyboard::Key::F4;
case NSF5FunctionKey: return Keyboard::F5; case NSF5FunctionKey: return Keyboard::Key::F5;
case NSF6FunctionKey: return Keyboard::F6; case NSF6FunctionKey: return Keyboard::Key::F6;
case NSF7FunctionKey: return Keyboard::F7; case NSF7FunctionKey: return Keyboard::Key::F7;
case NSF8FunctionKey: return Keyboard::F8; case NSF8FunctionKey: return Keyboard::Key::F8;
case NSF9FunctionKey: return Keyboard::F9; case NSF9FunctionKey: return Keyboard::Key::F9;
case NSF10FunctionKey: return Keyboard::F10; case NSF10FunctionKey: return Keyboard::Key::F10;
case NSF11FunctionKey: return Keyboard::F11; case NSF11FunctionKey: return Keyboard::Key::F11;
case NSF12FunctionKey: return Keyboard::F12; case NSF12FunctionKey: return Keyboard::Key::F12;
case NSF13FunctionKey: return Keyboard::F13; case NSF13FunctionKey: return Keyboard::Key::F13;
case NSF14FunctionKey: return Keyboard::F14; case NSF14FunctionKey: return Keyboard::Key::F14;
case NSF15FunctionKey: return Keyboard::F15; case NSF15FunctionKey: return Keyboard::Key::F15;
case NSPauseFunctionKey: return Keyboard::Pause; case NSPauseFunctionKey: return Keyboard::Key::Pause;
default: return Keyboard::Unknown; default: return Keyboard::Key::Unknown;
} }
// clang-format on // clang-format on
} }
@ -256,122 +256,122 @@ UniChar HIDInputManager::toUnicode(Keyboard::Key key)
// clang-format off // clang-format off
switch (key) switch (key)
{ {
case Keyboard::A: return 0x41; case Keyboard::Key::A: return 0x41;
case Keyboard::B: return 0x42; case Keyboard::Key::B: return 0x42;
case Keyboard::C: return 0x43; case Keyboard::Key::C: return 0x43;
case Keyboard::D: return 0x44; case Keyboard::Key::D: return 0x44;
case Keyboard::E: return 0x45; case Keyboard::Key::E: return 0x45;
case Keyboard::F: return 0x46; case Keyboard::Key::F: return 0x46;
case Keyboard::G: return 0x47; case Keyboard::Key::G: return 0x47;
case Keyboard::H: return 0x48; case Keyboard::Key::H: return 0x48;
case Keyboard::I: return 0x49; case Keyboard::Key::I: return 0x49;
case Keyboard::J: return 0x4a; case Keyboard::Key::J: return 0x4a;
case Keyboard::K: return 0x4b; case Keyboard::Key::K: return 0x4b;
case Keyboard::L: return 0x4c; case Keyboard::Key::L: return 0x4c;
case Keyboard::M: return 0x4d; case Keyboard::Key::M: return 0x4d;
case Keyboard::N: return 0x4e; case Keyboard::Key::N: return 0x4e;
case Keyboard::O: return 0x4f; case Keyboard::Key::O: return 0x4f;
case Keyboard::P: return 0x50; case Keyboard::Key::P: return 0x50;
case Keyboard::Q: return 0x51; case Keyboard::Key::Q: return 0x51;
case Keyboard::R: return 0x52; case Keyboard::Key::R: return 0x52;
case Keyboard::S: return 0x53; case Keyboard::Key::S: return 0x53;
case Keyboard::T: return 0x54; case Keyboard::Key::T: return 0x54;
case Keyboard::U: return 0x55; case Keyboard::Key::U: return 0x55;
case Keyboard::V: return 0x56; case Keyboard::Key::V: return 0x56;
case Keyboard::W: return 0x57; case Keyboard::Key::W: return 0x57;
case Keyboard::X: return 0x58; case Keyboard::Key::X: return 0x58;
case Keyboard::Y: return 0x59; case Keyboard::Key::Y: return 0x59;
case Keyboard::Z: return 0x5a; case Keyboard::Key::Z: return 0x5a;
case Keyboard::Num0: return 0x30; case Keyboard::Key::Num0: return 0x30;
case Keyboard::Num1: return 0x31; case Keyboard::Key::Num1: return 0x31;
case Keyboard::Num2: return 0x32; case Keyboard::Key::Num2: return 0x32;
case Keyboard::Num3: return 0x33; case Keyboard::Key::Num3: return 0x33;
case Keyboard::Num4: return 0x34; case Keyboard::Key::Num4: return 0x34;
case Keyboard::Num5: return 0x35; case Keyboard::Key::Num5: return 0x35;
case Keyboard::Num6: return 0x36; case Keyboard::Key::Num6: return 0x36;
case Keyboard::Num7: return 0x37; case Keyboard::Key::Num7: return 0x37;
case Keyboard::Num8: return 0x38; case Keyboard::Key::Num8: return 0x38;
case Keyboard::Num9: return 0x39; case Keyboard::Key::Num9: return 0x39;
case Keyboard::Escape: return 0x1b; case Keyboard::Key::Escape: return 0x1b;
/* Not representable as Unicode: /* Not representable as Unicode:
* case Keyboard::LControl: return 0x; * case Keyboard::Key::LControl: return 0x;
* case Keyboard::LShift: return 0x; * case Keyboard::Key::LShift: return 0x;
* case Keyboard::LAlt: return 0x; * case Keyboard::Key::LAlt: return 0x;
* case Keyboard::LSystem: return 0x; * case Keyboard::Key::LSystem: return 0x;
* case Keyboard::RControl: return 0x; * case Keyboard::Key::RControl: return 0x;
* case Keyboard::RShift: return 0x; * case Keyboard::Key::RShift: return 0x;
* case Keyboard::RAlt: return 0x; * case Keyboard::Key::RAlt: return 0x;
* case Keyboard::RSystem: return 0x; * case Keyboard::Key::RSystem: return 0x;
*/ */
case Keyboard::Menu: return NSMenuFunctionKey; case Keyboard::Key::Menu: return NSMenuFunctionKey;
case Keyboard::LBracket: return 0x5b; case Keyboard::Key::LBracket: return 0x5b;
case Keyboard::RBracket: return 0x5d; case Keyboard::Key::RBracket: return 0x5d;
case Keyboard::Semicolon: return 0x3b; case Keyboard::Key::Semicolon: return 0x3b;
case Keyboard::Comma: return 0x2c; case Keyboard::Key::Comma: return 0x2c;
case Keyboard::Period: return 0x2e; case Keyboard::Key::Period: return 0x2e;
case Keyboard::Apostrophe: return 0x27; case Keyboard::Key::Apostrophe: return 0x27;
case Keyboard::Slash: return 0x2f; case Keyboard::Key::Slash: return 0x2f;
case Keyboard::Backslash: return 0x5c; case Keyboard::Key::Backslash: return 0x5c;
case Keyboard::Grave: return 0x60; case Keyboard::Key::Grave: return 0x60;
case Keyboard::Equal: return 0x3d; case Keyboard::Key::Equal: return 0x3d;
case Keyboard::Hyphen: return 0x2d; case Keyboard::Key::Hyphen: return 0x2d;
case Keyboard::Space: return 0x20; case Keyboard::Key::Space: return 0x20;
case Keyboard::Enter: return 0x0d; case Keyboard::Key::Enter: return 0x0d;
case Keyboard::Backspace: return 0x08; case Keyboard::Key::Backspace: return 0x08;
case Keyboard::Tab: return 0x09; case Keyboard::Key::Tab: return 0x09;
case Keyboard::PageUp: return NSPageUpFunctionKey; case Keyboard::Key::PageUp: return NSPageUpFunctionKey;
case Keyboard::PageDown: return NSPageDownFunctionKey; case Keyboard::Key::PageDown: return NSPageDownFunctionKey;
case Keyboard::End: return NSEndFunctionKey; case Keyboard::Key::End: return NSEndFunctionKey;
case Keyboard::Home: return NSHomeFunctionKey; case Keyboard::Key::Home: return NSHomeFunctionKey;
case Keyboard::Insert: return NSInsertFunctionKey; case Keyboard::Key::Insert: return NSInsertFunctionKey;
case Keyboard::Delete: return NSDeleteFunctionKey; case Keyboard::Key::Delete: return NSDeleteFunctionKey;
case Keyboard::Add: return 0x2b; case Keyboard::Key::Add: return 0x2b;
case Keyboard::Subtract: return 0x2d; case Keyboard::Key::Subtract: return 0x2d;
case Keyboard::Multiply: return 0x2a; case Keyboard::Key::Multiply: return 0x2a;
case Keyboard::Divide: return 0x2f; case Keyboard::Key::Divide: return 0x2f;
case Keyboard::Left: return NSLeftArrowFunctionKey; case Keyboard::Key::Left: return NSLeftArrowFunctionKey;
case Keyboard::Right: return NSRightArrowFunctionKey; case Keyboard::Key::Right: return NSRightArrowFunctionKey;
case Keyboard::Up: return NSUpArrowFunctionKey; case Keyboard::Key::Up: return NSUpArrowFunctionKey;
case Keyboard::Down: return NSDownArrowFunctionKey; case Keyboard::Key::Down: return NSDownArrowFunctionKey;
/* Those are not represented using Unicode. /* Those are not represented using Unicode.
* case Keyboard::Numpad0: return 0x; * case Keyboard::Key::Numpad0: return 0x;
* case Keyboard::Numpad1: return 0x; * case Keyboard::Key::Numpad1: return 0x;
* case Keyboard::Numpad2: return 0x; * case Keyboard::Key::Numpad2: return 0x;
* case Keyboard::Numpad3: return 0x; * case Keyboard::Key::Numpad3: return 0x;
* case Keyboard::Numpad4: return 0x; * case Keyboard::Key::Numpad4: return 0x;
* case Keyboard::Numpad5: return 0x; * case Keyboard::Key::Numpad5: return 0x;
* case Keyboard::Numpad6: return 0x; * case Keyboard::Key::Numpad6: return 0x;
* case Keyboard::Numpad7: return 0x; * case Keyboard::Key::Numpad7: return 0x;
* case Keyboard::Numpad8: return 0x; * case Keyboard::Key::Numpad8: return 0x;
* case Keyboard::Numpad9: return 0x; * case Keyboard::Key::Numpad9: return 0x;
*/ */
case Keyboard::F1: return NSF1FunctionKey; case Keyboard::Key::F1: return NSF1FunctionKey;
case Keyboard::F2: return NSF2FunctionKey; case Keyboard::Key::F2: return NSF2FunctionKey;
case Keyboard::F3: return NSF3FunctionKey; case Keyboard::Key::F3: return NSF3FunctionKey;
case Keyboard::F4: return NSF4FunctionKey; case Keyboard::Key::F4: return NSF4FunctionKey;
case Keyboard::F5: return NSF5FunctionKey; case Keyboard::Key::F5: return NSF5FunctionKey;
case Keyboard::F6: return NSF6FunctionKey; case Keyboard::Key::F6: return NSF6FunctionKey;
case Keyboard::F7: return NSF7FunctionKey; case Keyboard::Key::F7: return NSF7FunctionKey;
case Keyboard::F8: return NSF8FunctionKey; case Keyboard::Key::F8: return NSF8FunctionKey;
case Keyboard::F9: return NSF9FunctionKey; case Keyboard::Key::F9: return NSF9FunctionKey;
case Keyboard::F10: return NSF10FunctionKey; case Keyboard::Key::F10: return NSF10FunctionKey;
case Keyboard::F11: return NSF11FunctionKey; case Keyboard::Key::F11: return NSF11FunctionKey;
case Keyboard::F12: return NSF12FunctionKey; case Keyboard::Key::F12: return NSF12FunctionKey;
case Keyboard::F13: return NSF13FunctionKey; case Keyboard::Key::F13: return NSF13FunctionKey;
case Keyboard::F14: return NSF14FunctionKey; case Keyboard::Key::F14: return NSF14FunctionKey;
case Keyboard::F15: return NSF15FunctionKey; case Keyboard::Key::F15: return NSF15FunctionKey;
case Keyboard::Pause: return NSPauseFunctionKey; case Keyboard::Key::Pause: return NSPauseFunctionKey;
default: return 0x00; default: return 0x00;
} }
@ -570,7 +570,7 @@ bool HIDInputManager::isKeyPressed(Keyboard::Scancode code)
Keyboard::Key HIDInputManager::localize(Keyboard::Scancode code) Keyboard::Key HIDInputManager::localize(Keyboard::Scancode code)
{ {
if (code == Keyboard::Scan::Unknown) if (code == Keyboard::Scan::Unknown)
return Keyboard::Unknown; return Keyboard::Key::Unknown;
return m_scancodeToKeyMapping[code]; return m_scancodeToKeyMapping[code];
} }
@ -579,7 +579,7 @@ Keyboard::Key HIDInputManager::localize(Keyboard::Scancode code)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Keyboard::Scancode HIDInputManager::delocalize(Keyboard::Key key) Keyboard::Scancode HIDInputManager::delocalize(Keyboard::Key key)
{ {
if (key == Keyboard::Unknown) if (key == Keyboard::Key::Unknown)
return Keyboard::Scan::Unknown; return Keyboard::Scan::Unknown;
return m_keyToScancodeMapping[key]; return m_keyToScancodeMapping[key];
@ -858,7 +858,7 @@ void HIDInputManager::buildMappings()
break; break;
} }
Keyboard::Key code = Keyboard::Unknown; Keyboard::Key code = Keyboard::Key::Unknown;
if (translateToString) if (translateToString)
{ {
// Unicode string length is usually less or equal to 4 // Unicode string length is usually less or equal to 4
@ -889,9 +889,9 @@ void HIDInputManager::buildMappings()
if (length > 0) if (length > 0)
code = localizedKey(string[0]); code = localizedKey(string[0]);
} }
if (code == Keyboard::Unknown) if (code == Keyboard::Key::Unknown)
code = localizedKeyFallback(scan); code = localizedKeyFallback(scan);
if (code == Keyboard::Unknown) if (code == Keyboard::Key::Unknown)
continue; continue;
// Register the bi-mapping // Register the bi-mapping
@ -1354,69 +1354,69 @@ Keyboard::Key HIDInputManager::localizedKeyFallback(Keyboard::Scancode code)
// clang-format off // clang-format off
switch (code) switch (code)
{ {
case Keyboard::Scan::Enter: return Keyboard::Enter; case Keyboard::Scan::Enter: return Keyboard::Key::Enter;
case Keyboard::Scan::Escape: return Keyboard::Escape; case Keyboard::Scan::Escape: return Keyboard::Key::Escape;
case Keyboard::Scan::Backspace: return Keyboard::Backspace; case Keyboard::Scan::Backspace: return Keyboard::Key::Backspace;
case Keyboard::Scan::Tab: return Keyboard::Tab; case Keyboard::Scan::Tab: return Keyboard::Key::Tab;
case Keyboard::Scan::Space: return Keyboard::Space; case Keyboard::Scan::Space: return Keyboard::Key::Space;
case Keyboard::Scan::F1: return Keyboard::F1; case Keyboard::Scan::F1: return Keyboard::Key::F1;
case Keyboard::Scan::F2: return Keyboard::F2; case Keyboard::Scan::F2: return Keyboard::Key::F2;
case Keyboard::Scan::F3: return Keyboard::F3; case Keyboard::Scan::F3: return Keyboard::Key::F3;
case Keyboard::Scan::F4: return Keyboard::F4; case Keyboard::Scan::F4: return Keyboard::Key::F4;
case Keyboard::Scan::F5: return Keyboard::F5; case Keyboard::Scan::F5: return Keyboard::Key::F5;
case Keyboard::Scan::F6: return Keyboard::F6; case Keyboard::Scan::F6: return Keyboard::Key::F6;
case Keyboard::Scan::F7: return Keyboard::F7; case Keyboard::Scan::F7: return Keyboard::Key::F7;
case Keyboard::Scan::F8: return Keyboard::F8; case Keyboard::Scan::F8: return Keyboard::Key::F8;
case Keyboard::Scan::F9: return Keyboard::F9; case Keyboard::Scan::F9: return Keyboard::Key::F9;
case Keyboard::Scan::F10: return Keyboard::F10; case Keyboard::Scan::F10: return Keyboard::Key::F10;
case Keyboard::Scan::F11: return Keyboard::F11; case Keyboard::Scan::F11: return Keyboard::Key::F11;
case Keyboard::Scan::F12: return Keyboard::F12; case Keyboard::Scan::F12: return Keyboard::Key::F12;
case Keyboard::Scan::F13: return Keyboard::F13; case Keyboard::Scan::F13: return Keyboard::Key::F13;
case Keyboard::Scan::F14: return Keyboard::F14; case Keyboard::Scan::F14: return Keyboard::Key::F14;
case Keyboard::Scan::F15: return Keyboard::F15; case Keyboard::Scan::F15: return Keyboard::Key::F15;
case Keyboard::Scan::Pause: return Keyboard::Pause; case Keyboard::Scan::Pause: return Keyboard::Key::Pause;
case Keyboard::Scan::Insert: return Keyboard::Insert; case Keyboard::Scan::Insert: return Keyboard::Key::Insert;
case Keyboard::Scan::Home: return Keyboard::Home; case Keyboard::Scan::Home: return Keyboard::Key::Home;
case Keyboard::Scan::PageUp: return Keyboard::PageUp; case Keyboard::Scan::PageUp: return Keyboard::Key::PageUp;
case Keyboard::Scan::Delete: return Keyboard::Delete; case Keyboard::Scan::Delete: return Keyboard::Key::Delete;
case Keyboard::Scan::End: return Keyboard::End; case Keyboard::Scan::End: return Keyboard::Key::End;
case Keyboard::Scan::PageDown: return Keyboard::PageDown; case Keyboard::Scan::PageDown: return Keyboard::Key::PageDown;
case Keyboard::Scan::Right: return Keyboard::Right; case Keyboard::Scan::Right: return Keyboard::Key::Right;
case Keyboard::Scan::Left: return Keyboard::Left; case Keyboard::Scan::Left: return Keyboard::Key::Left;
case Keyboard::Scan::Down: return Keyboard::Down; case Keyboard::Scan::Down: return Keyboard::Key::Down;
case Keyboard::Scan::Up: return Keyboard::Up; case Keyboard::Scan::Up: return Keyboard::Key::Up;
case Keyboard::Scan::NumpadDivide: return Keyboard::Divide; case Keyboard::Scan::NumpadDivide: return Keyboard::Key::Divide;
case Keyboard::Scan::NumpadMultiply: return Keyboard::Multiply; case Keyboard::Scan::NumpadMultiply: return Keyboard::Key::Multiply;
case Keyboard::Scan::NumpadMinus: return Keyboard::Subtract; case Keyboard::Scan::NumpadMinus: return Keyboard::Key::Subtract;
case Keyboard::Scan::NumpadPlus: return Keyboard::Add; case Keyboard::Scan::NumpadPlus: return Keyboard::Key::Add;
case Keyboard::Scan::NumpadEnter: return Keyboard::Enter; case Keyboard::Scan::NumpadEnter: return Keyboard::Key::Enter;
case Keyboard::Scan::Numpad1: return Keyboard::Numpad1; case Keyboard::Scan::Numpad1: return Keyboard::Key::Numpad1;
case Keyboard::Scan::Numpad2: return Keyboard::Numpad2; case Keyboard::Scan::Numpad2: return Keyboard::Key::Numpad2;
case Keyboard::Scan::Numpad3: return Keyboard::Numpad3; case Keyboard::Scan::Numpad3: return Keyboard::Key::Numpad3;
case Keyboard::Scan::Numpad4: return Keyboard::Numpad4; case Keyboard::Scan::Numpad4: return Keyboard::Key::Numpad4;
case Keyboard::Scan::Numpad5: return Keyboard::Numpad5; case Keyboard::Scan::Numpad5: return Keyboard::Key::Numpad5;
case Keyboard::Scan::Numpad6: return Keyboard::Numpad6; case Keyboard::Scan::Numpad6: return Keyboard::Key::Numpad6;
case Keyboard::Scan::Numpad7: return Keyboard::Numpad7; case Keyboard::Scan::Numpad7: return Keyboard::Key::Numpad7;
case Keyboard::Scan::Numpad8: return Keyboard::Numpad8; case Keyboard::Scan::Numpad8: return Keyboard::Key::Numpad8;
case Keyboard::Scan::Numpad9: return Keyboard::Numpad9; case Keyboard::Scan::Numpad9: return Keyboard::Key::Numpad9;
case Keyboard::Scan::Numpad0: return Keyboard::Numpad0; case Keyboard::Scan::Numpad0: return Keyboard::Key::Numpad0;
case Keyboard::Scan::LControl: return Keyboard::LControl; case Keyboard::Scan::LControl: return Keyboard::Key::LControl;
case Keyboard::Scan::LShift: return Keyboard::LShift; case Keyboard::Scan::LShift: return Keyboard::Key::LShift;
case Keyboard::Scan::LAlt: return Keyboard::LAlt; case Keyboard::Scan::LAlt: return Keyboard::Key::LAlt;
case Keyboard::Scan::LSystem: return Keyboard::LSystem; case Keyboard::Scan::LSystem: return Keyboard::Key::LSystem;
case Keyboard::Scan::RControl: return Keyboard::RControl; case Keyboard::Scan::RControl: return Keyboard::Key::RControl;
case Keyboard::Scan::RShift: return Keyboard::RShift; case Keyboard::Scan::RShift: return Keyboard::Key::RShift;
case Keyboard::Scan::RAlt: return Keyboard::RAlt; case Keyboard::Scan::RAlt: return Keyboard::Key::RAlt;
case Keyboard::Scan::RSystem: return Keyboard::RSystem; case Keyboard::Scan::RSystem: return Keyboard::Key::RSystem;
default: return Keyboard::Unknown; default: return Keyboard::Key::Unknown;
} }
// clang-format on // clang-format on
} }

View File

@ -174,8 +174,8 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req
NSRightShiftKeyMask, NSRightShiftKeyMask,
state.leftShiftWasDown, state.leftShiftWasDown,
state.rightShiftWasDown, state.rightShiftWasDown,
sf::Keyboard::LShift, sf::Keyboard::Key::LShift,
sf::Keyboard::RShift, sf::Keyboard::Key::RShift,
sf::Keyboard::Scan::LShift, sf::Keyboard::Scan::LShift,
sf::Keyboard::Scan::RShift, sf::Keyboard::Scan::RShift,
requester); requester);
@ -186,8 +186,8 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req
NSRightCommandKeyMask, NSRightCommandKeyMask,
state.leftCommandWasDown, state.leftCommandWasDown,
state.rightCommandWasDown, state.rightCommandWasDown,
sf::Keyboard::LSystem, sf::Keyboard::Key::LSystem,
sf::Keyboard::RSystem, sf::Keyboard::Key::RSystem,
sf::Keyboard::Scan::LSystem, sf::Keyboard::Scan::LSystem,
sf::Keyboard::Scan::RSystem, sf::Keyboard::Scan::RSystem,
requester); requester);
@ -198,8 +198,8 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req
NSRightAlternateKeyMask, NSRightAlternateKeyMask,
state.leftAlternateWasDown, state.leftAlternateWasDown,
state.rightAlternateWasDown, state.rightAlternateWasDown,
sf::Keyboard::LAlt, sf::Keyboard::Key::LAlt,
sf::Keyboard::RAlt, sf::Keyboard::Key::RAlt,
sf::Keyboard::Scan::LAlt, sf::Keyboard::Scan::LAlt,
sf::Keyboard::Scan::RAlt, sf::Keyboard::Scan::RAlt,
requester); requester);
@ -210,8 +210,8 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req
NSRightControlKeyMask, NSRightControlKeyMask,
state.leftControlWasDown, state.leftControlWasDown,
state.rightControlWasDown, state.rightControlWasDown,
sf::Keyboard::LControl, sf::Keyboard::Key::LControl,
sf::Keyboard::RControl, sf::Keyboard::Key::RControl,
sf::Keyboard::Scan::LControl, sf::Keyboard::Scan::LControl,
sf::Keyboard::Scan::RControl, sf::Keyboard::Scan::RControl,
requester); requester);
@ -220,7 +220,7 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req
processOneModifier(modifiers, processOneModifier(modifiers,
NSEventModifierFlagCapsLock, NSEventModifierFlagCapsLock,
state.capsLockWasOn, state.capsLockWasOn,
sf::Keyboard::Unknown, sf::Keyboard::Key::Unknown,
sf::Keyboard::Scan::CapsLock, sf::Keyboard::Scan::CapsLock,
requester); requester);
} }

View File

@ -86,7 +86,7 @@
{ {
sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent]; sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
if ((key.code != sf::Keyboard::Unknown) || (key.scancode != sf::Keyboard::Scan::Unknown)) if ((key.code != sf::Keyboard::Key::Unknown) || (key.scancode != sf::Keyboard::Scan::Unknown))
m_requester->keyDown(key); m_requester->keyDown(key);
} }
@ -158,7 +158,7 @@
sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent]; sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
if ((key.code != sf::Keyboard::Unknown) || (key.scancode != sf::Keyboard::Scan::Unknown)) if ((key.code != sf::Keyboard::Key::Unknown) || (key.scancode != sf::Keyboard::Scan::Unknown))
m_requester->keyUp(key); m_requester->keyUp(key);
} }

View File

@ -48,7 +48,7 @@
/// ///
/// \param event a key event /// \param event a key event
/// ///
/// \return sf::Keyboard::Unknown as Code if the key is unknown /// \return sf::Keyboard::Key::Unknown as Code if the key is unknown
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+ (sf::Event::KeyEvent)convertNSKeyEventToSFMLEvent:(NSEvent*)event; + (sf::Event::KeyEvent)convertNSKeyEventToSFMLEvent:(NSEvent*)event;

View File

@ -19,10 +19,10 @@ TEST_CASE("[Window] sf::Keyboard", runDisplayTests())
{ {
SECTION("isKeyPressed(Key)") SECTION("isKeyPressed(Key)")
{ {
CHECK(!sf::Keyboard::isKeyPressed(sf::Keyboard::W)); CHECK(!sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W));
CHECK(!sf::Keyboard::isKeyPressed(sf::Keyboard::A)); CHECK(!sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A));
CHECK(!sf::Keyboard::isKeyPressed(sf::Keyboard::S)); CHECK(!sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S));
CHECK(!sf::Keyboard::isKeyPressed(sf::Keyboard::D)); CHECK(!sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D));
} }
SECTION("isKeyPressed(Scancode)") SECTION("isKeyPressed(Scancode)")
@ -35,12 +35,12 @@ TEST_CASE("[Window] sf::Keyboard", runDisplayTests())
SECTION("localize(Scancode)") SECTION("localize(Scancode)")
{ {
CHECK(sf::Keyboard::localize(sf::Keyboard::Scan::Space) == sf::Keyboard::Space); CHECK(sf::Keyboard::localize(sf::Keyboard::Scan::Space) == sf::Keyboard::Key::Space);
} }
SECTION("delocalize(Key)") SECTION("delocalize(Key)")
{ {
CHECK(sf::Keyboard::delocalize(sf::Keyboard::Space) == sf::Keyboard::Scan::Space); CHECK(sf::Keyboard::delocalize(sf::Keyboard::Key::Space) == sf::Keyboard::Scan::Space);
} }
SECTION("getDescription(Scancode)") SECTION("getDescription(Scancode)")

View File

@ -73,7 +73,7 @@ int main()
} }
// Escape pressed: exit // Escape pressed: exit
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Key::Escape)
{ {
window.close(); window.close();
} }

View File

@ -71,7 +71,7 @@ int main()
} }
// Escape pressed: exit // Escape pressed: exit
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Key::Escape)
{ {
window.close(); window.close();
} }