GameControllerShortcuts.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * GameControllerShortcuts.cpp, 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. #include <SDL.h>
  11. #include "StdInc.h"
  12. #include "GameControllerShortcuts.h"
  13. #include "../gui/ShortcutHandler.h"
  14. const ButtonShortcutsMap & getButtonShortcutsMap() {
  15. static const ButtonShortcutsMap buttonShortcutsMap =
  16. {
  17. // SDL_CONTROLLER_BUTTON_A for mouse left click
  18. {SDL_CONTROLLER_BUTTON_B, {EShortcut::GLOBAL_CANCEL, EShortcut::GLOBAL_RETURN,
  19. EShortcut::ADVENTURE_EXIT_WORLD_VIEW}},
  20. {SDL_CONTROLLER_BUTTON_X, {EShortcut::GLOBAL_ACCEPT, EShortcut::GLOBAL_RETURN, EShortcut::LOBBY_BEGIN_GAME,
  21. EShortcut::LOBBY_LOAD_GAME, EShortcut::LOBBY_SAVE_GAME,
  22. EShortcut::ADVENTURE_VIEW_SELECTED, EShortcut::ADVENTURE_EXIT_WORLD_VIEW,
  23. EShortcut::BATTLE_TACTICS_END}},
  24. // SDL_CONTROLLER_BUTTON_Y for mouse right click
  25. {SDL_CONTROLLER_BUTTON_LEFTSHOULDER, {EShortcut::ADVENTURE_NEXT_HERO, EShortcut::BATTLE_DEFEND}},
  26. {SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, {EShortcut::ADVENTURE_NEXT_TOWN, EShortcut::BATTLE_WAIT}},
  27. {SDL_CONTROLLER_BUTTON_BACK, {EShortcut::GAME_END_TURN, EShortcut::BATTLE_END_WITH_AUTOCOMBAT}},
  28. {SDL_CONTROLLER_BUTTON_START, {EShortcut::GLOBAL_OPTIONS, EShortcut::ADVENTURE_GAME_OPTIONS}},
  29. {SDL_CONTROLLER_BUTTON_DPAD_UP, {EShortcut::MOVE_UP, EShortcut::ADVENTURE_VIEW_WORLD,
  30. EShortcut::RECRUITMENT_UPGRADE,
  31. EShortcut::RECRUITMENT_UPGRADE_ALL,
  32. EShortcut::BATTLE_CONSOLE_UP, EShortcut::RECRUITMENT_MAX}},
  33. {SDL_CONTROLLER_BUTTON_DPAD_DOWN, {EShortcut::MOVE_DOWN, EShortcut::ADVENTURE_KINGDOM_OVERVIEW,
  34. EShortcut::BATTLE_CONSOLE_DOWN, EShortcut::RECRUITMENT_MIN}},
  35. {SDL_CONTROLLER_BUTTON_DPAD_LEFT, {EShortcut::MOVE_LEFT, EShortcut::ADVENTURE_VIEW_SCENARIO}},
  36. {SDL_CONTROLLER_BUTTON_DPAD_RIGHT, {EShortcut::MOVE_RIGHT, EShortcut::ADVENTURE_THIEVES_GUILD}},
  37. {SDL_CONTROLLER_BUTTON_LEFTSTICK, {EShortcut::ADVENTURE_TOGGLE_MAP_LEVEL,
  38. EShortcut::BATTLE_TOGGLE_HEROES_STATS}},
  39. {SDL_CONTROLLER_BUTTON_RIGHTSTICK, {EShortcut::ADVENTURE_TOGGLE_GRID, EShortcut::BATTLE_TOGGLE_QUEUE}}
  40. };
  41. return buttonShortcutsMap;
  42. }
  43. const TriggerShortcutsMap & getTriggerShortcutsMap()
  44. {
  45. static const TriggerShortcutsMap triggerShortcutsMap = {
  46. {SDL_CONTROLLER_AXIS_TRIGGERLEFT, {EShortcut::ADVENTURE_VISIT_OBJECT, EShortcut::BATTLE_TACTICS_NEXT,
  47. EShortcut::BATTLE_USE_CREATURE_SPELL}},
  48. {SDL_CONTROLLER_AXIS_TRIGGERRIGHT, {EShortcut::ADVENTURE_CAST_SPELL, EShortcut::BATTLE_CAST_SPELL}}
  49. };
  50. return triggerShortcutsMap;
  51. }