SdlKeyEventManager.cpp 1003 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * author: Patrick-Christopher Mattulat
  3. * e-mail: webmaster@lynarstudios.com
  4. */
  5. #include <glossary/KeyboardKeys.hpp>
  6. #include <interface/IKeyboard.hpp>
  7. #include <window/SdlKeyEventManager.hpp>
  8. using ls::atlantis::glossary::KeyboardKeys;
  9. using ls::atlantis::interfaces::IKeyboard;
  10. using ls::atlantis::window::SdlKeyEventManager;
  11. using ::std::shared_ptr;
  12. SdlKeyEventManager::SdlKeyEventManager() = default;
  13. SdlKeyEventManager::~SdlKeyEventManager() = default;
  14. void SdlKeyEventManager::manageKeyDownEvent(const shared_ptr<IKeyboard> &_keyboard, const shared_ptr<SDL_Event> &_event)
  15. {
  16. if (_event->key.key == SDLK_ESCAPE)
  17. {
  18. _keyboard->updateKey(KeyboardKeys::ESCAPE, _keyboard->isFreed(KeyboardKeys::ESCAPE), true);
  19. }
  20. }
  21. void SdlKeyEventManager::manageKeyUpEvent(const shared_ptr<IKeyboard> &_keyboard, const shared_ptr<SDL_Event> &_event)
  22. {
  23. if (_event->key.key == SDLK_ESCAPE)
  24. {
  25. _keyboard->updateKey(KeyboardKeys::ESCAPE, true, _keyboard->isPressed(KeyboardKeys::ESCAPE));
  26. }
  27. }