ManaPlus
|
#include <inputmanager.h>
Public Member Functions | |
InputManager () | |
void | init () |
bool | handleEvent (const SDL_Event &event) |
bool | checkKey (const InputActionData *const key) const |
void | retrieve () |
void | store () const |
void | resetKeys () |
void | makeDefault (const InputActionT i) |
bool | hasConflicts (InputActionT &key1, InputActionT &key2) const |
void | callbackNewKey () |
InputFunction & | getKey (InputActionT index) A_CONST |
std::string | getKeyValueString (const InputActionT index) const |
std::string | getKeyStringLong (const InputActionT index) const |
std::string | getKeyValueByName (const std::string &keyName) |
std::string | getKeyValueByNameLong (const std::string &keyName) |
void | addActionKey (const InputActionT action, const InputTypeT type, const int val) |
void | setNewKey (const SDL_Event &event, const InputTypeT type) |
void | unassignKey () |
bool | isActionActive (const InputActionT index) const |
void | setNewKeyIndex (const InputActionT value) |
void | setSetupInput (Setup_Input *const setupInput) |
InputActionT | getNewKeyIndex () const |
void | updateKeyActionMap (KeyToActionMap &actionMap, KeyToIdMap &idMap, KeyTimeMap &keyTimeMap, const InputTypeT type) const |
bool | invokeKey (const InputActionData *const key, const InputActionT keyNum) |
bool | handleAssignKey (const SDL_Event &event, const InputTypeT type) |
bool | triggerAction (const KeysVector *const ptrs) |
InputActionT | getKeyIndex (const int value, const int grp, const InputTypeT type) const |
void | updateConditionMask (const bool pressed) |
InputActionT | getActionByKey (const SDL_Event &event) const |
void | executeAction (const InputActionT keyNum) |
bool | executeChatCommand (const std::string &cmd, const std::string &args, ChatTab *const tab) |
bool | executeRemoteChatCommand (const std::string &cmd, const std::string &args, ChatTab *const tab) |
bool | executeChatCommand (const InputActionT keyNum, const std::string &args, ChatTab *const tab) |
Static Public Member Functions | |
static void | handleRepeat () |
static void | update () |
static InputActionT | getActionByConfigField (const std::string &field) |
static void | addChatCommands (std::list< std::string > &arr) |
Protected Member Functions | |
void | resetKey (const InputActionT i) |
void | updateKeyString (const InputFunction &ki, const size_t actionIdx) |
Static Protected Member Functions | |
static bool | isActionActive0 (const InputActionT index) |
Protected Attributes | |
Setup_Input * | mSetupInput |
InputActionT | mNewKeyIndex |
int | mMask |
StringInpActionMap | mNameMap |
StringIntMap | mChatMap |
InputFunction | mKey [static_cast< size_t >(InputAction::TOTAL)] |
std::string | mKeyStr [static_cast< size_t >(InputAction::TOTAL)] |
Definition at line 46 of file inputmanager.h.
InputManager::InputManager | ( | ) |
Definition at line 80 of file inputmanager.cpp.
void InputManager::addActionKey | ( | const InputActionT | action, |
const InputTypeT | type, | ||
const int | val | ||
) |
Definition at line 511 of file inputmanager.cpp.
References QuitDialog::action(), CAST_S32, CAST_SIZE, inputFunctionSize, restrict, InputAction::TOTAL, and InputType::UNKNOWN.
|
static |
Definition at line 1082 of file inputmanager.cpp.
References CAST_S32, InputActionData::chatCommand, FOR_EACH, inputActionData, restrict, splitToStringVector(), InputAction::TOTAL, and UseArgs_true.
Referenced by ChatWindow::fillCommands().
void InputManager::callbackNewKey | ( | ) |
Definition at line 358 of file inputmanager.cpp.
References mNewKeyIndex, mSetupInput, and Setup_Input::newKeyCallback().
bool InputManager::checkKey | ( | const InputActionData *const | key | ) | const |
Definition at line 857 of file inputmanager.cpp.
References InputAction::NO_VALUE.
void InputManager::executeAction | ( | const InputActionT | keyNum | ) |
Definition at line 884 of file inputmanager.cpp.
References InputActionData::action, CAST_SIZE, inputActionData, and InputAction::TOTAL.
Referenced by WindowMenu::action(), HelpWindow::action(), InventoryWindow::action(), UploadListener::action(), Client::action(), TouchManager::executeAction(), TextField::focusGained(), PopupMenu::handleLink(), Desktop::handleLink(), ItemLinkHandler::handleLink(), and TextField::mousePressed().
bool InputManager::executeChatCommand | ( | const InputActionT | keyNum, |
const std::string & | args, | ||
ChatTab *const | tab | ||
) |
Definition at line 944 of file inputmanager.cpp.
References InputActionData::action, CAST_S32, CAST_SIZE, inputActionData, and InputAction::TOTAL.
bool InputManager::executeChatCommand | ( | const std::string & | cmd, |
const std::string & | args, | ||
ChatTab *const | tab | ||
) |
Definition at line 898 of file inputmanager.cpp.
References InputActionData::action, inputActionData, and reportAlways.
Referenced by InputActionReplayListener::action(), IPC::flush(), GuildTab::handleCommand(), PartyTab::handleCommand(), ChatTab::handleCommandStr(), PopupMenu::handleLink(), and ChatWindow::mousePressed().
bool InputManager::executeRemoteChatCommand | ( | const std::string & | cmd, |
const std::string & | args, | ||
ChatTab *const | tab | ||
) |
Definition at line 922 of file inputmanager.cpp.
References data, inputActionData, Protected_true, and restrict.
Referenced by InputActionRemoteListener::action(), ItemLinkHandler::handleCommandLink(), and Ea::PlayerRecv::processPlayerClientCommand().
|
static |
Definition at line 1071 of file inputmanager.cpp.
References CAST_S32, InputActionData::configField, inputActionData, InputAction::NO_VALUE, and InputAction::TOTAL.
InputActionT InputManager::getActionByKey | ( | const SDL_Event & | event | ) | const |
Definition at line 1055 of file inputmanager.cpp.
References CAST_S32, CAST_SIZE, KeyboardConfig::getActionId(), inputActionData, keyboard, and InputAction::NO_VALUE.
Referenced by SDLInput::convertKeyEventToKey().
InputFunction & InputManager::getKey | ( | InputActionT | index | ) |
Definition at line 388 of file inputmanager.cpp.
References CAST_S32, CAST_SIZE, InputAction::MOVE_UP, and InputAction::TOTAL.
Referenced by Joystick::isActionActive(), and KeyboardConfig::isActionActive().
InputActionT InputManager::getKeyIndex | ( | const int | value, |
const int | grp, | ||
const InputTypeT | type | ||
) | const |
Definition at line 1034 of file inputmanager.cpp.
References CAST_SIZE, inputActionData, inputFunctionSize, InputAction::NO_VALUE, restrict, and InputAction::TOTAL.
Referenced by KeyboardConfig::getKeyIndex().
std::string InputManager::getKeyStringLong | ( | const InputActionT | index | ) | const |
Definition at line 395 of file inputmanager.cpp.
References _, CAST_SIZE, KeyboardConfig::getKeyName(), inputFunctionSize, InputType::JOYSTICK, InputType::KEYBOARD, restrict, and strprintf().
Referenced by OutfitWindow::keyName(), and Setup_Input::refreshAssignedKey().
std::string InputManager::getKeyValueByName | ( | const std::string & | keyName | ) |
Definition at line 491 of file inputmanager.cpp.
std::string InputManager::getKeyValueByNameLong | ( | const std::string & | keyName | ) |
Definition at line 501 of file inputmanager.cpp.
Referenced by BrowserBoxTools::replaceKeys().
std::string InputManager::getKeyValueString | ( | const InputActionT | index | ) | const |
Definition at line 485 of file inputmanager.cpp.
References CAST_SIZE.
Referenced by ItemShortcutContainer::draw(), EmoteShortcutContainer::draw(), WindowMenu::mouseMoved(), ItemShortcutContainer::safeDraw(), EmoteShortcutContainer::safeDraw(), and StatusPopup::setLabelText().
|
inline |
Get the index of the new key to be assigned.
Definition at line 117 of file inputmanager.h.
References mNewKeyIndex.
Referenced by Setup_Input::keyUnresolved().
bool InputManager::handleAssignKey | ( | const SDL_Event & | event, |
const InputTypeT | type | ||
) |
Definition at line 576 of file inputmanager.cpp.
References Window::isWindowVisible(), InputAction::NO_VALUE, and setupWindow.
bool InputManager::handleEvent | ( | const SDL_Event & | event | ) |
Definition at line 598 of file inputmanager.cpp.
References BLOCK_END, BLOCK_START, Joystick::getActionVector(), KeyboardConfig::getActionVector(), gui, guiInput, KeyboardConfig::handleActivateKey(), KeyboardConfig::handleDeActicateKey(), Gui::handleInput(), InputAction::IGNORE_INPUT_1, InputAction::IGNORE_INPUT_2, TextDialog::isActive(), InputType::JOYSTICK, joystick, InputType::KEYBOARD, keyboard, multiTouchManager, SDLInput::pushInput(), quitDialog, KeyboardConfig::refreshActiveKeys(), and Joystick::validate().
Referenced by EventsManager::handleCommonEvents().
|
static |
Definition at line 753 of file inputmanager.cpp.
References Joystick::handleRepeat(), KeyboardConfig::handleRepeat(), joystick, keyboard, and tick_time.
Referenced by Game::handleInput().
bool InputManager::hasConflicts | ( | InputActionT & | key1, |
InputActionT & | key2 | ||
) | const |
No need to parse the square matrix: only check one triangle that's enough to detect conflicts
Definition at line 309 of file inputmanager.cpp.
References CAST_S32, InputActionData::grp, inputActionData, inputFunctionSize, restrict, InputAction::TOTAL, and InputType::UNKNOWN.
Referenced by Setup_Input::apply().
void InputManager::init | ( | ) |
Definition at line 90 of file inputmanager.cpp.
References CAST_SIZE, inputFunctionSize, mKey, mKeyStr, mNewKeyIndex, InputAction::NO_VALUE, resetKeys(), retrieve(), InputAction::TOTAL, InputItem::type, InputType::UNKNOWN, update(), InputItem::value, and InputFunction::values.
Referenced by Client::gameInit().
bool InputManager::invokeKey | ( | const InputActionData *const | key, |
const InputActionT | keyNum | ||
) |
Definition at line 868 of file inputmanager.cpp.
References InputActionData::action, CAST_SIZE, and inputActionData.
bool InputManager::isActionActive | ( | const InputActionT | index | ) | const |
Definition at line 365 of file inputmanager.cpp.
References CAST_SIZE, inputActionData, and restrict.
Referenced by InventoryWindow::action(), Actions::doSit(), ActorManager::findBeingByPixel(), ActorManager::findBeingsByPixel(), ActorManager::findNearestLivingBeing(), Game::handleInput(), Gui::handleKeyInput(), Game::handleMove(), TextField::keyPressed(), ChatWindow::keyPressed(), InventoryWindow::mouseClicked(), ChatWindow::mousePressed(), ItemContainer::mouseReleased(), InventoryWindow::moveItemToCraft(), and Viewport::validateSpeed().
|
staticprotected |
Definition at line 379 of file inputmanager.cpp.
References Joystick::isActionActive(), KeyboardConfig::isActionActive(), TouchManager::isActionActive(), joystick, keyboard, and touchManager.
void InputManager::makeDefault | ( | const InputActionT | i | ) |
Definition at line 300 of file inputmanager.cpp.
References InputAction::NO_VALUE, InputAction::TOTAL, and UserAgent::update().
Referenced by Setup_Input::action().
|
protected |
Definition at line 253 of file inputmanager.cpp.
References CAST_SIZE, inputActionData, inputFunctionSize, InputType::KEYBOARD, restrict, and InputType::UNKNOWN.
Referenced by resetKeys().
void InputManager::resetKeys | ( | ) |
Definition at line 294 of file inputmanager.cpp.
References CAST_S32, resetKey(), and InputAction::TOTAL.
Referenced by Setup_Input::action(), and init().
void InputManager::retrieve | ( | ) |
Definition at line 123 of file inputmanager.cpp.
References CAST_S32, InputActionData::chatCommand, config, InputActionData::configField, FOR_EACH, ConfigurationObject::getValue(), inputActionData, inputFunctionSize, InputType::JOYSTICK, InputType::KEYBOARD, mChatMap, mKey, mNameMap, InputType::MOUSE, restrict, splitToStringVector(), InputAction::TOTAL, and updateKeyString().
Referenced by Setup_Input::cancel(), and init().
void InputManager::setNewKey | ( | const SDL_Event & | event, |
const InputTypeT | type | ||
) |
Definition at line 546 of file inputmanager.cpp.
References Joystick::getButtonFromEvent(), KeyboardConfig::getKeyValueFromEvent(), InputType::JOYSTICK, joystick, InputType::KEYBOARD, and UserAgent::update().
|
inline |
Set the index of the new key to be assigned.
Definition at line 104 of file inputmanager.h.
References mNewKeyIndex.
Referenced by Setup_Input::action(), and Setup_Input::keyUnresolved().
|
inline |
Set a reference to the key setup window.
Definition at line 110 of file inputmanager.h.
References mSetupInput.
Referenced by Setup_Input::Setup_Input().
void InputManager::store | ( | ) | const |
Definition at line 195 of file inputmanager.cpp.
References CAST_S32, config, InputActionData::configField, inputActionData, inputFunctionSize, InputType::JOYSTICK, InputType::KEYBOARD, mKey, InputType::MOUSE, restrict, Configuration::setValue(), strprintf(), Catch::toString(), InputAction::TOTAL, and InputType::UNKNOWN.
Referenced by Setup_Input::apply().
bool InputManager::triggerAction | ( | const KeysVector *const | ptrs | ) |
Definition at line 1014 of file inputmanager.cpp.
References CAST_S32, CAST_SIZE, FOR_EACHP, inputActionData, and InputAction::TOTAL.
Referenced by Joystick::handleRepeat(), and KeyboardConfig::handleRepeat().
void InputManager::unassignKey | ( | ) |
Definition at line 562 of file inputmanager.cpp.
References CAST_SIZE, inputFunctionSize, mKey, mNewKeyIndex, restrict, InputType::UNKNOWN, update(), and updateKeyString().
Referenced by Setup_Input::action().
|
static |
Definition at line 116 of file inputmanager.cpp.
References joystick, keyboard, Joystick::update(), and KeyboardConfig::update().
Referenced by Setup_Input::action(), init(), and unassignKey().
void InputManager::updateConditionMask | ( | const bool | pressed | ) |
Definition at line 761 of file inputmanager.cpp.
References InputCondition::ALIVE, Settings::awayMode, chatWindow, Settings::disableGameModifiers, InputCondition::EMODS, InputCondition::ENABLED, NpcDialog::getActive(), Gui::getFocusHandler(), LocalPlayer::getFollow(), FocusHandler::getModalFocused(), gui, InputCondition::INGAME, Game::instance(), SellDialog::isActive(), BuyDialog::isActive(), Being::isAlive(), InventoryWindow::isAnyInputFocused(), NpcDialog::isAnyInputFocused(), KeyboardConfig::isEnabled(), TradeWindow::isInpupFocused(), ChatWindow::isInputFocused(), PlayerInfo::isInRoom(), InventoryWindow::isStorageActive(), ActorSprite::isTrickDead(), PlayerInfo::isVending(), Window::isWindowVisible(), InputCondition::KEY_DOWN, keyboard, localPlayer, InputCondition::NOAWAY, InputCondition::NOBLOCK, InputCondition::NOBUYSELL, InputCondition::NOFOLLOW, InputCondition::NOINPUT, InputCondition::NOMODAL, InputCondition::NONPCDIALOG, InputCondition::NONPCINPUT, InputCondition::NOROOM, InputCondition::NOSETUP, InputCondition::NOTALKING, InputCondition::NOTARGET, InputCondition::NOVENDING, restrict, settings, setupWindow, InputAction::STOP_ATTACK, tradeWindow, InputAction::UNTARGET, and InputCondition::VALIDSPEED.
Referenced by moveChar().
void InputManager::updateKeyActionMap | ( | KeyToActionMap & | actionMap, |
KeyToIdMap & | idMap, | ||
KeyTimeMap & | keyTimeMap, | ||
const InputTypeT | type | ||
) | const |
Definition at line 961 of file inputmanager.cpp.
References CAST_SIZE, FOR_EACH, Input::GRP_GUICHAN, Input::GRP_REPEAT, inputActionData, anonymous_namespace{inputmanager.cpp}::inputActionDataSorter, inputFunctionSize, InputActionSortFunctor::keys, restrict, and InputAction::TOTAL.
Referenced by Joystick::update(), and KeyboardConfig::update().
|
protected |
Definition at line 439 of file inputmanager.cpp.
References _, KeyboardConfig::getKeyName(), KeyboardConfig::getKeyShortString(), inputFunctionSize, InputType::JOYSTICK, InputType::KEYBOARD, restrict, STD_MOVE, and strprintf().
Referenced by retrieve(), and unassignKey().
|
protected |
Definition at line 181 of file inputmanager.h.
Referenced by retrieve().
|
protected |
Definition at line 183 of file inputmanager.h.
Referenced by init(), retrieve(), store(), and unassignKey().
|
protected |
Definition at line 184 of file inputmanager.h.
Referenced by init().
|
protected |
Definition at line 178 of file inputmanager.h.
|
protected |
Definition at line 180 of file inputmanager.h.
Referenced by retrieve().
|
protected |
Index of new key to be assigned
Definition at line 176 of file inputmanager.h.
Referenced by callbackNewKey(), getNewKeyIndex(), init(), setNewKeyIndex(), and unassignKey().
|
protected |
Reference to setup window
Definition at line 174 of file inputmanager.h.
Referenced by callbackNewKey(), and setSetupInput().