2015-06-21 15:33:46 +00:00
|
|
|
/*
|
|
|
|
Simple DirectMedia Layer
|
2024-01-01 21:19:49 +00:00
|
|
|
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
2015-06-21 15:33:46 +00:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
#include "./SDL_internal.h"
|
|
|
|
|
2022-06-27 17:19:39 +00:00
|
|
|
#if defined(__WIN32__) || defined(__GDK__)
|
2015-06-21 15:33:46 +00:00
|
|
|
#include "core/windows/SDL_windows.h"
|
2019-10-18 20:10:00 +00:00
|
|
|
#elif defined(__OS2__)
|
2021-11-20 18:51:10 +00:00
|
|
|
#include <stdlib.h> /* _exit() */
|
2019-10-18 00:51:49 +00:00
|
|
|
#elif !defined(__WINRT__)
|
2021-11-20 18:51:10 +00:00
|
|
|
#include <unistd.h> /* _exit(), etc. */
|
2015-06-21 15:33:46 +00:00
|
|
|
#endif
|
2020-10-14 20:01:06 +00:00
|
|
|
#if defined(__OS2__)
|
|
|
|
#include "core/os2/SDL_os2.h"
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifdef SDL_THREAD_OS2
|
2020-10-14 20:01:06 +00:00
|
|
|
#include "thread/os2/SDL_systls_c.h"
|
|
|
|
#endif
|
2021-11-20 18:51:10 +00:00
|
|
|
#endif
|
2015-06-21 15:33:46 +00:00
|
|
|
|
2021-04-02 18:35:11 +00:00
|
|
|
/* this checks for HAVE_DBUS_DBUS_H internally. */
|
|
|
|
#include "core/linux/SDL_dbus.h"
|
|
|
|
|
2019-10-16 17:54:35 +00:00
|
|
|
#if defined(__EMSCRIPTEN__)
|
|
|
|
#include <emscripten.h>
|
|
|
|
#endif
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
/* Initialization code for SDL */
|
|
|
|
|
|
|
|
#include "SDL.h"
|
|
|
|
#include "SDL_bits.h"
|
|
|
|
#include "SDL_revision.h"
|
|
|
|
#include "SDL_assert_c.h"
|
2022-04-28 22:01:34 +00:00
|
|
|
#include "SDL_log_c.h"
|
2015-06-21 15:33:46 +00:00
|
|
|
#include "events/SDL_events_c.h"
|
|
|
|
#include "haptic/SDL_haptic_c.h"
|
|
|
|
#include "joystick/SDL_joystick_c.h"
|
2018-08-21 19:11:34 +00:00
|
|
|
#include "sensor/SDL_sensor_c.h"
|
2015-06-21 15:33:46 +00:00
|
|
|
|
|
|
|
/* Initialization/Cleanup routines */
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_TIMERS_DISABLED
|
2022-11-30 20:51:59 +00:00
|
|
|
#include "timer/SDL_timer_c.h"
|
2015-06-21 15:33:46 +00:00
|
|
|
#endif
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
2015-06-21 15:33:46 +00:00
|
|
|
extern int SDL_HelperWindowCreate(void);
|
|
|
|
extern int SDL_HelperWindowDestroy(void);
|
|
|
|
#endif
|
|
|
|
|
2022-05-03 13:39:00 +00:00
|
|
|
#ifdef SDL_BUILD_MAJOR_VERSION
|
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MAJOR_VERSION,
|
|
|
|
SDL_MAJOR_VERSION == SDL_BUILD_MAJOR_VERSION);
|
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MINOR_VERSION,
|
|
|
|
SDL_MINOR_VERSION == SDL_BUILD_MINOR_VERSION);
|
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MICRO_VERSION,
|
|
|
|
SDL_PATCHLEVEL == SDL_BUILD_MICRO_VERSION);
|
|
|
|
#endif
|
|
|
|
|
2022-05-03 12:17:59 +00:00
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_min, SDL_MAJOR_VERSION >= 0);
|
|
|
|
/* Limited only by the need to fit in SDL_version */
|
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_max, SDL_MAJOR_VERSION <= 255);
|
|
|
|
|
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_MINOR_VERSION_min, SDL_MINOR_VERSION >= 0);
|
|
|
|
/* Limited only by the need to fit in SDL_version */
|
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_MINOR_VERSION_max, SDL_MINOR_VERSION <= 255);
|
|
|
|
|
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_PATCHLEVEL_min, SDL_PATCHLEVEL >= 0);
|
2022-05-04 15:40:11 +00:00
|
|
|
/* Limited by its encoding in SDL_VERSIONNUM and in the ABI versions */
|
2022-05-03 12:17:59 +00:00
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_PATCHLEVEL_max, SDL_PATCHLEVEL <= 99);
|
2015-06-21 15:33:46 +00:00
|
|
|
|
2019-10-14 16:41:06 +00:00
|
|
|
/* This is not declared in any header, although it is shared between some
|
|
|
|
parts of SDL, because we don't want anything calling it without an
|
|
|
|
extremely good reason. */
|
2019-10-30 14:43:49 +00:00
|
|
|
extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
|
2019-11-19 23:47:40 +00:00
|
|
|
SDL_NORETURN void SDL_ExitProcess(int exitcode)
|
2019-10-14 16:41:06 +00:00
|
|
|
{
|
2022-06-27 17:19:39 +00:00
|
|
|
#if defined(__WIN32__) || defined(__GDK__)
|
2019-10-14 16:41:06 +00:00
|
|
|
/* "if you do not know the state of all threads in your process, it is
|
|
|
|
better to call TerminateProcess than ExitProcess"
|
|
|
|
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */
|
|
|
|
TerminateProcess(GetCurrentProcess(), exitcode);
|
|
|
|
/* MingW doesn't have TerminateProcess marked as noreturn, so add an
|
|
|
|
ExitProcess here that will never be reached but make MingW happy. */
|
|
|
|
ExitProcess(exitcode);
|
|
|
|
#elif defined(__EMSCRIPTEN__)
|
2022-11-30 20:51:59 +00:00
|
|
|
emscripten_cancel_main_loop(); /* this should "kill" the app. */
|
|
|
|
emscripten_force_exit(exitcode); /* this should "kill" the app. */
|
2019-10-14 16:41:06 +00:00
|
|
|
exit(exitcode);
|
|
|
|
#elif defined(__HAIKU__) /* Haiku has _Exit, but it's not marked noreturn. */
|
|
|
|
_exit(exitcode);
|
|
|
|
#elif defined(HAVE__EXIT) /* Upper case _Exit() */
|
|
|
|
_Exit(exitcode);
|
|
|
|
#else
|
|
|
|
_exit(exitcode);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
/* The initialized subsystems */
|
|
|
|
#ifdef SDL_MAIN_NEEDED
|
|
|
|
static SDL_bool SDL_MainIsReady = SDL_FALSE;
|
|
|
|
#else
|
|
|
|
static SDL_bool SDL_MainIsReady = SDL_TRUE;
|
|
|
|
#endif
|
|
|
|
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
|
2022-11-30 20:51:59 +00:00
|
|
|
static Uint8 SDL_SubsystemRefCount[32];
|
2015-06-21 15:33:46 +00:00
|
|
|
|
|
|
|
/* Private helper to increment a subsystem's ref counter. */
|
2022-11-30 20:51:59 +00:00
|
|
|
static void SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
2022-11-16 17:53:48 +00:00
|
|
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
|
|
|
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
|
|
|
if (subsystem_index >= 0) {
|
Fixes made in response to running a static code analyzer under MS Windows.
Most of these are probably harmless, but the changes to SDL_immdevice.c and SDL_pixels.c appear to have fixed genuine bugs.
SDL_audiocvt.c: By separating the calculation of the divisor, I got rid of the suspicion that dividing a double by an integer led to loss of precision.
SDL_immdevice.c: Added a missing test, one that could have otherwise led to dereferencing a null pointer.
SDL_events.c, SDL_gamecontroller.c, SDL_joystick.c, SDL_malloc.c, SDL_video.c: Made it clear the return values weren't used.
SDL_hidapi_shield.c: The size is zero, so nothing bad would have happened, but the SDL_memset() was still being given an address outside of the array's range.
SDL_dinputjoystick.c: Initialize local data, just in case IDirectInputDevice8_GetProperty() isn't guaranteed to write to it.
SDL_render_sw.c: drawstate.viewport could be null (as seen on line 691).
SDL.c: SDL_MostSignificantBitIndex32() could return -1, though I don't know if you want to cope with that (what I did) or SDL_assert() that it can't happen.
SDL_hints.c: Replaced boolean tests on pointer values with comparisons to NULL.
SDL_pixels.c: Looks like the switch is genuinely missing a break!
SDL_rect_impl.h: The MacOS static checker pointed out issues with the X comparisons that were handled by assertions; I added assertions for the Y comparisons.
SDL_yuv.c, SDL_windowskeyboard.c, SDL_windowswindow.c: Checked error-result returns.
2022-10-06 02:26:09 +00:00
|
|
|
++SDL_SubsystemRefCount[subsystem_index];
|
2022-11-16 17:53:48 +00:00
|
|
|
}
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Private helper to decrement a subsystem's ref counter. */
|
2022-11-30 20:51:59 +00:00
|
|
|
static void SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
2022-11-16 17:53:48 +00:00
|
|
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
|
|
|
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
|
2015-06-21 15:33:46 +00:00
|
|
|
--SDL_SubsystemRefCount[subsystem_index];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Private helper to check if a system needs init. */
|
2022-11-30 20:51:59 +00:00
|
|
|
static SDL_bool SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
2022-11-16 17:53:48 +00:00
|
|
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
|
|
|
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
|
|
|
return ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) ? SDL_TRUE : SDL_FALSE;
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Private helper to check if a system needs to be quit. */
|
2022-11-30 20:51:59 +00:00
|
|
|
static SDL_bool SDL_PrivateShouldQuitSubsystem(Uint32 subsystem)
|
|
|
|
{
|
2022-11-16 17:53:48 +00:00
|
|
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
|
|
|
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
|
|
|
|
return SDL_FALSE;
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
|
|
|
|
* isn't zero.
|
|
|
|
*/
|
2022-11-16 17:53:48 +00:00
|
|
|
return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
|
2023-11-07 15:53:16 +00:00
|
|
|
/* Private helper to either increment's existing ref counter,
|
|
|
|
* or fully init a new subsystem. */
|
|
|
|
static SDL_bool SDL_PrivateInitOrIncrSubsystem(Uint32 subsystem)
|
|
|
|
{
|
|
|
|
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
|
|
|
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
|
|
|
if (subsystem_index < 0) {
|
|
|
|
return SDL_FALSE;
|
|
|
|
}
|
|
|
|
if (SDL_SubsystemRefCount[subsystem_index] > 0) {
|
|
|
|
++SDL_SubsystemRefCount[subsystem_index];
|
|
|
|
return SDL_TRUE;
|
|
|
|
}
|
|
|
|
return SDL_InitSubSystem(subsystem) == 0;
|
|
|
|
}
|
|
|
|
|
2022-11-30 20:51:59 +00:00
|
|
|
void SDL_SetMainReady(void)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
|
|
|
SDL_MainIsReady = SDL_TRUE;
|
|
|
|
}
|
|
|
|
|
2022-11-30 20:51:59 +00:00
|
|
|
int SDL_InitSubSystem(Uint32 flags)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
2021-10-12 22:55:31 +00:00
|
|
|
Uint32 flags_initialized = 0;
|
2021-11-20 18:51:10 +00:00
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
if (!SDL_MainIsReady) {
|
2022-01-17 16:22:30 +00:00
|
|
|
return SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
|
2022-04-27 13:39:24 +00:00
|
|
|
SDL_LogInit();
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
/* Clear the error message */
|
|
|
|
SDL_ClearError();
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifdef SDL_USE_LIBDBUS
|
2021-04-02 18:35:11 +00:00
|
|
|
SDL_DBus_Init();
|
|
|
|
#endif
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifdef SDL_THREAD_OS2
|
2020-10-14 20:01:06 +00:00
|
|
|
SDL_OS2TLSAlloc(); /* thread/os2/SDL_systls.c */
|
|
|
|
#endif
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK)) {
|
2018-09-24 18:49:25 +00:00
|
|
|
if (SDL_HelperWindowCreate() < 0) {
|
2021-10-12 22:55:31 +00:00
|
|
|
goto quit_and_error;
|
2018-09-24 18:49:25 +00:00
|
|
|
}
|
|
|
|
}
|
2015-06-21 15:33:46 +00:00
|
|
|
#endif
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_TIMERS_DISABLED
|
2015-06-21 15:33:46 +00:00
|
|
|
SDL_TicksInit();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Initialize the event subsystem */
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_EVENTS) {
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_EVENTS_DISABLED
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
|
2019-03-15 18:08:30 +00:00
|
|
|
if (SDL_EventsInit() < 0) {
|
2021-10-12 22:55:31 +00:00
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_EVENTS);
|
2021-10-12 22:55:31 +00:00
|
|
|
flags_initialized |= SDL_INIT_EVENTS;
|
2015-06-21 15:33:46 +00:00
|
|
|
#else
|
2021-10-12 22:55:31 +00:00
|
|
|
SDL_SetError("SDL not built with events support");
|
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the timer subsystem */
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_TIMER) {
|
2023-11-17 03:06:26 +00:00
|
|
|
#if !defined(SDL_TIMERS_DISABLED) && !defined(SDL_TIMER_DUMMY)
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
|
|
|
|
if (SDL_TimerInit() < 0) {
|
2021-10-12 22:55:31 +00:00
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
|
2021-10-12 22:55:31 +00:00
|
|
|
flags_initialized |= SDL_INIT_TIMER;
|
2015-06-21 15:33:46 +00:00
|
|
|
#else
|
2021-10-12 22:55:31 +00:00
|
|
|
SDL_SetError("SDL not built with timer support");
|
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the video subsystem */
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_VIDEO) {
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_VIDEO_DISABLED
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
|
2023-11-07 15:53:16 +00:00
|
|
|
/* video implies events */
|
|
|
|
if (!SDL_PrivateInitOrIncrSubsystem(SDL_INIT_EVENTS)) {
|
|
|
|
goto quit_and_error;
|
|
|
|
}
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_VideoInit(NULL) < 0) {
|
2021-10-12 22:55:31 +00:00
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
|
2021-10-12 22:55:31 +00:00
|
|
|
flags_initialized |= SDL_INIT_VIDEO;
|
2015-06-21 15:33:46 +00:00
|
|
|
#else
|
2021-10-12 22:55:31 +00:00
|
|
|
SDL_SetError("SDL not built with video support");
|
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the audio subsystem */
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_AUDIO) {
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_AUDIO_DISABLED
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
|
2023-11-07 15:53:16 +00:00
|
|
|
/* audio implies events */
|
|
|
|
if (!SDL_PrivateInitOrIncrSubsystem(SDL_INIT_EVENTS)) {
|
|
|
|
goto quit_and_error;
|
|
|
|
}
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_AudioInit(NULL) < 0) {
|
2021-10-12 22:55:31 +00:00
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
|
2021-10-12 22:55:31 +00:00
|
|
|
flags_initialized |= SDL_INIT_AUDIO;
|
2015-06-21 15:33:46 +00:00
|
|
|
#else
|
2021-10-12 22:55:31 +00:00
|
|
|
SDL_SetError("SDL not built with audio support");
|
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the joystick subsystem */
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_JOYSTICK) {
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_JOYSTICK_DISABLED
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
|
2023-11-07 15:53:16 +00:00
|
|
|
/* joystick implies events */
|
|
|
|
if (!SDL_PrivateInitOrIncrSubsystem(SDL_INIT_EVENTS)) {
|
|
|
|
goto quit_and_error;
|
|
|
|
}
|
|
|
|
|
2022-11-30 20:51:59 +00:00
|
|
|
if (SDL_JoystickInit() < 0) {
|
|
|
|
goto quit_and_error;
|
|
|
|
}
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
|
2021-10-12 22:55:31 +00:00
|
|
|
flags_initialized |= SDL_INIT_JOYSTICK;
|
2015-06-21 15:33:46 +00:00
|
|
|
#else
|
2021-10-12 22:55:31 +00:00
|
|
|
SDL_SetError("SDL not built with joystick support");
|
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_GAMECONTROLLER) {
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_JOYSTICK_DISABLED
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
|
2023-11-07 15:53:16 +00:00
|
|
|
/* game controller implies joystick */
|
|
|
|
if (!SDL_PrivateInitOrIncrSubsystem(SDL_INIT_JOYSTICK)) {
|
|
|
|
goto quit_and_error;
|
|
|
|
}
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_GameControllerInit() < 0) {
|
2021-10-12 22:55:31 +00:00
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
|
2021-10-12 22:55:31 +00:00
|
|
|
flags_initialized |= SDL_INIT_GAMECONTROLLER;
|
2015-06-21 15:33:46 +00:00
|
|
|
#else
|
2021-10-12 22:55:31 +00:00
|
|
|
SDL_SetError("SDL not built with joystick support");
|
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the haptic subsystem */
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_HAPTIC) {
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_HAPTIC_DISABLED
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
|
|
|
|
if (SDL_HapticInit() < 0) {
|
2021-10-12 22:55:31 +00:00
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
|
2021-10-12 22:55:31 +00:00
|
|
|
flags_initialized |= SDL_INIT_HAPTIC;
|
2015-06-21 15:33:46 +00:00
|
|
|
#else
|
2021-10-12 22:55:31 +00:00
|
|
|
SDL_SetError("SDL not built with haptic (force feedback) support");
|
|
|
|
goto quit_and_error;
|
2015-06-21 15:33:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-08-21 19:11:34 +00:00
|
|
|
/* Initialize the sensor subsystem */
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_SENSOR) {
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_SENSOR_DISABLED
|
2018-08-21 19:11:34 +00:00
|
|
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_SENSOR)) {
|
|
|
|
if (SDL_SensorInit() < 0) {
|
2021-10-12 22:55:31 +00:00
|
|
|
goto quit_and_error;
|
2018-08-21 19:11:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_SENSOR);
|
2021-10-12 22:55:31 +00:00
|
|
|
flags_initialized |= SDL_INIT_SENSOR;
|
2018-08-21 19:11:34 +00:00
|
|
|
#else
|
2021-10-12 22:55:31 +00:00
|
|
|
SDL_SetError("SDL not built with sensor support");
|
|
|
|
goto quit_and_error;
|
2018-08-21 19:11:34 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-11-30 20:51:59 +00:00
|
|
|
(void)flags_initialized; /* make static analysis happy, since this only gets used in error cases. */
|
2022-03-24 15:00:43 +00:00
|
|
|
|
2022-11-27 16:38:43 +00:00
|
|
|
return 0;
|
2021-11-20 18:51:10 +00:00
|
|
|
|
2021-10-12 22:55:31 +00:00
|
|
|
quit_and_error:
|
|
|
|
SDL_QuitSubSystem(flags_initialized);
|
2022-11-27 16:38:43 +00:00
|
|
|
return -1;
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 20:51:59 +00:00
|
|
|
int SDL_Init(Uint32 flags)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
|
|
|
return SDL_InitSubSystem(flags);
|
|
|
|
}
|
|
|
|
|
2022-11-30 20:51:59 +00:00
|
|
|
void SDL_QuitSubSystem(Uint32 flags)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
2021-11-20 18:51:10 +00:00
|
|
|
#if defined(__OS2__)
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifdef SDL_THREAD_OS2
|
2020-10-14 20:01:06 +00:00
|
|
|
SDL_OS2TLSFree(); /* thread/os2/SDL_systls.c */
|
|
|
|
#endif
|
|
|
|
SDL_OS2Quit();
|
|
|
|
#endif
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
/* Shut down requested initialized subsystems */
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_SENSOR_DISABLED
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_SENSOR) {
|
2018-08-21 19:11:34 +00:00
|
|
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_SENSOR)) {
|
2018-09-24 18:49:25 +00:00
|
|
|
SDL_SensorQuit();
|
|
|
|
}
|
2018-08-21 19:11:34 +00:00
|
|
|
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_SENSOR);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_JOYSTICK_DISABLED
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_GAMECONTROLLER) {
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
|
|
|
|
SDL_GameControllerQuit();
|
2023-11-07 15:53:16 +00:00
|
|
|
/* game controller implies joystick */
|
|
|
|
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
|
|
|
|
}
|
|
|
|
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_JOYSTICK) {
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
|
|
|
|
SDL_JoystickQuit();
|
2023-11-07 15:53:16 +00:00
|
|
|
/* joystick implies events */
|
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_HAPTIC_DISABLED
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_HAPTIC) {
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
|
|
|
|
SDL_HapticQuit();
|
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_AUDIO_DISABLED
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_AUDIO) {
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
|
|
|
|
SDL_AudioQuit();
|
2023-11-07 15:53:16 +00:00
|
|
|
/* audio implies events */
|
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_VIDEO_DISABLED
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_VIDEO) {
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
|
|
|
|
SDL_VideoQuit();
|
2023-11-07 15:53:16 +00:00
|
|
|
/* video implies events */
|
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#if !defined(SDL_TIMERS_DISABLED) && !defined(SDL_TIMER_DUMMY)
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_TIMER) {
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
|
|
|
|
SDL_TimerQuit();
|
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_EVENTS_DISABLED
|
2023-02-04 14:51:37 +00:00
|
|
|
if (flags & SDL_INIT_EVENTS) {
|
2015-06-21 15:33:46 +00:00
|
|
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
|
2019-03-15 18:08:30 +00:00
|
|
|
SDL_EventsQuit();
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_EVENTS);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-05-23 17:59:03 +00:00
|
|
|
Uint32 SDL_WasInit(Uint32 flags)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
|
|
|
|
Uint32 initialized = 0;
|
|
|
|
|
2018-11-20 05:17:00 +00:00
|
|
|
/* Fast path for checking one flag */
|
|
|
|
if (SDL_HasExactlyOneBitSet32(flags)) {
|
|
|
|
int subsystem_index = SDL_MostSignificantBitIndex32(flags);
|
|
|
|
return SDL_SubsystemRefCount[subsystem_index] ? flags : 0;
|
|
|
|
}
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
if (!flags) {
|
|
|
|
flags = SDL_INIT_EVERYTHING;
|
|
|
|
}
|
|
|
|
|
|
|
|
num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
|
|
|
|
|
|
|
|
/* Iterate over each bit in flags, and check the matching subsystem. */
|
|
|
|
for (i = 0; i < num_subsystems; ++i) {
|
|
|
|
if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
|
|
|
|
initialized |= (1 << i);
|
|
|
|
}
|
|
|
|
|
|
|
|
flags >>= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return initialized;
|
|
|
|
}
|
|
|
|
|
2022-11-30 20:51:59 +00:00
|
|
|
void SDL_Quit(void)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
|
|
|
SDL_bInMainQuit = SDL_TRUE;
|
|
|
|
|
|
|
|
/* Quit all subsystems */
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
2015-06-21 15:33:46 +00:00
|
|
|
SDL_HelperWindowDestroy();
|
|
|
|
#endif
|
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifndef SDL_TIMERS_DISABLED
|
2015-06-21 15:33:46 +00:00
|
|
|
SDL_TicksQuit();
|
|
|
|
#endif
|
|
|
|
|
2023-11-17 03:06:26 +00:00
|
|
|
#ifdef SDL_USE_LIBDBUS
|
2021-04-02 18:35:11 +00:00
|
|
|
SDL_DBus_Quit();
|
|
|
|
#endif
|
|
|
|
|
2024-01-02 18:15:32 +00:00
|
|
|
SDL_ClearHints();
|
|
|
|
SDL_AssertionsQuit();
|
|
|
|
|
2022-04-27 13:39:24 +00:00
|
|
|
SDL_LogQuit();
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
/* Now that every subsystem has been quit, we reset the subsystem refcount
|
|
|
|
* and the list of initialized subsystems.
|
|
|
|
*/
|
2022-11-30 20:51:59 +00:00
|
|
|
SDL_memset(SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount));
|
2015-06-21 15:33:46 +00:00
|
|
|
|
2022-09-09 03:08:20 +00:00
|
|
|
SDL_TLSCleanup();
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
SDL_bInMainQuit = SDL_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the library version number */
|
2022-11-30 20:51:59 +00:00
|
|
|
void SDL_GetVersion(SDL_version *ver)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
2022-11-26 21:09:50 +00:00
|
|
|
static SDL_bool check_hint = SDL_TRUE;
|
|
|
|
static SDL_bool legacy_version = SDL_FALSE;
|
|
|
|
|
2023-11-10 14:30:56 +00:00
|
|
|
if (!ver) {
|
2022-11-30 20:51:59 +00:00
|
|
|
return;
|
2022-09-27 00:06:18 +00:00
|
|
|
}
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
SDL_VERSION(ver);
|
2022-09-27 00:06:18 +00:00
|
|
|
|
2022-11-26 21:09:50 +00:00
|
|
|
if (check_hint) {
|
|
|
|
check_hint = SDL_FALSE;
|
|
|
|
legacy_version = SDL_GetHintBoolean("SDL_LEGACY_VERSION", SDL_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (legacy_version) {
|
2022-09-27 00:06:18 +00:00
|
|
|
/* Prior to SDL 2.24.0, the patch version was incremented with every release */
|
|
|
|
ver->patch = ver->minor;
|
|
|
|
ver->minor = 0;
|
|
|
|
}
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the library source revision */
|
2023-05-23 17:59:03 +00:00
|
|
|
const char *SDL_GetRevision(void)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
|
|
|
return SDL_REVISION;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the library source revision number */
|
2023-05-23 17:59:03 +00:00
|
|
|
int SDL_GetRevisionNumber(void)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
2021-02-12 19:15:29 +00:00
|
|
|
return 0; /* doesn't make sense without Mercurial. */
|
2015-06-21 15:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the name of the platform */
|
2023-05-23 17:59:03 +00:00
|
|
|
const char *SDL_GetPlatform(void)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
2023-11-17 03:06:26 +00:00
|
|
|
#if defined(__AIX__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "AIX";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__ANDROID__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "Android";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__BSDI__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "BSDI";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__DREAMCAST__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "Dreamcast";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__EMSCRIPTEN__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "Emscripten";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__FREEBSD__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "FreeBSD";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__HAIKU__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "Haiku";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__HPUX__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "HP-UX";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__IRIX__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "Irix";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__LINUX__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "Linux";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__MINT__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "Atari MiNT";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__MACOS__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "MacOS Classic";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__MACOSX__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "Mac OS X";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__NACL__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "NaCl";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__NETBSD__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "NetBSD";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__OPENBSD__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "OpenBSD";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__OS2__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "OS/2";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__OSF__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "OSF/1";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__QNXNTO__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "QNX Neutrino";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__RISCOS__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "RISC OS";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__SOLARIS__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "Solaris";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__WIN32__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "Windows";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__WINRT__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "WinRT";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__WINGDK__)
|
2022-06-27 17:19:39 +00:00
|
|
|
return "WinGDK";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__XBOXONE__)
|
2022-07-01 20:59:14 +00:00
|
|
|
return "Xbox One";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__XBOXSERIES__)
|
2022-09-21 21:22:38 +00:00
|
|
|
return "Xbox Series X|S";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__TVOS__)
|
2016-09-14 01:18:06 +00:00
|
|
|
return "tvOS";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__IPHONEOS__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "iOS";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__PS2__)
|
2022-06-05 22:04:56 +00:00
|
|
|
return "PlayStation 2";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__PSP__)
|
2015-06-21 15:33:46 +00:00
|
|
|
return "PlayStation Portable";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__VITA__)
|
2020-11-02 15:09:43 +00:00
|
|
|
return "PlayStation Vita";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__NGAGE__)
|
2022-05-03 15:51:49 +00:00
|
|
|
return "Nokia N-Gage";
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__3DS__)
|
2021-03-30 08:32:39 +00:00
|
|
|
return "Nintendo 3DS";
|
2015-06-21 15:33:46 +00:00
|
|
|
#else
|
|
|
|
return "Unknown (see SDL_platform.h)";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-05-23 17:59:03 +00:00
|
|
|
SDL_bool SDL_IsTablet(void)
|
2018-08-22 03:03:54 +00:00
|
|
|
{
|
2023-11-17 03:06:26 +00:00
|
|
|
#if defined(__ANDROID__)
|
2018-08-22 03:03:54 +00:00
|
|
|
extern SDL_bool SDL_IsAndroidTablet(void);
|
|
|
|
return SDL_IsAndroidTablet();
|
2023-11-17 03:06:26 +00:00
|
|
|
#elif defined(__IPHONEOS__)
|
2018-08-22 03:03:54 +00:00
|
|
|
extern SDL_bool SDL_IsIPad(void);
|
|
|
|
return SDL_IsIPad();
|
|
|
|
#else
|
|
|
|
return SDL_FALSE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-02-18 17:09:56 +00:00
|
|
|
#if defined(__WIN32__)
|
|
|
|
|
2018-02-21 17:40:47 +00:00
|
|
|
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
|
2023-07-10 00:05:32 +00:00
|
|
|
/* FIXME: Still need to include DllMain() on Watcom C ? */
|
2015-06-21 15:33:46 +00:00
|
|
|
|
2023-07-10 00:05:32 +00:00
|
|
|
BOOL APIENTRY MINGW32_FORCEALIGN _DllMainCRTStartup(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
2015-06-21 15:33:46 +00:00
|
|
|
{
|
|
|
|
switch (ul_reason_for_call) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
case DLL_THREAD_ATTACH:
|
|
|
|
case DLL_THREAD_DETACH:
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2018-02-21 17:40:47 +00:00
|
|
|
#endif /* Building DLL */
|
2015-06-21 15:33:46 +00:00
|
|
|
|
2022-06-27 17:19:39 +00:00
|
|
|
#endif /* defined(__WIN32__) || defined(__GDK__) */
|
2018-02-18 17:09:56 +00:00
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
/* vi: set sts=4 ts=4 sw=4 expandtab: */
|