1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-02-03 18:14:01 +00:00

Some preparations to compile with SDL1.2 (not yet!)

This commit is contained in:
fgenesis 2017-02-05 21:25:06 +01:00
parent 0b7334c7b7
commit c581ab01d8
3 changed files with 21 additions and 11 deletions

View file

@ -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<std::string, SDLKey> 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
}

View file

@ -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

View file

@ -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"