From 15b7e8f11f8fcf48efe50c7af00fe9864c3d1732 Mon Sep 17 00:00:00 2001 From: beaglejoe Date: Tue, 8 Dec 2015 16:33:19 +0000 Subject: [PATCH] Fix for Numpad key #936 git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6300 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 748aed9ec239bca84d9140ff1b5e10fdbb3016ca Former-commit-id: de047abaa7cac97f050ee55a74157bf76665a590 --- src/libs/tgf/eventloop.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libs/tgf/eventloop.cpp b/src/libs/tgf/eventloop.cpp index b8abb59a..aa62126c 100644 --- a/src/libs/tgf/eventloop.cpp +++ b/src/libs/tgf/eventloop.cpp @@ -58,8 +58,10 @@ private: // Private data members. //! Initialization flag for the underlying software layers. static bool _bInitialized; +#if SDL_MAJOR_VERSION < 2 //! Unicode for each typed SDL key sym + modifier std::map _mapUnicodes; +#endif }; GfEventLoop::Private::Private() @@ -82,6 +84,10 @@ GfEventLoop::Private::Private() // is typed ; we never clears this map, but assume not that many such combinations // will be typed in a game session (could theorically go up to 2^23 combinations, though ;-) // Known issues (TODO): No support for Caps and NumLock keys ... don't use them ! + +// As of SDL2, this translation to unicode is no longer needed. SDL2 has unicode support +// It can now be used to translate keycodes to other keycodes. See SDLK_KP_ENTER +// below, we do not want to treat the two keys as distinct. int GfEventLoop::Private::translateKeySym(int code, int modifier, int unicode) { #if SDL_MAJOR_VERSION < 2 @@ -112,6 +118,10 @@ int GfEventLoop::Private::translateKeySym(int code, int modifier, int unicode) // Done. return keyUnicode; #else + // Make the Numpad key behave like the regular key + if(SDLK_KP_ENTER == code) + code = SDLK_RETURN; + return code; #endif }