#include "control/haptic_manager.hpp"
#include "util/log.hpp"
+#if SDL_VERSION_ATLEAST(1,3,0)
HapticManager::HapticManager () /* {{{ */
{
int i;
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 : */
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());