src/SDL.c
author Jørgen P. Tjernø <jorgen@valvesoftware.com>
Mon, 25 Feb 2013 16:52:50 -0800
changeset 6924 5be9b933146a
parent 6885 700f1b25f77f
child 6927 982b03203b73
permissions -rw-r--r--
sdl2 - fix ref counting on init, make sure you refcount each init calls and not just the first one
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
     2
  Simple DirectMedia Layer
6885
700f1b25f77f Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6867
diff changeset
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
     7
  arising from the use of this software.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
    11
  freely, subject to the following restrictions:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5359
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    20
*/
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
    21
#include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    23
/* Initialization code for SDL */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    24
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    25
#include "SDL.h"
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    26
#include "SDL_bits.h"
5310
a9945ce48999 Made it possible to build SDL from a fresh checkout without any additional steps.
Sam Lantinga <slouken@libsdl.org>
parents: 5270
diff changeset
    27
#include "SDL_revision.h"
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    28
#include "SDL_fatal.h"
4472
791b3256fb22 Mostly cleaned up warnings with -Wmissing-prototypes
Sam Lantinga <slouken@libsdl.org>
parents: 4419
diff changeset
    29
#include "SDL_assert_c.h"
791b3256fb22 Mostly cleaned up warnings with -Wmissing-prototypes
Sam Lantinga <slouken@libsdl.org>
parents: 4419
diff changeset
    30
#include "haptic/SDL_haptic_c.h"
791b3256fb22 Mostly cleaned up warnings with -Wmissing-prototypes
Sam Lantinga <slouken@libsdl.org>
parents: 4419
diff changeset
    31
#include "joystick/SDL_joystick_c.h"
3647
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents: 3319
diff changeset
    32
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    33
/* Initialization/Cleanup routines */
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    34
#if !SDL_TIMERS_DISABLED
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    35
extern void SDL_StartTicks(void);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
    36
extern int SDL_TimerInit(void);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    37
extern void SDL_TimerQuit(void);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    38
#endif
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
    39
#if defined(__WIN32__)
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
    40
extern int SDL_HelperWindowCreate(void);
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
    41
extern int SDL_HelperWindowDestroy(void);
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
    42
#endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    43
3647
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents: 3319
diff changeset
    44
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    45
/* The initialized subsystems */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    46
static Uint32 ticks_started = 0;
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
    47
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    48
static Uint8 SDL_SubsystemRefCount[ 32 ];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    49
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    50
/* Private helper to increment a subsystem's ref counter. */
6867
4c899e841091 Fix build issue on Win/Haiku.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    51
static void
4c899e841091 Fix build issue on Win/Haiku.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    52
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    53
{
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    54
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    55
    SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    56
    ++SDL_SubsystemRefCount[subsystem_index];
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    57
}
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    58
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    59
/* Private helper to decrement a subsystem's ref counter. */
6867
4c899e841091 Fix build issue on Win/Haiku.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    60
static void
4c899e841091 Fix build issue on Win/Haiku.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    61
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
    62
{
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    63
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    64
    if (SDL_SubsystemRefCount[subsystem_index] > 0) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    65
        --SDL_SubsystemRefCount[subsystem_index];
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    66
    }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    67
}
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    68
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    69
/* Private helper to check if a system needs init. */
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    70
static SDL_bool
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    71
SDL_PrivateShouldInitSubsystem(Uint32 flags, Uint32 subsystem)
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    72
{
6867
4c899e841091 Fix build issue on Win/Haiku.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    73
    int subsystem_index;
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    74
    if ((flags & subsystem) == 0) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    75
      return SDL_FALSE;
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    76
    }
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
    77
6867
4c899e841091 Fix build issue on Win/Haiku.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    78
    subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    79
    SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    80
    return (SDL_SubsystemRefCount[subsystem_index] == 0);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    81
}
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    82
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    83
/* Private helper to check if a system needs to be quit. */
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    84
static SDL_bool
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    85
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    86
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    87
    if (SDL_SubsystemRefCount[subsystem_index] == 0) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    88
      return SDL_FALSE;
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    89
    }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    90
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    91
    /* If we're in SDL_Quit, we shut down every subsystem, even if refcount
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    92
     * isn't zero.
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    93
     */
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
    94
    return SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit;
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
    95
}
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    96
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
    97
int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
    98
