src/SDL.c
author Sam Lantinga <slouken@libsdl.org>
Tue, 21 Aug 2018 12:11:34 -0700
changeset 12130 24142c5073a4
parent 11885 e6fc3ef41ffd
child 12137 161f67f4a7c6
permissions -rw-r--r--
First pass on the new SDL sensor API
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@11811
     3
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
icculus@8093
    21
#include "./SDL_internal.h"
slouken@0
    22
slouken@7828
    23
#if defined(__WIN32__)
slouken@7828
    24
#include "core/windows/SDL_windows.h"
slouken@7828
    25
#endif
slouken@7828
    26
slouken@0
    27
/* Initialization code for SDL */
slouken@0
    28
slouken@1361
    29
#include "SDL.h"
jorgen@6866
    30
#include "SDL_bits.h"
slouken@5310
    31
#include "SDL_revision.h"
slouken@4472
    32
#include "SDL_assert_c.h"
slouken@7360
    33
#include "events/SDL_events_c.h"
slouken@4472
    34
#include "haptic/SDL_haptic_c.h"
slouken@4472
    35
#include "joystick/SDL_joystick_c.h"
slouken@12130
    36
#include "sensor/SDL_sensor_c.h"
slouken@3647
    37
slouken@0
    38
/* Initialization/Cleanup routines */
slouken@1361
    39
#if !SDL_TIMERS_DISABLED
slouken@10609
    40
# include "timer/SDL_timer_c.h"
slouken@0
    41
#endif
slouken@7110
    42
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
    43
extern int SDL_HelperWindowCreate(void);
slouken@2713
    44
extern int SDL_HelperWindowDestroy(void);
slouken@2713
    45
#endif
slouken@0
    46
slouken@3647
    47
slouken@0
    48
/* The initialized subsystems */
slouken@7281
    49
#ifdef SDL_MAIN_NEEDED
slouken@7281
    50
static SDL_bool SDL_MainIsReady = SDL_FALSE;
slouken@7281
    51
#else
slouken@7281
    52
static SDL_bool SDL_MainIsReady = SDL_TRUE;
slouken@7281
    53
#endif
slouken@6690
    54
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
jorgen@6866
    55
static Uint8 SDL_SubsystemRefCount[ 32 ];
slouken@0
    56
jorgen@6866
    57
/* Private helper to increment a subsystem's ref counter. */
jorgen@6867
    58
static void
jorgen@6867
    59
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
slouken@6690
    60
{
jorgen@6866
    61
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    62
    SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
jorgen@6866
    63
    ++SDL_SubsystemRefCount[subsystem_index];
jorgen@6866
    64
}
slouken@6690
    65
jorgen@6866
    66
/* Private helper to decrement a subsystem's ref counter. */
jorgen@6867
    67
static void
jorgen@6867
    68
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
jorgen@6866
    69
{
jorgen@6866
    70
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    71
    if (SDL_SubsystemRefCount[subsystem_index] > 0) {
jorgen@6866
    72
        --SDL_SubsystemRefCount[subsystem_index];
jorgen@6866
    73
    }
jorgen@6866
    74
}
jorgen@6866
    75
jorgen@6866
    76
/* Private helper to check if a system needs init. */
jorgen@6866
    77
static SDL_bool
jorgen@6927
    78
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
jorgen@6866
    79
{
jorgen@6927
    80
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    81
    SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
icculus@10925
    82
    return (SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE;
jorgen@6866
    83
}
jorgen@6866
    84
jorgen@6866
    85
/* Private helper to check if a system needs to be quit. */
jorgen@6866
    86
static SDL_bool
jorgen@6866
    87
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
jorgen@6866
    88
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    89
    if (SDL_SubsystemRefCount[subsystem_index] == 0) {
jorgen@6866
    90
      return SDL_FALSE;
jorgen@6866
    91
    }
jorgen@6866
    92
jorgen@6866
    93
    /* If we're in SDL_Quit, we shut down every subsystem, even if refcount
jorgen@6866
    94
     * isn't zero.
jorgen@6866
    95
     */
icculus@10925
    96
    return (SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
slouken@6690
    97
}
slouken@0
    98
slouken@7281
    99
void
slouken@7281
   100
SDL_SetMainReady(void)
slouken@7281
   101
{
slouken@7281
   102
    SDL_MainIsReady = SDL_TRUE;
slouken@7281
   103
}
slouken@7281
   104
slouken@1895
   105
int
slouken@1895
   106
SDL_InitSubSystem(Uint32 flags)
slouken@0
   107
{
slouken@7281
   108
    if (!SDL_MainIsReady) {
slouken@7281
   109
        SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
slouken@7281
   110
        return -1;
slouken@7281
   111
    }
slouken@7281
   112
icculus@7590
   113
    /* Clear the error message */
icculus@7590
   114
    SDL_ClearError();
icculus@7590
   115
slouken@10549
   116
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@10549
   117
        /* game controller implies joystick */
slouken@10549
   118
        flags |= SDL_INIT_JOYSTICK;
slouken@10549
   119
    }
slouken@10549
   120
slouken@10549
   121
    if ((flags & (SDL_INIT_VIDEO|SDL_INIT_JOYSTICK))) {
slouken@10549
   122
        /* video or joystick implies events */
slouken@10549
   123
        flags |= SDL_INIT_EVENTS;
slouken@10549
   124
    }
slouken@10549
   125
icculus@7590
   126
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@7918
   127
	if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) {
slouken@7918
   128
		if (SDL_HelperWindowCreate() < 0) {
slouken@7918
   129
			return -1;
slouken@7918
   130
		}
slouken@7918
   131
	}
