diff src/SDL.c @ 2713:0906692aa6a4

Final merge of Google Summer of Code 2008 work... Force Feedback for SDL by Edgar Simo, mentored by Ryan C. Gordon
author Sam Lantinga <slouken@libsdl.org>
date Mon, 25 Aug 2008 09:55:03 +0000
parents 8f1ab2f7c722
children 99210400e8b9
line wrap: on
line diff
--- a/src/SDL.c	Mon Aug 25 08:50:37 2008 +0000
+++ b/src/SDL.c	Mon Aug 25 09:55:03 2008 +0000
@@ -38,6 +38,10 @@
 extern int SDL_JoystickInit(void);
 extern void SDL_JoystickQuit(void);
 #endif
+#if !SDL_HAPTIC_DISABLED
+extern int SDL_HapticInit(void);
+extern int SDL_HapticQuit(void);
+#endif
 #if !SDL_CDROM_DISABLED
 extern int SDL_CDROMInit(void);
 extern void SDL_CDROMQuit(void);
@@ -47,6 +51,10 @@
 extern int SDL_TimerInit(void);
 extern void SDL_TimerQuit(void);
 #endif
+#if defined(__WIN32__)
+extern int SDL_HelperWindowCreate(void);
+extern int SDL_HelperWindowDestroy(void);
+#endif
 
 /* The initialized subsystems */
 static Uint32 SDL_initialized = 0;
@@ -123,6 +131,22 @@
     }
 #endif
 
+#if !SDL_HAPTIC_DISABLED
+    /* Initialize the haptic subsystem */
+    if ((flags & SDL_INIT_HAPTIC) && !(SDL_initialized & SDL_INIT_HAPTIC)) {
+        if (SDL_HapticInit() < 0) {
+            return (-1);
+        }
+        SDL_initialized |= SDL_INIT_HAPTIC;
+    }
+#else
+    if (flags & SDL_INIT_HAPTIC) {
+        SDL_SetError("SDL not built with haptic (force feedback) support");
+        return (-1);
+    }
+#endif
+
+
 #if !SDL_CDROM_DISABLED
     /* Initialize the CD-ROM subsystem */
     if ((flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM)) {
@@ -152,6 +176,12 @@
     /* Clear the error message */
     SDL_ClearError();
 
+#if defined(__WIN32__)
+    if (SDL_HelperWindowCreate() < 0) {
+        return -1;
+    }
+#endif
+
     /* Initialize the desired subsystems */
     if (SDL_InitSubSystem(flags) < 0) {
         return (-1);
@@ -180,6 +210,12 @@
         SDL_initialized &= ~SDL_INIT_JOYSTICK;
     }
 #endif
+#if !SDL_HAPTIC_DISABLED
+    if ((flags & SDL_initialized & SDL_INIT_HAPTIC)) {
+        SDL_HapticQuit();
+        SDL_initialized &= ~SDL_INIT_HAPTIC;
+    }
+#endif
 #if !SDL_TIMERS_DISABLED
     if ((flags & SDL_initialized & SDL_INIT_TIMER)) {
         SDL_TimerQuit();
@@ -217,6 +253,10 @@
     printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n");
     fflush(stdout);
 #endif
+
+#if defined(__WIN32__)
+    SDL_HelperWindowDestroy();
+#endif
     SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
 
 #ifdef CHECK_LEAKS