summaryrefslogtreecommitdiff
path: root/src/inputmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/inputmanager.cpp')
-rw-r--r--src/inputmanager.cpp36
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)