SDL_InitSubSystem(Uint32 flags)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    99
{
6128
2804d71badce Initialize timers first so the tick counter is valid by the time the audio and video systems initialize.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   100
#if !SDL_TIMERS_DISABLED
2804d71badce Initialize timers first so the tick counter is valid by the time the audio and video systems initialize.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   101
    if (!ticks_started) {
2804d71badce Initialize timers first so the tick counter is valid by the time the audio and video systems initialize.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   102
        SDL_StartTicks();
2804d71badce Initialize timers first so the tick counter is valid by the time the audio and video systems initialize.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   103
        ticks_started = 1;
2804d71badce Initialize timers first so the tick counter is valid by the time the audio and video systems initialize.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   104
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   105
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   106
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   107
    /* Initialize the timer subsystem */
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   108
    if ((flags & SDL_INIT_TIMER) ){
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   109
        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_TIMER)) {
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   110
#if !SDL_TIMERS_DISABLED
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   111
            if (SDL_TimerInit() < 0) {
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   112
                return (-1);
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   113
            }
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   114
        }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   115
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   116
#else
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   117
        SDL_SetError("SDL not built with timer support");
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   118
        return (-1);
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   119
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   120
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   121
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   122
    /* Initialize the video/event subsystem */
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   123
    if ((flags & SDL_INIT_VIDEO) ){
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   124
        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_VIDEO)) {
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   125
#if !SDL_VIDEO_DISABLED
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   126
            if (SDL_VideoInit(NULL) < 0) {
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   127
                return (-1);
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   128
            }
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   129
        }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   130
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   131
#else
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   132
        SDL_SetError("SDL not built with video support");
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   133
        return (-1);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   134
#endif
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   135
    }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   136
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   137
    /* Initialize the audio subsystem */
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   138
    if ((flags & SDL_INIT_AUDIO) ){
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   139
        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_AUDIO)) {
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   140
#if !SDL_AUDIO_DISABLED
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   141
            if (SDL_AudioInit(NULL) < 0) {
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   142
                return (-1);
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   143
            }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   144
        }
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   145
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   146
#else
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   147
        SDL_SetError("SDL not built with audio support");
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   148
        return (-1);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   149
#endif
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   150
    }
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   151
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   152
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   153
        // Game controller implies Joystick.
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   154
        flags |= SDL_INIT_JOYSTICK;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   155
    }
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   156
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   157
    /* Initialize the joystick subsystem */
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   158
    if ((flags & SDL_INIT_JOYSTICK) ){
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   159
        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_JOYSTICK)) {
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   160
#if !SDL_JOYSTICK_DISABLED
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   161
           if (SDL_JoystickInit() < 0) {
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   162
               return (-1);
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   163
           }
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   164
        }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   165
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   166
#else
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   167
        SDL_SetError("SDL not built with joystick support");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   168
        return (-1);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   169
#endif
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   170
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   171
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   172
    if ((flags & SDL_INIT_GAMECONTROLLER) ){
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   173
        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_GAMECONTROLLER)) {
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   174
#if !SDL_JOYSTICK_DISABLED
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   175
            if (SDL_GameControllerInit() < 0) {
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   176
                return (-1);
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   177
            }
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   178
        }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   179
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   180
#else
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   181
        SDL_SetError("SDL not built with joystick support");
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   182
        return (-1);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   183
#endif
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   184
    }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   185
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   186
    /* Initialize the haptic subsystem */
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   187
    if ((flags & SDL_INIT_HAPTIC) ){
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   188
        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_HAPTIC)) {
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   189
#if !SDL_HAPTIC_DISABLED
6924
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   190
            if (SDL_HapticInit() < 0) {
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   191
             return (-1);
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   192
         }
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   193
        }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   194
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   195
#else
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   196
        SDL_SetError("SDL not built with haptic (force feedback) support");
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   197
        return (-1);
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   198
#endif
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   199
    }
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   200
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   201
    return (0);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   202
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   203
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   204
int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   205
SDL_Init(Uint32 flags)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   206
{
3647
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents: 3319
diff changeset
   207
    if (SDL_AssertionsInit() < 0) {
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents: 3319
diff changeset
   208
        return -1;
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents: 3319
diff changeset
   209
    }
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents: 3319
diff changeset
   210
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   211
    /* Clear the error message */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   212
    SDL_ClearError();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   213
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   214
#if defined(__WIN32__)
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   215
    if (SDL_HelperWindowCreate() < 0) {
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   216
        return -1;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   217
    }
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   218
#endif
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   219
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   220
    /* Initialize the desired subsystems */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   221
    if (SDL_InitSubSystem(flags) < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   222
        return (-1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   223
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   224
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   225
    /* Everything is initialized */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   226
    if (!(flags & SDL_INIT_NOPARACHUTE)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   227
        SDL_InstallParachute();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   228
    }
3647
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents: 3319
diff changeset
   229
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   230
    return (0);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   231
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   232
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   233
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   234
SDL_QuitSubSystem(Uint32 flags)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   235
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   236
    /* Shut down requested initialized subsystems */
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
   237
#if !SDL_JOYSTICK_DISABLED
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   238
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   239
        // Game controller implies Joystick.
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   240
        flags |= SDL_INIT_JOYSTICK;
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   241
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   242
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   243
            SDL_GameControllerQuit();
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   244
		}
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   245
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   246
    }
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   247
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   248
    if ((flags & SDL_INIT_JOYSTICK)) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   249
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   250
			SDL_JoystickQuit();
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   251
		}
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   252
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   253
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   254
#endif
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   255
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   256
#if !SDL_HAPTIC_DISABLED
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   257
    if ((flags & SDL_INIT_HAPTIC)) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   258
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   259
			SDL_HapticQuit();
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   260
		}
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   261
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   262
    }
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   263
#endif
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   264
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
   265
