diff --git a/Windows/SDL2/bin/sdl2-config b/Windows/SDL2/bin/sdl2-config index 1b5111525..3c2023a02 100755 --- a/Windows/SDL2/bin/sdl2-config +++ b/Windows/SDL2/bin/sdl2-config @@ -40,7 +40,7 @@ while test $# -gt 0; do lib_suffix=$optarg ;; --version) - echo 2.26.3 + echo 2.28.3 ;; --cflags) echo -I${prefix}/include -Dmain=SDL_main diff --git a/Windows/SDL2/include/SDL_assert.h b/Windows/SDL2/include/SDL_assert.h index ba6dcd17c..7ce823ec5 100644 --- a/Windows/SDL2/include/SDL_assert.h +++ b/Windows/SDL2/include/SDL_assert.h @@ -55,6 +55,8 @@ assert can have unique static variables associated with it. #define SDL_TriggerBreakpoint() __builtin_debugtrap() #elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) ) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) +#elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv) + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" ) #elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */ #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" ) #elif defined(__APPLE__) && defined(__arm__) @@ -125,12 +127,10 @@ typedef struct SDL_AssertData const struct SDL_AssertData *next; } SDL_AssertData; -#if (SDL_ASSERT_LEVEL > 0) - /* Never call this directly. Use the SDL_assert* macros. */ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, - const char *, - const char *, int) + const char *, + const char *, int) #if defined(__clang__) #if __has_feature(attribute_analyzer_noreturn) /* this tells Clang's static analysis that we're a custom assert function, @@ -151,9 +151,7 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, #define SDL_enabled_assert(condition) \ do { \ while ( !(condition) ) { \ - static struct SDL_AssertData sdl_assert_data = { \ - 0, 0, #condition, 0, 0, 0, 0 \ - }; \ + static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \ const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \ if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ continue; /* go again. */ \ @@ -164,8 +162,6 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, } \ } while (SDL_NULL_WHILE_LOOP_CONDITION) -#endif /* enabled assertions support code */ - /* Enable various levels of assertions. */ #if SDL_ASSERT_LEVEL == 0 /* assertions disabled */ # define SDL_assert(condition) SDL_disabled_assert(condition) diff --git a/Windows/SDL2/include/SDL_atomic.h b/Windows/SDL2/include/SDL_atomic.h index 22ea0191a..1dd816a38 100644 --- a/Windows/SDL2/include/SDL_atomic.h +++ b/Windows/SDL2/include/SDL_atomic.h @@ -240,7 +240,7 @@ typedef void (*SDL_KernelMemoryBarrierFunc)(); /* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */ #if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) #define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */ -#elif (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__) +#elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__aarch64__) #define SDL_CPUPauseInstruction() __asm__ __volatile__("yield" ::: "memory") #elif (defined(__powerpc__) || defined(__powerpc64__)) #define SDL_CPUPauseInstruction() __asm__ __volatile__("or 27,27,27"); @@ -249,9 +249,8 @@ typedef void (*SDL_KernelMemoryBarrierFunc)(); #elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)) #define SDL_CPUPauseInstruction() __yield() #elif defined(__WATCOMC__) && defined(__386__) - /* watcom assembler rejects PAUSE if CPU < i686, and it refuses REP NOP as an invalid combination. Hardcode the bytes. */ extern __inline void SDL_CPUPauseInstruction(void); - #pragma aux SDL_CPUPauseInstruction = "db 0f3h,90h" + #pragma aux SDL_CPUPauseInstruction = ".686p" ".xmm2" "pause" #else #define SDL_CPUPauseInstruction() #endif diff --git a/Windows/SDL2/include/SDL_audio.h b/Windows/SDL2/include/SDL_audio.h index 2c0f21191..ccd35982d 100644 --- a/Windows/SDL2/include/SDL_audio.h +++ b/Windows/SDL2/include/SDL_audio.h @@ -169,13 +169,13 @@ typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream, * The calculated values in this structure are calculated by SDL_OpenAudio(). * * For multi-channel audio, the default SDL channel mapping is: - * 2: FL FR (stereo) - * 3: FL FR LFE (2.1 surround) - * 4: FL FR BL BR (quad) - * 5: FL FR LFE BL BR (4.1 surround) - * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR) - * 7: FL FR FC LFE BC SL SR (6.1 surround) - * 8: FL FR FC LFE BL BR SL SR (7.1 surround) + * 2: FL FR (stereo) + * 3: FL FR LFE (2.1 surround) + * 4: FL FR BL BR (quad) + * 5: FL FR LFE BL BR (4.1 surround) + * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR) + * 7: FL FR FC LFE BC SL SR (6.1 surround) + * 8: FL FR FC LFE BL BR SL SR (7.1 surround) */ typedef struct SDL_AudioSpec { diff --git a/Windows/SDL2/include/SDL_blendmode.h b/Windows/SDL2/include/SDL_blendmode.h index b8621165d..4ecbe5078 100644 --- a/Windows/SDL2/include/SDL_blendmode.h +++ b/Windows/SDL2/include/SDL_blendmode.h @@ -52,7 +52,7 @@ typedef enum dstA = dstA */ SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)) - dstA = (srcA * dstA) + (dstA * (1-srcA)) */ + dstA = dstA */ SDL_BLENDMODE_INVALID = 0x7FFFFFFF /* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */ diff --git a/Windows/SDL2/include/SDL_endian.h b/Windows/SDL2/include/SDL_endian.h index 582c3a8b8..71bc06729 100644 --- a/Windows/SDL2/include/SDL_endian.h +++ b/Windows/SDL2/include/SDL_endian.h @@ -140,7 +140,7 @@ extern "C" { #if HAS_BUILTIN_BSWAP16 #define SDL_Swap16(x) __builtin_bswap16(x) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) +#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL) #pragma intrinsic(_byteswap_ushort) #define SDL_Swap16(x) _byteswap_ushort(x) #elif defined(__i386__) && !HAS_BROKEN_BSWAP @@ -189,7 +189,7 @@ SDL_Swap16(Uint16 x) #if HAS_BUILTIN_BSWAP32 #define SDL_Swap32(x) __builtin_bswap32(x) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) +#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL) #pragma intrinsic(_byteswap_ulong) #define SDL_Swap32(x) _byteswap_ulong(x) #elif defined(__i386__) && !HAS_BROKEN_BSWAP @@ -241,7 +241,7 @@ SDL_Swap32(Uint32 x) #if HAS_BUILTIN_BSWAP64 #define SDL_Swap64(x) __builtin_bswap64(x) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) +#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL) #pragma intrinsic(_byteswap_uint64) #define SDL_Swap64(x) _byteswap_uint64(x) #elif defined(__i386__) && !HAS_BROKEN_BSWAP diff --git a/Windows/SDL2/include/SDL_gamecontroller.h b/Windows/SDL2/include/SDL_gamecontroller.h index d66e1b060..140054d36 100644 --- a/Windows/SDL2/include/SDL_gamecontroller.h +++ b/Windows/SDL2/include/SDL_gamecontroller.h @@ -724,10 +724,10 @@ typedef enum SDL_CONTROLLER_BUTTON_DPAD_LEFT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */ - SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 */ - SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 */ - SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 */ - SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 */ + SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 (upper left, facing the back) */ + SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 (upper right, facing the back) */ + SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 (lower left, facing the back) */ + SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 (lower right, facing the back) */ SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */ SDL_CONTROLLER_BUTTON_MAX } SDL_GameControllerButton; diff --git a/Windows/SDL2/include/SDL_hints.h b/Windows/SDL2/include/SDL_hints.h index 1317924ee..00beef51e 100644 --- a/Windows/SDL2/include/SDL_hints.h +++ b/Windows/SDL2/include/SDL_hints.h @@ -92,7 +92,7 @@ extern "C" { * By default this hint is not set and the APK expansion files are not searched. */ #define SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION" - + /** * \brief Android APK expansion patch file version. Should be a string number like "1", "2" etc. * @@ -132,13 +132,13 @@ extern "C" { * \brief A variable to control whether we trap the Android back button to handle it manually. * This is necessary for the right mouse button to work on some Android devices, or * to be able to trap the back button for use in your code reliably. If set to true, - * the back button will show up as an SDL_KEYDOWN / SDL_KEYUP pair with a keycode of + * the back button will show up as an SDL_KEYDOWN / SDL_KEYUP pair with a keycode of * SDL_SCANCODE_AC_BACK. * * The variable can be set to the following values: * "0" - Back button will be handled as usual for system. (default) * "1" - Back button will be trapped, allowing you to handle the key press - * manually. (This will also let right mouse click work on systems + * manually. (This will also let right mouse click work on systems * where the right mouse button functions as back.) * * The value of this hint is used at runtime, so it can be changed at any time. @@ -147,7 +147,7 @@ extern "C" { /** * \brief Specify an application name. - * + * * This hint lets you specify the application name sent to the OS when * required. For example, this will often appear in volume control applets for * audio streams, and in lists of applications which are inhibiting the @@ -377,6 +377,17 @@ extern "C" { */ #define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT" +/** + * \brief A variable that controls whether the on-screen keyboard should be shown when text input is active + * + * The variable can be set to the following values: + * "0" - Do not show the on-screen keyboard + * "1" - Show the on-screen keyboard + * + * The default value is "1". This hint must be set before text input is activated. + */ +#define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD" + /** * \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs * @@ -507,7 +518,7 @@ extern "C" { /** * \brief If set, game controller face buttons report their values according to their labels instead of their positional layout. - * + * * For example, on Nintendo Switch controllers, normally you'd get: * * (Y) @@ -569,9 +580,9 @@ extern "C" { * * The variable can be set to the following values: * "0" - SDL_TEXTEDITING events are sent, and it is the application's - * responsibility to render the text from these events and + * responsibility to render the text from these events and * differentiate it somehow from committed text. (default) - * "1" - If supported by the IME then SDL_TEXTEDITING events are not sent, + * "1" - If supported by the IME then SDL_TEXTEDITING events are not sent, * and text that is being composed will be rendered in its own UI. */ #define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING" @@ -996,6 +1007,15 @@ extern "C" { */ #define SDL_HINT_JOYSTICK_THREAD "SDL_JOYSTICK_THREAD" +/** + * \brief A variable controlling whether Windows.Gaming.Input should be used for controller handling. + * + * This variable can be set to the following values: + * "0" - WGI is not used + * "1" - WGI is used (the default) + */ +#define SDL_HINT_JOYSTICK_WGI "SDL_JOYSTICK_WGI" + /** * \brief Determines whether SDL enforces that DRM master is required in order * to initialize the KMSDRM video backend. @@ -1310,6 +1330,8 @@ extern "C" { * * This variable can be one of the following values: * "primary" (default), "portrait", "landscape", "inverted-portrait", "inverted-landscape" + * + * Since SDL 2.0.22 this variable accepts a comma-separated list of values above. */ #define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION "SDL_QTWAYLAND_CONTENT_ORIENTATION" @@ -1452,6 +1474,17 @@ extern "C" { */ #define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" +/** + * \brief A variable controlling whether the Metal render driver select low power device over default one + * + * This variable can be set to the following values: + * "0" - Use the prefered OS device + * "1" - Select a low power one + * + * By default the prefered OS device is used. + */ +#define SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE "SDL_RENDER_METAL_PREFER_LOW_POWER_DEVICE" + /** * \brief A variable controlling if VSYNC is automatically disable if doesn't reach the enough FPS * @@ -1495,7 +1528,7 @@ extern "C" { * disabled. You should use a string that describes what your program is doing * (and, therefore, why the screensaver is disabled). For example, "Playing a * game" or "Watching a video". - * + * * Setting this to "" or leaving it unset will have SDL use a reasonable * default: "Playing a game" or something similar. * @@ -1509,13 +1542,13 @@ extern "C" { * On some platforms, like Linux, a realtime priority thread may be subject to restrictions * that require special handling by the application. This hint exists to let SDL know that * the app is prepared to handle said restrictions. - * + * * On Linux, SDL will apply the following configuration to any thread that becomes realtime: * * The SCHED_RESET_ON_FORK bit will be set on the scheduling policy, * * An RLIMIT_RTTIME budget will be configured to the rtkit specified limit. * * Exceeding this limit will result in the kernel sending SIGKILL to the app, * * Refer to the man pages for more information. - * + * * This variable can be set to the following values: * "0" - default platform specific behaviour * "1" - Force SDL_THREAD_PRIORITY_TIME_CRITICAL to a realtime scheduling policy @@ -1603,7 +1636,7 @@ extern "C" { #define SDL_HINT_TV_REMOTE_AS_JOYSTICK "SDL_TV_REMOTE_AS_JOYSTICK" /** - * \brief A variable controlling whether the screensaver is enabled. + * \brief A variable controlling whether the screensaver is enabled. * * This variable can be set to the following values: * "0" - Disable screensaver @@ -1616,7 +1649,7 @@ extern "C" { /** * \brief Tell the video driver that we only want a double buffer. * - * By default, most lowlevel 2D APIs will use a triple buffer scheme that + * By default, most lowlevel 2D APIs will use a triple buffer scheme that * wastes no CPU time on waiting for vsync after issuing a flip, but * introduces a frame of latency. On the other hand, using a double buffer * scheme instead is recommended for cases where low latency is an important @@ -1747,9 +1780,9 @@ extern "C" { /** * \brief A variable that is the address of another SDL_Window* (as a hex string formatted with "%p"). -* +* * If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has -* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly +* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly * created SDL_Window: * * 1. Its pixel format will be set to the same pixel format as this SDL_Window. This is @@ -1815,13 +1848,13 @@ extern "C" { /** * \brief A variable controlling whether the X11 _NET_WM_BYPASS_COMPOSITOR hint should be used. - * + * * This variable can be set to the following values: * "0" - Disable _NET_WM_BYPASS_COMPOSITOR * "1" - Enable _NET_WM_BYPASS_COMPOSITOR - * + * * By default SDL will use _NET_WM_BYPASS_COMPOSITOR - * + * */ #define SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR "SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR" @@ -1955,7 +1988,29 @@ extern "C" { #define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING "SDL_WINDOWS_DISABLE_THREAD_NAMING" /** - * \brief A variable controlling whether the windows message loop is processed by SDL + * \brief Controls whether menus can be opened with their keyboard shortcut (Alt+mnemonic). + * + * If the mnemonics are enabled, then menus can be opened by pressing the Alt + * key and the corresponding mnemonic (for example, Alt+F opens the File menu). + * However, in case an invalid mnemonic is pressed, Windows makes an audible + * beep to convey that nothing happened. This is true even if the window has + * no menu at all! + * + * Because most SDL applications don't have menus, and some want to use the Alt + * key for other purposes, SDL disables mnemonics (and the beeping) by default. + * + * Note: This also affects keyboard events: with mnemonics enabled, when a + * menu is opened from the keyboard, you will not receive a KEYUP event for + * the mnemonic key, and *might* not receive one for Alt. + * + * This variable can be set to the following values: + * "0" - Alt+mnemonic does nothing, no beeping. (default) + * "1" - Alt+mnemonic opens menus, invalid mnemonics produce a beep. + */ +#define SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS "SDL_WINDOWS_ENABLE_MENU_MNEMONICS" + +/** + * \brief A variable controlling whether the windows message loop is processed by SDL * * This variable can be set to the following values: * "0" - The window message loop is not run @@ -1996,7 +2051,7 @@ extern "C" { #define SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL "SDL_WINDOWS_FORCE_SEMAPHORE_KERNEL" /** - * \brief A variable to specify custom icon resource id from RC file on Windows platform + * \brief A variable to specify custom icon resource id from RC file on Windows platform */ #define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON" #define SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL "SDL_WINDOWS_INTRESOURCE_ICON_SMALL" @@ -2035,16 +2090,16 @@ extern "C" { * * This hint must be set before initializing the video subsystem. * - * The main purpose of declaring DPI awareness is to disable OS bitmap scaling of SDL windows on monitors with + * The main purpose of declaring DPI awareness is to disable OS bitmap scaling of SDL windows on monitors with * a DPI scale factor. - * + * * This hint is equivalent to requesting DPI awareness via external means (e.g. calling SetProcessDpiAwarenessContext) * and does not cause SDL to use a virtualized coordinate system, so it will generally give you 1 SDL coordinate = 1 pixel * even on high-DPI displays. - * + * * For more information, see: * https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows - * + * * This variable can be set to the following values: * "" - Do not change the DPI awareness (default). * "unaware" - Declare the process as DPI unaware. (Windows 8.1 and later). @@ -2062,16 +2117,16 @@ extern "C" { /** * \brief Uses DPI-scaled points as the SDL coordinate system on Windows. - * + * * This changes the SDL coordinate system units to be DPI-scaled points, rather than pixels everywhere. * This means windows will be appropriately sized, even when created on high-DPI displays with scaling. - * + * * e.g. requesting a 640x480 window from SDL, on a display with 125% scaling in Windows display settings, * will create a window with an 800x600 client area (in pixels). * * Setting this to "1" implicitly requests process DPI awareness (setting SDL_WINDOWS_DPI_AWARENESS is unnecessary), * and forces SDL_WINDOW_ALLOW_HIGHDPI on all windows. - * + * * This variable can be set to the following values: * "0" - SDL coordinates equal Windows coordinates. No automatic window resizing when dragging * between monitors with different scale factors (unless this is performed by @@ -2082,7 +2137,7 @@ extern "C" { #define SDL_HINT_WINDOWS_DPI_SCALING "SDL_WINDOWS_DPI_SCALING" /** - * \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden + * \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden * * This variable can be set to the following values: * "0" - The window frame is not interactive when the cursor is hidden (no move, resize, etc) @@ -2093,7 +2148,7 @@ extern "C" { #define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN" /** -* \brief A variable controlling whether the window is activated when the SDL_ShowWindow function is called +* \brief A variable controlling whether the window is activated when the SDL_ShowWindow function is called * * This variable can be set to the following values: * "0" - The window is activated when the SDL_ShowWindow function is called diff --git a/Windows/SDL2/include/SDL_joystick.h b/Windows/SDL2/include/SDL_joystick.h index 07d6a2e0a..b9b4f6228 100644 --- a/Windows/SDL2/include/SDL_joystick.h +++ b/Windows/SDL2/include/SDL_joystick.h @@ -44,6 +44,7 @@ #include "SDL_stdinc.h" #include "SDL_error.h" #include "SDL_guid.h" +#include "SDL_mutex.h" #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -66,6 +67,9 @@ extern "C" { /** * The joystick structure used to identify an SDL joystick */ +#ifdef SDL_THREAD_SAFETY_ANALYSIS +extern SDL_mutex *SDL_joystick_lock; +#endif struct _SDL_Joystick; typedef struct _SDL_Joystick SDL_Joystick; @@ -131,7 +135,7 @@ typedef enum * * \since This function is available since SDL 2.0.7. */ -extern DECLSPEC void SDLCALL SDL_LockJoysticks(void); +extern DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock); /** @@ -146,7 +150,7 @@ extern DECLSPEC void SDLCALL SDL_LockJoysticks(void); * * \since This function is available since SDL 2.0.7. */ -extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void); +extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock); /** * Count the number of joysticks attached to the system. @@ -284,13 +288,12 @@ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_in /** * Get the instance ID of a joystick. * - * This can be called before any joysticks are opened. If the index is out of - * range, this function will return -1. + * This can be called before any joysticks are opened. * * \param device_index the index of the joystick to query (the N'th joystick * on the system * \returns the instance id of the selected joystick. If called on an invalid - * index, this function returns zero + * index, this function returns -1. * * \since This function is available since SDL 2.0.6. */ diff --git a/Windows/SDL2/include/SDL_keycode.h b/Windows/SDL2/include/SDL_keycode.h index 2523506d7..710622302 100644 --- a/Windows/SDL2/include/SDL_keycode.h +++ b/Windows/SDL2/include/SDL_keycode.h @@ -40,7 +40,7 @@ * an SDLK_* constant for those keys that do not generate characters. * * A special exception is the number keys at the top of the keyboard which - * always map to SDLK_0...SDLK_9, regardless of layout. + * map to SDLK_0...SDLK_9 on AZERTY layouts. */ typedef Sint32 SDL_Keycode; diff --git a/Windows/SDL2/include/SDL_main.h b/Windows/SDL2/include/SDL_main.h index 14d39f1ec..5cc8e5913 100644 --- a/Windows/SDL2/include/SDL_main.h +++ b/Windows/SDL2/include/SDL_main.h @@ -263,6 +263,13 @@ extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_fun */ extern DECLSPEC int SDLCALL SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved); +/** + * Callback from the application to let the suspend continue. + * + * \since This function is available since SDL 2.28.0. + */ +extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void); + #endif /* __GDK__ */ #ifdef __cplusplus diff --git a/Windows/SDL2/include/SDL_mouse.h b/Windows/SDL2/include/SDL_mouse.h index c5712efc5..aa0757573 100644 --- a/Windows/SDL2/include/SDL_mouse.h +++ b/Windows/SDL2/include/SDL_mouse.h @@ -198,13 +198,9 @@ extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y); /** * Set relative mouse mode. * - * While the mouse is in relative mode, the cursor is hidden, and the driver - * will try to report continuous motion in the current window. Only relative - * motion events will be delivered, the mouse position will not change. - * - * Note that this function will not be able to provide continuous relative - * motion when used over Microsoft Remote Desktop, instead motion is limited - * to the bounds of the screen. + * While the mouse is in relative mode, the cursor is hidden, the mouse + * position is constrained to the window, and SDL will report continuous + * relative mouse motion even if the mouse is at the edge of the window. * * This function will flush any pending mouse motion. * @@ -389,6 +385,9 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void); /** * Get the default cursor. * + * You do not have to call SDL_FreeCursor() on the return value, but it is + * safe to do so. + * * \returns the default cursor on success or NULL on failure. * * \since This function is available since SDL 2.0.0. diff --git a/Windows/SDL2/include/SDL_mutex.h b/Windows/SDL2/include/SDL_mutex.h index 54b6a53a3..e679d3808 100644 --- a/Windows/SDL2/include/SDL_mutex.h +++ b/Windows/SDL2/include/SDL_mutex.h @@ -31,6 +31,80 @@ #include "SDL_stdinc.h" #include "SDL_error.h" +/******************************************************************************/ +/* Enable thread safety attributes only with clang. + * The attributes can be safely erased when compiling with other compilers. + */ +#if defined(SDL_THREAD_SAFETY_ANALYSIS) && \ + defined(__clang__) && (!defined(SWIG)) +#define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) +#else +#define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) /* no-op */ +#endif + +#define SDL_CAPABILITY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(capability(x)) + +#define SDL_SCOPED_CAPABILITY \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) + +#define SDL_GUARDED_BY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) + +#define SDL_PT_GUARDED_BY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) + +#define SDL_ACQUIRED_BEFORE(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x)) + +#define SDL_ACQUIRED_AFTER(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x)) + +#define SDL_REQUIRES(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(x)) + +#define SDL_REQUIRES_SHARED(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(x)) + +#define SDL_ACQUIRE(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(x)) + +#define SDL_ACQUIRE_SHARED(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(x)) + +#define SDL_RELEASE(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(x)) + +#define SDL_RELEASE_SHARED(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(x)) + +#define SDL_RELEASE_GENERIC(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(x)) + +#define SDL_TRY_ACQUIRE(x, y) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(x, y)) + +#define SDL_TRY_ACQUIRE_SHARED(x, y) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(x, y)) + +#define SDL_EXCLUDES(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x)) + +#define SDL_ASSERT_CAPABILITY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) + +#define SDL_ASSERT_SHARED_CAPABILITY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) + +#define SDL_RETURN_CAPABILITY(x) \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) + +#define SDL_NO_THREAD_SAFETY_ANALYSIS \ + SDL_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) + +/******************************************************************************/ + + #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus @@ -96,7 +170,7 @@ extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); * * \since This function is available since SDL 2.0.0. */ -extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); +extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex) SDL_ACQUIRE(mutex); #define SDL_mutexP(m) SDL_LockMutex(m) /** @@ -119,7 +193,7 @@ extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); * \sa SDL_LockMutex * \sa SDL_UnlockMutex */ -extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex); +extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex) SDL_TRY_ACQUIRE(0, mutex); /** * Unlock the mutex. @@ -138,7 +212,7 @@ extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex); * * \since This function is available since SDL 2.0.0. */ -extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); +extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex) SDL_RELEASE(mutex); #define SDL_mutexV(m) SDL_UnlockMutex(m) /** @@ -276,7 +350,7 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); * successful it will atomically decrement the semaphore value. * * \param sem the semaphore to wait on - * \param ms the length of the timeout, in milliseconds + * \param timeout the length of the timeout, in milliseconds * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not * succeed in the allotted time, or a negative error code on failure; * call SDL_GetError() for more information. @@ -290,7 +364,7 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); * \sa SDL_SemValue * \sa SDL_SemWait */ -extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms); +extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout); /** * Atomically increment a semaphore's value and wake waiting threads. diff --git a/Windows/SDL2/include/SDL_opengl_glext.h b/Windows/SDL2/include/SDL_opengl_glext.h index 8527e1744..ff6ad12ce 100644 --- a/Windows/SDL2/include/SDL_opengl_glext.h +++ b/Windows/SDL2/include/SDL_opengl_glext.h @@ -1,4 +1,8 @@ -#ifndef __gl_glext_h_ +/* SDL modified the include guard to be compatible with Mesa and Apple include guards: + * - Mesa uses: __gl_glext_h_ + * - Apple uses: __glext_h_ */ +#if !defined(__glext_h_) && !defined(__gl_glext_h_) +#define __glext_h_ 1 #define __gl_glext_h_ 1 #ifdef __cplusplus diff --git a/Windows/SDL2/include/SDL_power.h b/Windows/SDL2/include/SDL_power.h index be06c8b4f..1d75704c4 100644 --- a/Windows/SDL2/include/SDL_power.h +++ b/Windows/SDL2/include/SDL_power.h @@ -48,7 +48,6 @@ typedef enum SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ } SDL_PowerState; - /** * Get the current power supply details. * @@ -65,17 +64,17 @@ typedef enum * It's possible a platform can only report battery percentage or time left * but not both. * - * \param secs seconds of battery life left, you can pass a NULL here if you - * don't care, will return -1 if we can't determine a value, or - * we're not running on a battery - * \param pct percentage of battery life left, between 0 and 100, you can pass - * a NULL here if you don't care, will return -1 if we can't - * determine a value, or we're not running on a battery + * \param seconds seconds of battery life left, you can pass a NULL here if + * you don't care, will return -1 if we can't determine a + * value, or we're not running on a battery + * \param percent percentage of battery life left, between 0 and 100, you can + * pass a NULL here if you don't care, will return -1 if we + * can't determine a value, or we're not running on a battery * \returns an SDL_PowerState enum representing the current battery state. * * \since This function is available since SDL 2.0.0. */ -extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); +extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *seconds, int *percent); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/Windows/SDL2/include/SDL_render.h b/Windows/SDL2/include/SDL_render.h index c72950142..2d3f07366 100644 --- a/Windows/SDL2/include/SDL_render.h +++ b/Windows/SDL2/include/SDL_render.h @@ -1731,6 +1731,11 @@ extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, * * \param renderer the rendering context * + * \threadsafety You may only call this function on the main thread. If this + * happens to work on a background thread on any given platform + * or backend, it's purely by luck and you should not rely on it + * to work next time. + * * \since This function is available since SDL 2.0.0. * * \sa SDL_RenderClear @@ -1885,7 +1890,7 @@ extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer); * Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give * SDL a drawable to render to, which might happen if the window is * hidden/minimized/offscreen. This doesn't apply to command encoders for - * render targets, just the window's backbacker. Check your return values! + * render targets, just the window's backbuffer. Check your return values! * * \param renderer The renderer to query * \returns an `id` on success, or NULL if the diff --git a/Windows/SDL2/include/SDL_revision.h b/Windows/SDL2/include/SDL_revision.h index 99af2a5b0..086440df6 100644 --- a/Windows/SDL2/include/SDL_revision.h +++ b/Windows/SDL2/include/SDL_revision.h @@ -1,7 +1,7 @@ /* Generated by updaterev.sh, do not edit */ #ifdef SDL_VENDOR_INFO -#define SDL_REVISION "SDL-release-2.26.3-0-gadf31f6ec (" SDL_VENDOR_INFO ")" +#define SDL_REVISION "SDL-release-2.28.3-0-g8a5ba43d0 (" SDL_VENDOR_INFO ")" #else -#define SDL_REVISION "SDL-release-2.26.3-0-gadf31f6ec" +#define SDL_REVISION "SDL-release-2.28.3-0-g8a5ba43d0" #endif #define SDL_REVISION_NUMBER 0 diff --git a/Windows/SDL2/include/SDL_sensor.h b/Windows/SDL2/include/SDL_sensor.h index 3010e497e..9ecce44b1 100644 --- a/Windows/SDL2/include/SDL_sensor.h +++ b/Windows/SDL2/include/SDL_sensor.h @@ -84,7 +84,7 @@ typedef enum * The accelerometer returns the current acceleration in SI meters per * second squared. This measurement includes the force of gravity, so * a device at rest will have an value of SDL_STANDARD_GRAVITY away - * from the center of the earth. + * from the center of the earth, which is a positive Y value. * * values[0]: Acceleration on the x axis * values[1]: Acceleration on the y axis diff --git a/Windows/SDL2/include/SDL_stdinc.h b/Windows/SDL2/include/SDL_stdinc.h index bbce3d06f..182ed86ee 100644 --- a/Windows/SDL2/include/SDL_stdinc.h +++ b/Windows/SDL2/include/SDL_stdinc.h @@ -30,12 +30,6 @@ #include "SDL_config.h" -#ifdef __APPLE__ -#ifndef _DARWIN_C_SOURCE -#define _DARWIN_C_SOURCE 1 /* for memset_pattern4() */ -#endif -#endif - #ifdef HAVE_SYS_TYPES_H #include #endif @@ -85,7 +79,9 @@ Visual Studio. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx for more information. */ -# define _USE_MATH_DEFINES +# ifndef _USE_MATH_DEFINES +# define _USE_MATH_DEFINES +# endif # endif # include #endif @@ -528,9 +524,7 @@ extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, /* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */ SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords) { -#ifdef __APPLE__ - memset_pattern4(dst, &val, dwords * 4); -#elif defined(__GNUC__) && defined(__i386__) +#if defined(__GNUC__) && defined(__i386__) int u0, u1, u2; __asm__ __volatile__ ( "cld \n\t" @@ -694,7 +688,7 @@ extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t * outbytesleft); /** - * This function converts a string between encodings in one pass, returning a + * This function converts a buffer or string between encodings in one pass, returning a * string that must be freed with SDL_free() or NULL on error. * * \since This function is available since SDL 2.0.0. @@ -722,6 +716,20 @@ size_t strlcpy(char* dst, const char* src, size_t size); size_t strlcat(char* dst, const char* src, size_t size); #endif +#ifndef HAVE_WCSLCPY +size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size); +#endif + +#ifndef HAVE_WCSLCAT +size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size); +#endif + +/* Starting LLVM 16, the analyser errors out if these functions do not have + their prototype defined (clang-diagnostic-implicit-function-declaration) */ +#include +#include +#include + #define SDL_malloc malloc #define SDL_calloc calloc #define SDL_realloc realloc diff --git a/Windows/SDL2/include/SDL_thread.h b/Windows/SDL2/include/SDL_thread.h index 849f70bd4..b829bbad5 100644 --- a/Windows/SDL2/include/SDL_thread.h +++ b/Windows/SDL2/include/SDL_thread.h @@ -35,7 +35,7 @@ #include "SDL_atomic.h" #include "SDL_mutex.h" -#if defined(__WIN32__) || defined(__GDK__) +#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__WINRT__) #include /* _beginthreadex() and _endthreadex() */ #endif #if defined(__OS2__) /* for _beginthread() and _endthread() */ @@ -88,7 +88,7 @@ typedef enum { typedef int (SDLCALL * SDL_ThreadFunction) (void *data); -#if defined(__WIN32__) || defined(__GDK__) +#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__WINRT__) /** * \file SDL_thread.h * diff --git a/Windows/SDL2/include/SDL_version.h b/Windows/SDL2/include/SDL_version.h index 739134a73..40396a42f 100644 --- a/Windows/SDL2/include/SDL_version.h +++ b/Windows/SDL2/include/SDL_version.h @@ -58,7 +58,7 @@ typedef struct SDL_version /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL */ #define SDL_MAJOR_VERSION 2 -#define SDL_MINOR_VERSION 26 +#define SDL_MINOR_VERSION 28 #define SDL_PATCHLEVEL 3 /** diff --git a/Windows/SDL2/include/SDL_video.h b/Windows/SDL2/include/SDL_video.h index c70facb5e..c8b2d7a0d 100644 --- a/Windows/SDL2/include/SDL_video.h +++ b/Windows/SDL2/include/SDL_video.h @@ -187,7 +187,8 @@ typedef enum SDL_DISPLAYEVENT_NONE, /**< Never used */ SDL_DISPLAYEVENT_ORIENTATION, /**< Display orientation has changed to data1 */ SDL_DISPLAYEVENT_CONNECTED, /**< Display has been added to the system */ - SDL_DISPLAYEVENT_DISCONNECTED /**< Display has been removed from the system */ + SDL_DISPLAYEVENT_DISCONNECTED, /**< Display has been removed from the system */ + SDL_DISPLAYEVENT_MOVED /**< Display has changed position */ } SDL_DisplayEventID; /** @@ -1274,6 +1275,17 @@ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window); extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags); +/** + * Return whether the window has a surface associated with it. + * + * \returns SDL_TRUE if there is a surface associated with the window, or SDL_FALSE otherwise. + * + * \since This function is available since SDL 2.28.0. + * + * \sa SDL_GetWindowSurface + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasWindowSurface(SDL_Window *window); + /** * Get the SDL surface associated with the window. * @@ -1294,6 +1306,8 @@ extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, * * \since This function is available since SDL 2.0.0. * + * \sa SDL_DestroyWindowSurface + * \sa SDL_HasWindowSurface * \sa SDL_UpdateWindowSurface * \sa SDL_UpdateWindowSurfaceRects */ @@ -1328,7 +1342,7 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window); * * \param window the window to update * \param rects an array of SDL_Rect structures representing areas of the - * surface to copy + * surface to copy, in pixels * \param numrects the number of rectangles * \returns 0 on success or a negative error code on failure; call * SDL_GetError() for more information. @@ -1342,6 +1356,20 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, const SDL_Rect * rects, int numrects); +/** + * Destroy the surface associated with the window. + * + * \param window the window to update + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.28.0. + * + * \sa SDL_GetWindowSurface + * \sa SDL_HasWindowSurface + */ +extern DECLSPEC int SDLCALL SDL_DestroyWindowSurface(SDL_Window *window); + /** * Set a window's input grab mode. * diff --git a/Windows/SDL2/include/begin_code.h b/Windows/SDL2/include/begin_code.h index 1f01e0bc6..4142ffeba 100644 --- a/Windows/SDL2/include/begin_code.h +++ b/Windows/SDL2/include/begin_code.h @@ -28,10 +28,10 @@ */ /* This shouldn't be nested -- included it around code only. */ -#ifdef _begin_code_h +#ifdef SDL_begin_code_h #error Nested inclusion of begin_code.h #endif -#define _begin_code_h +#define SDL_begin_code_h #ifndef SDL_DEPRECATED # if defined(__GNUC__) && (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ @@ -171,17 +171,17 @@ #define SDL_FALLTHROUGH [[fallthrough]] #else #if defined(__has_attribute) -#define _HAS_FALLTHROUGH __has_attribute(__fallthrough__) +#define SDL_HAS_FALLTHROUGH __has_attribute(__fallthrough__) #else -#define _HAS_FALLTHROUGH 0 +#define SDL_HAS_FALLTHROUGH 0 #endif /* __has_attribute */ -#if _HAS_FALLTHROUGH && \ +#if SDL_HAS_FALLTHROUGH && \ ((defined(__GNUC__) && __GNUC__ >= 7) || \ (defined(__clang_major__) && __clang_major__ >= 10)) #define SDL_FALLTHROUGH __attribute__((__fallthrough__)) #else #define SDL_FALLTHROUGH do {} while (0) /* fallthrough */ -#endif /* _HAS_FALLTHROUGH */ -#undef _HAS_FALLTHROUGH +#endif /* SDL_HAS_FALLTHROUGH */ +#undef SDL_HAS_FALLTHROUGH #endif /* C++17 or C2x */ #endif /* SDL_FALLTHROUGH not defined */ diff --git a/Windows/SDL2/include/close_code.h b/Windows/SDL2/include/close_code.h index 874a926b7..b5ff3e204 100644 --- a/Windows/SDL2/include/close_code.h +++ b/Windows/SDL2/include/close_code.h @@ -26,10 +26,10 @@ * after you finish any function and structure declarations in your headers */ -#ifndef _begin_code_h +#ifndef SDL_begin_code_h #error close_code.h included without matching begin_code.h #endif -#undef _begin_code_h +#undef SDL_begin_code_h /* Reset structure packing at previous byte alignment */ #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) diff --git a/Windows/SDL2/lib/SDL2.dll b/Windows/SDL2/lib/SDL2.dll index 431a05437..5f8f7030c 100644 Binary files a/Windows/SDL2/lib/SDL2.dll and b/Windows/SDL2/lib/SDL2.dll differ diff --git a/Windows/SDL2/lib/SDL2.lib b/Windows/SDL2/lib/SDL2.lib index a3583601d..b35ba62a2 100644 Binary files a/Windows/SDL2/lib/SDL2.lib and b/Windows/SDL2/lib/SDL2.lib differ diff --git a/Windows/SDL2/lib/libSDL2.dll.a b/Windows/SDL2/lib/libSDL2.dll.a index 7e5750f65..91ac2b8b9 100644 Binary files a/Windows/SDL2/lib/libSDL2.dll.a and b/Windows/SDL2/lib/libSDL2.dll.a differ diff --git a/Windows/SDL2/lib/libSDL2main.a b/Windows/SDL2/lib/libSDL2main.a index 8e67e9eda..e38628c5f 100644 Binary files a/Windows/SDL2/lib/libSDL2main.a and b/Windows/SDL2/lib/libSDL2main.a differ diff --git a/Windows/SDL2/lib64/SDL2.dll b/Windows/SDL2/lib64/SDL2.dll index 71f5b89a3..95107d916 100644 Binary files a/Windows/SDL2/lib64/SDL2.dll and b/Windows/SDL2/lib64/SDL2.dll differ diff --git a/Windows/SDL2/lib64/SDL2.lib b/Windows/SDL2/lib64/SDL2.lib index a237dfcda..99c5321ca 100644 Binary files a/Windows/SDL2/lib64/SDL2.lib and b/Windows/SDL2/lib64/SDL2.lib differ diff --git a/Windows/SDL2/lib64/libSDL2.dll.a b/Windows/SDL2/lib64/libSDL2.dll.a index 1aca6b8d6..fb3322496 100644 Binary files a/Windows/SDL2/lib64/libSDL2.dll.a and b/Windows/SDL2/lib64/libSDL2.dll.a differ diff --git a/Windows/SDL2/lib64/libSDL2main.a b/Windows/SDL2/lib64/libSDL2main.a index 4a1069e49..517f6a43c 100644 Binary files a/Windows/SDL2/lib64/libSDL2main.a and b/Windows/SDL2/lib64/libSDL2main.a differ diff --git a/Windows/SDL2/main/SDL_windows.h b/Windows/SDL2/main/SDL_windows.h index 13b0f2fa8..3842e082b 100644 --- a/Windows/SDL2/main/SDL_windows.h +++ b/Windows/SDL2/main/SDL_windows.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 1997-2023 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -34,31 +34,97 @@ #ifndef UNICODE #define UNICODE 1 #endif +#undef WINVER #undef _WIN32_WINNT -#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */ +#if defined(SDL_VIDEO_RENDER_D3D12) +#define _WIN32_WINNT 0xA00 /* For D3D12, 0xA00 is required */ +#elif defined(HAVE_SHELLSCALINGAPI_H) +#define _WIN32_WINNT 0x603 /* For DPI support */ +#else +#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */ +#endif +#define WINVER _WIN32_WINNT + +#elif defined(__WINGDK__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#ifndef STRICT +#define STRICT 1 +#endif +#ifndef UNICODE +#define UNICODE 1 +#endif +#undef WINVER +#undef _WIN32_WINNT +#define _WIN32_WINNT 0xA00 +#define WINVER _WIN32_WINNT + +#elif defined(__XBOXONE__) || defined(__XBOXSERIES__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#ifndef STRICT +#define STRICT 1 +#endif +#ifndef UNICODE +#define UNICODE 1 +#endif +#undef WINVER +#undef _WIN32_WINNT +#define _WIN32_WINNT 0xA00 +#define WINVER _WIN32_WINNT +#endif + +/* See https://github.com/libsdl-org/SDL/pull/7607 */ +/* force_align_arg_pointer attribute requires gcc >= 4.2.x. */ +#if defined(__clang__) +#define HAVE_FORCE_ALIGN_ARG_POINTER +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) +#define HAVE_FORCE_ALIGN_ARG_POINTER +#endif +#if defined(__GNUC__) && defined(__i386__) && defined(HAVE_FORCE_ALIGN_ARG_POINTER) +#define MINGW32_FORCEALIGN __attribute__((force_align_arg_pointer)) +#else +#define MINGW32_FORCEALIGN #endif #include -#include /* for REFIID with broken mingw.org headers */ +#include /* for REFIID with broken mingw.org headers */ + +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if defined(_MSC_VER) && (_MSC_VER <= 1200) +#ifndef DWORD_PTR +#define DWORD_PTR DWORD +#endif +#ifndef LONG_PTR +#define LONG_PTR LONG +#endif +#endif #include "SDL_rect.h" /* Routines to convert from UTF8 to native Windows text */ -#define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (const char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) -#define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (const char *)(S), SDL_strlen(S)+1) +#define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (const char *)(S), (SDL_wcslen(S) + 1) * sizeof(WCHAR)) +#define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (const char *)(S), SDL_strlen(S) + 1) /* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ -#define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (const char *)(S), (SDL_strlen(S)+1)) -#define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (const char *)(S), SDL_strlen(S)+1) +#define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (const char *)(S), (SDL_strlen(S) + 1)) +#define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (const char *)(S), SDL_strlen(S) + 1) #if UNICODE #define WIN_StringToUTF8 WIN_StringToUTF8W #define WIN_UTF8ToString WIN_UTF8ToStringW -#define SDL_tcslen SDL_wcslen -#define SDL_tcsstr SDL_wcsstr +#define SDL_tcslen SDL_wcslen +#define SDL_tcsstr SDL_wcsstr #else #define WIN_StringToUTF8 WIN_StringToUTF8A #define WIN_UTF8ToString WIN_UTF8ToStringA -#define SDL_tcslen SDL_strlen -#define SDL_tcsstr SDL_strstr +#define SDL_tcslen SDL_strlen +#define SDL_tcsstr SDL_strstr +#endif + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { #endif /* Sets an error message based on a given HRESULT */ @@ -93,13 +159,21 @@ extern BOOL WIN_IsWindows8OrGreater(void); extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid); /* Checks to see if two GUID are the same. */ -extern BOOL WIN_IsEqualGUID(const GUID * a, const GUID * b); +extern BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b); extern BOOL WIN_IsEqualIID(REFIID a, REFIID b); /* Convert between SDL_rect and RECT */ extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect); extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect); +/* Returns SDL_TRUE if the rect is empty */ +extern BOOL WIN_IsRectEmpty(const RECT *rect); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + #endif /* _INCLUDED_WINDOWS_H */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/Windows/SDL2/main/SDL_windows_main.c b/Windows/SDL2/main/SDL_windows_main.c index d00989c3a..0ce41a20d 100644 --- a/Windows/SDL2/main/SDL_windows_main.c +++ b/Windows/SDL2/main/SDL_windows_main.c @@ -8,7 +8,7 @@ #ifdef __WIN32__ /* Include this so we define UNICODE properly */ -#include "SDL_windows.h" /* copied here from the SDL2 source tree */ +#include "SDL_windows.h" #include /* CommandLineToArgvW() */ /* Include the SDL main definition header */ @@ -16,12 +16,11 @@ #include "SDL_main.h" #ifdef main -# undef main +#undef main #endif /* main */ /* Pop up an out of memory message, returns to Windows */ -static BOOL -OutOfMemory(void) +static BOOL OutOfMemory(void) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "Out of memory - aborting", NULL); return FALSE; @@ -29,16 +28,15 @@ OutOfMemory(void) #if defined(_MSC_VER) /* The VC++ compiler needs main/wmain defined */ -# define console_ansi_main main -# if UNICODE -# define console_wmain wmain -# endif +#define console_ansi_main main +#if UNICODE +#define console_wmain wmain +#endif #endif /* Gets the arguments with GetCommandLine, converts them to argc and argv and calls SDL_main */ -static int -main_getcmdline(void) +static int main_getcmdline(void) { LPWSTR *argvw; char **argv; @@ -56,17 +54,17 @@ main_getcmdline(void) /* Parse it into argv and argc */ argv = (char **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv)); - if (!argv) { + if (argv == NULL) { return OutOfMemory(); } for (i = 0; i < argc; ++i) { DWORD len; char *arg = WIN_StringToUTF8W(argvw[i]); - if (!arg) { + if (arg == NULL) { return OutOfMemory(); } len = (DWORD)SDL_strlen(arg); - argv[i] = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len + 1); + argv[i] = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (size_t)len + 1); if (!argv[i]) { return OutOfMemory(); } @@ -91,25 +89,22 @@ main_getcmdline(void) } /* This is where execution begins [console apps, ansi] */ -int -console_ansi_main(int argc, char *argv[]) +int console_ansi_main(int argc, char *argv[]) { return main_getcmdline(); } - #if UNICODE /* This is where execution begins [console apps, unicode] */ -int -console_wmain(int argc, wchar_t *wargv[], wchar_t *wenvp) +int console_wmain(int argc, wchar_t *wargv[], wchar_t *wenvp) { return main_getcmdline(); } #endif /* This is where execution begins [windowed apps] */ -int WINAPI -WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) +int WINAPI MINGW32_FORCEALIGN +WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) /* NOLINT(readability-inconsistent-declaration-parameter-name) */ { return main_getcmdline(); } diff --git a/Windows/SDL2/watcom/SDL2.def b/Windows/SDL2/watcom/SDL2.def index ed849a0b6..5904992bc 100644 --- a/Windows/SDL2/watcom/SDL2.def +++ b/Windows/SDL2/watcom/SDL2.def @@ -843,3 +843,6 @@ SDL_GameControllerGetSensorDataWithTimestamp SDL_SensorGetDataWithTimestamp SDL_ResetHints SDL_strcasestr +SDL_HasWindowSurface +SDL_DestroyWindowSurface + diff --git a/Windows/SDL2/watcom/SDL2.exp b/Windows/SDL2/watcom/SDL2.exp index f3b21e1c8..066acebb9 100644 --- a/Windows/SDL2/watcom/SDL2.exp +++ b/Windows/SDL2/watcom/SDL2.exp @@ -840,3 +840,5 @@ ++'_SDL_SensorGetDataWithTimestamp'.'SDL2.dll'..'SDL_SensorGetDataWithTimestamp' ++'_SDL_ResetHints'.'SDL2.dll'..'SDL_ResetHints' ++'_SDL_strcasestr'.'SDL2.dll'..'SDL_strcasestr' +++'_SDL_HasWindowSurface'.'SDL2.dll'..'SDL_HasWindowSurface' +++'_SDL_DestroyWindowSurface'.'SDL2.dll'..'SDL_DestroyWindowSurface' diff --git a/Windows/SDL2/watcom/SDL2.lib b/Windows/SDL2/watcom/SDL2.lib index badd61308..577131a7e 100644 Binary files a/Windows/SDL2/watcom/SDL2.lib and b/Windows/SDL2/watcom/SDL2.lib differ