From: Florian Forster Date: Fri, 15 Jan 2010 15:51:13 +0000 (+0100) Subject: supertux/main, control/haptic_manager: Add SDL 1.2 compatibility code. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ede91db5aa7b350c80b931e29e0355f368ad2bb2;p=supertux.git supertux/main, control/haptic_manager: Add SDL 1.2 compatibility code. --- diff --git a/src/control/haptic_manager.cpp b/src/control/haptic_manager.cpp index 826d3ffb3..cda578291 100644 --- a/src/control/haptic_manager.cpp +++ b/src/control/haptic_manager.cpp @@ -19,6 +19,7 @@ #include "control/haptic_manager.hpp" #include "util/log.hpp" +#if SDL_VERSION_ATLEAST(1,3,0) HapticManager::HapticManager () /* {{{ */ { int i; @@ -90,5 +91,20 @@ void HapticManager::playEffect (haptic_effect_t idx) { /* {{{ */ SDL_HapticRunEffect (_device, _effect_ids[idx], /* iterations = */ 1); } /* }}} void playEffect */ +#else /* if SDL < 1.3 */ +/* If the SDL version is too old, provide dummy methods that don't to anything. + * This avoid using defines all over the place. */ +HapticManager::HapticManager () { + log_debug << "Haptic manager: Disabled because SDL version is too old." << std::endl; +} + +void HapticManager::addJoystick (SDL_Joystick *j) { + /* do nothing. */ +} + +void HapticManager::playEffect (haptic_effect_t idx) { + /* do nothing. */ +} +#endif /* SDL < 1.3 */ /* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index 48c2b7ebd..1a0516168 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -401,7 +401,14 @@ Main::parse_commandline(int argc, char** argv) void Main::init_sdl() { - if(SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC) < 0) { + int init_flags; + + init_flags = SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK; +#ifdef SDL_INIT_HAPTIC + init_flags |= SDL_INIT_HAPTIC; +#endif + + if(SDL_Init(init_flags) < 0) { std::stringstream msg; msg << "Couldn't initialize SDL: " << SDL_GetError(); throw std::runtime_error(msg.str());