comparison 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
comparison
equal deleted inserted replaced
2712:c4e697245676 2713:0906692aa6a4
36 /* Initialization/Cleanup routines */ 36 /* Initialization/Cleanup routines */
37 #if !SDL_JOYSTICK_DISABLED 37 #if !SDL_JOYSTICK_DISABLED
38 extern int SDL_JoystickInit(void); 38 extern int SDL_JoystickInit(void);
39 extern void SDL_JoystickQuit(void); 39 extern void SDL_JoystickQuit(void);
40 #endif 40 #endif
41 #if !SDL_HAPTIC_DISABLED
42 extern int SDL_HapticInit(void);
43 extern int SDL_HapticQuit(void);
44 #endif
41 #if !SDL_CDROM_DISABLED 45 #if !SDL_CDROM_DISABLED
42 extern int SDL_CDROMInit(void); 46 extern int SDL_CDROMInit(void);
43 extern void SDL_CDROMQuit(void); 47 extern void SDL_CDROMQuit(void);
44 #endif 48 #endif
45 #if !SDL_TIMERS_DISABLED 49 #if !SDL_TIMERS_DISABLED
46 extern void SDL_StartTicks(void); 50 extern void SDL_StartTicks(void);
47 extern int SDL_TimerInit(void); 51 extern int SDL_TimerInit(void);
48 extern void SDL_TimerQuit(void); 52 extern void SDL_TimerQuit(void);
53 #endif
54 #if defined(__WIN32__)
55 extern int SDL_HelperWindowCreate(void);
56 extern int SDL_HelperWindowDestroy(void);
49 #endif 57 #endif
50 58
51 /* The initialized subsystems */ 59 /* The initialized subsystems */
52 static Uint32 SDL_initialized = 0; 60 static Uint32 SDL_initialized = 0;
53 static Uint32 ticks_started = 0; 61 static Uint32 ticks_started = 0;
121 SDL_SetError("SDL not built with joystick support"); 129 SDL_SetError("SDL not built with joystick support");
122 return (-1); 130 return (-1);
123 } 131 }
124 #endif 132 #endif
125 133
134 #if !SDL_HAPTIC_DISABLED
135 /* Initialize the haptic subsystem */
136 if ((flags & SDL_INIT_HAPTIC) && !(SDL_initialized & SDL_INIT_HAPTIC)) {
137 if (SDL_HapticInit() < 0) {
138 return (-1);
139 }
140 SDL_initialized |= SDL_INIT_HAPTIC;
141 }
142 #else
143 if (flags & SDL_INIT_HAPTIC) {
144 SDL_SetError("SDL not built with haptic (force feedback) support");
145 return (-1);
146 }
147 #endif
148
149
126 #if !SDL_CDROM_DISABLED 150 #if !SDL_CDROM_DISABLED
127 /* Initialize the CD-ROM subsystem */ 151 /* Initialize the CD-ROM subsystem */
128 if ((flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM)) { 152 if ((flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM)) {
129 if (SDL_CDROMInit() < 0) { 153 if (SDL_CDROMInit() < 0) {
130 return (-1); 154 return (-1);
149 } 173 }
150 #endif 174 #endif
151 175
152 /* Clear the error message */ 176 /* Clear the error message */
153 SDL_ClearError(); 177 SDL_ClearError();
178
179 #if defined(__WIN32__)
180 if (SDL_HelperWindowCreate() < 0) {
181 return -1;
182 }
183 #endif
154 184
155 /* Initialize the desired subsystems */ 185 /* Initialize the desired subsystems */
156 if (SDL_InitSubSystem(flags) < 0) { 186 if (SDL_InitSubSystem(flags) < 0) {
157 return (-1); 187 return (-1);
158 } 188 }
178 if ((flags & SDL_initialized & SDL_INIT_JOYSTICK)) { 208 if ((flags & SDL_initialized & SDL_INIT_JOYSTICK)) {
179 SDL_JoystickQuit(); 209 SDL_JoystickQuit();
180 SDL_initialized &= ~SDL_INIT_JOYSTICK; 210 SDL_initialized &= ~SDL_INIT_JOYSTICK;
181 } 211 }
182 #endif 212 #endif
213 #if !SDL_HAPTIC_DISABLED
214 if ((flags & SDL_initialized & SDL_INIT_HAPTIC)) {
215 SDL_HapticQuit();
216 SDL_initialized &= ~SDL_INIT_HAPTIC;
217 }
218 #endif
183 #if !SDL_TIMERS_DISABLED 219 #if !SDL_TIMERS_DISABLED
184 if ((flags & SDL_initialized & SDL_INIT_TIMER)) { 220 if ((flags & SDL_initialized & SDL_INIT_TIMER)) {
185 SDL_TimerQuit(); 221 SDL_TimerQuit();
186 SDL_initialized &= ~SDL_INIT_TIMER; 222 SDL_initialized &= ~SDL_INIT_TIMER;
187 } 223 }
214 { 250 {
215 /* Quit all subsystems */ 251 /* Quit all subsystems */
216 #ifdef DEBUG_BUILD 252 #ifdef DEBUG_BUILD
217 printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n"); 253 printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n");
218 fflush(stdout); 254 fflush(stdout);
255 #endif
256
257 #if defined(__WIN32__)
258 SDL_HelperWindowDestroy();
219 #endif 259 #endif
220 SDL_QuitSubSystem(SDL_INIT_EVERYTHING); 260 SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
221 261
222 #ifdef CHECK_LEAKS 262 #ifdef CHECK_LEAKS
223 #ifdef DEBUG_BUILD 263 #ifdef DEBUG_BUILD