diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-04-15 19:00:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-04-15 19:34:01 +0300 |
commit | 29ef15b2fd5d3b3af1adaa8a4e168f9b791a9ed7 (patch) | |
tree | 8623a9f6274a4548262566e20c75f30806e08b25 /src/inputmanager.cpp | |
parent | 4193299e2e05d40477a50e5cb0fcc906227f53a2 (diff) | |
download | manaplus-29ef15b2fd5d3b3af1adaa8a4e168f9b791a9ed7.tar.gz manaplus-29ef15b2fd5d3b3af1adaa8a4e168f9b791a9ed7.tar.bz2 manaplus-29ef15b2fd5d3b3af1adaa8a4e168f9b791a9ed7.tar.xz manaplus-29ef15b2fd5d3b3af1adaa8a4e168f9b791a9ed7.zip |
In input settings tab add default button for reset selected action to default value.
Diffstat (limited to 'src/inputmanager.cpp')
-rw-r--r-- | src/inputmanager.cpp | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp index e7ac40cf0..51eca37f7 100644 --- a/src/inputmanager.cpp +++ b/src/inputmanager.cpp @@ -80,8 +80,13 @@ void InputManager::init() mNewKeyIndex = Input::KEY_NO_VALUE; - makeDefault(); + resetKeys(); retrieve(); + update(); +} + +void InputManager::update() +{ keyboard.update(); if (joystick) joystick->update(); @@ -183,7 +188,7 @@ void InputManager::store() } } -void InputManager::makeDefault() +void InputManager::resetKeys() { for (int i = 0; i < Input::KEY_TOTAL; i++) { @@ -200,6 +205,25 @@ void InputManager::makeDefault() } } +void InputManager::makeDefault(int i) +{ + if (i >= 0 && i < Input::KEY_TOTAL) + { + KeyFunction &key = mKey[i]; + for (size_t i2 = 1; i2 < KeyFunctionSize; i2 ++) + { + key.values[i2].type = INPUT_UNKNOWN; + key.values[i2].value = -1; + } + key.values[0].type = keyData[i].defaultType1; + key.values[0].value = keyData[i].defaultValue1; + key.values[1].type = keyData[i].defaultType2; + key.values[1].value = keyData[i].defaultValue2; + + update(); + } +} + bool InputManager::hasConflicts(int &key1, int &key2) { size_t i; @@ -381,9 +405,7 @@ void InputManager::setNewKey(const SDL_Event &event, int type) if (val != -1) { addActionKey(mNewKeyIndex, type, val); - keyboard.update(); - if (joystick) - joystick->update(); + update(); } } @@ -395,9 +417,7 @@ void InputManager::unassignKey() key.values[i].type = INPUT_UNKNOWN; key.values[i].value = -1; } - keyboard.update(); - if (joystick) - joystick->update(); + update(); } bool InputManager::handleAssignKey(const SDL_Event &event, int type) |