| 139 | } |
| 140 | |
| 141 | int |
| 142 | SDL_InitSubSystem(Uint32 flags) |
| 143 | { |
| 144 | if (!SDL_MainIsReady) { |
| 145 | SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?"); |
| 146 | return -1; |
| 147 | } |
| 148 | |
| 149 | /* Clear the error message */ |
| 150 | SDL_ClearError(); |
| 151 | |
| 152 | if ((flags & SDL_INIT_GAMECONTROLLER)) { |
| 153 | /* game controller implies joystick */ |
| 154 | flags |= SDL_INIT_JOYSTICK; |
| 155 | } |
| 156 | |
| 157 | if ((flags & (SDL_INIT_VIDEO|SDL_INIT_JOYSTICK))) { |
| 158 | /* video or joystick implies events */ |
| 159 | flags |= SDL_INIT_EVENTS; |
| 160 | } |
| 161 | |
| 162 | #if SDL_VIDEO_DRIVER_WINDOWS |
| 163 | if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) { |
| 164 | if (SDL_HelperWindowCreate() < 0) { |
| 165 | return -1; |
| 166 | } |
| 167 | } |
| 168 | #endif |
| 169 | |
| 170 | #if !SDL_TIMERS_DISABLED |
| 171 | SDL_TicksInit(); |
| 172 | #endif |
| 173 | |
| 174 | /* Initialize the event subsystem */ |
| 175 | if ((flags & SDL_INIT_EVENTS)) { |
| 176 | #if !SDL_EVENTS_DISABLED |
| 177 | if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) { |
| 178 | if (SDL_EventsInit() < 0) { |
| 179 | return (-1); |
| 180 | } |
| 181 | } |
| 182 | SDL_PrivateSubsystemRefCountIncr(SDL_INIT_EVENTS); |
| 183 | #else |
| 184 | return SDL_SetError("SDL not built with events support"); |
| 185 | #endif |
| 186 | } |
| 187 | |
| 188 | /* Initialize the timer subsystem */ |
| 189 | if ((flags & SDL_INIT_TIMER)){ |
| 190 | #if !SDL_TIMERS_DISABLED |
| 191 | if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) { |
| 192 | if (SDL_TimerInit() < 0) { |
| 193 | return (-1); |
| 194 | } |
| 195 | } |
| 196 | SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER); |
| 197 | #else |
| 198 | return SDL_SetError("SDL not built with timer support"); |