summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-31 00:19:18 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-31 00:19:18 +0300
commit694e07d193e7c5758a7d672b45668651b034003d (patch)
tree20a4aec8dee2b3b5475db9f3667e797fb43c603b /src
parentc9a84749b3b71d4df6cc3b9b488d60dc4a013a20 (diff)
downloadmv-694e07d193e7c5758a7d672b45668651b034003d.tar.gz
mv-694e07d193e7c5758a7d672b45668651b034003d.tar.bz2
mv-694e07d193e7c5758a7d672b45668651b034003d.tar.xz
mv-694e07d193e7c5758a7d672b45668651b034003d.zip
Convert InputAction enum into strong typed enum.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/actions/actions.cpp4
-rw-r--r--src/actions/commands.cpp2
-rw-r--r--src/actions/move.cpp2
-rw-r--r--src/actions/pets.cpp2
-rw-r--r--src/defaults.cpp32
-rw-r--r--src/enums/input/inputaction.h1158
-rw-r--r--src/events/inputevent.h13
-rw-r--r--src/events/keyevent.h9
-rw-r--r--src/game.cpp13
-rw-r--r--src/game.h4
-rw-r--r--src/gui/buttoninfo.h8
-rw-r--r--src/gui/buttontext.h7
-rw-r--r--src/gui/gui.cpp4
-rw-r--r--src/gui/models/touchactionmodel.cpp8
-rw-r--r--src/gui/models/touchactionmodel.h10
-rw-r--r--src/gui/popups/popupmenu.cpp5
-rw-r--r--src/gui/popups/statuspopup.cpp4
-rw-r--r--src/gui/popups/statuspopup.h5
-rw-r--r--src/gui/sdlinput.cpp4
-rw-r--r--src/gui/setupactiondata.h6
-rw-r--r--src/gui/viewport.cpp16
-rw-r--r--src/gui/widgets/button.cpp4
-rw-r--r--src/gui/widgets/checkbox.cpp2
-rw-r--r--src/gui/widgets/dropdown.cpp2
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/guitable.cpp2
-rw-r--r--src/gui/widgets/inttextfield.cpp2
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/listbox.cpp2
-rw-r--r--src/gui/widgets/radiobutton.cpp2
-rw-r--r--src/gui/widgets/setuptouchitem.cpp8
-rw-r--r--src/gui/widgets/slider.cpp2
-rw-r--r--src/gui/widgets/tabbedarea.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_input.cpp46
-rw-r--r--src/gui/widgets/tabs/setup_input.h12
-rw-r--r--src/gui/widgets/textbox.cpp2
-rw-r--r--src/gui/widgets/textfield.cpp9
-rw-r--r--src/gui/widgets/textfield.h4
-rw-r--r--src/gui/windowmenu.cpp6
-rw-r--r--src/gui/windowmenu.h4
-rw-r--r--src/gui/windows/charcreatedialog.cpp2
-rw-r--r--src/gui/windows/charselectdialog.cpp2
-rw-r--r--src/gui/windows/chatwindow.cpp30
-rw-r--r--src/gui/windows/editserverdialog.cpp8
-rw-r--r--src/gui/windows/inventorywindow.cpp17
-rw-r--r--src/gui/windows/logindialog.cpp8
-rw-r--r--src/gui/windows/outfitwindow.cpp4
-rw-r--r--src/gui/windows/quitdialog.cpp2
-rw-r--r--src/gui/windows/registerdialog.cpp8
-rw-r--r--src/gui/windows/updaterwindow.cpp8
-rw-r--r--src/gui/windows/worldselectdialog.cpp8
-rw-r--r--src/input/inputactiondata.h4
-rw-r--r--src/input/inputactionmap.h9
-rw-r--r--src/input/inputactionoperators.cpp32
-rw-r--r--src/input/inputactionoperators.h31
-rw-r--r--src/input/inputactionsortfunctor.h6
-rw-r--r--src/input/inputmanager.cpp126
-rw-r--r--src/input/inputmanager.h52
-rw-r--r--src/input/joystick.cpp2
-rw-r--r--src/input/joystick.h2
-rw-r--r--src/input/keyboardconfig.cpp14
-rw-r--r--src/input/keyboardconfig.h10
-rw-r--r--src/input/keyinput.h10
-rw-r--r--src/listeners/inputactionreplaylistener.cpp2
-rw-r--r--src/listeners/inputactionreplaylistener.h4
-rw-r--r--src/touchmanager.cpp12
-rw-r--r--src/touchmanager.h14
69 files changed, 1004 insertions, 858 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 55cea4c33..cf2436da1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -905,6 +905,8 @@ SET(SRCS
enums/input/inputaction.h
input/inputactiondata.h
input/inputactionmap.h
+ input/inputactionoperators.cpp
+ input/inputactionoperators.h
input/inputactionsortfunctor.h
input/inputcondition.h
input/inputfunction.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 38a4bb42b..c53304bdb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1041,6 +1041,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
enums/input/inputaction.h \
input/inputactiondata.h \
input/inputactionmap.h \
+ input/inputactionoperators.cpp \
+ input/inputactionoperators.h \
input/inputactionsortfunctor.h \
input/inputcondition.h \
input/inputfunction.h \
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 0b8e8aedc..a3c17cb1d 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -65,6 +65,8 @@
#include "gui/widgets/tabs/chat/chattab.h"
+#include "input/inputactionoperators.h"
+
#if defined USE_OPENGL
#include "render/normalopenglgraphics.h"
#endif
@@ -284,7 +286,7 @@ static int getAmountFromEvent(const InputEvent &event,
impHandler(emote)
{
- const int emotion = 1 + event.action - InputAction::EMOTE_1;
+ const int emotion = 1 + (event.action - InputAction::EMOTE_1);
if (emotion > 0)
{
if (emoteShortcut)
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index 99b09914d..2de80b1f2 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -45,6 +45,8 @@
#include "gui/widgets/tabs/chat/whispertab.h"
+#include "input/inputactionoperators.h"
+
#include "net/adminhandler.h"
#include "net/chathandler.h"
#include "net/guildhandler.h"
diff --git a/src/actions/move.cpp b/src/actions/move.cpp
index d708b1485..29d190ef9 100644
--- a/src/actions/move.cpp
+++ b/src/actions/move.cpp
@@ -36,6 +36,8 @@
#include "gui/popups/popupmenu.h"
+#include "input/inputactionoperators.h"
+
#include "net/playerhandler.h"
#include "debug.h"
diff --git a/src/actions/pets.cpp b/src/actions/pets.cpp
index a6c9a24df..24f0d51c4 100644
--- a/src/actions/pets.cpp
+++ b/src/actions/pets.cpp
@@ -33,6 +33,8 @@
#include "gui/chatconsts.h"
+#include "input/inputactionoperators.h"
+
#include "listeners/inputactionreplaylistener.h"
#include "net/chathandler.h"
diff --git a/src/defaults.cpp b/src/defaults.cpp
index c8ca23f54..dbecffe75 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -326,19 +326,25 @@ DefaultsData* getConfigDefaults()
AddDEF("selfMouseHeal", true);
AddDEF("serverslistupdate", "");
AddDEF("fadeoutmusic", true);
- AddDEF("screenActionKeyboard", InputAction::SHOW_KEYBOARD);
- AddDEF("screenActionButton0", InputAction::TALK);
- AddDEF("screenActionButton1", InputAction::TARGET_ATTACK);
- AddDEF("screenActionButton2", InputAction::PICKUP);
- AddDEF("screenActionButton3", InputAction::STOP_SIT);
- AddDEF("screenActionButton4", InputAction::TARGET_NPC);
- AddDEF("screenActionButton5", InputAction::WINDOW_STATUS);
- AddDEF("screenActionButton6", InputAction::WINDOW_INVENTORY);
- AddDEF("screenActionButton7", InputAction::WINDOW_SKILL);
- AddDEF("screenActionButton8", InputAction::WINDOW_SOCIAL);
- AddDEF("screenActionButton9", InputAction::WINDOW_DEBUG);
- AddDEF("screenActionButton10", InputAction::CHANGE_TRADE);
- AddDEF("screenActionButton11", InputAction::DIRECT_DOWN);
+ AddDEF("screenActionKeyboard", static_cast<int>(
+ InputAction::SHOW_KEYBOARD));
+ AddDEF("screenActionButton0", static_cast<int>(InputAction::TALK));
+ AddDEF("screenActionButton1", static_cast<int>(
+ InputAction::TARGET_ATTACK));
+ AddDEF("screenActionButton2", static_cast<int>(InputAction::PICKUP));
+ AddDEF("screenActionButton3", static_cast<int>(InputAction::STOP_SIT));
+ AddDEF("screenActionButton4", static_cast<int>(InputAction::TARGET_NPC));
+ AddDEF("screenActionButton5", static_cast<int>(
+ InputAction::WINDOW_STATUS));
+ AddDEF("screenActionButton6", static_cast<int>(
+ InputAction::WINDOW_INVENTORY));
+ AddDEF("screenActionButton7", static_cast<int>(InputAction::WINDOW_SKILL));
+ AddDEF("screenActionButton8", static_cast<int>(
+ InputAction::WINDOW_SOCIAL));
+ AddDEF("screenActionButton9", static_cast<int>(InputAction::WINDOW_DEBUG));
+ AddDEF("screenActionButton10", static_cast<int>(
+ InputAction::CHANGE_TRADE));
+ AddDEF("screenActionButton11", static_cast<int>(InputAction::DIRECT_DOWN));
AddDEF("screenButtonsFormat", 0);
AddDEF("autoresizeminimaps", false);
AddDEF("showGuildOnline", false);
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index f398029e7..5032ca2b6 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -20,588 +20,590 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef INPUT_INPUTACTION_H
-#define INPUT_INPUTACTION_H
+#ifndef ENUMS_INPUT_INPUTACTION_H
+#define ENUMS_INPUT_INPUTACTION_H
+
+#include "enums/simpletypes/enumdefines.h"
#ifdef WIN32
#undef ERROR
#undef IGNORE
#endif
-namespace InputAction
+
+/**
+ * All the key functions.
+ * KEY_NO_VALUE is used in initialization, and should be unchanged.
+ * KEY_TOTAL should always be last (used as a conditional in loops).
+ * The key assignment view gets arranged according to the order of
+ * these values.
+ */
+enumStart(InputAction)
{
- /**
- * All the key functions.
- * KEY_NO_VALUE is used in initialization, and should be unchanged.
- * KEY_TOTAL should always be last (used as a conditional in loops).
- * The key assignment view gets arranged according to the order of
- * these values.
- */
- enum Type
- {
- NO_VALUE = -1,
- MOVE_UP,
- MOVE_DOWN,
- MOVE_LEFT,
- MOVE_RIGHT,
- ATTACK,
- TARGET_ATTACK,
- MOVE_TO_TARGET,
- CHANGE_MOVE_TO_TARGET,
- MOVE_TO_HOME,
- SET_HOME,
- MOVE_TO_POINT,
- TALK,
- STOP_ATTACK,
- UNTARGET,
- TARGET_MONSTER,
- TARGET_NPC,
- TARGET_PLAYER,
- PICKUP,
- CHANGE_PICKUP_TYPE,
- HIDE_WINDOWS,
- SIT,
- SCREENSHOT,
- CHANGE_TRADE,
- PATHFIND,
- OK,
- QUIT,
- SHORTCUTS_KEY,
- SHORTCUT_1,
- SHORTCUT_2,
- SHORTCUT_3,
- SHORTCUT_4,
- SHORTCUT_5,
- SHORTCUT_6,
- SHORTCUT_7,
- SHORTCUT_8,
- SHORTCUT_9,
- SHORTCUT_10,
- SHORTCUT_11,
- SHORTCUT_12,
- SHORTCUT_13,
- SHORTCUT_14,
- SHORTCUT_15,
- SHORTCUT_16,
- SHORTCUT_17,
- SHORTCUT_18,
- SHORTCUT_19,
- SHORTCUT_20,
- WINDOW_HELP,
- WINDOW_STATUS,
- WINDOW_INVENTORY,
- WINDOW_EQUIPMENT,
- WINDOW_SKILL,
- WINDOW_MINIMAP,
- WINDOW_CHAT,
- WINDOW_SHORTCUT,
- WINDOW_SETUP,
- WINDOW_DEBUG,
- WINDOW_SOCIAL,
- WINDOW_EMOTE_SHORTCUT,
- WINDOW_OUTFIT,
- WINDOW_SHOP,
- WINDOW_DROP,
- WINDOW_KILLS,
- WINDOW_SPELLS,
- UNUSED1,
- WINDOW_ONLINE,
- WINDOW_DIDYOUKNOW,
- WINDOW_QUESTS,
- PREV_SOCIAL_TAB,
- NEXT_SOCIAL_TAB,
- EMOTE,
- EMOTE_1,
- EMOTE_2,
- EMOTE_3,
- EMOTE_4,
- EMOTE_5,
- EMOTE_6,
- EMOTE_7,
- EMOTE_8,
- EMOTE_9,
- EMOTE_10,
- EMOTE_11,
- EMOTE_12,
- EMOTE_13,
- EMOTE_14,
- EMOTE_15,
- EMOTE_16,
- EMOTE_17,
- EMOTE_18,
- EMOTE_19,
- EMOTE_20,
- EMOTE_21,
- EMOTE_22,
- EMOTE_23,
- EMOTE_24,
- EMOTE_25,
- EMOTE_26,
- EMOTE_27,
- EMOTE_28,
- EMOTE_29,
- EMOTE_30,
- EMOTE_31,
- EMOTE_32,
- EMOTE_33,
- EMOTE_34,
- EMOTE_35,
- EMOTE_36,
- EMOTE_37,
- EMOTE_38,
- EMOTE_39,
- EMOTE_40,
- EMOTE_41,
- EMOTE_42,
- EMOTE_43,
- EMOTE_44,
- EMOTE_45,
- EMOTE_46,
- EMOTE_47,
- EMOTE_48,
- WEAR_OUTFIT,
- COPY_OUTFIT,
- COPY_EQUIPED_OUTFIT,
- OUTFIT_1,
- OUTFIT_2,
- OUTFIT_3,
- OUTFIT_4,
- OUTFIT_5,
- OUTFIT_6,
- OUTFIT_7,
- OUTFIT_8,
- OUTFIT_9,
- OUTFIT_10,
- OUTFIT_11,
- OUTFIT_12,
- OUTFIT_13,
- OUTFIT_14,
- OUTFIT_15,
- OUTFIT_16,
- OUTFIT_17,
- OUTFIT_18,
- OUTFIT_19,
- OUTFIT_20,
- OUTFIT_21,
- OUTFIT_22,
- OUTFIT_23,
- OUTFIT_24,
- OUTFIT_25,
- OUTFIT_26,
- OUTFIT_27,
- OUTFIT_28,
- OUTFIT_29,
- OUTFIT_30,
- OUTFIT_31,
- OUTFIT_32,
- OUTFIT_33,
- OUTFIT_34,
- OUTFIT_35,
- OUTFIT_36,
- OUTFIT_37,
- OUTFIT_38,
- OUTFIT_39,
- OUTFIT_40,
- OUTFIT_41,
- OUTFIT_42,
- OUTFIT_43,
- OUTFIT_44,
- OUTFIT_45,
- OUTFIT_46,
- OUTFIT_47,
- OUTFIT_48,
- MOVE_TO_POINT_1,
- MOVE_TO_POINT_2,
- MOVE_TO_POINT_3,
- MOVE_TO_POINT_4,
- MOVE_TO_POINT_5,
- MOVE_TO_POINT_6,
- MOVE_TO_POINT_7,
- MOVE_TO_POINT_8,
- MOVE_TO_POINT_9,
- MOVE_TO_POINT_10,
- MOVE_TO_POINT_11,
- MOVE_TO_POINT_12,
- MOVE_TO_POINT_13,
- MOVE_TO_POINT_14,
- MOVE_TO_POINT_15,
- MOVE_TO_POINT_16,
- MOVE_TO_POINT_17,
- MOVE_TO_POINT_18,
- MOVE_TO_POINT_19,
- MOVE_TO_POINT_20,
- MOVE_TO_POINT_21,
- MOVE_TO_POINT_22,
- MOVE_TO_POINT_23,
- MOVE_TO_POINT_24,
- MOVE_TO_POINT_25,
- MOVE_TO_POINT_26,
- MOVE_TO_POINT_27,
- MOVE_TO_POINT_28,
- MOVE_TO_POINT_29,
- MOVE_TO_POINT_30,
- MOVE_TO_POINT_31,
- MOVE_TO_POINT_32,
- MOVE_TO_POINT_33,
- MOVE_TO_POINT_34,
- MOVE_TO_POINT_35,
- MOVE_TO_POINT_36,
- MOVE_TO_POINT_37,
- MOVE_TO_POINT_38,
- MOVE_TO_POINT_39,
- MOVE_TO_POINT_40,
- MOVE_TO_POINT_41,
- MOVE_TO_POINT_42,
- MOVE_TO_POINT_43,
- MOVE_TO_POINT_44,
- MOVE_TO_POINT_45,
- MOVE_TO_POINT_46,
- MOVE_TO_POINT_47,
- MOVE_TO_POINT_48,
- TOGGLE_CHAT,
- SCROLL_CHAT_UP,
- SCROLL_CHAT_DOWN,
- PREV_CHAT_TAB,
- NEXT_CHAT_TAB,
- CLOSE_CHAT_TAB,
- CHAT_PREV_HISTORY,
- CHAT_NEXT_HISTORY,
- IGNORE_INPUT_1,
- IGNORE_INPUT_2,
- DIRECT_UP,
- DIRECT_DOWN,
- DIRECT_LEFT,
- DIRECT_RIGHT,
- CRAZY_MOVES,
- CHANGE_CRAZY_MOVES_TYPE,
- QUICK_DROP,
- QUICK_DROPN,
- SWITCH_QUICK_DROP,
- MAGIC_INMA1,
- MAGIC_ITENPLZ,
- MAGIC_ATTACK,
- SWITCH_MAGIC_ATTACK,
- SWITCH_PVP_ATTACK,
- INVERT_DIRECTION,
- CHANGE_ATTACK_WEAPON_TYPE,
- CHANGE_ATTACK_TYPE,
- CHANGE_FOLLOW_MODE,
- CHANGE_IMITATION_MODE,
- DISABLE_GAME_MODIFIERS,
- CHANGE_AUDIO,
- AWAY,
- RIGHT_CLICK,
- CAMERA,
- RESERVED1,
- GUI_UP,
- GUI_DOWN,
- GUI_LEFT,
- GUI_RIGHT,
- GUI_SELECT,
- GUI_SELECT2,
- GUI_CANCEL,
- GUI_HOME,
- GUI_END,
- GUI_DELETE,
- GUI_BACKSPACE,
- GUI_TAB,
- GUI_PAGE_UP,
- GUI_PAGE_DOWN,
- GUI_INSERT,
- GUI_MOD,
- SAFE_VIDEO,
- STOP_SIT,
- SHOW_KEYBOARD,
- SHOW_WINDOWS,
- CHAT_MOD,
- MOVE_FORWARD,
- GUI_CTRL,
- GUI_B,
- GUI_C,
- GUI_D,
- GUI_E,
- GUI_F,
- GUI_H,
- GUI_K,
- GUI_U,
- GUI_V,
- GUI_W,
- PREV_SHORTCUTS_TAB,
- NEXT_SHORTCUTS_TAB,
- PREV_COMMANDS_TAB,
- NEXT_COMMANDS_TAB,
- OPEN_TRADE,
- GUI_F1,
- GUI_F2,
- GUI_F3,
- GUI_F4,
- GUI_F5,
- GUI_F6,
- GUI_F7,
- GUI_F8,
- GUI_F9,
- GUI_F10,
- GUI_F11,
- GUI_F12,
- WINDOW_ABOUT,
- WINDOW_UPDATER,
- TARGET_CLOSEST_MONSTER,
- CLOSE_ALL_CHAT_TABS,
- IGNORE_ALL_WHISPERS,
- CHAT_ANNOUNCE,
- IPC_TOGGLE,
- WHERE,
- WHO,
- WHISPER,
- QUERY,
- CLEAR_CHAT_TAB,
- IGNORE,
- UNIGNORE,
- FRIEND,
- DISREGARD,
- NEUTRAL,
- BLACKLIST,
- ENEMY,
- ERASE,
- CLEAN_GRAPHICS,
- CLEAN_FONTS,
- CREATE_PARTY,
- CREATE_GUILD,
- PARTY,
- ME,
- TOGGLE,
- PRESENT,
- PRINT_ALL,
- MOVE,
- TARGET,
- ATTACK_HUMAN,
- COMMAMD_OUTFIT,
- COMMAMD_EMOTE,
- COMMAND_EMOTE_PET,
- AWAY_MESSAGE,
- PSEUDO_AWAY,
- FOLLOW,
- NAVIGATE,
- IMITATION,
- SEND_MAIL,
- TRADE,
- PRICE_LOAD,
- PRICE_SAVE,
- CACHE_INFO,
- DISCONNECT,
- UNDRESS,
- DIRS,
- INFO,
- WAIT,
- UPTIME,
- ADD_PRIORITY_ATTACK,
- ADD_ATTACK,
- REMOVE_ATTACK,
- ADD_IGNORE_ATTACK,
- DUMP,
- SERVER_IGNORE_ALL,
- SERVER_UNIGNORE_ALL,
- SET_DROP,
- ERROR,
- DUMP_GRAPHICS,
- DUMP_ENVIRONMENT,
- DUMP_TESTS,
- DUMP_OGL,
- DUMP_GL,
- DUMP_MODS,
- URL,
- OPEN_URL,
- EXECUTE,
- TEST_SDL_FONT,
- ENABLE_HIGHLIGHT,
- DISABLE_HIGHLIGHT,
- DONT_REMOVE_NAME,
- REMOVE_NAME,
- DISABLE_AWAY,
- ENABLE_AWAY,
- TEST_PARTICLE,
- CREATE_ITEMS,
- TALK_RAW,
- TALK_PET,
- UPLOAD_CONFIG,
- UPLOAD_SERVER_CONFIG,
- UPLOAD_LOG,
- GM,
- HACK,
- DEBUG_SPAWN,
- PET_EMOTE,
- PET_EMOTE_1,
- PET_EMOTE_2,
- PET_EMOTE_3,
- PET_EMOTE_4,
- PET_EMOTE_5,
- PET_EMOTE_6,
- PET_EMOTE_7,
- PET_EMOTE_8,
- PET_EMOTE_9,
- PET_EMOTE_10,
- PET_EMOTE_11,
- PET_EMOTE_12,
- PET_EMOTE_13,
- PET_EMOTE_14,
- PET_EMOTE_15,
- PET_EMOTE_16,
- PET_EMOTE_17,
- PET_EMOTE_18,
- PET_EMOTE_19,
- PET_EMOTE_20,
- PET_EMOTE_21,
- PET_EMOTE_22,
- PET_EMOTE_23,
- PET_EMOTE_24,
- PET_EMOTE_25,
- PET_EMOTE_26,
- PET_EMOTE_27,
- PET_EMOTE_28,
- PET_EMOTE_29,
- PET_EMOTE_30,
- PET_EMOTE_31,
- PET_EMOTE_32,
- PET_EMOTE_33,
- PET_EMOTE_34,
- PET_EMOTE_35,
- PET_EMOTE_36,
- PET_EMOTE_37,
- PET_EMOTE_38,
- PET_EMOTE_39,
- PET_EMOTE_40,
- PET_EMOTE_41,
- PET_EMOTE_42,
- PET_EMOTE_43,
- PET_EMOTE_44,
- PET_EMOTE_45,
- PET_EMOTE_46,
- PET_EMOTE_47,
- PET_EMOTE_48,
- CATCH_PET,
- IGNORE_WHISPER,
- UNIGNORE_WHISPER,
- MERCENARY_FIRE,
- TARGET_MERCENARY,
- TARGET_PET,
- PET_SET_NAME,
- HOMUNCULUS_SET_NAME,
- HOMUNCULUS_FIRE,
- WINDOW_BANK,
- PREV_INV_TAB,
- NEXT_INV_TAB,
- CONTEXT_MENU,
- BUY,
- SELL,
- WHISPER2,
- GUILD,
- NUKE,
- USE,
- CHAT_ADD,
- WHISPER_TEXT,
- NAVIGATE_TO,
- CAMERA_MOVE,
- DROP_ITEM,
- DROP_ITEM_ALL,
- DROP_INV,
- DROP_INV_ALL,
- USE_INV,
- INV_TO_STORAGE,
- TRADE_ADD,
- STORAGE_TO_INV,
- ITEM_PROTECT,
- ITEM_UNPROTECT,
- KICK_PARTY,
- ADD_TEXT,
- KICK,
- LEAVE_PARTY,
- WARP,
- CLEAR_CHAT,
- PET_MOVE_UP,
- PET_MOVE_DOWN,
- PET_MOVE_LEFT,
- PET_MOVE_RIGHT,
- PET_DIRECT_UP,
- PET_DIRECT_DOWN,
- PET_DIRECT_LEFT,
- PET_DIRECT_RIGHT,
- PET_AI_START,
- PET_AI_STOP,
- CHAT_GENERAL_TAB,
- CHAT_DEBUG_TAB,
- CHAT_BATTLE_TAB,
- CHAT_TRADE_TAB,
- CHAT_LANG_TAB,
- CHAT_GM_TAB,
- CHAT_PARTY_TAB,
- CHAT_GUILD_TAB,
- DROP_CLEAR,
- WINDOW_CART,
- HEAL_MOST_DAMAGED,
- PET_MOVE,
- HOMUN_TALK,
- HOMUN_SMILE,
- HOMUN_EMOTE,
- HOMUN_EMOTE_1,
- HOMUN_EMOTE_2,
- HOMUN_EMOTE_3,
- HOMUN_EMOTE_4,
- HOMUN_EMOTE_5,
- HOMUN_EMOTE_6,
- HOMUN_EMOTE_7,
- HOMUN_EMOTE_8,
- HOMUN_EMOTE_9,
- HOMUN_EMOTE_10,
- HOMUN_EMOTE_11,
- HOMUN_EMOTE_12,
- HOMUN_EMOTE_13,
- HOMUN_EMOTE_14,
- HOMUN_EMOTE_15,
- HOMUN_EMOTE_16,
- HOMUN_EMOTE_17,
- HOMUN_EMOTE_18,
- HOMUN_EMOTE_19,
- HOMUN_EMOTE_20,
- HOMUN_EMOTE_21,
- HOMUN_EMOTE_22,
- HOMUN_EMOTE_23,
- HOMUN_EMOTE_24,
- HOMUN_EMOTE_25,
- HOMUN_EMOTE_26,
- HOMUN_EMOTE_27,
- HOMUN_EMOTE_28,
- HOMUN_EMOTE_29,
- HOMUN_EMOTE_30,
- HOMUN_EMOTE_31,
- HOMUN_EMOTE_32,
- HOMUN_EMOTE_33,
- HOMUN_EMOTE_34,
- HOMUN_EMOTE_35,
- HOMUN_EMOTE_36,
- HOMUN_EMOTE_37,
- HOMUN_EMOTE_38,
- HOMUN_EMOTE_39,
- HOMUN_EMOTE_40,
- HOMUN_EMOTE_41,
- HOMUN_EMOTE_42,
- HOMUN_EMOTE_43,
- HOMUN_EMOTE_44,
- HOMUN_EMOTE_45,
- HOMUN_EMOTE_46,
- HOMUN_EMOTE_47,
- HOMUN_EMOTE_48,
- KICK_GUILD,
- HAT,
- CREATE_PUBLIC_ROOM,
- JOIN_ROOM,
- LEAVE_ROOM,
- WINDOW_QUICK_SETTINGS,
- WINDOW_MAIL,
- CONF_SET,
- SERVER_CONF_SET,
- CONG_GET,
- SERVER_CONG_GET,
- TOTAL
- };
-} // namespace InputAction
+ UNDEFINED_VALUE = -2,
+ NO_VALUE = -1,
+ MOVE_UP,
+ MOVE_DOWN,
+ MOVE_LEFT,
+ MOVE_RIGHT,
+ ATTACK,
+ TARGET_ATTACK,
+ MOVE_TO_TARGET,
+ CHANGE_MOVE_TO_TARGET,
+ MOVE_TO_HOME,
+ SET_HOME,
+ MOVE_TO_POINT,
+ TALK,
+ STOP_ATTACK,
+ UNTARGET,
+ TARGET_MONSTER,
+ TARGET_NPC,
+ TARGET_PLAYER,
+ PICKUP,
+ CHANGE_PICKUP_TYPE,
+ HIDE_WINDOWS,
+ SIT,
+ SCREENSHOT,
+ CHANGE_TRADE,
+ PATHFIND,
+ OK,
+ QUIT,
+ SHORTCUTS_KEY,
+ SHORTCUT_1,
+ SHORTCUT_2,
+ SHORTCUT_3,
+ SHORTCUT_4,
+ SHORTCUT_5,
+ SHORTCUT_6,
+ SHORTCUT_7,
+ SHORTCUT_8,
+ SHORTCUT_9,
+ SHORTCUT_10,
+ SHORTCUT_11,
+ SHORTCUT_12,
+ SHORTCUT_13,
+ SHORTCUT_14,
+ SHORTCUT_15,
+ SHORTCUT_16,
+ SHORTCUT_17,
+ SHORTCUT_18,
+ SHORTCUT_19,
+ SHORTCUT_20,
+ WINDOW_HELP,
+ WINDOW_STATUS,
+ WINDOW_INVENTORY,
+ WINDOW_EQUIPMENT,
+ WINDOW_SKILL,
+ WINDOW_MINIMAP,
+ WINDOW_CHAT,
+ WINDOW_SHORTCUT,
+ WINDOW_SETUP,
+ WINDOW_DEBUG,
+ WINDOW_SOCIAL,
+ WINDOW_EMOTE_SHORTCUT,
+ WINDOW_OUTFIT,
+ WINDOW_SHOP,
+ WINDOW_DROP,
+ WINDOW_KILLS,
+ WINDOW_SPELLS,
+ UNUSED1,
+ WINDOW_ONLINE,
+ WINDOW_DIDYOUKNOW,
+ WINDOW_QUESTS,
+ PREV_SOCIAL_TAB,
+ NEXT_SOCIAL_TAB,
+ EMOTE,
+ EMOTE_1,
+ EMOTE_2,
+ EMOTE_3,
+ EMOTE_4,
+ EMOTE_5,
+ EMOTE_6,
+ EMOTE_7,
+ EMOTE_8,
+ EMOTE_9,
+ EMOTE_10,
+ EMOTE_11,
+ EMOTE_12,
+ EMOTE_13,
+ EMOTE_14,
+ EMOTE_15,
+ EMOTE_16,
+ EMOTE_17,
+ EMOTE_18,
+ EMOTE_19,
+ EMOTE_20,
+ EMOTE_21,
+ EMOTE_22,
+ EMOTE_23,
+ EMOTE_24,
+ EMOTE_25,
+ EMOTE_26,
+ EMOTE_27,
+ EMOTE_28,
+ EMOTE_29,
+ EMOTE_30,
+ EMOTE_31,
+ EMOTE_32,
+ EMOTE_33,
+ EMOTE_34,
+ EMOTE_35,
+ EMOTE_36,
+ EMOTE_37,
+ EMOTE_38,
+ EMOTE_39,
+ EMOTE_40,
+ EMOTE_41,
+ EMOTE_42,
+ EMOTE_43,
+ EMOTE_44,
+ EMOTE_45,
+ EMOTE_46,
+ EMOTE_47,
+ EMOTE_48,
+ WEAR_OUTFIT,
+ COPY_OUTFIT,
+ COPY_EQUIPED_OUTFIT,
+ OUTFIT_1,
+ OUTFIT_2,
+ OUTFIT_3,
+ OUTFIT_4,
+ OUTFIT_5,
+ OUTFIT_6,
+ OUTFIT_7,
+ OUTFIT_8,
+ OUTFIT_9,
+ OUTFIT_10,
+ OUTFIT_11,
+ OUTFIT_12,
+ OUTFIT_13,
+ OUTFIT_14,
+ OUTFIT_15,
+ OUTFIT_16,
+ OUTFIT_17,
+ OUTFIT_18,
+ OUTFIT_19,
+ OUTFIT_20,
+ OUTFIT_21,
+ OUTFIT_22,
+ OUTFIT_23,
+ OUTFIT_24,
+ OUTFIT_25,
+ OUTFIT_26,
+ OUTFIT_27,
+ OUTFIT_28,
+ OUTFIT_29,
+ OUTFIT_30,
+ OUTFIT_31,
+ OUTFIT_32,
+ OUTFIT_33,
+ OUTFIT_34,
+ OUTFIT_35,
+ OUTFIT_36,
+ OUTFIT_37,
+ OUTFIT_38,
+ OUTFIT_39,
+ OUTFIT_40,
+ OUTFIT_41,
+ OUTFIT_42,
+ OUTFIT_43,
+ OUTFIT_44,
+ OUTFIT_45,
+ OUTFIT_46,
+ OUTFIT_47,
+ OUTFIT_48,
+ MOVE_TO_POINT_1,
+ MOVE_TO_POINT_2,
+ MOVE_TO_POINT_3,
+ MOVE_TO_POINT_4,
+ MOVE_TO_POINT_5,
+ MOVE_TO_POINT_6,
+ MOVE_TO_POINT_7,
+ MOVE_TO_POINT_8,
+ MOVE_TO_POINT_9,
+ MOVE_TO_POINT_10,
+ MOVE_TO_POINT_11,
+ MOVE_TO_POINT_12,
+ MOVE_TO_POINT_13,
+ MOVE_TO_POINT_14,
+ MOVE_TO_POINT_15,
+ MOVE_TO_POINT_16,
+ MOVE_TO_POINT_17,
+ MOVE_TO_POINT_18,
+ MOVE_TO_POINT_19,
+ MOVE_TO_POINT_20,
+ MOVE_TO_POINT_21,
+ MOVE_TO_POINT_22,
+ MOVE_TO_POINT_23,
+ MOVE_TO_POINT_24,
+ MOVE_TO_POINT_25,
+ MOVE_TO_POINT_26,
+ MOVE_TO_POINT_27,
+ MOVE_TO_POINT_28,
+ MOVE_TO_POINT_29,
+ MOVE_TO_POINT_30,
+ MOVE_TO_POINT_31,
+ MOVE_TO_POINT_32,
+ MOVE_TO_POINT_33,
+ MOVE_TO_POINT_34,
+ MOVE_TO_POINT_35,
+ MOVE_TO_POINT_36,
+ MOVE_TO_POINT_37,
+ MOVE_TO_POINT_38,
+ MOVE_TO_POINT_39,
+ MOVE_TO_POINT_40,
+ MOVE_TO_POINT_41,
+ MOVE_TO_POINT_42,
+ MOVE_TO_POINT_43,
+ MOVE_TO_POINT_44,
+ MOVE_TO_POINT_45,
+ MOVE_TO_POINT_46,
+ MOVE_TO_POINT_47,
+ MOVE_TO_POINT_48,
+ TOGGLE_CHAT,
+ SCROLL_CHAT_UP,
+ SCROLL_CHAT_DOWN,
+ PREV_CHAT_TAB,
+ NEXT_CHAT_TAB,
+ CLOSE_CHAT_TAB,
+ CHAT_PREV_HISTORY,
+ CHAT_NEXT_HISTORY,
+ IGNORE_INPUT_1,
+ IGNORE_INPUT_2,
+ DIRECT_UP,
+ DIRECT_DOWN,
+ DIRECT_LEFT,
+ DIRECT_RIGHT,
+ CRAZY_MOVES,
+ CHANGE_CRAZY_MOVES_TYPE,
+ QUICK_DROP,
+ QUICK_DROPN,
+ SWITCH_QUICK_DROP,
+ MAGIC_INMA1,
+ MAGIC_ITENPLZ,
+ MAGIC_ATTACK,
+ SWITCH_MAGIC_ATTACK,
+ SWITCH_PVP_ATTACK,
+ INVERT_DIRECTION,
+ CHANGE_ATTACK_WEAPON_TYPE,
+ CHANGE_ATTACK_TYPE,
+ CHANGE_FOLLOW_MODE,
+ CHANGE_IMITATION_MODE,
+ DISABLE_GAME_MODIFIERS,
+ CHANGE_AUDIO,
+ AWAY,
+ RIGHT_CLICK,
+ CAMERA,
+ RESERVED1,
+ GUI_UP,
+ GUI_DOWN,
+ GUI_LEFT,
+ GUI_RIGHT,
+ GUI_SELECT,
+ GUI_SELECT2,
+ GUI_CANCEL,
+ GUI_HOME,
+ GUI_END,
+ GUI_DELETE,
+ GUI_BACKSPACE,
+ GUI_TAB,
+ GUI_PAGE_UP,
+ GUI_PAGE_DOWN,
+ GUI_INSERT,
+ GUI_MOD,
+ SAFE_VIDEO,
+ STOP_SIT,
+ SHOW_KEYBOARD,
+ SHOW_WINDOWS,
+ CHAT_MOD,
+ MOVE_FORWARD,
+ GUI_CTRL,
+ GUI_B,
+ GUI_C,
+ GUI_D,
+ GUI_E,
+ GUI_F,
+ GUI_H,
+ GUI_K,
+ GUI_U,
+ GUI_V,
+ GUI_W,
+ PREV_SHORTCUTS_TAB,
+ NEXT_SHORTCUTS_TAB,
+ PREV_COMMANDS_TAB,
+ NEXT_COMMANDS_TAB,
+ OPEN_TRADE,
+ GUI_F1,
+ GUI_F2,
+ GUI_F3,
+ GUI_F4,
+ GUI_F5,
+ GUI_F6,
+ GUI_F7,
+ GUI_F8,
+ GUI_F9,
+ GUI_F10,
+ GUI_F11,
+ GUI_F12,
+ WINDOW_ABOUT,
+ WINDOW_UPDATER,
+ TARGET_CLOSEST_MONSTER,
+ CLOSE_ALL_CHAT_TABS,
+ IGNORE_ALL_WHISPERS,
+ CHAT_ANNOUNCE,
+ IPC_TOGGLE,
+ WHERE,
+ WHO,
+ WHISPER,
+ QUERY,
+ CLEAR_CHAT_TAB,
+ IGNORE,
+ UNIGNORE,
+ FRIEND,
+ DISREGARD,
+ NEUTRAL,
+ BLACKLIST,
+ ENEMY,
+ ERASE,
+ CLEAN_GRAPHICS,
+ CLEAN_FONTS,
+ CREATE_PARTY,
+ CREATE_GUILD,
+ PARTY,
+ ME,
+ TOGGLE,
+ PRESENT,
+ PRINT_ALL,
+ MOVE,
+ TARGET,
+ ATTACK_HUMAN,
+ COMMAMD_OUTFIT,
+ COMMAMD_EMOTE,
+ COMMAND_EMOTE_PET,
+ AWAY_MESSAGE,
+ PSEUDO_AWAY,
+ FOLLOW,
+ NAVIGATE,
+ IMITATION,
+ SEND_MAIL,
+ TRADE,
+ PRICE_LOAD,
+ PRICE_SAVE,
+ CACHE_INFO,
+ DISCONNECT,
+ UNDRESS,
+ DIRS,
+ INFO,
+ WAIT,
+ UPTIME,
+ ADD_PRIORITY_ATTACK,
+ ADD_ATTACK,
+ REMOVE_ATTACK,
+ ADD_IGNORE_ATTACK,
+ DUMP,
+ SERVER_IGNORE_ALL,
+ SERVER_UNIGNORE_ALL,
+ SET_DROP,
+ ERROR,
+ DUMP_GRAPHICS,
+ DUMP_ENVIRONMENT,
+ DUMP_TESTS,
+ DUMP_OGL,
+ DUMP_GL,
+ DUMP_MODS,
+ URL,
+ OPEN_URL,
+ EXECUTE,
+ TEST_SDL_FONT,
+ ENABLE_HIGHLIGHT,
+ DISABLE_HIGHLIGHT,
+ DONT_REMOVE_NAME,
+ REMOVE_NAME,
+ DISABLE_AWAY,
+ ENABLE_AWAY,
+ TEST_PARTICLE,
+ CREATE_ITEMS,
+ TALK_RAW,
+ TALK_PET,
+ UPLOAD_CONFIG,
+ UPLOAD_SERVER_CONFIG,
+ UPLOAD_LOG,
+ GM,
+ HACK,
+ DEBUG_SPAWN,
+ PET_EMOTE,
+ PET_EMOTE_1,
+ PET_EMOTE_2,
+ PET_EMOTE_3,
+ PET_EMOTE_4,
+ PET_EMOTE_5,
+ PET_EMOTE_6,
+ PET_EMOTE_7,
+ PET_EMOTE_8,
+ PET_EMOTE_9,
+ PET_EMOTE_10,
+ PET_EMOTE_11,
+ PET_EMOTE_12,
+ PET_EMOTE_13,
+ PET_EMOTE_14,
+ PET_EMOTE_15,
+ PET_EMOTE_16,
+ PET_EMOTE_17,
+ PET_EMOTE_18,
+ PET_EMOTE_19,
+ PET_EMOTE_20,
+ PET_EMOTE_21,
+ PET_EMOTE_22,
+ PET_EMOTE_23,
+ PET_EMOTE_24,
+ PET_EMOTE_25,
+ PET_EMOTE_26,
+ PET_EMOTE_27,
+ PET_EMOTE_28,
+ PET_EMOTE_29,
+ PET_EMOTE_30,
+ PET_EMOTE_31,
+ PET_EMOTE_32,
+ PET_EMOTE_33,
+ PET_EMOTE_34,
+ PET_EMOTE_35,
+ PET_EMOTE_36,
+ PET_EMOTE_37,
+ PET_EMOTE_38,
+ PET_EMOTE_39,
+ PET_EMOTE_40,
+ PET_EMOTE_41,
+ PET_EMOTE_42,
+ PET_EMOTE_43,
+ PET_EMOTE_44,
+ PET_EMOTE_45,
+ PET_EMOTE_46,
+ PET_EMOTE_47,
+ PET_EMOTE_48,
+ CATCH_PET,
+ IGNORE_WHISPER,
+ UNIGNORE_WHISPER,
+ MERCENARY_FIRE,
+ TARGET_MERCENARY,
+ TARGET_PET,
+ PET_SET_NAME,
+ HOMUNCULUS_SET_NAME,
+ HOMUNCULUS_FIRE,
+ WINDOW_BANK,
+ PREV_INV_TAB,
+ NEXT_INV_TAB,
+ CONTEXT_MENU,
+ BUY,
+ SELL,
+ WHISPER2,
+ GUILD,
+ NUKE,
+ USE,
+ CHAT_ADD,
+ WHISPER_TEXT,
+ NAVIGATE_TO,
+ CAMERA_MOVE,
+ DROP_ITEM,
+ DROP_ITEM_ALL,
+ DROP_INV,
+ DROP_INV_ALL,
+ USE_INV,
+ INV_TO_STORAGE,
+ TRADE_ADD,
+ STORAGE_TO_INV,
+ ITEM_PROTECT,
+ ITEM_UNPROTECT,
+ KICK_PARTY,
+ ADD_TEXT,
+ KICK,
+ LEAVE_PARTY,
+ WARP,
+ CLEAR_CHAT,
+ PET_MOVE_UP,
+ PET_MOVE_DOWN,
+ PET_MOVE_LEFT,
+ PET_MOVE_RIGHT,
+ PET_DIRECT_UP,
+ PET_DIRECT_DOWN,
+ PET_DIRECT_LEFT,
+ PET_DIRECT_RIGHT,
+ PET_AI_START,
+ PET_AI_STOP,
+ CHAT_GENERAL_TAB,
+ CHAT_DEBUG_TAB,
+ CHAT_BATTLE_TAB,
+ CHAT_TRADE_TAB,
+ CHAT_LANG_TAB,
+ CHAT_GM_TAB,
+ CHAT_PARTY_TAB,
+ CHAT_GUILD_TAB,
+ DROP_CLEAR,
+ WINDOW_CART,
+ HEAL_MOST_DAMAGED,
+ PET_MOVE,
+ HOMUN_TALK,
+ HOMUN_SMILE,
+ HOMUN_EMOTE,
+ HOMUN_EMOTE_1,
+ HOMUN_EMOTE_2,
+ HOMUN_EMOTE_3,
+ HOMUN_EMOTE_4,
+ HOMUN_EMOTE_5,
+ HOMUN_EMOTE_6,
+ HOMUN_EMOTE_7,
+ HOMUN_EMOTE_8,
+ HOMUN_EMOTE_9,
+ HOMUN_EMOTE_10,
+ HOMUN_EMOTE_11,
+ HOMUN_EMOTE_12,
+ HOMUN_EMOTE_13,
+ HOMUN_EMOTE_14,
+ HOMUN_EMOTE_15,
+ HOMUN_EMOTE_16,
+ HOMUN_EMOTE_17,
+ HOMUN_EMOTE_18,
+ HOMUN_EMOTE_19,
+ HOMUN_EMOTE_20,
+ HOMUN_EMOTE_21,
+ HOMUN_EMOTE_22,
+ HOMUN_EMOTE_23,
+ HOMUN_EMOTE_24,
+ HOMUN_EMOTE_25,
+ HOMUN_EMOTE_26,
+ HOMUN_EMOTE_27,
+ HOMUN_EMOTE_28,
+ HOMUN_EMOTE_29,
+ HOMUN_EMOTE_30,
+ HOMUN_EMOTE_31,
+ HOMUN_EMOTE_32,
+ HOMUN_EMOTE_33,
+ HOMUN_EMOTE_34,
+ HOMUN_EMOTE_35,
+ HOMUN_EMOTE_36,
+ HOMUN_EMOTE_37,
+ HOMUN_EMOTE_38,
+ HOMUN_EMOTE_39,
+ HOMUN_EMOTE_40,
+ HOMUN_EMOTE_41,
+ HOMUN_EMOTE_42,
+ HOMUN_EMOTE_43,
+ HOMUN_EMOTE_44,
+ HOMUN_EMOTE_45,
+ HOMUN_EMOTE_46,
+ HOMUN_EMOTE_47,
+ HOMUN_EMOTE_48,
+ KICK_GUILD,
+ HAT,
+ CREATE_PUBLIC_ROOM,
+ JOIN_ROOM,
+ LEAVE_ROOM,
+ WINDOW_QUICK_SETTINGS,
+ WINDOW_MAIL,
+ CONF_SET,
+ SERVER_CONF_SET,
+ CONG_GET,
+ SERVER_CONG_GET,
+ TOTAL
+}
+enumEnd(InputAction);
-#endif // INPUT_INPUTACTION_H
+#endif // ENUMS_INPUT_INPUTACTION_H
diff --git a/src/events/inputevent.h b/src/events/inputevent.h
index 129e4d716..2eb615bb0 100644
--- a/src/events/inputevent.h
+++ b/src/events/inputevent.h
@@ -21,6 +21,8 @@
#ifndef EVENTS_INPUTEVENT_H
#define EVENTS_INPUTEVENT_H
+#include "enums/input/inputaction.h"
+
#include <map>
#include <string>
#include <vector>
@@ -29,14 +31,14 @@
class ChatTab;
-typedef std::vector<int> KeysVector;
+typedef std::vector<InputActionT> KeysVector;
typedef KeysVector::iterator KeysVectorIter;
typedef KeysVector::const_iterator KeysVectorCIter;
typedef std::map<int, KeysVector> KeyToActionMap;
typedef KeyToActionMap::iterator KeyToActionMapIter;
-typedef std::map<int, int> KeyToIdMap;
+typedef std::map<int, InputActionT> KeyToIdMap;
typedef KeyToIdMap::iterator KeyToIdMapIter;
typedef std::map<int, int> KeyTimeMap;
@@ -44,7 +46,8 @@ typedef KeyTimeMap::iterator KeyTimeMapIter;
struct InputEvent final
{
- InputEvent(const int action0, const int mask0) :
+ InputEvent(const InputActionT action0,
+ const int mask0) :
args(),
tab(nullptr),
action(action0),
@@ -56,7 +59,7 @@ struct InputEvent final
const int mask0) :
args(args0),
tab(tab0),
- action(-1),
+ action(InputAction::NO_VALUE),
mask(mask0)
{ }
@@ -64,7 +67,7 @@ struct InputEvent final
const std::string args;
ChatTab *const tab;
- const int action;
+ const InputActionT action;
const int mask;
};
diff --git a/src/events/keyevent.h b/src/events/keyevent.h
index 9f0a54972..d7b5b71b0 100644
--- a/src/events/keyevent.h
+++ b/src/events/keyevent.h
@@ -65,6 +65,9 @@
#define EVENTS_KEYEVENT_H
#include "enums/events/keyeventtype.h"
+
+#include "enums/input/inputaction.h"
+
#include "events/inputguievent.h"
#include "input/key.h"
@@ -89,7 +92,7 @@ class KeyEvent: public InputGuiEvent
*/
KeyEvent(Widget *const source,
KeyEventTypeT type,
- const int actionId,
+ const InputActionT actionId,
const Key &key) :
InputGuiEvent(source),
mKey(key),
@@ -122,7 +125,7 @@ class KeyEvent: public InputGuiEvent
const Key &getKey() const A_WARN_UNUSED
{ return mKey; }
- int getActionId() const A_WARN_UNUSED
+ InputActionT getActionId() const A_WARN_UNUSED
{ return mActionId; }
#ifdef USE_SDL2
@@ -148,7 +151,7 @@ class KeyEvent: public InputGuiEvent
*/
KeyEventTypeT mType;
- int mActionId;
+ InputActionT mActionId;
};
#endif // EVENTS_KEYEVENT_H
diff --git a/src/game.cpp b/src/game.cpp
index 88d38f1a4..5ffc461f5 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1129,7 +1129,7 @@ void Game::updateHistory(const SDL_Event &event)
{
bool old = false;
- const int key = keyboard.getKeyIndex(event);
+ const InputActionT key = keyboard.getKeyIndex(event);
const int time = cur_time;
int idx = -1;
for (int f = 0; f < MAX_LASTKEYS; f ++)
@@ -1152,8 +1152,11 @@ void Game::updateHistory(const SDL_Event &event)
for (int f = 0; f < MAX_LASTKEYS; f ++)
{
LastKey &lastKey = mLastKeys[f];
- if (lastKey.key == -1 || lastKey.time < mLastKeys[idx].time)
+ if (lastKey.key == InputAction::NO_VALUE ||
+ lastKey.time < mLastKeys[idx].time)
+ {
idx = f;
+ }
}
}
@@ -1186,13 +1189,13 @@ void Game::checkKeys()
for (int f = 0; f < MAX_LASTKEYS; f ++)
{
LastKey &lastKey = mLastKeys[f];
- if (lastKey.key != -1)
+ if (lastKey.key != InputAction::NO_VALUE)
{
if (lastKey.time + timeRange < time)
{
if (lastKey.cnt > cntInTime)
mValidSpeed = false;
- lastKey.key = -1;
+ lastKey.key = InputAction::NO_VALUE;
}
}
}
@@ -1209,7 +1212,7 @@ void Game::clearKeysArray()
for (int f = 0; f < MAX_LASTKEYS; f ++)
{
mLastKeys[f].time = 0;
- mLastKeys[f].key = -1;
+ mLastKeys[f].key = InputAction::NO_VALUE;
mLastKeys[f].cnt = 0;
}
}
diff --git a/src/game.h b/src/game.h
index e7326c442..e491a6944 100644
--- a/src/game.h
+++ b/src/game.h
@@ -23,6 +23,8 @@
#ifndef GAME_H
#define GAME_H
+#include "enums/input/inputaction.h"
+
#include <string>
#include "localconsts.h"
@@ -37,7 +39,7 @@ class Map;
struct LastKey final
{
- int key;
+ InputActionT key;
int time;
int cnt;
};
diff --git a/src/gui/buttoninfo.h b/src/gui/buttoninfo.h
index a6c7eb9e0..15f0c3052 100644
--- a/src/gui/buttoninfo.h
+++ b/src/gui/buttoninfo.h
@@ -21,6 +21,8 @@
#ifndef GUI_BUTTONINFO_H
#define GUI_BUTTONINFO_H
+#include "enums/input/inputaction.h"
+
#include "enums/simpletypes/visible.h"
#include "localconsts.h"
@@ -29,7 +31,9 @@ class Button;
struct ButtonInfo final
{
- ButtonInfo(Button *const button0, const int key0, const Visible visible0) :
+ ButtonInfo(Button *const button0,
+ const InputActionT key0,
+ const Visible visible0) :
button(button0),
key(key0),
visible(visible0)
@@ -39,7 +43,7 @@ struct ButtonInfo final
A_DELETE_COPY(ButtonInfo)
Button *button;
- int key;
+ InputActionT key;
Visible visible;
};
#endif // GUI_BUTTONINFO_H
diff --git a/src/gui/buttontext.h b/src/gui/buttontext.h
index d2c5a2d39..50df128dd 100644
--- a/src/gui/buttontext.h
+++ b/src/gui/buttontext.h
@@ -21,13 +21,16 @@
#ifndef GUI_BUTTONTEXT_H
#define GUI_BUTTONTEXT_H
+#include "enums/input/inputaction.h"
+
#include "localconsts.h"
#include <string>
struct ButtonText final
{
- ButtonText(const std::string &text0, const int key0) :
+ ButtonText(const std::string &text0,
+ const InputActionT key0) :
text(text0),
key(key0)
{
@@ -36,7 +39,7 @@ struct ButtonText final
A_DELETE_COPY(ButtonText)
std::string text;
- int key;
+ InputActionT key;
};
#endif // GUI_BUTTONTEXT_H
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index f978fc091..ac61261d3 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -437,8 +437,8 @@ bool Gui::handleKeyInput()
// tabbing is enable check for tab press and
// change focus.
if (!eventConsumed && keyInput.getActionId()
- == static_cast<int>(InputAction::GUI_TAB)
- && keyInput.getType() == KeyEventType::PRESSED)
+ == InputAction::GUI_TAB &&
+ keyInput.getType() == KeyEventType::PRESSED)
{
if (inputManager.isActionActive(InputAction::GUI_MOD))
mFocusHandler->tabPrevious();
diff --git a/src/gui/models/touchactionmodel.cpp b/src/gui/models/touchactionmodel.cpp
index d9cced32a..7daff84ca 100644
--- a/src/gui/models/touchactionmodel.cpp
+++ b/src/gui/models/touchactionmodel.cpp
@@ -68,16 +68,16 @@ TouchActionsModel::TouchActionsModel() :
}
}
-int TouchActionsModel::getActionFromSelection(const int sel) const
+InputActionT TouchActionsModel::getActionFromSelection(const int sel) const
{
if (sel < 0 || sel > static_cast<signed int>(mActionId.size()))
- return -1;
+ return InputAction::NO_VALUE;
return mActionId[sel];
}
-int TouchActionsModel::getSelectionFromAction(const int action) const
+int TouchActionsModel::getSelectionFromAction(const InputActionT action) const
{
- const std::map<int, int>::const_iterator it
+ const std::map<InputActionT, int>::const_iterator it
= mActionToSelection.find(action);
if (it == mActionToSelection.end())
return 0;
diff --git a/src/gui/models/touchactionmodel.h b/src/gui/models/touchactionmodel.h
index 287232aae..05234907c 100644
--- a/src/gui/models/touchactionmodel.h
+++ b/src/gui/models/touchactionmodel.h
@@ -21,6 +21,8 @@
#ifndef GUI_MODELS_TOUCHACTIONMODEL_H
#define GUI_MODELS_TOUCHACTIONMODEL_H
+#include "enums/input/inputaction.h"
+
#include "gui/models/namesmodel.h"
#include "gui/widgets/setupitem.h"
@@ -35,13 +37,13 @@ class TouchActionsModel final : public NamesModel
~TouchActionsModel()
{ }
- int getActionFromSelection(const int sel) const;
+ InputActionT getActionFromSelection(const int sel) const;
- int getSelectionFromAction(const int action) const;
+ int getSelectionFromAction(const InputActionT action) const;
private:
- std::vector<int> mActionId;
- std::map<int, int> mActionToSelection;
+ std::vector<InputActionT> mActionId;
+ std::map<InputActionT, int> mActionToSelection;
};
#endif // GUI_MODELS_TOUCHACTIONMODEL_H
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 37c8e0d78..0e0e93e3f 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1526,7 +1526,7 @@ void PopupMenu::handleLink(const std::string &link,
{
const int id = atoi(link.substr(12).c_str());
if (id >= 0)
- inputManager.executeAction(id);
+ inputManager.executeAction(static_cast<InputActionT>(id));
}
else if (!link.compare(0, 6, "mute_+"))
{
@@ -2179,7 +2179,8 @@ void PopupMenu::showWindowsPopup()
if (!btn)
continue;
- mBrowserBox->addRow(strprintf("show window_%d", btn->key),
+ mBrowserBox->addRow(strprintf("show window_%d",
+ static_cast<int>(btn->key)),
btn->text.c_str());
}
mBrowserBox->addRow("##3---");
diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp
index 2bc4a9170..c54a57874 100644
--- a/src/gui/popups/statuspopup.cpp
+++ b/src/gui/popups/statuspopup.cpp
@@ -124,11 +124,11 @@ void StatusPopup::view(const int x, const int y)
void StatusPopup::setLabelText(const int num,
const std::string &text,
- const InputAction::Type key) const
+ const InputActionT key) const
{
Label *const label = mLabels[num];
label->setCaption(strprintf("%s %s", text.c_str(),
- inputManager.getKeyValueString(static_cast<int>(key)).c_str()));
+ inputManager.getKeyValueString(key).c_str()));
label->adjustSize();
}
diff --git a/src/gui/popups/statuspopup.h b/src/gui/popups/statuspopup.h
index cdfbde656..43b793821 100644
--- a/src/gui/popups/statuspopup.h
+++ b/src/gui/popups/statuspopup.h
@@ -62,8 +62,9 @@ class StatusPopup final : public Popup
private:
void updateLabels() const;
- void setLabelText(const int num, const std::string &text,
- const InputAction::Type key) const;
+ void setLabelText(const int num,
+ const std::string &text,
+ const InputActionT key) const;
Label *mLabels[STATUSPOPUP_NUM_LABELS];
};
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index 16204e5e1..8405dda90 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -292,8 +292,8 @@ void SDLInput::pushInput(const SDL_Event &event)
void SDLInput::convertKeyEventToKey(const SDL_Event &event, KeyInput &keyInput)
{
keyInput.setKey(Key(convertKeyCharacter(event)));
- const int actionId = inputManager.getActionByKey(event);
- if (actionId >= 0)
+ const InputActionT actionId = inputManager.getActionByKey(event);
+ if (actionId > InputActionT::NO_VALUE)
keyInput.setActionId(actionId);
}
diff --git a/src/gui/setupactiondata.h b/src/gui/setupactiondata.h
index f72614c11..03915d37a 100644
--- a/src/gui/setupactiondata.h
+++ b/src/gui/setupactiondata.h
@@ -24,6 +24,8 @@
#ifndef GUI_SETUPACTIONDATA_H
#define GUI_SETUPACTIONDATA_H
+#include "enums/input/inputaction.h"
+
#include <string>
#include "localconsts.h"
@@ -32,7 +34,7 @@ struct SetupActionData final
{
#ifdef ADVGCC
SetupActionData(const std::string &name0,
- const int actionId0,
+ const InputActionT actionId0,
const std::string &text0) :
name(name0),
actionId(actionId0),
@@ -43,7 +45,7 @@ struct SetupActionData final
#endif
std::string name;
- const int actionId;
+ const InputActionT actionId;
std::string text;
};
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 78b66b930..5c0c7328c 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -455,20 +455,18 @@ bool Viewport::leftMouseAction()
type == ActorType::Npc))
{
if ((localPlayer->withinAttackRange(mHoverBeing) ||
- inputManager.isActionActive(static_cast<int>(
- InputAction::ATTACK))))
+ inputManager.isActionActive(InputAction::ATTACK)))
{
validateSpeed();
if (!mStatsReUpdated && localPlayer != mHoverBeing)
{
localPlayer->attack(mHoverBeing,
!inputManager.isActionActive(
- static_cast<int>(InputAction::STOP_ATTACK)));
+ InputAction::STOP_ATTACK));
return true;
}
}
- else if (!inputManager.isActionActive(static_cast<int>(
- InputAction::ATTACK)))
+ else if (!inputManager.isActionActive(InputAction::ATTACK))
{
validateSpeed();
if (!mStatsReUpdated && localPlayer != mHoverBeing)
@@ -498,8 +496,7 @@ bool Viewport::leftMouseAction()
return true;
}
// Just walk around
- else if (!inputManager.isActionActive(static_cast<int>(
- InputAction::ATTACK)))
+ else if (!inputManager.isActionActive(InputAction::ATTACK))
{
validateSpeed();
localPlayer->stopAttack();
@@ -964,9 +961,8 @@ void Viewport::returnCamera()
void Viewport::validateSpeed()
{
- if (!inputManager.isActionActive(static_cast<int>(
- InputAction::TARGET_ATTACK)) && !inputManager.isActionActive(
- static_cast<int>(InputAction::ATTACK)))
+ if (!inputManager.isActionActive(InputAction::TARGET_ATTACK) &&
+ !inputManager.isActionActive(InputAction::ATTACK))
{
if (Game::instance())
Game::instance()->setValidSpeed();
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 9a6d43518..73a289630 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -843,7 +843,7 @@ void Button::adjustSize()
void Button::keyPressed(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
@@ -854,7 +854,7 @@ void Button::keyPressed(KeyEvent& event)
void Button::keyReleased(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT && mKeyPressed)
{
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 6459c5f1c..20a58bdf1 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -267,7 +267,7 @@ void CheckBox::mouseExited(MouseEvent& event)
void CheckBox::keyPressed(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 0d08dac60..890a2af1f 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -334,7 +334,7 @@ void DropDown::keyPressed(KeyEvent& event)
if (event.isConsumed())
return;
- const int actionId = event.getActionId();
+ const InputActionT actionId = event.getActionId();
switch (actionId)
{
case InputAction::GUI_SELECT:
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index eb6efedb6..7cba5872e 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -33,6 +33,8 @@
#include "gui/popups/textpopup.h"
+#include "input/inputactionoperators.h"
+
#include "resources/emotesprite.h"
#include "resources/image.h"
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index ba29033a9..d5242520f 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -474,7 +474,7 @@ Rect GuiTable::getChildrenArea()
// -- KeyListener notifications
void GuiTable::keyPressed(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp
index 1ba53b1af..b0e902223 100644
--- a/src/gui/widgets/inttextfield.cpp
+++ b/src/gui/widgets/inttextfield.cpp
@@ -53,7 +53,7 @@ IntTextField::IntTextField(const Widget2 *const widget,
void IntTextField::keyPressed(KeyEvent &event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_DELETE
|| action == InputAction::GUI_BACKSPACE)
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 15af7c286..eba9fd848 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -42,6 +42,8 @@
#include "gui/windows/inventorywindow.h"
#include "gui/windows/skilldialog.h"
+#include "input/inputactionoperators.h"
+
#include "resources/skillconsts.h"
#include "utils/stringutils.h"
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 5ab8945a9..8e0bd2921 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -237,7 +237,7 @@ void ListBox::draw(Graphics *graphics)
void ListBox::keyPressed(KeyEvent &event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
distributeActionEvent();
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 9fd9d81aa..a3c4d1797 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -266,7 +266,7 @@ void RadioButton::mouseExited(MouseEvent& event A_UNUSED)
void RadioButton::keyPressed(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
setSelected(true);
diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp
index 8d1b63dd7..eb8741abc 100644
--- a/src/gui/widgets/setuptouchitem.cpp
+++ b/src/gui/widgets/setuptouchitem.cpp
@@ -100,7 +100,7 @@ void SetupActionDropDown::createControls()
mDropDown->addActionListener(mParent);
mDropDown->setWidth(mWidth);
mDropDown->setSelected(mModel->getSelectionFromAction(
- atoi(mValue.c_str())));
+ static_cast<InputActionT>(atoi(mValue.c_str()))));
mWidget = mDropDown;
fixFirstItemSize(mLabel);
@@ -118,8 +118,8 @@ void SetupActionDropDown::fromWidget()
if (!mDropDown || !mModel)
return;
- mValue = toString(mModel->getActionFromSelection(
- mDropDown->getSelected()));
+ mValue = toString(static_cast<int>(mModel->getActionFromSelection(
+ mDropDown->getSelected())));
}
void SetupActionDropDown::toWidget()
@@ -128,5 +128,5 @@ void SetupActionDropDown::toWidget()
return;
mDropDown->setSelected(mModel->getSelectionFromAction(
- atoi(mValue.c_str())));
+ static_cast<InputActionT>(atoi(mValue.c_str()))));
}
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index c11dc2627..4adc3003f 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -423,7 +423,7 @@ void Slider::mouseWheelMovedDown(MouseEvent &event)
void Slider::keyPressed(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (mOrientation == HORIZONTAL)
{
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 79205617f..4acc9ffd2 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -738,7 +738,7 @@ void TabbedArea::keyPressed(KeyEvent& event)
if (mBlockSwitching || event.isConsumed() || !isFocused())
return;
- const int actionId = event.getActionId();
+ const InputActionT actionId = event.getActionId();
if (actionId == InputAction::GUI_LEFT)
{
diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp
index f1752d781..24a385c0f 100644
--- a/src/gui/widgets/tabs/setup_input.cpp
+++ b/src/gui/widgets/tabs/setup_input.cpp
@@ -27,6 +27,7 @@
#include "enums/gui/dialogtype.h"
+#include "input/inputactionoperators.h"
#include "input/inputmanager.h"
#include "input/keyboardconfig.h"
@@ -147,7 +148,7 @@ Setup_Input::~Setup_Input()
void Setup_Input::apply()
{
keyUnresolved();
- int key1, key2;
+ InputActionT key1, key2;
if (inputManager.hasConflicts(key1, key2))
{
@@ -193,7 +194,7 @@ void Setup_Input::action(const ActionEvent &event)
if (i >= 0 && i < mActionDataSize[selectedData])
{
if (setupActionData[selectedData][i].actionId
- == static_cast<int>(InputAction::NO_VALUE))
+ == InputAction::NO_VALUE)
{
mAssignKeyButton->setEnabled(false);
mUnassignKeyButton->setEnabled(false);
@@ -215,7 +216,7 @@ void Setup_Input::action(const ActionEvent &event)
if (i >= 0 && i < mActionDataSize[selectedData])
{
const SetupActionData &key = setupActionData[selectedData][i];
- const int ik = key.actionId;
+ const InputActionT ik = key.actionId;
inputManager.setNewKeyIndex(ik);
mKeyListModel->setElementAt(i, std::string(
gettext(key.name.c_str())).append(": ?"));
@@ -227,12 +228,11 @@ void Setup_Input::action(const ActionEvent &event)
if (i >= 0 && i < mActionDataSize[selectedData])
{
const SetupActionData &key = setupActionData[selectedData][i];
- const int ik = key.actionId;
+ const InputActionT ik = key.actionId;
inputManager.setNewKeyIndex(ik);
refreshAssignedKey(mKeyList->getSelected());
inputManager.unassignKey();
- inputManager.setNewKeyIndex(static_cast<int>(
- InputAction::NO_VALUE));
+ inputManager.setNewKeyIndex(InputAction::NO_VALUE);
}
mAssignKeyButton->setEnabled(true);
}
@@ -248,7 +248,7 @@ void Setup_Input::action(const ActionEvent &event)
if (i >= 0 && i < mActionDataSize[selectedData])
{
const SetupActionData &key = setupActionData[selectedData][i];
- const int ik = key.actionId;
+ const InputActionT ik = key.actionId;
inputManager.makeDefault(ik);
refreshKeys();
}
@@ -277,7 +277,7 @@ void Setup_Input::refreshAssignedKey(const int index)
{
const int selectedData = mKeyListModel->getSelectedData();
const SetupActionData &key = setupActionData[selectedData][index];
- if (key.actionId == static_cast<int>(InputAction::NO_VALUE))
+ if (key.actionId == InputAction::NO_VALUE)
{
const std::string str(" \342\200\225\342\200\225\342\200\225"
"\342\200\225\342\200\225 ");
@@ -297,7 +297,7 @@ void Setup_Input::refreshAssignedKey(const int index)
}
}
-void Setup_Input::newKeyCallback(const int index)
+void Setup_Input::newKeyCallback(const InputActionT index)
{
mKeySetting = false;
const int i = keyToSetupData(index);
@@ -306,7 +306,7 @@ void Setup_Input::newKeyCallback(const int index)
mAssignKeyButton->setEnabled(true);
}
-int Setup_Input::keyToSetupData(const int index) const
+int Setup_Input::keyToSetupData(const InputActionT index) const
{
const int selectedData = mKeyListModel->getSelectedData();
for (int i = 0; i < mActionDataSize[selectedData]; i++)
@@ -318,7 +318,7 @@ int Setup_Input::keyToSetupData(const int index) const
return -1;
}
-std::string Setup_Input::keyToString(const int index) const
+std::string Setup_Input::keyToString(const InputActionT index) const
{
for (int f = 0; f < setupGroups; f ++)
{
@@ -345,13 +345,13 @@ void Setup_Input::keyUnresolved()
if (mKeySetting)
{
newKeyCallback(inputManager.getNewKeyIndex());
- inputManager.setNewKeyIndex(static_cast<int>(InputAction::NO_VALUE));
+ inputManager.setNewKeyIndex(InputAction::NO_VALUE);
}
}
void Setup_Input::fixTranslation(SetupActionData *const actionDatas,
- const int actionStart,
- const int actionEnd,
+ const InputActionT actionStart,
+ const InputActionT actionEnd,
const std::string &text)
{
int k = 0;
@@ -360,7 +360,7 @@ void Setup_Input::fixTranslation(SetupActionData *const actionDatas,
{
SetupActionData &data = actionDatas[k];
- const int actionId = data.actionId;
+ const InputActionT actionId = data.actionId;
if (actionId >= actionStart && actionId <= actionEnd)
{
data.name = strprintf(gettext(text.c_str()),
@@ -373,22 +373,22 @@ void Setup_Input::fixTranslation(SetupActionData *const actionDatas,
void Setup_Input::fixTranslations()
{
fixTranslation(setupActionDataShortcuts,
- static_cast<int>(InputAction::SHORTCUT_1),
- static_cast<int>(InputAction::SHORTCUT_20),
+ InputAction::SHORTCUT_1,
+ InputAction::SHORTCUT_20,
"Item Shortcut %d");
fixTranslation(setupActionDataEmotes,
- static_cast<int>(InputAction::EMOTE_1),
- static_cast<int>(InputAction::EMOTE_48),
+ InputAction::EMOTE_1,
+ InputAction::EMOTE_48,
"Emote Shortcut %d");
fixTranslation(setupActionDataOutfits,
- static_cast<int>(InputAction::OUTFIT_1),
- static_cast<int>(InputAction::OUTFIT_48),
+ InputAction::OUTFIT_1,
+ InputAction::OUTFIT_48,
"Outfit Shortcut %d");
fixTranslation(setupActionDataMove,
- static_cast<int>(InputAction::MOVE_TO_POINT_1),
- static_cast<int>(InputAction::MOVE_TO_POINT_48),
+ InputAction::MOVE_TO_POINT_1,
+ InputAction::MOVE_TO_POINT_48,
"Move to point Shortcut %d");
}
diff --git a/src/gui/widgets/tabs/setup_input.h b/src/gui/widgets/tabs/setup_input.h
index 569c21e2b..eb97dd644 100644
--- a/src/gui/widgets/tabs/setup_input.h
+++ b/src/gui/widgets/tabs/setup_input.h
@@ -24,6 +24,8 @@
#ifndef GUI_WIDGETS_TABS_SETUP_INPUT_H
#define GUI_WIDGETS_TABS_SETUP_INPUT_H
+#include "enums/input/inputaction.h"
+
#include "gui/widgets/tabs/setuptab.h"
class Button;
@@ -63,7 +65,7 @@ class Setup_Input final : public SetupTab
/**
* The callback function when a new key has been pressed.
*/
- void newKeyCallback(const int index);
+ void newKeyCallback(const InputActionT index);
/**
* Shorthand method to update all the keys.
@@ -75,16 +77,16 @@ class Setup_Input final : public SetupTab
*/
void keyUnresolved();
- int keyToSetupData(const int index) const A_WARN_UNUSED;
+ int keyToSetupData(const InputActionT index) const A_WARN_UNUSED;
- std::string keyToString(const int index) const A_WARN_UNUSED;
+ std::string keyToString(const InputActionT index) const A_WARN_UNUSED;
private:
static void fixTranslations();
static void fixTranslation(SetupActionData *const actionDatas,
- const int actionStart,
- const int actionEnd,
+ const InputActionT actionStart,
+ const InputActionT actionEnd,
const std::string &text);
KeyListModel *mKeyListModel;
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 0919656ad..248fbcb9e 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -257,7 +257,7 @@ void TextBox::setText(const std::string& text)
void TextBox::keyPressed(KeyEvent& event)
{
const Key &key = event.getKey();
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
switch (action)
{
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 8639d8f80..0d7b3d883 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -365,9 +365,8 @@ void TextField::keyPressed(KeyEvent &event)
bool consumed(false);
#endif
- const int action = event.getActionId();
- if (!inputManager.isActionActive(static_cast<int>(
- InputAction::GUI_CTRL)))
+ const InputActionT action = event.getActionId();
+ if (!inputManager.isActionActive(InputAction::GUI_CTRL))
{
if (!handleNormalKeys(action, consumed))
{
@@ -389,7 +388,7 @@ void TextField::keyPressed(KeyEvent &event)
fixScroll();
}
-bool TextField::handleNormalKeys(const int action, bool &consumed)
+bool TextField::handleNormalKeys(const InputActionT action, bool &consumed)
{
switch (action)
{
@@ -473,7 +472,7 @@ bool TextField::handleNormalKeys(const int action, bool &consumed)
return true;
}
-void TextField::handleCtrlKeys(const int action, bool &consumed)
+void TextField::handleCtrlKeys(const InputActionT action, bool &consumed)
{
switch (action)
{
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index ffd956ed2..79ad3f110 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -238,9 +238,9 @@ class TextField notfinal : public Widget,
void fontChanged() override;
- bool handleNormalKeys(const int action, bool &consumed);
+ bool handleNormalKeys(const InputActionT action, bool &consumed);
- void handleCtrlKeys(const int action, bool &consumed);
+ void handleCtrlKeys(const InputActionT action, bool &consumed);
static Skin *mSkin;
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 012fd5a49..b1d225bf2 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -238,13 +238,13 @@ void WindowMenu::addButton(const char *const text,
const std::string &description,
int &restrict x,
int &restrict h,
- const int key,
+ const InputActionT key,
const Visible visible)
{
Button *const btn = new Button(this, gettext(text), text, this);
btn->setPosition(x, mPadding);
btn->setDescription(description);
- btn->setTag(key);
+ btn->setTag(static_cast<int>(key));
add(btn);
btn->setFocusable(false);
x += btn->getWidth() + mSpacing;
@@ -301,7 +301,7 @@ void WindowMenu::mouseMoved(MouseEvent &event)
const int x = event.getX();
const int y = event.getY();
- const int key = btn->getTag();
+ const InputActionT key = static_cast<InputActionT>(btn->getTag());
const Rect &rect = mDimension;
if (key != InputAction::NO_VALUE)
{
diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h
index 03bd86592..d91526750 100644
--- a/src/gui/windowmenu.h
+++ b/src/gui/windowmenu.h
@@ -23,6 +23,8 @@
#ifndef GUI_WINDOWMENU_H
#define GUI_WINDOWMENU_H
+#include "enums/input/inputaction.h"
+
#include "enums/simpletypes/visible.h"
#include "gui/widgets/container.h"
@@ -95,7 +97,7 @@ class WindowMenu final : public Container,
inline void addButton(const char *const text,
const std::string &description,
int &restrict x, int &restrict h,
- const int key,
+ const InputActionT key,
const Visible visible = Visible_true);
void updateButtons();
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index 87dc25115..436c4d841 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -685,7 +685,7 @@ void CharCreateDialog::updatePlayer()
void CharCreateDialog::keyPressed(KeyEvent &event)
{
- const int actionId = event.getActionId();
+ const InputActionT actionId = event.getActionId();
switch (actionId)
{
case InputAction::GUI_CANCEL:
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index dd82091b0..0ffba7984 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -353,7 +353,7 @@ void CharSelectDialog::use(const int selected)
void CharSelectDialog::keyPressed(KeyEvent &event)
{
- const int actionId = event.getActionId();
+ const InputActionT actionId = event.getActionId();
switch (actionId)
{
case InputAction::GUI_CANCEL:
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 747ba498e..7a62ad755 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -698,8 +698,7 @@ void ChatWindow::mousePressed(MouseEvent &event)
{
event.consume();
ChatTab *const cTab = dynamic_cast<ChatTab*>(tab);
- if (inputManager.isActionActive(static_cast<int>(
- InputAction::CHAT_MOD)))
+ if (inputManager.isActionActive(InputAction::CHAT_MOD))
{
inputManager.executeChatCommand(
InputAction::CLOSE_CHAT_TAB,
@@ -752,16 +751,16 @@ void ChatWindow::mouseDragged(MouseEvent &event)
}
#define ifKey(key, str) \
- else if (actionId == static_cast<int>(key)) \
+ else if (actionId == key) \
{ \
temp = str; \
}
void ChatWindow::keyPressed(KeyEvent &event)
{
- const int actionId = event.getActionId();
+ const InputActionT actionId = event.getActionId();
std::string temp;
- if (actionId == static_cast<int>(InputAction::GUI_DOWN))
+ if (actionId == InputAction::GUI_DOWN)
{
if (mCurHist != mHistory.end())
{
@@ -788,8 +787,9 @@ void ChatWindow::keyPressed(KeyEvent &event)
mChatInput->setText("");
}
}
- else if (actionId == static_cast<int>(InputAction::GUI_UP) &&
- mCurHist != mHistory.begin() && !mHistory.empty())
+ else if (actionId == InputAction::GUI_UP &&
+ mCurHist != mHistory.begin() &&
+ !mHistory.empty())
{
// Move backward through the history
--mCurHist;
@@ -798,7 +798,7 @@ void ChatWindow::keyPressed(KeyEvent &event)
mChatInput->setCaretPosition(static_cast<unsigned>(
mChatInput->getText().length()));
}
- else if (actionId == static_cast<int>(InputAction::GUI_INSERT) &&
+ else if (actionId == InputAction::GUI_INSERT &&
mChatInput->getText() != "")
{
// Add the current message to the history and clear the text
@@ -807,18 +807,18 @@ void ChatWindow::keyPressed(KeyEvent &event)
mCurHist = mHistory.end();
mChatInput->setText("");
}
- else if (actionId == static_cast<int>(InputAction::GUI_TAB) &&
+ else if (actionId == InputAction::GUI_TAB &&
!mChatInput->getText().empty())
{
autoComplete();
return;
}
- else if (actionId == static_cast<int>(InputAction::GUI_CANCEL) &&
+ else if (actionId == InputAction::GUI_CANCEL &&
mChatInput->isVisibleLocal())
{
mChatInput->processVisible(Visible_false);
}
- else if (actionId == static_cast<int>(InputAction::CHAT_PREV_HISTORY) &&
+ else if (actionId == InputAction::CHAT_PREV_HISTORY &&
mChatInput->isVisibleLocal())
{
const ChatTab *const tab = getFocused();
@@ -850,7 +850,7 @@ void ChatWindow::keyPressed(KeyEvent &event)
mChatInput->getText().length()));
}
}
- else if (actionId == static_cast<int>(InputAction::CHAT_NEXT_HISTORY) &&
+ else if (actionId == InputAction::CHAT_NEXT_HISTORY &&
mChatInput->isVisibleLocal())
{
const ChatTab *const tab = getFocused();
@@ -886,7 +886,7 @@ void ChatWindow::keyPressed(KeyEvent &event)
mChatInput->getText().length()));
}
}
- else if (actionId == static_cast<int>(InputAction::GUI_F1))
+ else if (actionId == InputAction::GUI_F1)
{
if (emoteWindow)
{
@@ -908,9 +908,9 @@ void ChatWindow::keyPressed(KeyEvent &event)
ifKey(InputAction::GUI_F11, "\u2618")
ifKey(InputAction::GUI_F12, "\u2592")
- if (inputManager.isActionActive(static_cast<int>(InputAction::GUI_CTRL)))
+ if (inputManager.isActionActive(InputAction::GUI_CTRL))
{
- if (actionId == static_cast<int>(InputAction::GUI_B))
+ if (actionId == InputAction::GUI_B)
{
std::string inputText = mChatInput->getTextBeforeCaret();
toLower(inputText);
diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp
index e6fd2e16c..18319dbde 100644
--- a/src/gui/windows/editserverdialog.cpp
+++ b/src/gui/windows/editserverdialog.cpp
@@ -299,14 +299,14 @@ void EditServerDialog::keyPressed(KeyEvent &event)
if (event.isConsumed())
return;
- const int actionId = event.getActionId();
+ const InputActionT actionId = event.getActionId();
- if (actionId == static_cast<int>(InputAction::GUI_CANCEL))
+ if (actionId == InputAction::GUI_CANCEL)
{
scheduleDelete();
}
- else if (actionId == static_cast<int>(InputAction::GUI_SELECT)
- || actionId == static_cast<int>(InputAction::GUI_SELECT2))
+ else if (actionId == InputAction::GUI_SELECT ||
+ actionId == InputAction::GUI_SELECT2)
{
action(ActionEvent(nullptr, mOkButton->getActionEventId()));
}
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index ed3742c9b..c5934b7ba 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -491,8 +491,7 @@ void InventoryWindow::action(const ActionEvent &event)
if (PlayerInfo::isItemProtected(item->getId()))
return;
- if (inputManager.isActionActive(static_cast<int>(
- InputAction::STOP_ATTACK)))
+ if (inputManager.isActionActive(InputAction::STOP_ATTACK))
{
PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
}
@@ -551,12 +550,12 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
if (clicks == 2 && gui)
gui->resetClickCount();
- const bool mod = (isStorageActive() && inputManager.isActionActive(
- static_cast<int>(InputAction::STOP_ATTACK)));
+ const bool mod = (isStorageActive() &&
+ inputManager.isActionActive(InputAction::STOP_ATTACK));
- const bool mod2 = (tradeWindow && tradeWindow->isWindowVisible()
- && inputManager.isActionActive(static_cast<int>(
- InputAction::STOP_ATTACK)));
+ const bool mod2 = (tradeWindow &&
+ tradeWindow->isWindowVisible() &&
+ inputManager.isActionActive(InputAction::STOP_ATTACK));
if (!mod && !mod2 && event.getButton() == MouseButton::RIGHT)
{
@@ -707,13 +706,13 @@ void InventoryWindow::mouseExited(MouseEvent &event A_UNUSED)
void InventoryWindow::keyPressed(KeyEvent &event)
{
- if (event.getActionId() == static_cast<int>(InputAction::GUI_MOD))
+ if (event.getActionId() == InputAction::GUI_MOD)
mSplit = true;
}
void InventoryWindow::keyReleased(KeyEvent &event)
{
- if (event.getActionId() == static_cast<int>(InputAction::GUI_MOD))
+ if (event.getActionId() == InputAction::GUI_MOD)
mSplit = false;
}
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
index f2b41c7b5..5230ef4fe 100644
--- a/src/gui/windows/logindialog.cpp
+++ b/src/gui/windows/logindialog.cpp
@@ -252,13 +252,13 @@ void LoginDialog::keyPressed(KeyEvent &event)
return;
}
- const int actionId = event.getActionId();
- if (actionId == static_cast<int>(InputAction::GUI_CANCEL))
+ const InputActionT actionId = event.getActionId();
+ if (actionId == InputAction::GUI_CANCEL)
{
action(ActionEvent(nullptr, mServerButton->getActionEventId()));
}
- else if (actionId == static_cast<int>(InputAction::GUI_SELECT)
- || actionId == static_cast<int>(InputAction::GUI_SELECT2))
+ else if (actionId == InputAction::GUI_SELECT ||
+ actionId == InputAction::GUI_SELECT2)
{
action(ActionEvent(nullptr, mLoginButton->getActionEventId()));
}
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index b3a17915d..c1d9b1d24 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -30,6 +30,7 @@
#include "being/playerinfo.h"
+#include "input/inputactionoperators.h"
#include "input/inputmanager.h"
#include "gui/viewport.h"
@@ -590,8 +591,7 @@ std::string OutfitWindow::keyName(const int number)
{
if (number < 0 || number >= SHORTCUT_EMOTES)
return "";
- return inputManager.getKeyStringLong(static_cast<int>(
- InputAction::EMOTE_1) + number);
+ return inputManager.getKeyStringLong(InputAction::EMOTE_1 + number);
}
void OutfitWindow::next()
diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp
index bd710670c..d16a22ff8 100644
--- a/src/gui/windows/quitdialog.cpp
+++ b/src/gui/windows/quitdialog.cpp
@@ -202,7 +202,7 @@ void QuitDialog::action(const ActionEvent &event)
void QuitDialog::keyPressed(KeyEvent &event)
{
- const int actionId = event.getActionId();
+ const InputActionT actionId = event.getActionId();
int dir = 0;
switch (actionId)
diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp
index 85ad80988..1f0dc68e2 100644
--- a/src/gui/windows/registerdialog.cpp
+++ b/src/gui/windows/registerdialog.cpp
@@ -279,13 +279,13 @@ void RegisterDialog::keyPressed(KeyEvent &event)
mRegisterButton->setEnabled(canSubmit());
return;
}
- const int actionId = event.getActionId();
- if (actionId == static_cast<int>(InputAction::GUI_CANCEL))
+ const InputActionT actionId = event.getActionId();
+ if (actionId == InputAction::GUI_CANCEL)
{
action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
}
- else if (actionId == static_cast<int>(InputAction::GUI_SELECT)
- || actionId == static_cast<int>(InputAction::GUI_SELECT2))
+ else if (actionId == InputAction::GUI_SELECT ||
+ actionId == InputAction::GUI_SELECT2)
{
action(ActionEvent(nullptr, mRegisterButton->getActionEventId()));
}
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index ca094f1b6..1a6a75093 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -329,8 +329,8 @@ void UpdaterWindow::action(const ActionEvent &event)
void UpdaterWindow::keyPressed(KeyEvent &event)
{
- const int actionId = event.getActionId();
- if (actionId == static_cast<int>(InputAction::GUI_CANCEL))
+ const InputActionT actionId = event.getActionId();
+ if (actionId == InputAction::GUI_CANCEL)
{
action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
if (client->getState() != STATE_GAME)
@@ -338,8 +338,8 @@ void UpdaterWindow::keyPressed(KeyEvent &event)
else
deleteSelf();
}
- else if (actionId == static_cast<int>(InputAction::GUI_SELECT)
- || actionId == static_cast<int>(InputAction::GUI_SELECT2))
+ else if (actionId == InputAction::GUI_SELECT ||
+ actionId == InputAction::GUI_SELECT2)
{
if (mDownloadStatus == UPDATE_COMPLETE ||
mDownloadStatus == UPDATE_ERROR)
diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp
index ee5af8123..a2604cf80 100644
--- a/src/gui/windows/worldselectdialog.cpp
+++ b/src/gui/windows/worldselectdialog.cpp
@@ -120,15 +120,15 @@ void WorldSelectDialog::action(const ActionEvent &event)
void WorldSelectDialog::keyPressed(KeyEvent &event)
{
- const int actionId = event.getActionId();
+ const InputActionT actionId = event.getActionId();
- if (actionId == static_cast<int>(InputAction::GUI_CANCEL))
+ if (actionId == InputAction::GUI_CANCEL)
{
action(ActionEvent(nullptr,
mChangeLoginButton->getActionEventId()));
}
- else if (actionId == static_cast<int>(InputAction::GUI_SELECT)
- || actionId == static_cast<int>(InputAction::GUI_SELECT2))
+ else if (actionId == InputAction::GUI_SELECT ||
+ actionId == InputAction::GUI_SELECT2)
{
action(ActionEvent(nullptr, mChooseWorld->getActionEventId()));
}
diff --git a/src/input/inputactiondata.h b/src/input/inputactiondata.h
index c0a2b975b..f25a5a7f7 100644
--- a/src/input/inputactiondata.h
+++ b/src/input/inputactiondata.h
@@ -25,6 +25,8 @@
#include "actions/actionfuncptr.h"
+#include "enums/input/inputaction.h"
+
#include "enums/simpletypes/useargs.h"
struct InputActionData final
@@ -36,7 +38,7 @@ struct InputActionData final
const int defaultValue2;
const int grp;
const ActionFuncPtr action;
- const int modKeyIndex;
+ const InputActionT modKeyIndex;
const int priority;
const int condition;
const std::string chatCommand;
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index cd57e47a7..b96a187f8 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -43,18 +43,19 @@
#include "localconsts.h"
#define defaultAction(name) \
- InputType::UNKNOWN, InputAction::NO_VALUE, \
- InputType::UNKNOWN, InputAction::NO_VALUE, \
+ InputType::UNKNOWN, -1, \
+ InputType::UNKNOWN, -1, \
Input::GRP_DEFAULT, \
name, \
InputAction::NO_VALUE, 50
#define addKey(name) InputType::KEYBOARD, name
-#define emptyKey InputType::UNKNOWN, InputAction::NO_VALUE
+#define emptyKey InputType::UNKNOWN, -1
#define joystickButton(num) InputType::JOYSTICK, num
// keyData must be in same order as enum keyAction.
-static const InputActionData inputActionData[InputAction::TOTAL] = {
+static const InputActionData inputActionData
+ [static_cast<size_t>(InputAction::TOTAL)] = {
{"keyMoveUp",
addKey(SDLK_UP),
emptyKey,
diff --git a/src/input/inputactionoperators.cpp b/src/input/inputactionoperators.cpp
new file mode 100644
index 000000000..a2c0eb496
--- /dev/null
+++ b/src/input/inputactionoperators.cpp
@@ -0,0 +1,32 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "input/inputactionoperators.h"
+
+InputActionT operator+(InputActionT action, const int& i)
+{
+ action = static_cast<InputActionT>(static_cast<int>(action) + i);
+ return action;
+}
+
+int operator-(const InputActionT &action1, const InputActionT &action2)
+{
+ return static_cast<int>(action1) - static_cast<int>(action2);
+}
diff --git a/src/input/inputactionoperators.h b/src/input/inputactionoperators.h
new file mode 100644
index 000000000..2a5244c46
--- /dev/null
+++ b/src/input/inputactionoperators.h
@@ -0,0 +1,31 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef INPUT_INPUTACTIONOPERATORS_H
+#define INPUT_INPUTACTIONOPERATORS_H
+
+#include "enums/input/inputaction.h"
+
+InputActionT operator+(InputActionT action, const int& i);
+int operator-(const InputActionT &action1, const InputActionT &action2);
+
+#endif // INPUT_INPUTACTIONOPERATORS_H
diff --git a/src/input/inputactionsortfunctor.h b/src/input/inputactionsortfunctor.h
index 9582d70e0..fbd9b79f3 100644
--- a/src/input/inputactionsortfunctor.h
+++ b/src/input/inputactionsortfunctor.h
@@ -28,9 +28,11 @@
class InputActionSortFunctor final
{
public:
- bool operator() (const int key1, const int key2) const
+ bool operator() (const InputActionT key1,
+ const InputActionT key2) const
{
- return keys[key1].priority >= keys[key2].priority;
+ return keys[static_cast<size_t>(key1)].priority
+ >= keys[static_cast<size_t>(key2)].priority;
}
const InputActionData *keys;
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
index 8b5cb97e2..12c28c806 100644
--- a/src/input/inputmanager.cpp
+++ b/src/input/inputmanager.cpp
@@ -83,7 +83,9 @@ InputManager::InputManager() :
void InputManager::init()
{
- for (unsigned int i = 0; i < InputAction::TOTAL; i++)
+ for (unsigned int i = 0;
+ i < static_cast<unsigned int>(InputAction::TOTAL);
+ i ++)
{
InputFunction &kf = mKey[i];
for (unsigned int f = 0; f < inputFunctionSize; f ++)
@@ -110,7 +112,7 @@ void InputManager::update()
void InputManager::retrieve()
{
- for (int i = 0; i < InputAction::TOTAL; i++)
+ for (int i = 0; i < static_cast<int>(InputAction::TOTAL); i ++)
{
const std::string &cmd = inputActionData[i].chatCommand;
if (!cmd.empty())
@@ -128,7 +130,7 @@ void InputManager::retrieve()
#endif
if (!cf.empty())
{
- mNameMap[cf] = i;
+ mNameMap[cf] = static_cast<InputActionT>(i);
InputFunction &kf = mKey[i];
const std::string keyStr = config.getValue(cf, "");
const size_t keyStrSize = keyStr.size();
@@ -174,7 +176,7 @@ void InputManager::retrieve()
void InputManager::store() const
{
- for (int i = 0; i < InputAction::TOTAL; i++)
+ for (int i = 0; i < static_cast<int>(InputAction::TOTAL); i ++)
{
#ifdef USE_SDL2
const std::string cf = std::string("sdl2")
@@ -226,16 +228,16 @@ void InputManager::store() const
}
}
-void InputManager::resetKey(const int i)
+void InputManager::resetKey(const InputActionT i)
{
- InputFunction &key = mKey[i];
+ InputFunction &key = mKey[static_cast<size_t>(i)];
for (size_t i2 = 1; i2 < inputFunctionSize; i2 ++)
{
InputItem &ki2 = key.values[i2];
ki2.type = InputType::UNKNOWN;
ki2.value = -1;
}
- const InputActionData &kd = inputActionData[i];
+ const InputActionData &kd = inputActionData[static_cast<size_t>(i)];
InputItem &val0 = key.values[0];
val0.type = kd.defaultType1;
InputItem &val1 = key.values[1];
@@ -257,26 +259,27 @@ void InputManager::resetKey(const int i)
void InputManager::resetKeys()
{
- for (int i = 0; i < InputAction::TOTAL; i++)
- resetKey(i);
+ for (int i = 0; i < static_cast<int>(InputAction::TOTAL); i++)
+ resetKey(static_cast<InputActionT>(i));
}
-void InputManager::makeDefault(const int i)
+void InputManager::makeDefault(const InputActionT i)
{
- if (i >= 0 && i < InputAction::TOTAL)
+ if (i > InputAction::NO_VALUE && i < InputAction::TOTAL)
{
resetKey(i);
update();
}
}
-bool InputManager::hasConflicts(int &restrict key1, int &restrict key2) const
+bool InputManager::hasConflicts(InputActionT &restrict key1,
+ InputActionT &restrict key2) const
{
/**
* No need to parse the square matrix: only check one triangle
* that's enough to detect conflicts
*/
- for (int i = 0; i < InputAction::TOTAL; i++)
+ for (int i = 0; i < static_cast<int>(InputAction::TOTAL); i++)
{
const InputActionData &kdi = inputActionData[i];
if (!*kdi.configField)
@@ -286,11 +289,11 @@ bool InputManager::hasConflicts(int &restrict key1, int &restrict key2) const
for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++)
{
const InputItem &vali2 = ki.values[i2];
- if (vali2.value == InputAction::NO_VALUE)
+ if (vali2.value == -1)
continue;
size_t j;
- for (j = i, j++; j < InputAction::TOTAL; j++)
+ for (j = i, j++; j < static_cast<int>(InputAction::TOTAL); j++)
{
if ((kdi.grp & inputActionData[j].grp) == 0
|| !*kdi.configField)
@@ -307,8 +310,8 @@ bool InputManager::hasConflicts(int &restrict key1, int &restrict key2) const
&& vali2.value == valj2.value
&& vali2.type == valj2.type)
{
- key1 = static_cast<int>(i);
- key2 = static_cast<int>(j);
+ key1 = static_cast<InputActionT>(i);
+ key2 = static_cast<InputActionT>(j);
return true;
}
}
@@ -323,12 +326,12 @@ void InputManager::callbackNewKey()
mSetupInput->newKeyCallback(mNewKeyIndex);
}
-bool InputManager::isActionActive(const int index) const
+bool InputManager::isActionActive(const InputActionT index) const
{
if (!isActionActive0(index))
return false;
- const InputActionData &key = inputActionData[index];
+ const InputActionData &key = inputActionData[static_cast<size_t>(index)];
// logger->log("isActionActive mask=%d, condition=%d, index=%d",
// mMask, key.condition, index);
if ((key.condition & mMask) != key.condition)
@@ -336,7 +339,7 @@ bool InputManager::isActionActive(const int index) const
return true;
}
-bool InputManager::isActionActive0(const int index)
+bool InputManager::isActionActive0(const InputActionT index)
{
if (keyboard.isActionActive(index))
return true;
@@ -345,17 +348,17 @@ bool InputManager::isActionActive0(const int index)
return touchManager.isActionActive(index);
}
-InputFunction &InputManager::getKey(int index)
+InputFunction &InputManager::getKey(InputActionT index)
{
- if (index < 0 || index >= InputAction::TOTAL)
- index = 0;
- return mKey[index];
+ if (static_cast<int>(index) < 0 || index >= InputAction::TOTAL)
+ index = InputAction::MOVE_UP;
+ return mKey[static_cast<size_t>(index)];
}
-std::string InputManager::getKeyStringLong(const int index) const
+std::string InputManager::getKeyStringLong(const InputActionT index) const
{
std::string keyStr;
- const InputFunction &ki = mKey[index];
+ const InputFunction &ki = mKey[static_cast<size_t>(index)];
for (size_t i = 0; i < inputFunctionSize; i ++)
{
@@ -395,10 +398,10 @@ std::string InputManager::getKeyStringLong(const int index) const
return keyStr;
}
-std::string InputManager::getKeyValueString(const int index) const
+std::string InputManager::getKeyValueString(const InputActionT index) const
{
std::string keyStr;
- const InputFunction &ki = mKey[index];
+ const InputFunction &ki = mKey[static_cast<size_t>(index)];
for (size_t i = 0; i < inputFunctionSize; i ++)
{
@@ -441,7 +444,7 @@ std::string InputManager::getKeyValueString(const int index) const
std::string InputManager::getKeyValueByName(const std::string &keyName)
{
- const StringIntMapCIter it = mNameMap.find(keyName);
+ const StringInpActionMapCIter it = mNameMap.find(keyName);
if (it == mNameMap.end())
return std::string();
@@ -450,21 +453,22 @@ std::string InputManager::getKeyValueByName(const std::string &keyName)
std::string InputManager::getKeyValueByNameLong(const std::string &keyName)
{
- const StringIntMapCIter it = mNameMap.find(keyName);
+ const StringInpActionMapCIter it = mNameMap.find(keyName);
if (it == mNameMap.end())
return std::string();
return getKeyStringLong((*it).second);
}
-void InputManager::addActionKey(const int action, const int type,
+void InputManager::addActionKey(const InputActionT action,
+ const int type,
const int val)
{
- if (action < 0 || action >= InputAction::TOTAL)
+ if (static_cast<int>(action) < 0 || action >= InputAction::TOTAL)
return;
int idx = -1;
- InputFunction &key = mKey[action];
+ InputFunction &key = mKey[static_cast<size_t>(action)];
for (size_t i = 0; i < inputFunctionSize; i ++)
{
const InputItem &val2 = key.values[i];
@@ -507,7 +511,7 @@ void InputManager::setNewKey(const SDL_Event &event, const int type)
void InputManager::unassignKey()
{
- InputFunction &key = mKey[mNewKeyIndex];
+ InputFunction &key = mKey[static_cast<size_t>(mNewKeyIndex)];
for (size_t i = 0; i < inputFunctionSize; i ++)
{
InputItem &val = key.values[i];
@@ -747,27 +751,29 @@ bool InputManager::checkKey(const InputActionData *const key) const
}
bool InputManager::invokeKey(const InputActionData *const key,
- const int keyNum)
+ const InputActionT keyNum)
{
// no validation to keyNum because it validated in caller
if (checkKey(key))
{
InputEvent evt(keyNum, mMask);
- ActionFuncPtr func = *(inputActionData[keyNum].action);
+ ActionFuncPtr func = *(inputActionData[
+ static_cast<size_t>(keyNum)].action);
if (func && func(evt))
return true;
}
return false;
}
-void InputManager::executeAction(const int keyNum)
+void InputManager::executeAction(const InputActionT keyNum)
{
- if (keyNum < 0 || keyNum >= InputAction::TOTAL)
+ if (keyNum < InputAction::MOVE_UP || keyNum >= InputAction::TOTAL)
return;
InputEvent evt(keyNum, mMask);
- ActionFuncPtr func = *(inputActionData[keyNum].action);
+ ActionFuncPtr func = *(inputActionData[static_cast<size_t>(
+ keyNum)].action);
if (func)
func(evt);
}
@@ -790,13 +796,14 @@ bool InputManager::executeChatCommand(const std::string &cmd,
return false;
}
-bool InputManager::executeChatCommand(const int keyNum,
+bool InputManager::executeChatCommand(const InputActionT keyNum,
const std::string &args,
ChatTab *const tab)
{
- if (keyNum < 0 || keyNum >= InputAction::TOTAL)
+ if (static_cast<int>(keyNum) < 0 || keyNum >= InputAction::TOTAL)
return false;
- ActionFuncPtr func = *(inputActionData[keyNum].action);
+ ActionFuncPtr func = *(inputActionData[static_cast<size_t>(
+ keyNum)].action);
if (func)
{
InputEvent evt(args, tab, mMask);
@@ -814,7 +821,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap,
actionMap.clear();
keyTimeMap.clear();
- for (size_t i = 0; i < InputAction::TOTAL; i ++)
+ for (size_t i = 0; i < static_cast<size_t>(InputAction::TOTAL); i ++)
{
const InputFunction &key = mKey[i];
const InputActionData &kd = inputActionData[i];
@@ -824,7 +831,10 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap,
{
const InputItem &ki = key.values[i2];
if (ki.type == type && ki.value != -1)
- actionMap[ki.value].push_back(static_cast<int>(i));
+ {
+ actionMap[ki.value].push_back(
+ static_cast<InputActionT>(i));
+ }
}
}
if (kd.configField && (kd.grp & Input::GRP_GUICHAN))
@@ -833,7 +843,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap,
{
const InputItem &ki = key.values[i2];
if (ki.type == type && ki.value != -1)
- idMap[ki.value] = static_cast<int>(i);
+ idMap[ki.value] = static_cast<InputActionT>(i);
}
}
if (kd.configField && (kd.grp & Input::GRP_REPEAT))
@@ -865,20 +875,21 @@ bool InputManager::triggerAction(const KeysVector *const ptrs)
FOR_EACHP (KeysVectorCIter, it, ptrs)
{
- const int keyNum = *it;
- if (keyNum < 0 || keyNum >= InputAction::TOTAL)
+ const InputActionT keyNum = *it;
+ if (static_cast<int>(keyNum) < 0 || keyNum >= InputAction::TOTAL)
continue;
- if (invokeKey(&inputActionData[keyNum], keyNum))
+ if (invokeKey(&inputActionData[static_cast<size_t>(keyNum)], keyNum))
return true;
}
return false;
}
-int InputManager::getKeyIndex(const int value, const int grp,
- const int type) const
+InputActionT InputManager::getKeyIndex(const int value,
+ const int grp,
+ const int type) const
{
- for (size_t i = 0; i < InputAction::TOTAL; i++)
+ for (size_t i = 0; i < static_cast<size_t>(InputAction::TOTAL); i++)
{
const InputFunction &key = mKey[i];
const InputActionData &kd = inputActionData[i];
@@ -888,28 +899,31 @@ int InputManager::getKeyIndex(const int value, const int grp,
if (value == vali2.value && (grp & kd.grp) != 0
&& vali2.type == type)
{
- return static_cast<int>(i);
+ return static_cast<InputActionT>(i);
}
}
}
return InputAction::NO_VALUE;
}
-int InputManager::getActionByKey(const SDL_Event &event) const
+InputActionT InputManager::getActionByKey(const SDL_Event &event) const
{
// for now support only keyboard events
if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
{
- const int idx = keyboard.getActionId(event);
- if (idx >= 0 && checkKey(&inputActionData[idx]))
+ const InputActionT idx = keyboard.getActionId(event);
+ if (static_cast<int>(idx) >= 0 &&
+ checkKey(&inputActionData[static_cast<size_t>(idx)]))
+ {
return idx;
+ }
}
return InputAction::NO_VALUE;
}
void InputManager::addChatCommands(std::list<std::string> &arr)
{
- for (int i = 0; i < InputAction::TOTAL; i++)
+ for (int i = 0; i < static_cast<int>(InputAction::TOTAL); i++)
{
const InputActionData &ad = inputActionData[i];
std::string cmd = ad.chatCommand;
diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h
index 9526e8cdd..79a197799 100644
--- a/src/input/inputmanager.h
+++ b/src/input/inputmanager.h
@@ -37,6 +37,9 @@ class Setup_Input;
struct InputActionData;
+typedef std::map<std::string, InputActionT> StringInpActionMap;
+typedef StringInpActionMap::const_iterator StringInpActionMapCIter;
+
class InputManager final
{
public:
@@ -56,35 +59,37 @@ class InputManager final
void resetKeys();
- void makeDefault(const int i);
+ void makeDefault(const InputActionT i);
- bool hasConflicts(int &restrict key1,
- int &restrict key2) const A_WARN_UNUSED;
+ bool hasConflicts(InputActionT &restrict key1,
+ InputActionT &restrict key2) const A_WARN_UNUSED;
void callbackNewKey();
- InputFunction &getKey(int index) A_WARN_UNUSED;
+ InputFunction &getKey(InputActionT index) A_WARN_UNUSED;
- std::string getKeyValueString(const int index) const A_WARN_UNUSED;
+ std::string getKeyValueString(const InputActionT index) const A_WARN_UNUSED;
- std::string getKeyStringLong(const int index) const A_WARN_UNUSED;
+ std::string getKeyStringLong(const InputActionT index) const A_WARN_UNUSED;
std::string getKeyValueByName(const std::string &keyName);
std::string getKeyValueByNameLong(const std::string &keyName);
- void addActionKey(const int action, const int type, const int val);
+ void addActionKey(const InputActionT action,
+ const int type,
+ const int val);
void setNewKey(const SDL_Event &event, const int type);
void unassignKey();
- bool isActionActive(const int index) const A_WARN_UNUSED;
+ bool isActionActive(const InputActionT index) const A_WARN_UNUSED;
/**
* Set the index of the new key to be assigned.
*/
- void setNewKeyIndex(const int value)
+ void setNewKeyIndex(const InputActionT value)
{ mNewKeyIndex = value; }
/**
@@ -96,14 +101,15 @@ class InputManager final
/**
* Get the index of the new key to be assigned.
*/
- int getNewKeyIndex() const A_WARN_UNUSED
+ InputActionT getNewKeyIndex() const A_WARN_UNUSED
{ return mNewKeyIndex; }
void updateKeyActionMap(KeyToActionMap &actionMap,
KeyToIdMap &idMap, KeyTimeMap &keyTimeMap,
const int type) const;
- bool invokeKey(const InputActionData *const key, const int keyNum);
+ bool invokeKey(const InputActionData *const key,
+ const InputActionT keyNum);
bool handleAssignKey(const SDL_Event &event, const int type);
@@ -111,42 +117,44 @@ class InputManager final
bool triggerAction(const KeysVector *const ptrs);
- int getKeyIndex(const int value, const int grp,
- const int type) const A_WARN_UNUSED;
+ InputActionT getKeyIndex(const int value,
+ const int grp,
+ const int type) const A_WARN_UNUSED;
static void update();
void updateConditionMask();
- int getActionByKey(const SDL_Event &event) const A_WARN_UNUSED;
+ InputActionT getActionByKey(const SDL_Event &event)
+ const A_WARN_UNUSED;
- void executeAction(const int keyNum);
+ void executeAction(const InputActionT keyNum);
bool executeChatCommand(const std::string &cmd,
const std::string &args,
ChatTab *const tab);
- bool executeChatCommand(const int keyNum,
+ bool executeChatCommand(const InputActionT keyNum,
const std::string &args,
ChatTab *const tab);
void addChatCommands(std::list<std::string> &arr);
protected:
- void resetKey(const int i);
+ void resetKey(const InputActionT i);
- static bool isActionActive0(const int index) A_WARN_UNUSED;
+ static bool isActionActive0(const InputActionT index) A_WARN_UNUSED;
- Setup_Input *mSetupInput; /**< Reference to setup window */
+ Setup_Input *mSetupInput; /**< Reference to setup window */
- int mNewKeyIndex; /**< Index of new key to be assigned */
+ InputActionT mNewKeyIndex; /**< Index of new key to be assigned */
int mMask;
- StringIntMap mNameMap;
+ StringInpActionMap mNameMap;
StringIntMap mChatMap;
- InputFunction mKey[InputAction::TOTAL];
+ InputFunction mKey[static_cast<size_t>(InputAction::TOTAL)];
};
extern InputManager inputManager;
diff --git a/src/input/joystick.cpp b/src/input/joystick.cpp
index e54347907..9e674a263 100644
--- a/src/input/joystick.cpp
+++ b/src/input/joystick.cpp
@@ -320,7 +320,7 @@ int Joystick::getButtonFromEvent(const SDL_Event &event) const
return event.jbutton.button;
}
-bool Joystick::isActionActive(const int index) const
+bool Joystick::isActionActive(const InputActionT index) const
{
if (!validate())
return false;
diff --git a/src/input/joystick.h b/src/input/joystick.h
index 01937c829..d5f31798a 100644
--- a/src/input/joystick.h
+++ b/src/input/joystick.h
@@ -124,7 +124,7 @@ class Joystick final
int getButtonFromEvent(const SDL_Event &event) const A_WARN_UNUSED;
- bool isActionActive(const int index) const A_WARN_UNUSED;
+ bool isActionActive(const InputActionT index) const A_WARN_UNUSED;
bool validate() const A_WARN_UNUSED;
diff --git a/src/input/keyboardconfig.cpp b/src/input/keyboardconfig.cpp
index 9229d4184..80ad2fcd9 100644
--- a/src/input/keyboardconfig.cpp
+++ b/src/input/keyboardconfig.cpp
@@ -73,7 +73,7 @@ int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event)
#endif
}
-int KeyboardConfig::getKeyIndex(const SDL_Event &event, const int grp)
+InputActionT KeyboardConfig::getKeyIndex(const SDL_Event &event, const int grp)
{
const int keyValue = getKeyValueFromEvent(event);
return inputManager.getKeyIndex(keyValue, grp, InputType::KEYBOARD);
@@ -86,9 +86,9 @@ void KeyboardConfig::refreshActiveKeys()
std::string KeyboardConfig::getKeyName(const int key)
{
- if (key == InputAction::NO_VALUE)
+ if (key == -1)
return "";
- if (key >= 0)
+ if (key > -1)
{
#ifdef USE_SDL2
return SDL_GetKeyName(SDL_GetKeyFromScancode(
@@ -99,7 +99,7 @@ std::string KeyboardConfig::getKeyName(const int key)
}
// TRANSLATORS: long key name, should be short
- return strprintf(_("key_%d"), key);
+ return strprintf(_("key_%d"), static_cast<int>(key));
}
std::string KeyboardConfig::getKeyShortString(const std::string &key)
@@ -174,16 +174,16 @@ KeysVector *KeyboardConfig::getActionVectorByKey(const int i)
return nullptr;
}
-int KeyboardConfig::getActionId(const SDL_Event &event)
+InputActionT KeyboardConfig::getActionId(const SDL_Event &event)
{
const int i = getKeyValueFromEvent(event);
// logger->log("getActionId: %d", i);
if (i != 0 && i < SDLK_LAST && mKeyToId.find(i) != mKeyToId.end())
return mKeyToId[i];
- return -1;
+ return InputAction::NO_VALUE;
}
-bool KeyboardConfig::isActionActive(const int index) const
+bool KeyboardConfig::isActionActive(const InputActionT index) const
{
if (!mActiveKeys)
return false;
diff --git a/src/input/keyboardconfig.h b/src/input/keyboardconfig.h
index 7b1d09e33..5b36fd65c 100644
--- a/src/input/keyboardconfig.h
+++ b/src/input/keyboardconfig.h
@@ -54,8 +54,8 @@ class KeyboardConfig final
/**
* Get the key function index by providing the keys value.
*/
- static int getKeyIndex(const SDL_Event &event,
- const int grp = 1) A_WARN_UNUSED;
+ static InputActionT getKeyIndex(const SDL_Event &event,
+ const int grp = 1) A_WARN_UNUSED;
/**
* Set the enable flag, which will stop the user from doing actions.
@@ -79,9 +79,9 @@ class KeyboardConfig final
KeysVector *getActionVectorByKey(const int i) A_WARN_UNUSED;
- static std::string getKeyName(const int key)A_WARN_UNUSED;
+ static std::string getKeyName(const int key) A_WARN_UNUSED;
- bool isActionActive(const int index) const A_WARN_UNUSED;
+ bool isActionActive(const InputActionT index) const A_WARN_UNUSED;
void update();
@@ -93,7 +93,7 @@ class KeyboardConfig final
void handleDeActicateKey(const int key);
- int getActionId(const SDL_Event &event) A_WARN_UNUSED;
+ InputActionT getActionId(const SDL_Event &event) A_WARN_UNUSED;
void handleRepeat(const int time);
diff --git a/src/input/keyinput.h b/src/input/keyinput.h
index 8555d8bbb..229b4d212 100644
--- a/src/input/keyinput.h
+++ b/src/input/keyinput.h
@@ -66,6 +66,8 @@
#include "enums/events/keyeventtype.h"
+#include "enums/input/inputaction.h"
+
#include "input/key.h"
#include "localconsts.h"
@@ -79,7 +81,7 @@ class KeyInput final
#ifdef USE_SDL2
mText(),
#endif
- mActionId(-2)
+ mActionId(InputAction::UNDEFINED_VALUE)
{ }
~KeyInput()
@@ -105,12 +107,12 @@ class KeyInput final
return mKey;
}
- void setActionId(const int n)
+ void setActionId(const InputActionT n)
{
mActionId = n;
}
- int getActionId() const A_WARN_UNUSED
+ InputActionT getActionId() const A_WARN_UNUSED
{
return mActionId;
}
@@ -142,7 +144,7 @@ class KeyInput final
std::string mText;
#endif
- int mActionId;
+ InputActionT mActionId;
};
#endif // INPUT_KEYINPUT_H
diff --git a/src/listeners/inputactionreplaylistener.cpp b/src/listeners/inputactionreplaylistener.cpp
index 11f81ee0f..130b5fa7d 100644
--- a/src/listeners/inputactionreplaylistener.cpp
+++ b/src/listeners/inputactionreplaylistener.cpp
@@ -37,7 +37,7 @@ InputActionReplayListener::InputActionReplayListener() :
void InputActionReplayListener::openDialog(const std::string &caption,
const std::string &text,
- const InputAction::Type action0)
+ const InputActionT action0)
{
mDialog = new EditDialog(caption, text, "OK");
mDialog->postInit();
diff --git a/src/listeners/inputactionreplaylistener.h b/src/listeners/inputactionreplaylistener.h
index d1d762639..5df084c70 100644
--- a/src/listeners/inputactionreplaylistener.h
+++ b/src/listeners/inputactionreplaylistener.h
@@ -43,11 +43,11 @@ class InputActionReplayListener final : public ActionListener
void openDialog(const std::string &caption,
const std::string &text,
- const InputAction::Type action0);
+ const InputActionT action0);
protected:
EditDialog *mDialog;
- InputAction::Type mAction;
+ InputActionT mAction;
};
extern InputActionReplayListener inputActionReplayListener;
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index b7db9d83f..f3adecf8e 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -328,11 +328,14 @@ bool TouchManager::processEvent(const MouseInput &mouseInput)
return false;
}
-bool TouchManager::isActionActive(const int index) const
+bool TouchManager::isActionActive(const InputActionT index) const
{
- if (index < 0 || index >= actionsSize)
+ if (static_cast<int>(index) < 0 ||
+ static_cast<int>(index) >= actionsSize)
+ {
return false;
- return mActions[index];
+ }
+ return mActions[static_cast<size_t>(index)];
}
void TouchManager::resize(const int width, const int height)
@@ -670,5 +673,6 @@ void TouchManager::setTempHide(const bool b)
void TouchManager::executeAction(const std::string &event)
{
- inputManager.executeAction(config.getIntValue(event));
+ inputManager.executeAction(static_cast<InputActionT>(
+ config.getIntValue(event)));
}
diff --git a/src/touchmanager.h b/src/touchmanager.h
index a8c83b8d7..932d1981f 100644
--- a/src/touchmanager.h
+++ b/src/touchmanager.h
@@ -38,7 +38,7 @@ class MouseInput;
typedef void (*TouchFuncPtr) (const MouseInput &mouseInput);
-const int actionsSize = InputAction::TOTAL;
+const int actionsSize = static_cast<int>(InputAction::TOTAL);
const int buttonsCount = 12;
struct TouchItem final
@@ -131,12 +131,16 @@ class TouchManager final : public ConfigListener
bool processEvent(const MouseInput &mouseInput);
- bool isActionActive(const int index) const;
+ bool isActionActive(const InputActionT index) const;
- void setActionActive(const int index, const bool value)
+ void setActionActive(const InputActionT index,
+ const bool value)
{
- if (index >= 0 && index < actionsSize)
- mActions[index] = value;
+ if (static_cast<int>(index) >= 0 &&
+ static_cast<int>(index) < actionsSize)
+ {
+ mActions[static_cast<size_t>(index)] = value;
+ }
}
void resize(const int width, const int height);