| | |
| | | /* |
| | | Simple DirectMedia Layer |
| | | Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> |
| | | Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> |
| | | |
| | | This software is provided 'as-is', without any express or implied |
| | | warranty. In no event will the authors be held liable for any damages |
| | |
| | | misrepresented as being the original software. |
| | | 3. This notice may not be removed or altered from any source distribution. |
| | | */ |
| | | #include "SDL_config.h" |
| | | #include "./SDL_internal.h" |
| | | |
| | | #if defined(__WIN32__) |
| | | #include "core/windows/SDL_windows.h" |
| | |
| | | #include "events/SDL_events_c.h" |
| | | #include "haptic/SDL_haptic_c.h" |
| | | #include "joystick/SDL_joystick_c.h" |
| | | #include "sensor/SDL_sensor_c.h" |
| | | |
| | | /* Initialization/Cleanup routines */ |
| | | #if !SDL_TIMERS_DISABLED |
| | | extern int SDL_TimerInit(void); |
| | | extern void SDL_TimerQuit(void); |
| | | extern void SDL_InitTicks(void); |
| | | # include "timer/SDL_timer_c.h" |
| | | #endif |
| | | #if SDL_VIDEO_DRIVER_WINDOWS |
| | | extern int SDL_HelperWindowCreate(void); |
| | |
| | | { |
| | | int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); |
| | | SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255); |
| | | return (SDL_SubsystemRefCount[subsystem_index] == 0); |
| | | return (SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE; |
| | | } |
| | | |
| | | /* Private helper to check if a system needs to be quit. */ |
| | |
| | | /* If we're in SDL_Quit, we shut down every subsystem, even if refcount |
| | | * isn't zero. |
| | | */ |
| | | return SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit; |
| | | return (SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE; |
| | | } |
| | | |
| | | void |
| | |
| | | /* Clear the error message */ |
| | | SDL_ClearError(); |
| | | |
| | | #if SDL_VIDEO_DRIVER_WINDOWS |
| | | if (SDL_HelperWindowCreate() < 0) { |
| | | return -1; |
| | | } |
| | | #endif |
| | | |
| | | #if !SDL_TIMERS_DISABLED |
| | | SDL_InitTicks(); |
| | | #endif |
| | | |
| | | if ((flags & SDL_INIT_GAMECONTROLLER)) { |
| | | /* game controller implies joystick */ |
| | | flags |= SDL_INIT_JOYSTICK; |
| | |
| | | /* video or joystick implies events */ |
| | | flags |= SDL_INIT_EVENTS; |
| | | } |
| | | |
| | | #if SDL_VIDEO_DRIVER_WINDOWS |
| | | if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) { |
| | | if (SDL_HelperWindowCreate() < 0) { |
| | | return -1; |
| | | } |
| | | } |
| | | #endif |
| | | |
| | | #if !SDL_TIMERS_DISABLED |
| | | SDL_TicksInit(); |
| | | #endif |
| | | |
| | | /* Initialize the event subsystem */ |
| | | if ((flags & SDL_INIT_EVENTS)) { |
| | |
| | | #endif |
| | | } |
| | | |
| | | /* Initialize the sensor subsystem */ |
| | | if ((flags & SDL_INIT_SENSOR)){ |
| | | #if !SDL_SENSOR_DISABLED |
| | | if (SDL_PrivateShouldInitSubsystem(SDL_INIT_SENSOR)) { |
| | | if (SDL_SensorInit() < 0) { |
| | | return (-1); |
| | | } |
| | | } |
| | | SDL_PrivateSubsystemRefCountIncr(SDL_INIT_SENSOR); |
| | | #else |
| | | return SDL_SetError("SDL not built with sensor support"); |
| | | #endif |
| | | } |
| | | |
| | | return (0); |
| | | } |
| | | |
| | |
| | | SDL_QuitSubSystem(Uint32 flags) |
| | | { |
| | | /* Shut down requested initialized subsystems */ |
| | | #if !SDL_SENSOR_DISABLED |
| | | if ((flags & SDL_INIT_SENSOR)) { |
| | | if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_SENSOR)) { |
| | | SDL_SensorQuit(); |
| | | } |
| | | SDL_PrivateSubsystemRefCountDecr(SDL_INIT_SENSOR); |
| | | } |
| | | #endif |
| | | |
| | | #if !SDL_JOYSTICK_DISABLED |
| | | if ((flags & SDL_INIT_GAMECONTROLLER)) { |
| | | /* game controller implies joystick */ |
| | |
| | | #endif |
| | | SDL_QuitSubSystem(SDL_INIT_EVERYTHING); |
| | | |
| | | #if !SDL_TIMERS_DISABLED |
| | | SDL_TicksQuit(); |
| | | #endif |
| | | |
| | | SDL_ClearHints(); |
| | | SDL_AssertionsQuit(); |
| | | SDL_LogResetPriorities(); |
| | |
| | | return "AIX"; |
| | | #elif __ANDROID__ |
| | | return "Android"; |
| | | #elif __BEOS__ |
| | | return "BeOS"; |
| | | #elif __BSDI__ |
| | | return "BSDI"; |
| | | #elif __DREAMCAST__ |
| | | return "Dreamcast"; |
| | | #elif __EMSCRIPTEN__ |
| | | return "Emscripten"; |
| | | #elif __FREEBSD__ |
| | | return "FreeBSD"; |
| | | #elif __HAIKU__ |
| | |
| | | return "MacOS Classic"; |
| | | #elif __MACOSX__ |
| | | return "Mac OS X"; |
| | | #elif __NACL__ |
| | | return "NaCl"; |
| | | #elif __NETBSD__ |
| | | return "NetBSD"; |
| | | #elif __OPENBSD__ |
| | |
| | | return "Solaris"; |
| | | #elif __WIN32__ |
| | | return "Windows"; |
| | | #elif __WINRT__ |
| | | return "WinRT"; |
| | | #elif __TVOS__ |
| | | return "tvOS"; |
| | | #elif __IPHONEOS__ |
| | | return "iOS"; |
| | | #elif __PSP__ |
| | |
| | | #endif |
| | | } |
| | | |
| | | SDL_bool |
| | | SDL_IsTablet() |
| | | { |
| | | #if __ANDROID__ |
| | | extern SDL_bool SDL_IsAndroidTablet(void); |
| | | return SDL_IsAndroidTablet(); |
| | | #elif __IPHONEOS__ |
| | | extern SDL_bool SDL_IsIPad(void); |
| | | return SDL_IsIPad(); |
| | | #else |
| | | return SDL_FALSE; |
| | | #endif |
| | | } |
| | | |
| | | #if defined(__WIN32__) |
| | | |
| | | #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL)) |
| | | #if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB) |
| | | /* Need to include DllMain() on Watcom C for some reason.. */ |
| | | |
| | | BOOL APIENTRY |
| | |
| | | } |
| | | return TRUE; |
| | | } |
| | | #endif /* building DLL with Watcom C */ |
| | | #endif /* Building DLL */ |
| | | |
| | | #endif /* __WIN32__ */ |
| | | |