icculus@7590
   132
#endif
icculus@7590
   133
slouken@6128
   134
#if !SDL_TIMERS_DISABLED
slouken@8268
   135
    SDL_TicksInit();
jorgen@6866
   136
#endif
slouken@6690
   137
slouken@7360
   138
    /* Initialize the event subsystem */
slouken@7360
   139
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   140
#if !SDL_EVENTS_DISABLED
slouken@7360
   141
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   142
            if (SDL_StartEventLoop() < 0) {
slouken@7360
   143
                return (-1);
slouken@7360
   144
            }
slouken@7360
   145
            SDL_QuitInit();
slouken@7360
   146
        }
slouken@7360
   147
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_EVENTS);
slouken@7360
   148
#else
slouken@7360
   149
        return SDL_SetError("SDL not built with events support");
slouken@7360
   150
#endif
slouken@7360
   151
    }
slouken@7360
   152
jorgen@6866
   153
    /* Initialize the timer subsystem */
slouken@7360
   154
    if ((flags & SDL_INIT_TIMER)){
jorgen@6866
   155
#if !SDL_TIMERS_DISABLED
jorgen@6927
   156
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
jorgen@6924
   157
            if (SDL_TimerInit() < 0) {
jorgen@6924
   158
                return (-1);
jorgen@6924
   159
            }
jorgen@6866
   160
        }
jorgen@6866
   161
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
slouken@6128
   162
#else
icculus@7037
   163
        return SDL_SetError("SDL not built with timer support");
jorgen@6866
   164
#endif
slouken@6128
   165
    }
slouken@6128
   166
slouken@7360
   167
    /* Initialize the video subsystem */
slouken@7360
   168
    if ((flags & SDL_INIT_VIDEO)){
slouken@1361
   169
#if !SDL_VIDEO_DISABLED
jorgen@6927
   170
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
jorgen@6924
   171
            if (SDL_VideoInit(NULL) < 0) {
jorgen@6924
   172
                return (-1);
jorgen@6924
   173
            }
jorgen@6866
   174
        }
jorgen@6866
   175
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
slouken@0
   176
#else
icculus@7037
   177
        return SDL_SetError("SDL not built with video support");
jorgen@6866
   178
#endif
slouken@1895
   179
    }
slouken@0
   180
jorgen@6866
   181
    /* Initialize the audio subsystem */
slouken@7360
   182
    if ((flags & SDL_INIT_AUDIO)){
slouken@1361
   183
#if !SDL_AUDIO_DISABLED
jorgen@6927
   184
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
jorgen@6924
   185
            if (SDL_AudioInit(NULL) < 0) {
jorgen@6924
   186
                return (-1);
jorgen@6924
   187
            }
jorgen@6866
   188
        }
jorgen@6866
   189
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
slouken@0
   190
#else
icculus@7037
   191
        return SDL_SetError("SDL not built with audio support");
jorgen@6866
   192
#endif
slouken@1895
   193
    }
slouken@0
   194
jorgen@6866
   195
    /* Initialize the joystick subsystem */
slouken@7360
   196
    if ((flags & SDL_INIT_JOYSTICK)){
slouken@1361
   197
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   198
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
jorgen@6924
   199
           if (SDL_JoystickInit() < 0) {
jorgen@6924
   200
               return (-1);
jorgen@6924
   201
           }
slouken@1895
   202
        }
jorgen@6866
   203
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
slouken@0
   204
#else
icculus@7037
   205
        return SDL_SetError("SDL not built with joystick support");
