From 694e07d193e7c5758a7d672b45668651b034003d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 31 May 2015 00:19:18 +0300 Subject: Convert InputAction enum into strong typed enum. --- src/events/inputevent.h | 13 ++++++++----- src/events/keyevent.h | 9 ++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src/events') 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 #include #include @@ -29,14 +31,14 @@ class ChatTab; -typedef std::vector KeysVector; +typedef std::vector KeysVector; typedef KeysVector::iterator KeysVectorIter; typedef KeysVector::const_iterator KeysVectorCIter; typedef std::map KeyToActionMap; typedef KeyToActionMap::iterator KeyToActionMapIter; -typedef std::map KeyToIdMap; +typedef std::map KeyToIdMap; typedef KeyToIdMap::iterator KeyToIdMapIter; typedef std::map 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 -- cgit v1.2.3-60-g2f50