ShortcutHandler.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * ShortcutHandler.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. enum class EShortcut;
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class JsonNode;
  14. VCMI_LIB_NAMESPACE_END
  15. class ShortcutHandler
  16. {
  17. std::multimap<std::string, EShortcut> mappedKeyboardShortcuts;
  18. std::multimap<std::string, EShortcut> mappedJoystickShortcuts;
  19. std::multimap<std::string, EShortcut> mappedJoystickAxes;
  20. std::multimap<std::string, EShortcut> loadShortcuts(const JsonNode & data) const;
  21. std::vector<EShortcut> translateShortcut(const std::multimap<std::string, EShortcut> & options, const std::string & key) const;
  22. public:
  23. ShortcutHandler();
  24. /// returns list of shortcuts assigned to provided SDL keycode
  25. std::vector<EShortcut> translateKeycode(const std::string & key) const;
  26. std::vector<EShortcut> translateJoystickButton(const std::string & key) const;
  27. std::vector<EShortcut> translateJoystickAxis(const std::string & key) const;
  28. /// attempts to find shortcut by its unique identifier. Returns EShortcut::NONE on failure
  29. EShortcut findShortcut(const std::string & identifier ) const;
  30. };