/* * ===================================================================================== * * Filename: InputHandler.hpp * * Description: * * Created: 17/01/2018 19:09:57 * * Author: Quentin Bazin, * * ===================================================================================== */ #ifndef INPUTHANDLER_HPP_ #define INPUTHANDLER_HPP_ #include #include "GameKey.hpp" #include "IntTypes.hpp" class InputHandler { public: virtual ~InputHandler() = default; virtual bool isKeyPressed(GameKey key) { return m_keysPressed[key]; } virtual bool isKeyPressedOnce(GameKey key); virtual bool isKeyPressedWithDelay(GameKey key, u16 delay); const std::map &keysPressed() const { return m_keysPressed; } protected: void addKey(GameKey key); std::map m_keysPressed; std::map m_keysPressedOnce; std::map m_lastTimePressed; }; #endif // INPUTHANDLER_HPP_