From 3e16eec4b33fb8882957b45c83c5c1f2b57625d2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 17 Jul 2014 16:13:39 +0300 Subject: Rename keydata into inputactiondata. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/gui/popups/statuspopup.h | 2 +- src/gui/setupactiondata.h | 2 +- src/input/inputactiondata.h | 62 ++++++++++++++++++++++++++++++++++++++++++++ src/input/inputactionmap.h | 4 +-- src/input/inputmanager.cpp | 38 +++++++++++++-------------- src/input/inputmanager.h | 6 ++--- src/input/keydata.h | 62 -------------------------------------------- src/input/keysortfunctor.h | 4 +-- 10 files changed, 92 insertions(+), 92 deletions(-) create mode 100644 src/input/inputactiondata.h delete mode 100644 src/input/keydata.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0360cca8e..8d98c9405 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -805,6 +805,7 @@ SET(SRCS textcommand.cpp textcommand.h input/inputaction.h + input/inputactiondata.h input/inputactionmap.h input/inputcondition.h input/inputmanager.cpp @@ -815,7 +816,6 @@ SET(SRCS input/joystick.h input/keyboardconfig.cpp input/keyboardconfig.h - input/keydata.h input/keyfunction.h input/keyinput.h input/keyitem.h diff --git a/src/Makefile.am b/src/Makefile.am index 1c5e0d660..01b9438c5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -927,6 +927,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ textcommand.h \ events/inputevent.h \ input/inputaction.h \ + input/inputactiondata.h \ input/inputactionmap.h \ input/inputcondition.h \ input/inputmanager.cpp \ @@ -936,7 +937,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ input/joystick.h \ input/keyboardconfig.cpp \ input/keyboardconfig.h \ - input/keydata.h \ input/keyfunction.h \ input/keyinput.h \ input/keyitem.h \ diff --git a/src/gui/popups/statuspopup.h b/src/gui/popups/statuspopup.h index e0fe09d14..6dcdd636f 100644 --- a/src/gui/popups/statuspopup.h +++ b/src/gui/popups/statuspopup.h @@ -25,7 +25,7 @@ #define GUI_POPUPS_STATUSPOPUP_H #include "input/inputaction.h" -#include "input/keydata.h" +#include "input/inputactiondata.h" #include "gui/widgets/popup.h" diff --git a/src/gui/setupactiondata.h b/src/gui/setupactiondata.h index 41fa6e3d9..718dc2dc2 100644 --- a/src/gui/setupactiondata.h +++ b/src/gui/setupactiondata.h @@ -25,7 +25,7 @@ #define GUI_SETUPACTIONDATA_H #include "input/inputaction.h" -#include "input/keydata.h" +#include "input/inputactiondata.h" #include "utils/gettext.h" #include "utils/stringutils.h" diff --git a/src/input/inputactiondata.h b/src/input/inputactiondata.h new file mode 100644 index 000000000..7681154df --- /dev/null +++ b/src/input/inputactiondata.h @@ -0,0 +1,62 @@ +/* + * The ManaPlus Client + * Copyright (C) 2007 Joshua Langley + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-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_KEYDATA_H +#define INPUT_KEYDATA_H + +#include "events/inputevent.h" + +#include + +typedef bool (*ActionFuncPtr) (const InputEvent &event); + +struct InputActionData final +{ + const char *configField; + int defaultType1; + int defaultValue1; + int defaultType2; + int defaultValue2; + int grp; + ActionFuncPtr action; + int modKeyIndex; + int priority; + int condition; +}; + +namespace Input +{ + enum KeyGroup + { + GRP_DEFAULT = 1, // default game key + GRP_CHAT = 2, // chat key + GRP_EMOTION = 4, // emotions key + GRP_OUTFIT = 8, // outfit key + GRP_GUI = 16, // gui key + GRP_MOVETOPOINT = 32, // move to point key + GRP_GUICHAN = 64, // for guichan based controls + GRP_REPEAT = 128 // repeat emulation keys + }; + +} // namespace Input + +#endif // INPUT_KEYDATA_H 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 // 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/keydata.h b/src/input/keydata.h deleted file mode 100644 index 8e4411bca..000000000 --- a/src/input/keydata.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2007 Joshua Langley - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-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_KEYDATA_H -#define INPUT_KEYDATA_H - -#include "events/inputevent.h" - -#include - -typedef bool (*ActionFuncPtr) (const InputEvent &event); - -struct KeyData final -{ - const char *configField; - int defaultType1; - int defaultValue1; - int defaultType2; - int defaultValue2; - int grp; - ActionFuncPtr action; - int modKeyIndex; - int priority; - int condition; -}; - -namespace Input -{ - enum KeyGroup - { - GRP_DEFAULT = 1, // default game key - GRP_CHAT = 2, // chat key - GRP_EMOTION = 4, // emotions key - GRP_OUTFIT = 8, // outfit key - GRP_GUI = 16, // gui key - GRP_MOVETOPOINT = 32, // move to point key - GRP_GUICHAN = 64, // for guichan based controls - GRP_REPEAT = 128 // repeat emulation keys - }; - -} // namespace Input - -#endif // INPUT_KEYDATA_H 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 -- cgit v1.2.3-60-g2f50