From 29ef15b2fd5d3b3af1adaa8a4e168f9b791a9ed7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 15 Apr 2012 19:00:38 +0300 Subject: In input settings tab add default button for reset selected action to default value. --- src/inputmanager.cpp | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'src/inputmanager.cpp') 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) -- cgit v1.2.3-60-g2f50