From c581ab01d8d67bb4c21094ee44d357e7d724e29e Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sun, 5 Feb 2017 21:25:06 +0100 Subject: [PATCH] Some preparations to compile with SDL1.2 (not yet!) --- BBGE/ActionInput.cpp | 27 +++++++++++++++++++++------ BBGE/BBGECompileConfig.h | 1 - BBGE/Joystick.cpp | 4 ---- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/BBGE/ActionInput.cpp b/BBGE/ActionInput.cpp index 823c917..1aa7a08 100644 --- a/BBGE/ActionInput.cpp +++ b/BBGE/ActionInput.cpp @@ -24,17 +24,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core.h" #include "SDL.h" -#ifndef BBGE_BUILD_SDL2 -#error Needs fixes for SDL 1.2, doesnt support scancodes -#endif static std::string inputcode2string(int k) { if(k <= 0) return std::string(); - if(k < SDL_NUM_SCANCODES) + if(k < KEY_MAXARRAY) { - const char *name = SDL_GetScancodeName((SDL_Scancode)k); + const char *name; +#ifdef BBGE_BUILD_SDL2 + name = SDL_GetScancodeName((SDL_Scancode)k); +#else + name = SDL_GetKeyName((SDLKey)k); +#endif if(name) return name; @@ -113,11 +115,15 @@ std::string getInputCodeToUserString(unsigned int k, size_t joystickID) // Special case keyboard input: // Return key name for current keyboard layout! // It's just confusing to see Y instead of Z with a german keyboard layout... - if(k < SDL_NUM_SCANCODES) + if(k < KEY_MAXARRAY) { +#ifdef BBGE_BUILD_SDL2 const SDL_Keycode kcode = SDL_GetKeyFromScancode((SDL_Scancode)k); if(kcode != SDLK_UNKNOWN) pretty = SDL_GetKeyName(kcode); +#else + pretty = SDL_GetKeyName((SDLKey)k); +#endif } if(k >= JOY_AXIS_0_POS && k < JOY_AXIS_END_POS) { @@ -143,6 +149,11 @@ std::string getInputCodeToUserString(unsigned int k, size_t joystickID) return inputcode2string(k); } +#ifndef BBGE_BUILD_SDL2 +static bool s_needKeyTabInit = false; +std::map s_keyNameMap; +#endif + int getStringToInputCode(const std::string& s) { if(s == "LMB") @@ -170,7 +181,11 @@ int getStringToInputCode(const std::string& s) if(s == "NONE") return 0; +#ifdef BBGE_BUILD_SDL2 return SDL_GetScancodeFromName(underscoresToSpaces(s).c_str()); +#else + return SDL_GetKeyFromName(underscoresToSpaces(s).c_str()); +#endif } diff --git a/BBGE/BBGECompileConfig.h b/BBGE/BBGECompileConfig.h index 0ecb6f2..f4419bd 100644 --- a/BBGE/BBGECompileConfig.h +++ b/BBGE/BBGECompileConfig.h @@ -10,7 +10,6 @@ #define BBGE_BUILD_FMOD_OPENAL_BRIDGE 1 #define BBGE_BUILD_ACHIEVEMENTS_INTERNAL 1 #define BBGE_BUILD_VFS 1 -#define BBGE_BUILD_SDL2 1 #endif diff --git a/BBGE/Joystick.cpp b/BBGE/Joystick.cpp index 41d57c2..b9e1b54 100644 --- a/BBGE/Joystick.cpp +++ b/BBGE/Joystick.cpp @@ -19,10 +19,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef BBGE_BUILD_SDL2 -#error test this -#endif - #include "Joystick.h" #include "Core.h"