keyboard_manager.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // SuperTux
  2. // Copyright (C) 2006 Matthias Braun <matze@braunis.de>,
  3. // 2007-2014 Ingo Ruhnke <grumbel@gmail.com>
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef HEADER_SUPERTUX_CONTROL_KEYBOARD_MANAGER_HPP
  18. #define HEADER_SUPERTUX_CONTROL_KEYBOARD_MANAGER_HPP
  19. #include <optional>
  20. #include "control/controller.hpp"
  21. #include "control/keyboard_config.hpp"
  22. class InputManager;
  23. struct SDL_KeyboardEvent;
  24. struct SDL_TextInputEvent;
  25. class KeyboardManager final
  26. {
  27. public:
  28. KeyboardManager(InputManager* parent, KeyboardConfig& keyboard_config);
  29. void process_key_event(const SDL_KeyboardEvent& event);
  30. void process_text_input_event(const SDL_TextInputEvent& event);
  31. void process_console_key_event(const SDL_KeyboardEvent& event);
  32. void process_menu_key_event(const SDL_KeyboardEvent& event);
  33. void bind_next_event_to(int player_id, Control id);
  34. private:
  35. InputManager* m_parent;
  36. KeyboardConfig& m_keyboard_config;
  37. std::optional<KeyboardConfig::PlayerControl> m_wait_for_key;
  38. bool m_lock_text_input;
  39. private:
  40. KeyboardManager(const KeyboardManager&) = delete;
  41. KeyboardManager& operator=(const KeyboardManager&) = delete;
  42. };
  43. #endif
  44. /* EOF */