#include <config.h>
#include <version.h>
+#include <SDL.h>
#include <SDL_image.h>
#include <physfs.h>
#include <iostream>
#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"
PHYSFS_permitSymbolicLinks(1);
// Initialize physfs (this is a slightly modified version of
- // PHYSFS_setSaneConfig
+ // PHYSFS_setSaneConfig)
const char* application = PACKAGE_NAME;
const char* userdir = PHYSFS_getUserDir();
- char* writedir = new char[strlen(userdir) + strlen(application) + 2];
+
+ char* writedir = new char[strlen(userdir) + strlen(application) +
+#ifndef _WIN32
+ 2];
+#else
+ 1];
+#endif
// Set configuration directory
- sprintf(writedir, "%s.%s", userdir, application);
+ sprintf(writedir,
+#ifndef _WIN32
+ "%s.%s",
+#else
+ "%s%s",
+#endif
+ userdir, application);
if(!PHYSFS_setWriteDir(writedir)) {
// try to create the directory
- char* mkdir = new char[strlen(application) + 2];
- sprintf(mkdir, ".%s", application);
+ char* mkdir = new char[strlen(application) +
+#ifndef _WIN32
+ 2];
+#else
+ 1];
+#endif
+ sprintf(mkdir,
+#ifndef _WIN32
+ ".%s",
+#else
+ "%s",
+#endif
+ application);
if(!PHYSFS_setWriteDir(userdir) || !PHYSFS_mkdir(mkdir)) {
std::ostringstream msg;
msg << "Failed creating configuration directory '"
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());
SDL_WM_SetIcon(icon, 0);
SDL_FreeSurface(icon);
}
-#ifndef NDEBUG
else {
log_warning << "Couldn't load icon '" << icon_fname << "'" << std::endl;
}
-#endif
SDL_ShowCursor(0);
}
}
-#ifndef NDEBUG
static Uint32 last_timelog_ticks = 0;
static const char* last_timelog_component = 0;
last_timelog_ticks = current_ticks;
last_timelog_component = component;
}
-#else
-static inline void timelog(const char* )
-{
-}
-#endif
int
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();