jorgen@6866
   206
#endif
slouken@1895
   207
    }
jorgen@6866
   208
slouken@7360
   209
    if ((flags & SDL_INIT_GAMECONTROLLER)){
jorgen@6866
   210
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   211
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6924
   212
            if (SDL_GameControllerInit() < 0) {
jorgen@6924
   213
                return (-1);
jorgen@6924
   214
            }
jorgen@6866
   215
        }
jorgen@6866
   216
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   217
#else
icculus@7037
   218
        return SDL_SetError("SDL not built with joystick support");
slouken@0
   219
#endif
jorgen@6866
   220
    }
slouken@0
   221
jorgen@6866
   222
    /* Initialize the haptic subsystem */
slouken@7360
   223
    if ((flags & SDL_INIT_HAPTIC)){
slouken@2713
   224
#if !SDL_HAPTIC_DISABLED
jorgen@6927
   225
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
jorgen@6924
   226
            if (SDL_HapticInit() < 0) {
jorgen@6927
   227
                return (-1);
jorgen@6927
   228
            }
jorgen@6866
   229
        }
jorgen@6866
   230
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
slouken@2713
   231
#else
icculus@7037
   232
        return SDL_SetError("SDL not built with haptic (force feedback) support");
jorgen@6866
   233
#endif
slouken@2713
   234
    }
jorgen@6866
   235
slouken@12130
   236
    /* Initialize the sensor subsystem */
slouken@12130
   237
    if ((flags & SDL_INIT_SENSOR)){
slouken@12130
   238
#if !SDL_SENSOR_DISABLED
slouken@12130
   239
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_SENSOR)) {
slouken@12130
   240
            if (SDL_SensorInit() < 0) {
slouken@12130
   241
                return (-1);
slouken@12130
   242
            }
slouken@12130
   243
        }
slouken@12130
   244
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_SENSOR);
slouken@12130
   245
#else
slouken@12130
   246
        return SDL_SetError("SDL not built with sensor support");
slouken@12130
   247
#endif
slouken@12130
   248
    }
slouken@12130
   249
slouken@1895
   250
    return (0);
slouken@0
   251
}
slouken@0
   252
slouken@1895
   253
int
slouken@1895
   254
SDL_Init(Uint32 flags)
slouken@0
   255
{
icculus@7590
   256
    return SDL_InitSubSystem(flags);
slouken@0
   257
}
slouken@0
   258
slouken@1895
   259
void
slouken@1895
   260
SDL_QuitSubSystem(Uint32 flags)
slouken@0
   261
{
slouken@1895
   262
    /* Shut down requested initialized subsystems */
slouken@12130
   263
#if !SDL_SENSOR_DISABLED
slouken@12130
   264
    if ((flags & SDL_INIT_SENSOR)) {
slouken@12130
   265
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_SENSOR)) {
slouken@12130
   266
			SDL_SensorQuit();
slouken@12130
   267
		}
slouken@12130
   268
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_SENSOR);
slouken@12130
   269
    }
slouken@12130
   270
#endif
slouken@12130
   271
slouken@1361
   272
#if !SDL_JOYSTICK_DISABLED
jorgen@6866
   273
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@7360
   274
        /* game controller implies joystick */
jorgen@6866
   275
        flags |= SDL_INIT_JOYSTICK;
jorgen@6866
   276
jorgen@6866
   277
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6866
   278
            SDL_GameControllerQuit();
slouken@7191
   279
        }
jorgen@6866
   280
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   281
    }
slouken@6690
   282
jorgen@6866
   283
    if ((flags & SDL_INIT_JOYSTICK)) {
slouken@7360
   284
        /* joystick implies events */
slouken@7360
   285
        flags |= SDL_INIT_EVENTS;
slouken@7360
   286
jorgen@6866
   287
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
slouken@7191
   288
            SDL_JoystickQuit();
slouken@7191
   289
        }
jorgen@6866
   290
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
slouken@1895
   291
    }
slouken@0
   292
#endif
jorgen@6866
   293
slouken@2713
   294
#if !SDL_HAPTIC_DISABLED
jorgen@6866
   295
    if ((flags & SDL_INIT_HAPTIC)) {
jorgen@6866
   296
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
slouken@7191
   297
            SDL_HapticQuit();
slouken@7191
   298
        }
jorgen@6866
   299
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
slouken@2713
   300
    }
slouken@2713
   301
#endif
jorgen@6866
   302
slouken@1361
   303
#if !SDL_AUDIO_DISABLED
jorgen@6866
   304
    if ((flags & SDL_INIT_AUDIO)) {
jorgen@6866
   305
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
slouken@7191
   306
            SDL_AudioQuit();
slouken@7191
   307
        }
