From a01c8632961792ba92a5c0bda8308d1260444b41 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 17 Jul 2014 22:11:37 +0300 Subject: Rename KeyFunction into InputFunction. --- src/input/inputfunction.h | 35 +++++++++++++++++++++++++++ src/input/inputmanager.cpp | 56 ++++++++++++++++++++++---------------------- src/input/inputmanager.h | 6 ++--- src/input/joystick.cpp | 4 ++-- src/input/keyboardconfig.cpp | 4 ++-- src/input/keyfunction.h | 35 --------------------------- 6 files changed, 70 insertions(+), 70 deletions(-) create mode 100644 src/input/inputfunction.h delete mode 100644 src/input/keyfunction.h (limited to 'src/input') diff --git a/src/input/inputfunction.h b/src/input/inputfunction.h new file mode 100644 index 000000000..6345e875d --- /dev/null +++ b/src/input/inputfunction.h @@ -0,0 +1,35 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 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 . + */ + +#ifndef INPUT_INPUTFUNCTION_H +#define INPUT_INPUTFUNCTION_H + +#include "input/inputitem.h" + +#include "localconsts.h" + +const unsigned int inputFunctionSize = 3; + +struct InputFunction final +{ + InputItem values[inputFunctionSize]; +}; + +#endif // INPUT_INPUTFUNCTION_H diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index f62b76c64..429297cfd 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -79,8 +79,8 @@ void InputManager::init() { for (unsigned int i = 0; i < InputAction::TOTAL; i++) { - KeyFunction &kf = mKey[i]; - for (unsigned int f = 0; f < KeyFunctionSize; f ++) + InputFunction &kf = mKey[i]; + for (unsigned int f = 0; f < inputFunctionSize; f ++) { InputItem &ki = kf.values[f]; ki.type = InputType::UNKNOWN; @@ -114,7 +114,7 @@ void InputManager::retrieve() if (!cf.empty()) { mNameMap[cf] = i; - KeyFunction &kf = mKey[i]; + InputFunction &kf = mKey[i]; const std::string keyStr = config.getValue(cf, ""); const size_t keyStrSize = keyStr.size(); if (keyStr.empty()) @@ -124,7 +124,7 @@ void InputManager::retrieve() splitToStringVector(keys, keyStr, ','); unsigned int i2 = 0; for (StringVectCIter it = keys.begin(), it_end = keys.end(); - it != it_end && i2 < KeyFunctionSize; ++ it) + it != it_end && i2 < inputFunctionSize; ++ it) { std::string keyStr2 = *it; if (keyStrSize < 2) @@ -169,9 +169,9 @@ void InputManager::store() const if (!cf.empty()) { std::string keyStr; - const KeyFunction &kf = mKey[i]; + const InputFunction &kf = mKey[i]; - for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++) + for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++) { const InputItem &key = kf.values[i2]; if (key.type != InputType::UNKNOWN) @@ -212,8 +212,8 @@ void InputManager::store() const void InputManager::resetKey(const int i) { - KeyFunction &key = mKey[i]; - for (size_t i2 = 1; i2 < KeyFunctionSize; i2 ++) + InputFunction &key = mKey[i]; + for (size_t i2 = 1; i2 < inputFunctionSize; i2 ++) { InputItem &ki2 = key.values[i2]; ki2.type = InputType::UNKNOWN; @@ -266,8 +266,8 @@ bool InputManager::hasConflicts(int &restrict key1, int &restrict key2) const if (!*kdi.configField) continue; - const KeyFunction &ki = mKey[i]; - for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++) + const InputFunction &ki = mKey[i]; + for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++) { const InputItem &vali2 = ki.values[i2]; if (vali2.value == InputAction::NO_VALUE) @@ -279,7 +279,7 @@ bool InputManager::hasConflicts(int &restrict key1, int &restrict key2) const if ((kdi.grp & inputActionData[j].grp) == 0 || !*kdi.configField) continue; - for (size_t j2 = 0; j2 < KeyFunctionSize; j2 ++) + for (size_t j2 = 0; j2 < inputFunctionSize; j2 ++) { const InputItem &valj2 = mKey[j].values[j2]; // Allow for item shortcut and emote keys to overlap @@ -326,7 +326,7 @@ bool InputManager::isActionActive0(const int index) return touchManager.isActionActive(index); } -KeyFunction &InputManager::getKey(int index) +InputFunction &InputManager::getKey(int index) { if (index < 0 || index >= InputAction::TOTAL) index = 0; @@ -336,9 +336,9 @@ KeyFunction &InputManager::getKey(int index) std::string InputManager::getKeyStringLong(const int index) const { std::string keyStr; - const KeyFunction &ki = mKey[index]; + const InputFunction &ki = mKey[index]; - for (size_t i = 0; i < KeyFunctionSize; i ++) + for (size_t i = 0; i < inputFunctionSize; i ++) { const InputItem &key = ki.values[i]; std::string str; @@ -379,9 +379,9 @@ std::string InputManager::getKeyStringLong(const int index) const std::string InputManager::getKeyValueString(const int index) const { std::string keyStr; - const KeyFunction &ki = mKey[index]; + const InputFunction &ki = mKey[index]; - for (size_t i = 0; i < KeyFunctionSize; i ++) + for (size_t i = 0; i < inputFunctionSize; i ++) { const InputItem &key = ki.values[i]; std::string str; @@ -437,8 +437,8 @@ void InputManager::addActionKey(const int action, const int type, return; int idx = -1; - KeyFunction &key = mKey[action]; - for (size_t i = 0; i < KeyFunctionSize; i ++) + InputFunction &key = mKey[action]; + for (size_t i = 0; i < inputFunctionSize; i ++) { const InputItem &val2 = key.values[i]; if (val2.type == InputType::UNKNOWN || (val2.type == type @@ -450,14 +450,14 @@ void InputManager::addActionKey(const int action, const int type, } if (idx == -1) { - for (size_t i = 1; i < KeyFunctionSize; i ++) + for (size_t i = 1; i < inputFunctionSize; i ++) { InputItem &val1 = key.values[i - 1]; InputItem &val2 = key.values[i]; val1.type = val2.type; val1.value = val2.value; } - idx = KeyFunctionSize - 1; + idx = inputFunctionSize - 1; } key.values[idx] = InputItem(type, val); @@ -480,8 +480,8 @@ void InputManager::setNewKey(const SDL_Event &event, const int type) void InputManager::unassignKey() { - KeyFunction &key = mKey[mNewKeyIndex]; - for (size_t i = 0; i < KeyFunctionSize; i ++) + InputFunction &key = mKey[mNewKeyIndex]; + for (size_t i = 0; i < inputFunctionSize; i ++) { InputItem &val = key.values[i]; val.type = InputType::UNKNOWN; @@ -729,11 +729,11 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, for (size_t i = 0; i < InputAction::TOTAL; i ++) { - const KeyFunction &key = mKey[i]; + const InputFunction &key = mKey[i]; const InputActionData &kd = inputActionData[i]; if (kd.action) { - for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++) + for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++) { const InputItem &ki = key.values[i2]; if (ki.type == type && ki.value != -1) @@ -742,7 +742,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, } if (kd.configField && (kd.grp & Input::GRP_GUICHAN)) { - for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++) + for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++) { const InputItem &ki = key.values[i2]; if (ki.type == type && ki.value != -1) @@ -751,7 +751,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, } if (kd.configField && (kd.grp & Input::GRP_REPEAT)) { - for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++) + for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++) { const InputItem &ki = key.values[i2]; if (ki.type == type && ki.value != -1) @@ -793,9 +793,9 @@ int InputManager::getKeyIndex(const int value, const int grp, { for (size_t i = 0; i < InputAction::TOTAL; i++) { - const KeyFunction &key = mKey[i]; + const InputFunction &key = mKey[i]; const InputActionData &kd = inputActionData[i]; - for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++) + for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++) { const InputItem &vali2 = key.values[i2]; if (value == vali2.value && (grp & kd.grp) != 0 diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h index 11db43402..02bc0315b 100644 --- a/src/input/inputmanager.h +++ b/src/input/inputmanager.h @@ -22,7 +22,7 @@ #define INPUT_INPUTMANAGER_H #include "input/inputaction.h" -#include "input/keyfunction.h" +#include "input/inputfunction.h" #include "events/inputevent.h" @@ -61,7 +61,7 @@ class InputManager final void callbackNewKey(); - KeyFunction &getKey(int index) A_WARN_UNUSED; + InputFunction &getKey(int index) A_WARN_UNUSED; std::string getKeyValueString(const int index) const A_WARN_UNUSED; @@ -131,7 +131,7 @@ class InputManager final std::map mNameMap; - KeyFunction mKey[InputAction::TOTAL]; + InputFunction mKey[InputAction::TOTAL]; }; extern InputManager inputManager; diff --git a/src/input/joystick.cpp b/src/input/joystick.cpp index 674633833..2170bdc48 100644 --- a/src/input/joystick.cpp +++ b/src/input/joystick.cpp @@ -325,8 +325,8 @@ bool Joystick::isActionActive(const int index) const if (!validate()) return false; - const KeyFunction &key = inputManager.getKey(index); - for (size_t i = 0; i < KeyFunctionSize; i ++) + const InputFunction &key = inputManager.getKey(index); + for (size_t i = 0; i < inputFunctionSize; i ++) { const InputItem &val = key.values[i]; if (val.type != InputType::JOYSTICK) diff --git a/src/input/keyboardconfig.cpp b/src/input/keyboardconfig.cpp index a8949e84a..b989b2d30 100644 --- a/src/input/keyboardconfig.cpp +++ b/src/input/keyboardconfig.cpp @@ -190,8 +190,8 @@ bool KeyboardConfig::isActionActive(const int index) const if (!mActiveKeys) return false; - const KeyFunction &key = inputManager.getKey(index); - for (size_t i = 0; i < KeyFunctionSize; i ++) + const InputFunction &key = inputManager.getKey(index); + for (size_t i = 0; i < inputFunctionSize; i ++) { const InputItem &val = key.values[i]; if (val.type != InputType::KEYBOARD) diff --git a/src/input/keyfunction.h b/src/input/keyfunction.h deleted file mode 100644 index 22d8e358f..000000000 --- a/src/input/keyfunction.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 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 . - */ - -#ifndef INPUT_KEYFUNCTION_H -#define INPUT_KEYFUNCTION_H - -#include "input/inputitem.h" - -#include "localconsts.h" - -const unsigned int KeyFunctionSize = 3; - -struct KeyFunction final -{ - InputItem values[KeyFunctionSize]; -}; - -#endif // INPUT_KEYFUNCTION_H -- cgit v1.2.3-70-g09d2