#if !SDL_AUDIO_DISABLED
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   266
    if ((flags & SDL_INIT_AUDIO)) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   267
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   268
			SDL_AudioQuit();
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   269
		}
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   270
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   271
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   272
#endif
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   273
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
   274
#if !SDL_VIDEO_DISABLED
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   275
    if ((flags & SDL_INIT_VIDEO)) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   276
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   277
			SDL_VideoQuit();
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   278
		}
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   279
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   280
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   281
#endif
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   282
6128
2804d71badce Initialize timers first so the tick counter is valid by the time the audio and video systems initialize.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   283
#if !SDL_TIMERS_DISABLED
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   284
    if ((flags & SDL_INIT_TIMER)) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   285
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   286
			SDL_TimerQuit();
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   287
		}
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   288
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
6128
2804d71badce Initialize timers first so the tick counter is valid by the time the audio and video systems initialize.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   289
    }
2804d71badce Initialize timers first so the tick counter is valid by the time the audio and video systems initialize.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   290
#endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   291
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   292
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   293
Uint32
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   294
SDL_WasInit(Uint32 flags)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   295
{
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   296
    int i;
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   297
    int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   298
    Uint32 initialized = 0;
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   299
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   300
    if (!flags) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   301
        flags = SDL_INIT_EVERYTHING;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   302
    }
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   303
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   304
    num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   305
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   306
    /* Iterate over each bit in flags, and check the matching subsystem. */
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   307
    for (i = 0; i < num_subsystems; ++i) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   308
        if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   309
            initialized |= (1 << i);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   310
        }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   311
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   312
        flags >>= 1;
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   313
    }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   314
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   315
    return initialized;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   316
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   317
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   318
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   319
SDL_Quit(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   320
{
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   321
    SDL_bInMainQuit = SDL_TRUE;
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   322
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   323
    /* Quit all subsystems */
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   324
#if defined(__WIN32__)
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   325
    SDL_HelperWindowDestroy();
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1909
diff changeset
   326
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   327
    SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   328
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   329
    /* Uninstall any parachute signal handlers */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   330
    SDL_UninstallParachute();
397
283d348cb624 Pth threading bug fix
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
   331
5189
6f6a9340fb93 Added a hint system to allow configuration hints to be specified by the application.
Sam Lantinga <slouken@libsdl.org>
parents: 5123
diff changeset
   332
    SDL_ClearHints();
3647
c5925cd41955 First pass at Ryan's assertion code, minor tweaks to come.
Sam Lantinga <slouken@libsdl.org>
parents: 3319
diff changeset
   333
    SDL_AssertionsQuit();
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents: 5189
diff changeset
   334
    SDL_LogResetPriorities();
6690
9548c8a58103 Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
Sam Lantinga <slouken@libsdl.org>
parents: 6441
diff changeset
   335
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   336
    /* Now that every subsystem has been quit, we reset the subsystem refcount
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   337
     * and the list of initialized subsystems.
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   338
     */
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   339
    SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   340
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6690
diff changeset
   341
    SDL_bInMainQuit = SDL_FALSE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   342
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   343
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   344
/* Get the library version number */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   345
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   346
SDL_GetVersion(SDL_version * ver)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   347
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   348
    SDL_VERSION(ver);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   349
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   350
2982
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   351
/* Get the library source revision */
4419
5e7e1f1a4056 Changed revision details to be a string (an hg changeset) instead of an int.
Ryan C. Gordon <icculus@icculus.org>
parents: 3697
diff changeset
   352
const char *
2996
972a69e47cd9 Added missing void
Sam Lantinga <slouken@libsdl.org>
parents: 2983
diff changeset
   353
SDL_GetRevision(void)
2982
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   354
{
2983
388c5a2daeac Fine tuned revision code, updated testver
Sam Lantinga <slouken@libsdl.org>
parents: 2982
diff changeset
   355
    return SDL_REVISION;
2982
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   356
}
b64c1d23039b Make the current revision number available
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   357
5359
d5fe4ed3a28d Added a revision number for easy compile-time tests.
Sam Lantinga <slouken@libsdl.org>
parents: 5310
diff changeset
   358
/* Get the library source revision number */
d5fe4ed3a28d Added a revision number for easy compile-time tests.
Sam Lantinga <slouken@libsdl.org>
parents: 5310
diff changeset
   359
int
d5fe4ed3a28d Added a revision number for easy compile-time tests.
Sam Lantinga <slouken@libsdl.org>
parents: 5310
diff changeset
   360
SDL_GetRevisionNumber(void)
d5fe4ed3a28d Added a revision number for easy compile-time tests.
Sam Lantinga <slouken@libsdl.org>
parents: 5310
diff changeset
   361
{
d5fe4ed3a28d Added a revision number for easy compile-time tests.
Sam Lantinga <slouken@libsdl.org>
parents: 5310
diff changeset
   362
    return SDL_REVISION_NUMBER;
d5fe4ed3a28d Added a revision number for easy compile-time tests.
Sam Lantinga <slouken@libsdl.org>
parents: 5310
diff changeset
   363
}
d5fe4ed3a28d Added a revision number for easy compile-time tests.
Sam Lantinga <slouken@libsdl.org>
parents: 5310
diff changeset
   364
3319
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   365
/* Get the name of the platform */
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   366
const char *
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   367
SDL_GetPlatform()
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   368
{
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   369
#if __AIX__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   370
    return "AIX";
6441
ada3545fed23 Fixed bug 1600 - SDL_GetPlatform() returns "unknown os" on Android
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   371
#elif __ANDROID__
ada3545fed23 Fixed bug 1600 - SDL_GetPlatform() returns "unknown os" on Android
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   372
    return "Android";
3319
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   373
#elif __HAIKU__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   374
/* Haiku must appear here before BeOS, since it also defines __BEOS__ */
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   375
    return "Haiku";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   376
#elif __BEOS__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   377
    return "BeOS";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   378
#elif __BSDI__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   379
    return "BSDI";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   380
#elif __DREAMCAST__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   381
    return "Dreamcast";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   382
#elif __FREEBSD__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   383
    return "FreeBSD";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   384
#elif __HPUX__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   385
    return "HP-UX";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   386
#elif __IRIX__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   387
    return "Irix";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   388
#elif __LINUX__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   389
    return "Linux";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   390
#elif __MINT__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   391
    return "Atari MiNT";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   392
#elif __MACOS__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   393
    return "MacOS Classic";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   394
#elif __MACOSX__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   395
    return "Mac OS X";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   396
#elif __NETBSD__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   397
    return "NetBSD";
5270
7aba0406c273 Frank Zago to sdl
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   398
#elif __NDS__
7aba0406c273 Frank Zago to sdl
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   399
    return "Nintendo DS";
3319
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   400
#elif __OPENBSD__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   401
    return "OpenBSD";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   402
#elif __OS2__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   403
    return "OS/2";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   404
#elif __OSF__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   405
    return "OSF/1";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   406
#elif __QNXNTO__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   407
    return "QNX Neutrino";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   408
#elif __RISCOS__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   409
    return "RISC OS";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   410
#elif __SOLARIS__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   411
    return "Solaris";
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   412
#elif __WIN32__
3319
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   413
    return "Windows";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   414
#elif __IPHONEOS__
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   415
    return "iPhone OS";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   416
#else
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   417
    return "Unknown (see SDL_platform.h)";
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   418
#endif
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   419
}
63d4517fc4ac Fixed bug #777
Sam Lantinga <slouken@libsdl.org>
parents: 3269
diff changeset
   420
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   421
#if defined(__WIN32__)
1330
450721ad5436 It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
   422
1465
8dfa9a6d69a5 Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents: 1433
diff changeset
   423
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
8dfa9a6d69a5 Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents: 1433
diff changeset
   424
/* Need to include DllMain() on Watcom C for some reason.. */
5090
327f181542f1 Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents: 5086
diff changeset
   425
#include "core/windows/SDL_windows.h"
1330
450721ad5436 It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
   426
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   427
BOOL APIENTRY
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   428
_DllMainCRTStartup(HANDLE hModule,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   429
                   DWORD ul_reason_for_call, LPVOID lpReserved)
1330
450721ad5436 It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
   430
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   431
    switch (ul_reason_for_call) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   432
    case DLL_PROCESS_ATTACH:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   433
    case DLL_THREAD_ATTACH:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   434
    case DLL_THREAD_DETACH:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   435
    case DLL_PROCESS_DETACH:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   436
        break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   437
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   438
    return TRUE;
1330
450721ad5436 It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
   439
}
1465
8dfa9a6d69a5 Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents: 1433
diff changeset
   440
#endif /* building DLL with Watcom C */
1330
450721ad5436 It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
   441
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   442
#endif /* __WIN32__ */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   443
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
   444
/* vi: set ts=4 sw=4 expandtab: */