jorgen@6866
   308
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
slouken@1895
   309
    }
slouken@0
   310
#endif
jorgen@6866
   311
slouken@1361
   312
#if !SDL_VIDEO_DISABLED
jorgen@6866
   313
    if ((flags & SDL_INIT_VIDEO)) {
slouken@7360
   314
        /* video implies events */
slouken@7360
   315
        flags |= SDL_INIT_EVENTS;
slouken@7360
   316
jorgen@6866
   317
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
slouken@7191
   318
            SDL_VideoQuit();
slouken@7191
   319
        }
jorgen@6866
   320
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
slouken@1895
   321
    }
slouken@0
   322
#endif
jorgen@6866
   323
slouken@6128
   324
#if !SDL_TIMERS_DISABLED
jorgen@6866
   325
    if ((flags & SDL_INIT_TIMER)) {
jorgen@6866
   326
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
slouken@7191
   327
            SDL_TimerQuit();
slouken@7191
   328
        }
jorgen@6866
   329
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
slouken@6128
   330
    }
slouken@6128
   331
#endif
slouken@7360
   332
slouken@7360
   333
#if !SDL_EVENTS_DISABLED
slouken@7360
   334
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   335
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   336
            SDL_QuitQuit();
slouken@7360
   337
            SDL_StopEventLoop();
slouken@7360
   338
        }
slouken@7360
   339
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_EVENTS);
slouken@7360
   340
    }
slouken@7360
   341
#endif
slouken@0
   342
}
slouken@0
   343
slouken@1895
   344
Uint32
slouken@1895
   345
SDL_WasInit(Uint32 flags)
slouken@0
   346
{
jorgen@6866
   347
    int i;
jorgen@6866
   348
    int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
jorgen@6866
   349
    Uint32 initialized = 0;
jorgen@6866
   350
slouken@1895
   351
    if (!flags) {
slouken@1895
   352
        flags = SDL_INIT_EVERYTHING;
slouken@1895
   353
    }
jorgen@6866
   354
jorgen@6866
   355
    num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
jorgen@6866
   356
jorgen@6866
   357
    /* Iterate over each bit in flags, and check the matching subsystem. */
jorgen@6866
   358
    for (i = 0; i < num_subsystems; ++i) {
jorgen@6866
   359
        if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
jorgen@6866
   360
            initialized |= (1 << i);
jorgen@6866
   361
        }
jorgen@6866
   362
jorgen@6866
   363
        flags >>= 1;
jorgen@6866
   364
    }
jorgen@6866
   365
jorgen@6866
   366
    return initialized;
slouken@0
   367
}
slouken@0
   368
slouken@1895
   369
void
slouken@1895
   370
SDL_Quit(void)
slouken@0
   371
{
jorgen@6866
   372
    SDL_bInMainQuit = SDL_TRUE;
jorgen@6866
   373
slouken@1895
   374
    /* Quit all subsystems */
slouken@7110
   375
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
   376
    SDL_HelperWindowDestroy();
slouken@2713
   377
#endif
slouken@1895
   378
    SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
slouken@0
   379
slouken@8268
   380
#if !SDL_TIMERS_DISABLED
slouken@8268
   381
    SDL_TicksQuit();
slouken@8268
   382
#endif
slouken@8268
   383
slouken@5189
   384
    SDL_ClearHints();
slouken@3647
   385
    SDL_AssertionsQuit();
slouken@5221
   386
    SDL_LogResetPriorities();
slouken@6690
   387
jorgen@6866
   388
    /* Now that every subsystem has been quit, we reset the subsystem refcount
jorgen@6866
   389
     * and the list of initialized subsystems.
jorgen@6866
   390
     */
jorgen@6866
   391
    SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) );
jorgen@6866
   392
jorgen@6866
   393
    SDL_bInMainQuit = SDL_FALSE;
slouken@0
   394
}
slouken@0
   395
slouken@1895
   396
/* Get the library version number */
slouken@1895
   397
void
slouken@1895
   398
SDL_GetVersion(SDL_version * ver)
slouken@0
   399
{
slouken@1895
   400
    SDL_VERSION(ver);
slouken@0
   401
}
slouken@0
   402
slouken@2982
   403
/* Get the library source revision */
icculus@4419
   404
const char *
slouken@2996
   405
SDL_GetRevision(void)
slouken@2982
   406
{
slouken@2983
   407
    return SDL_REVISION;
slouken@2982
   408
}
slouken@2982
   409
