2015-06-21 17:33:46 +02:00
|
|
|
/*
|
|
|
|
|
Simple DirectMedia Layer
|
2025-01-01 07:45:41 -08:00
|
|
|
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
2015-06-21 17:33:46 +02: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.
|
|
|
|
|
*/
|
2022-11-29 18:34:15 -08:00
|
|
|
#include "SDL_internal.h"
|
2022-10-20 18:47:17 +02:00
|
|
|
#include "SDL3/SDL_revision.h"
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2024-09-05 23:59:23 -04:00
|
|
|
#if defined(SDL_PLATFORM_WINDOWS)
|
2015-06-21 17:33:46 +02:00
|
|
|
#include "core/windows/SDL_windows.h"
|
2024-09-05 23:36:16 -04:00
|
|
|
#else
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
#include <unistd.h> // _exit(), etc.
|
2015-06-21 17:33:46 +02:00
|
|
|
#endif
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// this checks for HAVE_DBUS_DBUS_H internally.
|
2021-04-02 14:35:11 -04:00
|
|
|
#include "core/linux/SDL_dbus.h"
|
|
|
|
|
|
2024-01-24 02:40:51 +01:00
|
|
|
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
2019-10-16 13:54:35 -04:00
|
|
|
#include <emscripten.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Initialization code for SDL
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
|
#include "SDL_assert_c.h"
|
2024-02-24 20:29:39 -08:00
|
|
|
#include "SDL_hints_c.h"
|
2022-04-28 15:01:34 -07:00
|
|
|
#include "SDL_log_c.h"
|
2023-10-10 12:38:22 -07:00
|
|
|
#include "SDL_properties_c.h"
|
2023-10-18 15:46:07 -04:00
|
|
|
#include "audio/SDL_sysaudio.h"
|
2024-06-04 16:38:11 -07:00
|
|
|
#include "camera/SDL_camera_c.h"
|
2024-02-24 13:46:06 +01:00
|
|
|
#include "cpuinfo/SDL_cpuinfo_c.h"
|
2015-06-21 17:33:46 +02:00
|
|
|
#include "events/SDL_events_c.h"
|
|
|
|
|
#include "haptic/SDL_haptic_c.h"
|
2022-12-27 10:23:28 -08:00
|
|
|
#include "joystick/SDL_gamepad_c.h"
|
2015-06-21 17:33:46 +02:00
|
|
|
#include "joystick/SDL_joystick_c.h"
|
2024-06-23 00:41:19 -07:00
|
|
|
#include "render/SDL_sysrender.h"
|
2018-08-21 12:11:34 -07:00
|
|
|
#include "sensor/SDL_sensor_c.h"
|
2024-09-15 09:55:38 -07:00
|
|
|
#include "stdlib/SDL_getenv_c.h"
|
2024-07-11 10:38:40 -07:00
|
|
|
#include "thread/SDL_thread_c.h"
|
2024-07-08 14:59:18 -07:00
|
|
|
#include "video/SDL_pixels_c.h"
|
2024-09-30 22:15:38 -07:00
|
|
|
#include "video/SDL_surface_c.h"
|
2024-06-04 16:38:11 -07:00
|
|
|
#include "video/SDL_video_c.h"
|
2024-07-13 13:34:46 -04:00
|
|
|
#include "filesystem/SDL_filesystem_c.h"
|
2025-01-16 00:56:49 -05:00
|
|
|
#include "io/SDL_asyncio_c.h"
|
2024-10-07 11:11:12 -07:00
|
|
|
#ifdef SDL_PLATFORM_ANDROID
|
|
|
|
|
#include "core/android/SDL_android.h"
|
|
|
|
|
#endif
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2024-01-18 03:51:56 -08:00
|
|
|
#define SDL_INIT_EVERYTHING ~0U
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Initialization/Cleanup routines
|
2022-11-30 12:51:59 -08:00
|
|
|
#include "timer/SDL_timer_c.h"
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
2024-08-22 17:33:49 -07:00
|
|
|
extern bool SDL_HelperWindowCreate(void);
|
|
|
|
|
extern void SDL_HelperWindowDestroy(void);
|
2015-06-21 17:33:46 +02:00
|
|
|
#endif
|
|
|
|
|
|
2022-05-03 14:39:00 +01: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,
|
2024-05-14 07:47:13 -07:00
|
|
|
SDL_MICRO_VERSION == SDL_BUILD_MICRO_VERSION);
|
2022-05-03 14:39:00 +01:00
|
|
|
#endif
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Limited by its encoding in SDL_VERSIONNUM
|
2022-05-03 13:17:59 +01:00
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_min, SDL_MAJOR_VERSION >= 0);
|
2024-05-14 07:47:13 -07:00
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_MAJOR_VERSION_max, SDL_MAJOR_VERSION <= 10);
|
2022-05-03 13:17:59 +01:00
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_MINOR_VERSION_min, SDL_MINOR_VERSION >= 0);
|
2024-05-14 07:47:13 -07:00
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_MINOR_VERSION_max, SDL_MINOR_VERSION <= 999);
|
|
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_MICRO_VERSION_min, SDL_MICRO_VERSION >= 0);
|
|
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_MICRO_VERSION_max, SDL_MICRO_VERSION <= 999);
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2019-10-14 12:41:06 -04: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 15:43:49 +01:00
|
|
|
extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
|
2019-11-20 02:47:40 +03:00
|
|
|
SDL_NORETURN void SDL_ExitProcess(int exitcode)
|
2019-10-14 12:41:06 -04:00
|
|
|
{
|
2024-09-05 23:59:23 -04:00
|
|
|
#if defined(SDL_PLATFORM_WINDOWS)
|
2019-10-14 12:41:06 -04: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);
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_EMSCRIPTEN)
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
emscripten_cancel_main_loop(); // this should "kill" the app.
|
|
|
|
|
emscripten_force_exit(exitcode); // this should "kill" the app.
|
2019-10-14 12:41:06 -04:00
|
|
|
exit(exitcode);
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
#elif defined(SDL_PLATFORM_HAIKU) // Haiku has _Exit, but it's not marked noreturn.
|
2019-10-14 12:41:06 -04:00
|
|
|
_exit(exitcode);
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
#elif defined(HAVE__EXIT) // Upper case _Exit()
|
2019-10-14 12:41:06 -04:00
|
|
|
_Exit(exitcode);
|
|
|
|
|
#else
|
|
|
|
|
_exit(exitcode);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// App metadata
|
2024-07-28 07:22:46 -07:00
|
|
|
|
2024-09-18 07:52:28 -07:00
|
|
|
bool SDL_SetAppMetadata(const char *appname, const char *appversion, const char *appidentifier)
|
2024-07-28 07:22:46 -07:00
|
|
|
{
|
|
|
|
|
SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_NAME_STRING, appname);
|
|
|
|
|
SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_VERSION_STRING, appversion);
|
|
|
|
|
SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_IDENTIFIER_STRING, appidentifier);
|
2024-08-22 17:33:49 -07:00
|
|
|
return true;
|
2024-07-28 07:22:46 -07:00
|
|
|
}
|
|
|
|
|
|
2024-08-22 09:21:26 -07:00
|
|
|
static bool SDL_ValidMetadataProperty(const char *name)
|
2024-07-28 07:22:46 -07:00
|
|
|
{
|
|
|
|
|
if (!name || !*name) {
|
2024-08-22 09:21:26 -07:00
|
|
|
return false;
|
2024-07-28 07:22:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (SDL_strcmp(name, SDL_PROP_APP_METADATA_NAME_STRING) == 0 ||
|
|
|
|
|
SDL_strcmp(name, SDL_PROP_APP_METADATA_VERSION_STRING) == 0 ||
|
|
|
|
|
SDL_strcmp(name, SDL_PROP_APP_METADATA_IDENTIFIER_STRING) == 0 ||
|
|
|
|
|
SDL_strcmp(name, SDL_PROP_APP_METADATA_CREATOR_STRING) == 0 ||
|
|
|
|
|
SDL_strcmp(name, SDL_PROP_APP_METADATA_COPYRIGHT_STRING) == 0 ||
|
|
|
|
|
SDL_strcmp(name, SDL_PROP_APP_METADATA_URL_STRING) == 0 ||
|
|
|
|
|
SDL_strcmp(name, SDL_PROP_APP_METADATA_TYPE_STRING) == 0) {
|
2024-08-22 09:21:26 -07:00
|
|
|
return true;
|
2024-07-28 07:22:46 -07:00
|
|
|
}
|
2024-08-22 09:21:26 -07:00
|
|
|
return false;
|
2024-07-28 07:22:46 -07:00
|
|
|
}
|
|
|
|
|
|
2024-09-18 07:52:28 -07:00
|
|
|
bool SDL_SetAppMetadataProperty(const char *name, const char *value)
|
2024-07-28 07:22:46 -07:00
|
|
|
{
|
|
|
|
|
if (!SDL_ValidMetadataProperty(name)) {
|
|
|
|
|
return SDL_InvalidParamError("name");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SDL_SetStringProperty(SDL_GetGlobalProperties(), name, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *SDL_GetAppMetadataProperty(const char *name)
|
|
|
|
|
{
|
|
|
|
|
if (!SDL_ValidMetadataProperty(name)) {
|
|
|
|
|
SDL_InvalidParamError("name");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-28 14:45:38 -07:00
|
|
|
const char *value = NULL;
|
|
|
|
|
if (SDL_strcmp(name, SDL_PROP_APP_METADATA_NAME_STRING) == 0) {
|
|
|
|
|
value = SDL_GetHint(SDL_HINT_APP_NAME);
|
|
|
|
|
} else if (SDL_strcmp(name, SDL_PROP_APP_METADATA_IDENTIFIER_STRING) == 0) {
|
|
|
|
|
value = SDL_GetHint(SDL_HINT_APP_ID);
|
|
|
|
|
}
|
|
|
|
|
if (!value || !*value) {
|
|
|
|
|
value = SDL_GetStringProperty(SDL_GetGlobalProperties(), name, NULL);
|
|
|
|
|
}
|
2024-07-28 07:22:46 -07:00
|
|
|
if (!value || !*value) {
|
|
|
|
|
if (SDL_strcmp(name, SDL_PROP_APP_METADATA_NAME_STRING) == 0) {
|
|
|
|
|
value = "SDL Application";
|
|
|
|
|
} else if (SDL_strcmp(name, SDL_PROP_APP_METADATA_TYPE_STRING) == 0) {
|
|
|
|
|
value = "application";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// The initialized subsystems
|
2015-06-21 17:33:46 +02:00
|
|
|
#ifdef SDL_MAIN_NEEDED
|
2024-08-22 09:21:26 -07:00
|
|
|
static bool SDL_MainIsReady = false;
|
2015-06-21 17:33:46 +02:00
|
|
|
#else
|
2024-08-22 09:21:26 -07:00
|
|
|
static bool SDL_MainIsReady = true;
|
2015-06-21 17:33:46 +02:00
|
|
|
#endif
|
2024-12-05 12:35:23 -08:00
|
|
|
static SDL_ThreadID SDL_MainThreadID = 0;
|
2024-08-22 09:21:26 -07:00
|
|
|
static bool SDL_bInMainQuit = false;
|
2022-11-30 12:51:59 -08:00
|
|
|
static Uint8 SDL_SubsystemRefCount[32];
|
2015-06-21 17:33:46 +02:00
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Private helper to increment a subsystem's ref counter.
|
2022-12-27 15:05:51 -08:00
|
|
|
static void SDL_IncrementSubsystemRefCount(Uint32 subsystem)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2022-11-16 12:53:48 -05: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-05 19:26:09 -07:00
|
|
|
++SDL_SubsystemRefCount[subsystem_index];
|
2022-11-16 12:53:48 -05:00
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Private helper to decrement a subsystem's ref counter.
|
2022-12-27 15:05:51 -08:00
|
|
|
static void SDL_DecrementSubsystemRefCount(Uint32 subsystem)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2022-11-16 12:53:48 -05:00
|
|
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
|
|
|
|
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
|
2024-03-20 15:45:13 -07:00
|
|
|
if (SDL_bInMainQuit) {
|
|
|
|
|
SDL_SubsystemRefCount[subsystem_index] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
--SDL_SubsystemRefCount[subsystem_index];
|
|
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Private helper to check if a system needs init.
|
2024-08-22 09:21:26 -07:00
|
|
|
static bool SDL_ShouldInitSubsystem(Uint32 subsystem)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2022-11-16 12:53:48 -05:00
|
|
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
|
|
|
|
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
2023-11-03 09:27:29 -07:00
|
|
|
return ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0));
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Private helper to check if a system needs to be quit.
|
2024-08-22 09:21:26 -07:00
|
|
|
static bool SDL_ShouldQuitSubsystem(Uint32 subsystem)
|
2022-11-30 12:51:59 -08:00
|
|
|
{
|
2022-11-16 12:53:48 -05:00
|
|
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
|
|
|
|
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
|
2024-08-22 09:21:26 -07:00
|
|
|
return false;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
|
|
|
|
|
* isn't zero.
|
|
|
|
|
*/
|
2023-11-03 09:27:29 -07:00
|
|
|
return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-12 12:37:35 +03:00
|
|
|
/* Private helper to either increment's existing ref counter,
|
|
|
|
|
* or fully init a new subsystem. */
|
2024-08-22 09:21:26 -07:00
|
|
|
static bool SDL_InitOrIncrementSubsystem(Uint32 subsystem)
|
2023-10-12 12:37:35 +03:00
|
|
|
{
|
|
|
|
|
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
|
|
|
|
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
|
|
|
|
if (subsystem_index < 0) {
|
2024-08-22 09:21:26 -07:00
|
|
|
return false;
|
2023-10-12 12:37:35 +03:00
|
|
|
}
|
|
|
|
|
if (SDL_SubsystemRefCount[subsystem_index] > 0) {
|
|
|
|
|
++SDL_SubsystemRefCount[subsystem_index];
|
2024-08-22 09:21:26 -07:00
|
|
|
return true;
|
2023-10-12 12:37:35 +03:00
|
|
|
}
|
2024-08-22 17:33:49 -07:00
|
|
|
return SDL_InitSubSystem(subsystem);
|
2023-10-12 12:37:35 +03:00
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
void SDL_SetMainReady(void)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2024-08-22 09:21:26 -07:00
|
|
|
SDL_MainIsReady = true;
|
2024-12-05 12:35:23 -08:00
|
|
|
|
|
|
|
|
if (SDL_MainThreadID == 0) {
|
|
|
|
|
SDL_MainThreadID = SDL_GetCurrentThreadID();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SDL_IsMainThread(void)
|
|
|
|
|
{
|
|
|
|
|
if (SDL_MainThreadID == 0) {
|
|
|
|
|
// Not initialized yet?
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (SDL_MainThreadID == SDL_GetCurrentThreadID()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Initialize all the subsystems that require initialization before threads start
|
2024-07-12 08:50:15 -07:00
|
|
|
void SDL_InitMainThread(void)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2024-10-07 12:44:49 +01:00
|
|
|
static bool done_info = false;
|
|
|
|
|
|
2024-07-11 10:38:40 -07:00
|
|
|
SDL_InitTLSData();
|
2024-09-15 09:55:38 -07:00
|
|
|
SDL_InitEnvironment();
|
2024-07-12 08:50:15 -07:00
|
|
|
SDL_InitTicks();
|
2024-07-13 13:34:46 -04:00
|
|
|
SDL_InitFilesystem();
|
2024-10-07 12:44:49 +01:00
|
|
|
|
|
|
|
|
if (!done_info) {
|
|
|
|
|
const char *value;
|
|
|
|
|
|
|
|
|
|
value = SDL_GetAppMetadataProperty(SDL_PROP_APP_METADATA_NAME_STRING);
|
2024-10-08 14:30:28 -04:00
|
|
|
SDL_LogInfo(SDL_LOG_CATEGORY_SYSTEM, "App name: %s", value ? value : "<unspecified>");
|
2024-10-07 12:44:49 +01:00
|
|
|
value = SDL_GetAppMetadataProperty(SDL_PROP_APP_METADATA_VERSION_STRING);
|
|
|
|
|
SDL_LogInfo(SDL_LOG_CATEGORY_SYSTEM, "App version: %s", value ? value : "<unspecified>");
|
|
|
|
|
value = SDL_GetAppMetadataProperty(SDL_PROP_APP_METADATA_IDENTIFIER_STRING);
|
|
|
|
|
SDL_LogInfo(SDL_LOG_CATEGORY_SYSTEM, "App ID: %s", value ? value : "<unspecified>");
|
2024-10-07 17:08:28 +01:00
|
|
|
SDL_LogInfo(SDL_LOG_CATEGORY_SYSTEM, "SDL revision: %s", SDL_REVISION);
|
2024-10-07 12:44:49 +01:00
|
|
|
|
|
|
|
|
done_info = true;
|
|
|
|
|
}
|
2024-07-12 08:50:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void SDL_QuitMainThread(void)
|
|
|
|
|
{
|
2024-07-13 13:34:46 -04:00
|
|
|
SDL_QuitFilesystem();
|
2024-07-12 08:50:15 -07:00
|
|
|
SDL_QuitTicks();
|
2024-09-15 09:55:38 -07:00
|
|
|
SDL_QuitEnvironment();
|
2024-07-12 08:50:15 -07:00
|
|
|
SDL_QuitTLSData();
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-18 07:52:28 -07:00
|
|
|
bool SDL_InitSubSystem(SDL_InitFlags flags)
|
2024-07-12 08:50:15 -07:00
|
|
|
{
|
|
|
|
|
Uint32 flags_initialized = 0;
|
|
|
|
|
|
|
|
|
|
if (!SDL_MainIsReady) {
|
|
|
|
|
return SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_InitMainThread();
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifdef SDL_USE_LIBDBUS
|
2021-04-02 14:35:11 -04:00
|
|
|
SDL_DBus_Init();
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK)) {
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_HelperWindowCreate()) {
|
2021-10-12 18:55:31 -04:00
|
|
|
goto quit_and_error;
|
2018-09-24 11:49:25 -07:00
|
|
|
}
|
|
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
#endif
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Initialize the event subsystem
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_EVENTS) {
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldInitSubsystem(SDL_INIT_EVENTS)) {
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_EVENTS);
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_InitEvents()) {
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_EVENTS);
|
2021-10-12 18:55:31 -04:00
|
|
|
goto quit_and_error;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2023-01-20 17:06:49 -08:00
|
|
|
} else {
|
|
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_EVENTS);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2021-10-12 18:55:31 -04:00
|
|
|
flags_initialized |= SDL_INIT_EVENTS;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Initialize the video subsystem
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_VIDEO) {
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifndef SDL_VIDEO_DISABLED
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldInitSubsystem(SDL_INIT_VIDEO)) {
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// video implies events
|
2023-10-12 12:37:35 +03:00
|
|
|
if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) {
|
|
|
|
|
goto quit_and_error;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-05 12:35:23 -08:00
|
|
|
// We initialize video on the main thread
|
|
|
|
|
// On Apple platforms this is a requirement.
|
|
|
|
|
// On other platforms, this is the definition.
|
|
|
|
|
SDL_MainThreadID = SDL_GetCurrentThreadID();
|
|
|
|
|
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_VIDEO);
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_VideoInit(NULL)) {
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_VIDEO);
|
2024-09-15 11:40:31 -07:00
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
2021-10-12 18:55:31 -04:00
|
|
|
goto quit_and_error;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2023-01-20 17:06:49 -08:00
|
|
|
} else {
|
|
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_VIDEO);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2021-10-12 18:55:31 -04:00
|
|
|
flags_initialized |= SDL_INIT_VIDEO;
|
2015-06-21 17:33:46 +02:00
|
|
|
#else
|
2021-10-12 18:55:31 -04:00
|
|
|
SDL_SetError("SDL not built with video support");
|
|
|
|
|
goto quit_and_error;
|
2015-06-21 17:33:46 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Initialize the audio subsystem
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_AUDIO) {
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifndef SDL_AUDIO_DISABLED
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldInitSubsystem(SDL_INIT_AUDIO)) {
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// audio implies events
|
2023-10-12 12:37:35 +03:00
|
|
|
if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) {
|
|
|
|
|
goto quit_and_error;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_AUDIO);
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_InitAudio(NULL)) {
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_AUDIO);
|
2024-09-15 11:40:31 -07:00
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
2021-10-12 18:55:31 -04:00
|
|
|
goto quit_and_error;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2023-01-20 17:06:49 -08:00
|
|
|
} else {
|
|
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_AUDIO);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2021-10-12 18:55:31 -04:00
|
|
|
flags_initialized |= SDL_INIT_AUDIO;
|
2015-06-21 17:33:46 +02:00
|
|
|
#else
|
2021-10-12 18:55:31 -04:00
|
|
|
SDL_SetError("SDL not built with audio support");
|
|
|
|
|
goto quit_and_error;
|
2015-06-21 17:33:46 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Initialize the joystick subsystem
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_JOYSTICK) {
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifndef SDL_JOYSTICK_DISABLED
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// joystick implies events
|
2023-10-12 12:37:35 +03:00
|
|
|
if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) {
|
|
|
|
|
goto quit_and_error;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_JOYSTICK);
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_InitJoysticks()) {
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_JOYSTICK);
|
2024-09-15 11:40:31 -07:00
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
2022-11-30 12:51:59 -08:00
|
|
|
goto quit_and_error;
|
|
|
|
|
}
|
2023-01-20 17:06:49 -08:00
|
|
|
} else {
|
|
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_JOYSTICK);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2021-10-12 18:55:31 -04:00
|
|
|
flags_initialized |= SDL_INIT_JOYSTICK;
|
2015-06-21 17:33:46 +02:00
|
|
|
#else
|
2021-10-12 18:55:31 -04:00
|
|
|
SDL_SetError("SDL not built with joystick support");
|
|
|
|
|
goto quit_and_error;
|
2015-06-21 17:33:46 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_GAMEPAD) {
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifndef SDL_JOYSTICK_DISABLED
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldInitSubsystem(SDL_INIT_GAMEPAD)) {
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// game controller implies joystick
|
2023-10-12 12:37:35 +03:00
|
|
|
if (!SDL_InitOrIncrementSubsystem(SDL_INIT_JOYSTICK)) {
|
|
|
|
|
goto quit_and_error;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_GAMEPAD);
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_InitGamepads()) {
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_GAMEPAD);
|
2024-09-15 11:40:31 -07:00
|
|
|
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
2021-10-12 18:55:31 -04:00
|
|
|
goto quit_and_error;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2023-01-20 17:06:49 -08:00
|
|
|
} else {
|
|
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_GAMEPAD);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2022-12-27 09:46:24 -08:00
|
|
|
flags_initialized |= SDL_INIT_GAMEPAD;
|
2015-06-21 17:33:46 +02:00
|
|
|
#else
|
2021-10-12 18:55:31 -04:00
|
|
|
SDL_SetError("SDL not built with joystick support");
|
|
|
|
|
goto quit_and_error;
|
2015-06-21 17:33:46 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Initialize the haptic subsystem
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_HAPTIC) {
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifndef SDL_HAPTIC_DISABLED
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldInitSubsystem(SDL_INIT_HAPTIC)) {
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_HAPTIC);
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_InitHaptics()) {
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_HAPTIC);
|
2021-10-12 18:55:31 -04:00
|
|
|
goto quit_and_error;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2023-01-20 17:06:49 -08:00
|
|
|
} else {
|
|
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_HAPTIC);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2021-10-12 18:55:31 -04:00
|
|
|
flags_initialized |= SDL_INIT_HAPTIC;
|
2015-06-21 17:33:46 +02:00
|
|
|
#else
|
2021-10-12 18:55:31 -04:00
|
|
|
SDL_SetError("SDL not built with haptic (force feedback) support");
|
|
|
|
|
goto quit_and_error;
|
2015-06-21 17:33:46 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Initialize the sensor subsystem
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_SENSOR) {
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifndef SDL_SENSOR_DISABLED
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldInitSubsystem(SDL_INIT_SENSOR)) {
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_SENSOR);
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_InitSensors()) {
|
2023-01-20 17:06:49 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_SENSOR);
|
2021-10-12 18:55:31 -04:00
|
|
|
goto quit_and_error;
|
2018-08-21 12:11:34 -07:00
|
|
|
}
|
2023-01-20 17:06:49 -08:00
|
|
|
} else {
|
|
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_SENSOR);
|
2018-08-21 12:11:34 -07:00
|
|
|
}
|
2021-10-12 18:55:31 -04:00
|
|
|
flags_initialized |= SDL_INIT_SENSOR;
|
2018-08-21 12:11:34 -07:00
|
|
|
#else
|
2021-10-12 18:55:31 -04:00
|
|
|
SDL_SetError("SDL not built with sensor support");
|
|
|
|
|
goto quit_and_error;
|
2018-08-21 12:11:34 -07:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Initialize the camera subsystem
|
2023-12-01 10:59:13 -05:00
|
|
|
if (flags & SDL_INIT_CAMERA) {
|
|
|
|
|
#ifndef SDL_CAMERA_DISABLED
|
|
|
|
|
if (SDL_ShouldInitSubsystem(SDL_INIT_CAMERA)) {
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// camera implies events
|
2023-12-01 10:59:13 -05:00
|
|
|
if (!SDL_InitOrIncrementSubsystem(SDL_INIT_EVENTS)) {
|
|
|
|
|
goto quit_and_error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_CAMERA);
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_CameraInit(NULL)) {
|
2023-12-01 10:59:13 -05:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_CAMERA);
|
2024-09-15 11:40:31 -07:00
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
2023-12-01 10:59:13 -05:00
|
|
|
goto quit_and_error;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
SDL_IncrementSubsystemRefCount(SDL_INIT_CAMERA);
|
|
|
|
|
}
|
|
|
|
|
flags_initialized |= SDL_INIT_CAMERA;
|
|
|
|
|
#else
|
|
|
|
|
SDL_SetError("SDL not built with camera support");
|
|
|
|
|
goto quit_and_error;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
(void)flags_initialized; // make static analysis happy, since this only gets used in error cases.
|
2022-03-24 11:00:43 -04:00
|
|
|
|
2024-05-07 14:03:25 -07:00
|
|
|
return SDL_ClearError();
|
2021-11-20 21:51:10 +03:00
|
|
|
|
2021-10-12 18:55:31 -04:00
|
|
|
quit_and_error:
|
|
|
|
|
SDL_QuitSubSystem(flags_initialized);
|
2024-08-22 17:33:49 -07:00
|
|
|
return false;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
2024-09-18 07:52:28 -07:00
|
|
|
bool SDL_Init(SDL_InitFlags flags)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
|
return SDL_InitSubSystem(flags);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-27 10:31:51 -07:00
|
|
|
void SDL_QuitSubSystem(SDL_InitFlags flags)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Shut down requested initialized subsystems
|
2023-12-01 10:59:13 -05:00
|
|
|
|
|
|
|
|
#ifndef SDL_CAMERA_DISABLED
|
|
|
|
|
if (flags & SDL_INIT_CAMERA) {
|
|
|
|
|
if (SDL_ShouldQuitSubsystem(SDL_INIT_CAMERA)) {
|
|
|
|
|
SDL_QuitCamera();
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// camera implies events
|
2023-12-01 10:59:13 -05:00
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
|
|
|
|
}
|
|
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_CAMERA);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifndef SDL_SENSOR_DISABLED
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_SENSOR) {
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldQuitSubsystem(SDL_INIT_SENSOR)) {
|
|
|
|
|
SDL_QuitSensors();
|
2018-09-24 11:49:25 -07:00
|
|
|
}
|
2022-12-27 15:05:51 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_SENSOR);
|
2018-08-21 12:11:34 -07:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifndef SDL_JOYSTICK_DISABLED
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_GAMEPAD) {
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldQuitSubsystem(SDL_INIT_GAMEPAD)) {
|
|
|
|
|
SDL_QuitGamepads();
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// game controller implies joystick
|
2023-10-12 12:37:35 +03:00
|
|
|
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2022-12-27 15:05:51 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_GAMEPAD);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_JOYSTICK) {
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
|
|
|
|
|
SDL_QuitJoysticks();
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// joystick implies events
|
2023-10-12 12:37:35 +03:00
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2022-12-27 15:05:51 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_JOYSTICK);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifndef SDL_HAPTIC_DISABLED
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_HAPTIC) {
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
|
|
|
|
|
SDL_QuitHaptics();
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2022-12-27 15:05:51 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_HAPTIC);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifndef SDL_AUDIO_DISABLED
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_AUDIO) {
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldQuitSubsystem(SDL_INIT_AUDIO)) {
|
|
|
|
|
SDL_QuitAudio();
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// audio implies events
|
2023-10-12 12:37:35 +03:00
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2022-12-27 15:05:51 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_AUDIO);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifndef SDL_VIDEO_DISABLED
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_VIDEO) {
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldQuitSubsystem(SDL_INIT_VIDEO)) {
|
2024-06-23 00:41:19 -07:00
|
|
|
SDL_QuitRender();
|
2015-06-21 17:33:46 +02:00
|
|
|
SDL_VideoQuit();
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// video implies events
|
2023-10-12 12:37:35 +03:00
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2022-12-27 15:05:51 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_VIDEO);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-02-03 22:08:42 +01:00
|
|
|
if (flags & SDL_INIT_EVENTS) {
|
2022-12-27 15:05:51 -08:00
|
|
|
if (SDL_ShouldQuitSubsystem(SDL_INIT_EVENTS)) {
|
|
|
|
|
SDL_QuitEvents();
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2022-12-27 15:05:51 -08:00
|
|
|
SDL_DecrementSubsystemRefCount(SDL_INIT_EVENTS);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-27 10:31:51 -07:00
|
|
|
Uint32 SDL_WasInit(SDL_InitFlags flags)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
|
|
|
|
|
Uint32 initialized = 0;
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Fast path for checking one flag
|
2018-11-19 21:17:00 -08:00
|
|
|
if (SDL_HasExactlyOneBitSet32(flags)) {
|
|
|
|
|
int subsystem_index = SDL_MostSignificantBitIndex32(flags);
|
|
|
|
|
return SDL_SubsystemRefCount[subsystem_index] ? flags : 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-21 17:33:46 +02:00
|
|
|
if (!flags) {
|
|
|
|
|
flags = SDL_INIT_EVERYTHING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Iterate over each bit in flags, and check the matching subsystem.
|
2015-06-21 17:33:46 +02:00
|
|
|
for (i = 0; i < num_subsystems; ++i) {
|
|
|
|
|
if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
|
|
|
|
|
initialized |= (1 << i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flags >>= 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return initialized;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
void SDL_Quit(void)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2024-08-22 09:21:26 -07:00
|
|
|
SDL_bInMainQuit = true;
|
2015-06-21 17:33:46 +02:00
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Quit all subsystems
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
2015-06-21 17:33:46 +02:00
|
|
|
SDL_HelperWindowDestroy();
|
|
|
|
|
#endif
|
|
|
|
|
SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
|
|
|
|
|
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifdef SDL_USE_LIBDBUS
|
2021-04-02 14:35:11 -04:00
|
|
|
SDL_DBus_Quit();
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-09-16 22:57:42 -07:00
|
|
|
SDL_QuitTimers();
|
2024-08-27 21:57:27 -04:00
|
|
|
SDL_QuitAsyncIO();
|
2024-09-16 22:57:42 -07:00
|
|
|
|
2024-06-03 04:09:28 -07:00
|
|
|
SDL_SetObjectsInvalid();
|
2024-01-02 13:15:32 -05:00
|
|
|
SDL_AssertionsQuit();
|
|
|
|
|
|
2024-07-08 14:59:18 -07:00
|
|
|
SDL_QuitPixelFormatDetails();
|
|
|
|
|
|
2024-02-24 13:46:06 +01:00
|
|
|
SDL_QuitCPUInfo();
|
|
|
|
|
|
2015-06-21 17:33:46 +02:00
|
|
|
/* Now that every subsystem has been quit, we reset the subsystem refcount
|
|
|
|
|
* and the list of initialized subsystems.
|
|
|
|
|
*/
|
2022-11-30 12:51:59 -08:00
|
|
|
SDL_memset(SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount));
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2024-09-17 02:55:23 -07:00
|
|
|
SDL_QuitLog();
|
|
|
|
|
SDL_QuitHints();
|
|
|
|
|
SDL_QuitProperties();
|
|
|
|
|
|
2024-07-12 08:50:15 -07:00
|
|
|
SDL_QuitMainThread();
|
2024-05-23 11:22:00 -07:00
|
|
|
|
2024-08-22 09:21:26 -07:00
|
|
|
SDL_bInMainQuit = false;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Get the library version number
|
2024-05-14 07:47:13 -07:00
|
|
|
int SDL_GetVersion(void)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2024-05-14 07:47:13 -07:00
|
|
|
return SDL_VERSION;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Get the library source revision
|
2023-05-23 11:29:41 -07:00
|
|
|
const char *SDL_GetRevision(void)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2024-07-19 09:50:54 -07:00
|
|
|
return SDL_REVISION;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
2024-06-01 22:05:21 -04:00
|
|
|
// Get the name of the platform
|
2023-05-23 11:29:41 -07:00
|
|
|
const char *SDL_GetPlatform(void)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2024-10-15 18:02:07 -04:00
|
|
|
#if defined(SDL_PLATFORM_PRIVATE)
|
|
|
|
|
return SDL_PLATFORM_PRIVATE_NAME;
|
|
|
|
|
#elif defined(SDL_PLATFORM_AIX)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "AIX";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_ANDROID)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "Android";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_BSDI)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "BSDI";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_EMSCRIPTEN)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "Emscripten";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_FREEBSD)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "FreeBSD";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_HAIKU)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "Haiku";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_HPUX)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "HP-UX";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_IRIX)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "Irix";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_LINUX)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "Linux";
|
2022-11-25 16:00:06 -08:00
|
|
|
#elif defined(__MINT__)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "Atari MiNT";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_MACOS)
|
2022-11-25 16:00:06 -08:00
|
|
|
return "macOS";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_NETBSD)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "NetBSD";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_OPENBSD)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "OpenBSD";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_OS2)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "OS/2";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_OSF)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "OSF/1";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_QNXNTO)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "QNX Neutrino";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_RISCOS)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "RISC OS";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_SOLARIS)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "Solaris";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_WIN32)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "Windows";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_WINGDK)
|
2022-06-27 17:19:39 +00:00
|
|
|
return "WinGDK";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_XBOXONE)
|
2022-07-01 13:59:14 -07:00
|
|
|
return "Xbox One";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_XBOXSERIES)
|
2022-09-21 14:22:38 -07:00
|
|
|
return "Xbox Series X|S";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_IOS)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "iOS";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_TVOS)
|
2022-11-25 16:00:06 -08:00
|
|
|
return "tvOS";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_PS2)
|
2022-06-06 00:04:56 +02:00
|
|
|
return "PlayStation 2";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_PSP)
|
2015-06-21 17:33:46 +02:00
|
|
|
return "PlayStation Portable";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_VITA)
|
2020-11-02 18:09:43 +03:00
|
|
|
return "PlayStation Vita";
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_3DS)
|
2021-03-30 04:32:39 -04:00
|
|
|
return "Nintendo 3DS";
|
2023-07-21 21:01:37 +02:00
|
|
|
#elif defined(__managarm__)
|
|
|
|
|
return "Managarm";
|
2015-06-21 17:33:46 +02:00
|
|
|
#else
|
|
|
|
|
return "Unknown (see SDL_platform.h)";
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-18 07:52:28 -07:00
|
|
|
bool SDL_IsTablet(void)
|
2018-08-21 20:03:54 -07:00
|
|
|
{
|
2024-01-24 02:40:51 +01:00
|
|
|
#ifdef SDL_PLATFORM_ANDROID
|
2018-08-21 20:03:54 -07:00
|
|
|
return SDL_IsAndroidTablet();
|
2024-01-24 02:40:51 +01:00
|
|
|
#elif defined(SDL_PLATFORM_IOS)
|
2024-08-22 09:21:26 -07:00
|
|
|
extern bool SDL_IsIPad(void);
|
2018-08-21 20:03:54 -07:00
|
|
|
return SDL_IsIPad();
|
|
|
|
|
#else
|
2024-08-22 09:21:26 -07:00
|
|
|
return false;
|
2018-08-21 20:03:54 -07:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-01 17:20:00 +01:00
|
|
|
bool SDL_IsTV(void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef SDL_PLATFORM_ANDROID
|
|
|
|
|
return SDL_IsAndroidTV();
|
|
|
|
|
#elif defined(SDL_PLATFORM_IOS)
|
|
|
|
|
extern bool SDL_IsAppleTV(void);
|
|
|
|
|
return SDL_IsAppleTV();
|
|
|
|
|
#else
|
|
|
|
|
return false;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-16 11:02:49 -07:00
|
|
|
static SDL_Sandbox SDL_DetectSandbox(void)
|
|
|
|
|
{
|
|
|
|
|
#if defined(SDL_PLATFORM_LINUX)
|
|
|
|
|
if (access("/.flatpak-info", F_OK) == 0) {
|
|
|
|
|
return SDL_SANDBOX_FLATPAK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* For Snap, we check multiple variables because they might be set for
|
|
|
|
|
* unrelated reasons. This is the same thing WebKitGTK does. */
|
|
|
|
|
if (SDL_getenv("SNAP") && SDL_getenv("SNAP_NAME") && SDL_getenv("SNAP_REVISION")) {
|
|
|
|
|
return SDL_SANDBOX_SNAP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (access("/run/host/container-manager", F_OK) == 0) {
|
2024-10-18 12:45:07 -07:00
|
|
|
return SDL_SANDBOX_UNKNOWN_CONTAINER;
|
2024-10-16 11:02:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#elif defined(SDL_PLATFORM_MACOS)
|
|
|
|
|
if (SDL_getenv("APP_SANDBOX_CONTAINER_ID")) {
|
|
|
|
|
return SDL_SANDBOX_MACOS;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return SDL_SANDBOX_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_Sandbox SDL_GetSandbox(void)
|
|
|
|
|
{
|
|
|
|
|
static SDL_Sandbox sandbox;
|
|
|
|
|
static bool sandbox_initialized;
|
|
|
|
|
|
|
|
|
|
if (!sandbox_initialized) {
|
|
|
|
|
sandbox = SDL_DetectSandbox();
|
|
|
|
|
sandbox_initialized = true;
|
|
|
|
|
}
|
|
|
|
|
return sandbox;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-24 02:40:51 +01:00
|
|
|
#ifdef SDL_PLATFORM_WIN32
|
2018-02-18 09:09:56 -08:00
|
|
|
|
2018-02-21 09:40:47 -08:00
|
|
|
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// FIXME: Still need to include DllMain() on Watcom C ?
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2023-08-04 10:23:20 +03:00
|
|
|
BOOL APIENTRY MINGW32_FORCEALIGN _DllMainCRTStartup(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
2015-06-21 17:33:46 +02: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;
|
|
|
|
|
}
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
#endif // Building DLL
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2024-09-05 23:59:23 -04:00
|
|
|
#endif // defined(SDL_PLATFORM_WIN32)
|