summaryrefslogtreecommitdiff
path: root/src/keyboardconfig.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/keyboardconfig.cpp
parentb9fe47de21f8c899bfe36f70633a8c8110314d77 (diff)
downloadmv-c7f5d0a71d7318ccc4c3f28ab90d688a1a0868b3.tar.gz
mv-c7f5d0a71d7318ccc4c3f28ab90d688a1a0868b3.tar.bz2
mv-c7f5d0a71d7318ccc4c3f28ab90d688a1a0868b3.tar.xz
mv-c7f5d0a71d7318ccc4c3f28ab90d688a1a0868b3.zip
fix keyboard handling in gui in SDL2.
Diffstat (limited to 'src/keyboardconfig.cpp')
-rw-r--r--src/keyboardconfig.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index d0c56ec1d..2bc33fc41 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -61,10 +61,14 @@ void KeyboardConfig::deinit()
int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event) const
{
+#ifdef USE_SDL2
+ return event.key.keysym.scancode;
+#else
if (event.key.keysym.sym)
return event.key.keysym.sym;
else if (event.key.keysym.scancode > 1)
return -event.key.keysym.scancode;
+#endif
return 0;
}
@@ -84,7 +88,14 @@ std::string KeyboardConfig::getKeyName(const int key)
if (key == Input::KEY_NO_VALUE)
return "";
if (key >= 0)
+ {
+#ifdef USE_SDL2
+ return SDL_GetKeyName(SDL_GetKeyFromScancode(
+ static_cast<SDL_Scancode>(key)));
+#else
return SDL_GetKeyName(static_cast<SDLKey>(key));
+#endif
+ }
// TRANSLATORS: long key name, should be short
return strprintf(_("key_%d"), key);
@@ -138,7 +149,11 @@ std::string KeyboardConfig::getKeyShortString(const std::string &key)
SDLKey KeyboardConfig::getKeyFromEvent(const SDL_Event &event)
{
+#ifdef USE_SDL2
+ return event.key.keysym.scancode;
+#else
return event.key.keysym.sym;
+#endif
}
KeysVector *KeyboardConfig::getActionVector(const SDL_Event &event)