slouken@5359
   410
/* Get the library source revision number */
slouken@5359
   411
int
slouken@5359
   412
SDL_GetRevisionNumber(void)
slouken@5359
   413
{
slouken@5359
   414
    return SDL_REVISION_NUMBER;
slouken@5359
   415
}
slouken@5359
   416
slouken@3319
   417
/* Get the name of the platform */
slouken@3319
   418
const char *
slouken@3319
   419
SDL_GetPlatform()
slouken@3319
   420
{
slouken@3319
   421
#if __AIX__
slouken@3319
   422
    return "AIX";
slouken@6441
   423
#elif __ANDROID__
slouken@6441
   424
    return "Android";
slouken@3319
   425
#elif __BSDI__
slouken@3319
   426
    return "BSDI";
slouken@3319
   427
#elif __DREAMCAST__
slouken@3319
   428
    return "Dreamcast";
philipp@9341
   429
#elif __EMSCRIPTEN__
philipp@9341
   430
    return "Emscripten";
slouken@3319
   431
#elif __FREEBSD__
slouken@3319
   432
    return "FreeBSD";
icculus@7346
   433
#elif __HAIKU__
icculus@7346
   434
    return "Haiku";
slouken@3319
   435
#elif __HPUX__
slouken@3319
   436
    return "HP-UX";
slouken@3319
   437
#elif __IRIX__
slouken@3319
   438
    return "Irix";
slouken@3319
   439
#elif __LINUX__
slouken@3319
   440
    return "Linux";
slouken@3319
   441
#elif __MINT__
slouken@3319
   442
    return "Atari MiNT";
slouken@3319
   443
#elif __MACOS__
slouken@3319
   444
    return "MacOS Classic";
slouken@3319
   445
#elif __MACOSX__
slouken@3319
   446
    return "Mac OS X";
slouken@8886
   447
#elif __NACL__
slouken@8886
   448
    return "NaCl";
slouken@3319
   449
#elif __NETBSD__
slouken@3319
   450
    return "NetBSD";
slouken@3319
   451
#elif __OPENBSD__
slouken@3319
   452
    return "OpenBSD";
slouken@3319
   453
#elif __OS2__
slouken@3319
   454
    return "OS/2";
slouken@3319
   455
#elif __OSF__
slouken@3319
   456
    return "OSF/1";
slouken@3319
   457
#elif __QNXNTO__
slouken@3319
   458
    return "QNX Neutrino";
slouken@3319
   459
#elif __RISCOS__
slouken@3319
   460
    return "RISC OS";
slouken@3319
   461
#elif __SOLARIS__
slouken@3319
   462
    return "Solaris";
slouken@5086
   463
#elif __WIN32__
slouken@3319
   464
    return "Windows";
dludwig@9223
   465
#elif __WINRT__
dludwig@9223
   466
    return "WinRT";
slime73@10340
   467
#elif __TVOS__
slime73@10340
   468
    return "tvOS";
slouken@3319
   469
#elif __IPHONEOS__
slouken@7592
   470
    return "iOS";
kimonline@7009
   471
#elif __PSP__
kimonline@7009
   472
    return "PlayStation Portable";
slouken@3319
   473
#else
slouken@3319
   474
    return "Unknown (see SDL_platform.h)";
slouken@3319
   475
#endif
slouken@3319
   476
}
slouken@3319
   477
slouken@11883
   478
#if defined(__WIN32__)
slouken@11883
   479
slouken@11885
   480
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
slouken@1465
   481
/* Need to include DllMain() on Watcom C for some reason.. */
slouken@1330
   482
slouken@1895
   483
BOOL APIENTRY
slouken@1895
   484
_DllMainCRTStartup(HANDLE hModule,
slouken@1895
   485
                   DWORD ul_reason_for_call, LPVOID lpReserved)
slouken@1330
   486
{
slouken@1895
   487
    switch (ul_reason_for_call) {
slouken@1895
   488
    case DLL_PROCESS_ATTACH:
slouken@1895
   489
    case DLL_THREAD_ATTACH:
slouken@1895
   490
    case DLL_THREAD_DETACH:
slouken@1895
   491
    case DLL_PROCESS_DETACH:
slouken@1895
   492
        break;
slouken@1895
   493
    }
slouken@1895
   494
    return TRUE;
slouken@1330
   495
}
slouken@11885
   496
#endif /* Building DLL */
slouken@1330
   497
slouken@11883
   498
#endif /* __WIN32__ */
slouken@11883
   499
jorgen@6927
   500
/* vi: set sts=4 ts=4 sw=4 expandtab: */