From aba54925d82676f399fa98f15bbaf91ae1b4b9ec Mon Sep 17 00:00:00 2001 From: kimci86 Date: Thu, 23 Jun 2022 22:37:34 +0200 Subject: [PATCH] Add initial dummy scancode implementation on Linux (DRM) --- src/SFML/Window/DRM/InputImplUDev.cpp | 36 +++++++++++++++++++++++++++ src/SFML/Window/DRM/InputImplUDev.hpp | 32 ++++++++++++++++++------ 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/src/SFML/Window/DRM/InputImplUDev.cpp b/src/SFML/Window/DRM/InputImplUDev.cpp index a45b836ee..67f76d8e4 100644 --- a/src/SFML/Window/DRM/InputImplUDev.cpp +++ b/src/SFML/Window/DRM/InputImplUDev.cpp @@ -407,6 +407,7 @@ namespace // event.type = inputEvent.value ? sf::Event::KeyPressed : sf::Event::KeyReleased; event.key.code = kb; + event.key.scancode = sf::Keyboard::Scan::Unknown; // TODO: not implemented event.key.alt = altDown(); event.key.control = controlDown(); event.key.shift = shiftDown(); @@ -567,6 +568,41 @@ bool InputImpl::isKeyPressed(Keyboard::Key key) return keyMap[static_cast(key)]; } +//////////////////////////////////////////////////////////// +bool InputImpl::isKeyPressed(Keyboard::Scancode /* code */) +{ + // TODO: not implemented + err() << "sf::Keyboard::isKeyPressed(Keyboard::Scancode) is not implemented for DRM." << std::endl; + return false; +} + + +//////////////////////////////////////////////////////////// +Keyboard::Key InputImpl::localize(Keyboard::Scancode /* code */) +{ + // TODO: not implemented + err() << "sf::Keyboard::localize is not implemented for DRM." << std::endl; + return Keyboard::Unknown; +} + + +//////////////////////////////////////////////////////////// +Keyboard::Scancode InputImpl::delocalize(Keyboard::Key /* key */) +{ + // TODO: not implemented + err() << "sf::Keyboard::delocalize is not implemented for DRM." << std::endl; + return Keyboard::Scan::Unknown; +} + + +//////////////////////////////////////////////////////////// +String InputImpl::getDescription(Keyboard::Scancode /* code */) +{ + // TODO: not implemented + err() << "sf::Keyboard::getDescription is not implemented for DRM." << std::endl; + return ""; +} + //////////////////////////////////////////////////////////// void InputImpl::setVirtualKeyboardVisible(bool /*visible*/) diff --git a/src/SFML/Window/DRM/InputImplUDev.hpp b/src/SFML/Window/DRM/InputImplUDev.hpp index 4838dbf10..6a249ea05 100644 --- a/src/SFML/Window/DRM/InputImplUDev.hpp +++ b/src/SFML/Window/DRM/InputImplUDev.hpp @@ -46,19 +46,37 @@ class InputImpl public: //////////////////////////////////////////////////////////// - /// \brief Check if a key is pressed - /// - /// \param key Key to check - /// - /// \return True if the key is pressed, false otherwise + /// \copydoc sf::Keyboard::isKeyPressed(Key) /// //////////////////////////////////////////////////////////// static bool isKeyPressed(Keyboard::Key key); //////////////////////////////////////////////////////////// - /// \brief Show or hide the virtual keyboard + /// \copydoc sf::Keyboard::isKeyPressed(Scancode) /// - /// \param visible True to show, false to hide + //////////////////////////////////////////////////////////// + static bool isKeyPressed(Keyboard::Scancode code); + + //////////////////////////////////////////////////////////// + /// \copydoc sf::Keyboard::localize + /// + //////////////////////////////////////////////////////////// + static Keyboard::Key localize(Keyboard::Scancode code); + + //////////////////////////////////////////////////////////// + /// \copydoc sf::Keyboard::delocalize + /// + //////////////////////////////////////////////////////////// + static Keyboard::Scancode delocalize(Keyboard::Key key); + + //////////////////////////////////////////////////////////// + /// \copydoc sf::Keyboard::getDescription + /// + //////////////////////////////////////////////////////////// + static String getDescription(Keyboard::Scancode code); + + //////////////////////////////////////////////////////////// + /// \copydoc sf::Keyboard::setVirtualKeyboardVisible /// //////////////////////////////////////////////////////////// static void setVirtualKeyboardVisible(bool visible);