mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-04 02:24:00 +00:00
Some preparations to compile with SDL1.2 (not yet!)
This commit is contained in:
parent
0b7334c7b7
commit
c581ab01d8
3 changed files with 21 additions and 11 deletions
|
@ -24,17 +24,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#include "SDL.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)
|
static std::string inputcode2string(int k)
|
||||||
{
|
{
|
||||||
if(k <= 0)
|
if(k <= 0)
|
||||||
return std::string();
|
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)
|
if(name)
|
||||||
return name;
|
return name;
|
||||||
|
|
||||||
|
@ -113,11 +115,15 @@ std::string getInputCodeToUserString(unsigned int k, size_t joystickID)
|
||||||
// Special case keyboard input:
|
// Special case keyboard input:
|
||||||
// Return key name for current keyboard layout!
|
// Return key name for current keyboard layout!
|
||||||
// It's just confusing to see Y instead of Z with a german 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);
|
const SDL_Keycode kcode = SDL_GetKeyFromScancode((SDL_Scancode)k);
|
||||||
if(kcode != SDLK_UNKNOWN)
|
if(kcode != SDLK_UNKNOWN)
|
||||||
pretty = SDL_GetKeyName(kcode);
|
pretty = SDL_GetKeyName(kcode);
|
||||||
|
#else
|
||||||
|
pretty = SDL_GetKeyName((SDLKey)k);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if(k >= JOY_AXIS_0_POS && k < JOY_AXIS_END_POS)
|
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);
|
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)
|
int getStringToInputCode(const std::string& s)
|
||||||
{
|
{
|
||||||
if(s == "LMB")
|
if(s == "LMB")
|
||||||
|
@ -170,7 +181,11 @@ int getStringToInputCode(const std::string& s)
|
||||||
if(s == "NONE")
|
if(s == "NONE")
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
#ifdef BBGE_BUILD_SDL2
|
||||||
return SDL_GetScancodeFromName(underscoresToSpaces(s).c_str());
|
return SDL_GetScancodeFromName(underscoresToSpaces(s).c_str());
|
||||||
|
#else
|
||||||
|
return SDL_GetKeyFromName(underscoresToSpaces(s).c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#define BBGE_BUILD_FMOD_OPENAL_BRIDGE 1
|
#define BBGE_BUILD_FMOD_OPENAL_BRIDGE 1
|
||||||
#define BBGE_BUILD_ACHIEVEMENTS_INTERNAL 1
|
#define BBGE_BUILD_ACHIEVEMENTS_INTERNAL 1
|
||||||
#define BBGE_BUILD_VFS 1
|
#define BBGE_BUILD_VFS 1
|
||||||
#define BBGE_BUILD_SDL2 1
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -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.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BBGE_BUILD_SDL2
|
|
||||||
#error test this
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Joystick.h"
|
#include "Joystick.h"
|
||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue