SdlWindowApiEventManager.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * author: Patrick-Christopher Mattulat
  3. * e-mail: webmaster@lynarstudios.com
  4. */
  5. #include <interface/IKeyboard.hpp>
  6. #include <window/SdlKeyEventManager.hpp>
  7. #include <window/SdlWindowApiEventManager.hpp>
  8. using ls::atlantis::interfaces::IKeyboard;
  9. using ls::atlantis::window::SdlKeyEventManager;
  10. using ls::atlantis::window::SdlWindowApiEventManager;
  11. using ::std::make_shared;
  12. using ::std::shared_ptr;
  13. SdlWindowApiEventManager::SdlWindowApiEventManager()
  14. {
  15. this->sdlEvent = make_shared<SDL_Event>();
  16. }
  17. SdlWindowApiEventManager::~SdlWindowApiEventManager() = default;
  18. void SdlWindowApiEventManager::manage(const shared_ptr<IKeyboard> &_keyboard)
  19. {
  20. while (SDL_PollEvent(this->sdlEvent.get()))
  21. {
  22. switch (this->sdlEvent->type)
  23. {
  24. case SDL_EVENT_KEY_DOWN:
  25. {
  26. SdlKeyEventManager::manageKeyDownEvent(_keyboard, this->sdlEvent);
  27. } break;
  28. case SDL_EVENT_KEY_UP:
  29. {
  30. SdlKeyEventManager::manageKeyUpEvent(_keyboard, this->sdlEvent);
  31. } break;
  32. default:
  33. {
  34. // other use cases not supported, yet
  35. }
  36. }
  37. }
  38. }