diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-17 16:13:39 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-17 16:13:39 +0300 |
commit | 3e16eec4b33fb8882957b45c83c5c1f2b57625d2 (patch) | |
tree | 1ed0e3286446771049652551454fae234cad6a21 /src/input | |
parent | 25ef222f6fa5d0c9c13a76b3e2149cfec3b13227 (diff) | |
download | ManaVerse-3e16eec4b33fb8882957b45c83c5c1f2b57625d2.tar.gz ManaVerse-3e16eec4b33fb8882957b45c83c5c1f2b57625d2.tar.bz2 ManaVerse-3e16eec4b33fb8882957b45c83c5c1f2b57625d2.tar.xz ManaVerse-3e16eec4b33fb8882957b45c83c5c1f2b57625d2.zip |
Rename keydata into inputactiondata.
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/inputactiondata.h (renamed from src/input/keydata.h) | 2 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 4 | ||||
-rw-r--r-- | src/input/inputmanager.cpp | 38 | ||||
-rw-r--r-- | src/input/inputmanager.h | 6 | ||||
-rw-r--r-- | src/input/keysortfunctor.h | 4 |
5 files changed, 27 insertions, 27 deletions
diff --git a/src/input/keydata.h b/src/input/inputactiondata.h index 8e4411bca..7681154df 100644 --- a/src/input/keydata.h +++ b/src/input/inputactiondata.h @@ -29,7 +29,7 @@ typedef bool (*ActionFuncPtr) (const InputEvent &event); -struct KeyData final +struct InputActionData final { const char *configField; int defaultType1; diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index fb810a683..3ab04c98a 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -27,17 +27,17 @@ #include "localconsts.h" #include "input/inputaction.h" +#include "input/inputactiondata.h" #include "input/inputcondition.h" #include "input/inputmanager.h" #include "input/inputtype.h" -#include "input/keydata.h" #include "utils/gettext.h" #include <string> // keyData must be in same order as enum keyAction. -static const KeyData keyData[InputAction::TOTAL] = { +static const InputActionData inputActionData[InputAction::TOTAL] = { {"keyMoveUp", InputType::KEYBOARD, SDLK_UP, InputType::UNKNOWN, InputAction::NO_VALUE, diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 8b3539042..e61372c21 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -64,7 +64,7 @@ extern QuitDialog *quitDialog; namespace { - KeySortFunctor keyDataSorter; + KeySortFunctor inputActionDataSorter; } // namespace InputManager::InputManager() : @@ -107,9 +107,9 @@ void InputManager::retrieve() for (int i = 0; i < InputAction::TOTAL; i++) { #ifdef USE_SDL2 - const std::string cf = std::string("sdl2") + keyData[i].configField; + const std::string cf = std::string("sdl2") + inputActionData[i].configField; #else - const std::string cf = keyData[i].configField; + const std::string cf = inputActionData[i].configField; #endif if (!cf.empty()) { @@ -162,9 +162,9 @@ void InputManager::store() const for (int i = 0; i < InputAction::TOTAL; i++) { #ifdef USE_SDL2 - const std::string cf = std::string("sdl2") + keyData[i].configField; + const std::string cf = std::string("sdl2") + inputActionData[i].configField; #else - const std::string cf = keyData[i].configField; + const std::string cf = inputActionData[i].configField; #endif if (!cf.empty()) { @@ -219,7 +219,7 @@ void InputManager::resetKey(const int i) ki2.type = InputType::UNKNOWN; ki2.value = -1; } - const KeyData &kd = keyData[i]; + const InputActionData &kd = inputActionData[i]; KeyItem &val0 = key.values[0]; val0.type = kd.defaultType1; KeyItem &val1 = key.values[1]; @@ -262,7 +262,7 @@ bool InputManager::hasConflicts(int &restrict key1, int &restrict key2) const */ for (int i = 0; i < InputAction::TOTAL; i++) { - const KeyData &kdi = keyData[i]; + const InputActionData &kdi = inputActionData[i]; if (!*kdi.configField) continue; @@ -276,7 +276,7 @@ bool InputManager::hasConflicts(int &restrict key1, int &restrict key2) const size_t j; for (j = i, j++; j < InputAction::TOTAL; j++) { - if ((kdi.grp & keyData[j].grp) == 0 || !*kdi.configField) + if ((kdi.grp & inputActionData[j].grp) == 0 || !*kdi.configField) continue; for (size_t j2 = 0; j2 < KeyFunctionSize; j2 ++) @@ -309,7 +309,7 @@ bool InputManager::isActionActive(const int index) const if (!isActionActive0(index)) return false; - const KeyData &key = keyData[index]; + const InputActionData &key = inputActionData[index]; // logger->log("isActionActive mask=%d, condition=%d, index=%d", // mMask, key.condition, index); if ((key.condition & mMask) != key.condition) @@ -684,7 +684,7 @@ void InputManager::updateConditionMask() mMask |= InputCondition::NOFOLLOW; } -bool InputManager::checkKey(const KeyData *const key) const +bool InputManager::checkKey(const InputActionData *const key) const { // logger->log("checkKey mask=%d, condition=%d", mMask, key->condition); if (!key || (key->condition & mMask) != key->condition) @@ -694,14 +694,14 @@ bool InputManager::checkKey(const KeyData *const key) const || isActionActive0(key->modKeyIndex)); } -bool InputManager::invokeKey(const KeyData *const key, const int keyNum) +bool InputManager::invokeKey(const InputActionData *const key, const int keyNum) { // no validation to keyNum because it validated in caller if (checkKey(key)) { InputEvent evt(keyNum, mMask); - ActionFuncPtr func = *(keyData[keyNum].action); + ActionFuncPtr func = *(inputActionData[keyNum].action); if (func && func(evt)) return true; } @@ -714,7 +714,7 @@ void InputManager::executeAction(const int keyNum) return; InputEvent evt(keyNum, mMask); - ActionFuncPtr func = *(keyData[keyNum].action); + ActionFuncPtr func = *(inputActionData[keyNum].action); if (func) func(evt); } @@ -730,7 +730,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, for (size_t i = 0; i < InputAction::TOTAL; i ++) { const KeyFunction &key = mKey[i]; - const KeyData &kd = keyData[i]; + const InputActionData &kd = inputActionData[i]; if (kd.action) { for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++) @@ -760,12 +760,12 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, } } - keyDataSorter.keys = &keyData[0]; + inputActionDataSorter.keys = &inputActionData[0]; FOR_EACH (KeyToActionMapIter, it, actionMap) { KeysVector *const keys = &it->second; if (keys && keys->size() > 1) - std::sort(keys->begin(), keys->end(), keyDataSorter); + std::sort(keys->begin(), keys->end(), inputActionDataSorter); } } @@ -782,7 +782,7 @@ bool InputManager::triggerAction(const KeysVector *const ptrs) if (keyNum < 0 || keyNum >= InputAction::TOTAL) continue; - if (invokeKey(&keyData[keyNum], keyNum)) + if (invokeKey(&inputActionData[keyNum], keyNum)) return true; } return false; @@ -794,7 +794,7 @@ int InputManager::getKeyIndex(const int value, const int grp, for (size_t i = 0; i < InputAction::TOTAL; i++) { const KeyFunction &key = mKey[i]; - const KeyData &kd = keyData[i]; + const InputActionData &kd = inputActionData[i]; for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++) { const KeyItem &vali2 = key.values[i2]; @@ -814,7 +814,7 @@ int InputManager::getActionByKey(const SDL_Event &event) const if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP) { const int idx = keyboard.getActionId(event); - if (idx >= 0 && checkKey(&keyData[idx])) + if (idx >= 0 && checkKey(&inputActionData[idx])) return idx; } return InputAction::NO_VALUE; diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h index ee5f101a8..11db43402 100644 --- a/src/input/inputmanager.h +++ b/src/input/inputmanager.h @@ -33,7 +33,7 @@ class Setup_Input; -struct KeyData; +struct InputActionData; class InputManager final { @@ -46,7 +46,7 @@ class InputManager final bool handleEvent(const SDL_Event &event); - bool checkKey(const KeyData *const key) const A_WARN_UNUSED; + bool checkKey(const InputActionData *const key) const A_WARN_UNUSED; void retrieve(); @@ -99,7 +99,7 @@ class InputManager final KeyToIdMap &idMap, KeyTimeMap &keyTimeMap, const int type) const; - bool invokeKey(const KeyData *const key, const int keyNum); + bool invokeKey(const InputActionData *const key, const int keyNum); bool handleAssignKey(const SDL_Event &event, const int type); diff --git a/src/input/keysortfunctor.h b/src/input/keysortfunctor.h index fae1bedda..fedb4c395 100644 --- a/src/input/keysortfunctor.h +++ b/src/input/keysortfunctor.h @@ -21,7 +21,7 @@ #ifndef INPUT_KEYSORTFUNCTOR_H #define INPUT_KEYSORTFUNCTOR_H -#include "input/keydata.h" +#include "input/inputactiondata.h" #include "localconsts.h" @@ -33,7 +33,7 @@ class KeySortFunctor final return keys[key1].priority >= keys[key2].priority; } - const KeyData *keys; + const InputActionData *keys; }; #endif // INPUT_KEYSORTFUNCTOR_H |