summaryrefslogtreecommitdiff
path: root/src/inputmanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-23 18:03:05 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 21:08:16 +0300
commitc7f5d0a71d7318ccc4c3f28ab90d688a1a0868b3 (patch)
tree6585eb0acd0afa4f11cd0b87661ce527cabda9ae /src/inputmanager.cpp
parentb9fe47de21f8c899bfe36f70633a8c8110314d77 (diff)
downloadmanaverse-c7f5d0a71d7318ccc4c3f28ab90d688a1a0868b3.tar.gz
manaverse-c7f5d0a71d7318ccc4c3f28ab90d688a1a0868b3.tar.bz2
manaverse-c7f5d0a71d7318ccc4c3f28ab90d688a1a0868b3.tar.xz
manaverse-c7f5d0a71d7318ccc4c3f28ab90d688a1a0868b3.zip
fix keyboard handling in gui in SDL2.
Diffstat (limited to 'src/inputmanager.cpp')
-rw-r--r--src/inputmanager.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp
index b0a31b442..6e421498e 100644
--- a/src/inputmanager.cpp
+++ b/src/inputmanager.cpp
@@ -212,10 +212,21 @@ void InputManager::resetKeys()
const KeyData &kd = keyData[i];
KeyItem &val0 = key.values[0];
val0.type = kd.defaultType1;
- val0.value = kd.defaultValue1;
KeyItem &val1 = key.values[1];
val1.type = kd.defaultType2;
+#ifdef USE_SDL2
+ if (kd.defaultType1 == INPUT_KEYBOARD)
+ val0.value = SDL_GetScancodeFromKey(kd.defaultValue1);
+ else
+ val0.value = kd.defaultValue1;
+ if (kd.defaultType2 == INPUT_KEYBOARD)
+ val1.value = SDL_GetScancodeFromKey(kd.defaultValue2);
+ else
+ val1.value = kd.defaultValue2;
+#else
+ val0.value = kd.defaultValue1;
val1.value = kd.defaultValue2;
+#endif
}
}
@@ -233,10 +244,22 @@ void InputManager::makeDefault(const int i)
const KeyData &kd = keyData[i];
KeyItem &val0 = key.values[0];
val0.type = kd.defaultType1;
- val0.value = kd.defaultValue1;
KeyItem &val1 = key.values[1];
val1.type = kd.defaultType2;
+
+#ifdef USE_SDL2
+ if (kd.defaultType1 == INPUT_KEYBOARD)
+ val0.value = SDL_GetScancodeFromKey(kd.defaultValue1);
+ else
+ val0.value = kd.defaultValue1;
+ if (kd.defaultType2 == INPUT_KEYBOARD)
+ val1.value = SDL_GetScancodeFromKey(kd.defaultValue2);
+ else
+ val1.value = kd.defaultValue2;
+#else
+ val0.value = kd.defaultValue1;
val1.value = kd.defaultValue2;
+#endif
update();
}