From c7f5d0a71d7318ccc4c3f28ab90d688a1a0868b3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 23 Aug 2013 18:03:05 +0300 Subject: fix keyboard handling in gui in SDL2. --- src/inputmanager.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/inputmanager.cpp') 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(); } -- cgit v1.2.3-70-g09d2