supertux/main, control/haptic_manager: Add SDL 1.2 compatibility code.
[supertux.git] / src / supertux / main.cpp
index 98a6cc3..1a05161 100644 (file)
@@ -17,6 +17,7 @@
 #include <config.h>
 #include <version.h>
 
+#include <SDL.h>
 #include <SDL_image.h>
 #include <physfs.h>
 #include <iostream>
@@ -34,6 +35,7 @@ namespace supertux_apple {
 #include "addon/addon_manager.hpp"
 #include "audio/sound_manager.hpp"
 #include "control/joystickkeyboardcontroller.hpp"
+#include "control/haptic_manager.hpp"
 #include "math/random_generator.hpp"
 #include "physfs/ifile_stream.hpp"
 #include "physfs/physfs_sdl.hpp"
@@ -399,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) < 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());
@@ -555,6 +564,9 @@ Main::run(int argc, char** argv)
     init_physfs(argv[0]);
     init_sdl();
 
+    timelog("haptic");
+    g_haptic_manager = new HapticManager();
+
     timelog("controller");
     g_main_controller = new JoystickKeyboardController();