diff --git a/.github/workflows/cpactions.yml b/.github/workflows/cpactions.yml
index a2e676f3f8c52..acd40a930b44a 100644
--- a/.github/workflows/cpactions.yml
+++ b/.github/workflows/cpactions.yml
@@ -10,10 +10,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build
- uses: cross-platform-actions/action@v0.23.0
+ uses: cross-platform-actions/action@v0.24.0
with:
operating_system: freebsd
- version: '13.2'
+ version: '13.3'
shell: bash
run: |
sudo pkg update
diff --git a/CMakeLists.txt b/CMakeLists.txt
index be379a0a8ca62..3bed6ef5db034 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -87,7 +87,7 @@ endif()
# See docs/release_checklist.md
set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 30)
-set(SDL_MICRO_VERSION 5)
+set(SDL_MICRO_VERSION 6)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
# Set defaults preventing destination file conflicts
@@ -1812,14 +1812,6 @@ elseif(WINDOWS)
list(APPEND SOURCE_FILES ${WINRT_SOURCE_FILES})
endif()
- if(MSVC AND NOT SDL_LIBC)
- # Prevent codegen that would use the VC runtime libraries.
- set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/GS-;/Gs1048576")
- if(NOT ARCH_64 AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
- set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/arch:SSE")
- endif()
- endif()
-
if(SDL_MISC)
if(WINDOWS_STORE)
file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/winrt/*.cpp)
@@ -3562,6 +3554,20 @@ if(SDL_TEST)
set_property(TARGET SDL2_test PROPERTY INTERFACE_SDL_VERSION "SDL2")
endif()
+if(MSVC AND NOT SDL_LIBC)
+ set(targets SDL2)
+ if(TARGET SDL2-static)
+ list(APPEND targets SDL2-static)
+ endif()
+ if(TARGET SDL2_test)
+ list(APPEND targets SDL2_test)
+ endif()
+ set_property(TARGET ${targets} APPEND PROPERTY COMPILE_OPTIONS "/GS-;/Gs1048576")
+ if(NOT ARCH_64 AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
+ set_property(TARGET ${targets} APPEND PROPERTY COMPILE_OPTIONS "/arch:SSE")
+ endif()
+endif()
+
##### Installation targets #####
if(NOT SDL2_DISABLE_INSTALL)
if(SDL_SHARED)
diff --git a/Makefile.os2 b/Makefile.os2
index 80f95653eb465..b99d0f599aa26 100644
--- a/Makefile.os2
+++ b/Makefile.os2
@@ -15,7 +15,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 30
-MICRO_VERSION = 5
+MICRO_VERSION = 6
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
DESCRIPTION = Simple DirectMedia Layer 2
diff --git a/Makefile.w32 b/Makefile.w32
index d7a01f16eb06b..31e3438b471cd 100644
--- a/Makefile.w32
+++ b/Makefile.w32
@@ -6,7 +6,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 30
-MICRO_VERSION = 5
+MICRO_VERSION = 6
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
LIBHOME = .
diff --git a/Xcode-iOS/Demos/src/fireworks.c b/Xcode-iOS/Demos/src/fireworks.c
index a9af3fb583aa8..55762bd089c46 100644
--- a/Xcode-iOS/Demos/src/fireworks.c
+++ b/Xcode-iOS/Demos/src/fireworks.c
@@ -52,9 +52,9 @@ void spawnTrailFromEmitter(struct particle *emitter);
void spawnEmitterParticle(GLfloat x, GLfloat y);
void explodeEmitter(struct particle *emitter);
void initializeParticles(void);
-void initializeTexture();
+void initializeTexture(void);
int nextPowerOfTwo(int x);
-void drawParticles();
+void drawParticles(void);
void stepParticles(double deltaTime);
/* helper function (used in texture loading)
@@ -159,7 +159,7 @@ stepParticles(double deltaTime)
This draws all the particles shown on screen
*/
void
-drawParticles()
+drawParticles(void)
{
/* draw the background */
@@ -324,7 +324,7 @@ initializeParticles(void)
loads the particle texture
*/
void
-initializeTexture()
+initializeTexture(void)
{
int bpp; /* texture bits per pixel */
diff --git a/Xcode-iOS/Demos/src/keyboard.c b/Xcode-iOS/Demos/src/keyboard.c
index 4d630bae5f5ca..3e1bedf5b85f5 100644
--- a/Xcode-iOS/Demos/src/keyboard.c
+++ b/Xcode-iOS/Demos/src/keyboard.c
@@ -196,7 +196,7 @@ loadFont(void)
}
void
-draw()
+draw(void)
{
SDL_SetRenderDrawColor(renderer, bg_color.r, bg_color.g, bg_color.b, bg_color.a);
SDL_RenderClear(renderer);
diff --git a/Xcode/SDL/Info-Framework.plist b/Xcode/SDL/Info-Framework.plist
index 87d07aecd8c77..20b5c0ebbb20b 100644
--- a/Xcode/SDL/Info-Framework.plist
+++ b/Xcode/SDL/Info-Framework.plist
@@ -19,10 +19,10 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 2.30.5
+ 2.30.6
CFBundleSignature
SDLX
CFBundleVersion
- 2.30.5
+ 2.30.6
diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
index 82bf8b52e4166..ce34a86ed5f86 100644
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
@@ -9729,7 +9729,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = YES;
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
- DYLIB_CURRENT_VERSION = 3001.5.0;
+ DYLIB_CURRENT_VERSION = 3001.6.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_ALTIVEC_EXTENSIONS = YES;
@@ -9770,7 +9770,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_LINK_OBJC_RUNTIME = NO;
- MARKETING_VERSION = 2.30.5;
+ MARKETING_VERSION = 2.30.6;
OTHER_LDFLAGS = "-liconv";
};
name = Release;
@@ -9814,7 +9814,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
- DYLIB_CURRENT_VERSION = 3001.5.0;
+ DYLIB_CURRENT_VERSION = 3001.6.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@@ -9856,7 +9856,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_LINK_OBJC_RUNTIME = NO;
- MARKETING_VERSION = 2.30.5;
+ MARKETING_VERSION = 2.30.6;
OTHER_LDFLAGS = "-liconv";
};
name = Debug;
@@ -10063,7 +10063,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
- DYLIB_CURRENT_VERSION = 3001.5.0;
+ DYLIB_CURRENT_VERSION = 3001.6.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
@@ -10115,7 +10115,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
- DYLIB_CURRENT_VERSION = 3001.5.0;
+ DYLIB_CURRENT_VERSION = 3001.6.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
diff --git a/Xcode/SDL/pkg-support/SDL.info b/Xcode/SDL/pkg-support/SDL.info
index ee03b718a20d0..9a3789b678e24 100644
--- a/Xcode/SDL/pkg-support/SDL.info
+++ b/Xcode/SDL/pkg-support/SDL.info
@@ -1,4 +1,4 @@
-Title SDL 2.30.5
+Title SDL 2.30.6
Version 1
Description SDL Library for Mac OS X (http://www.libsdl.org)
DefaultLocation /Library/Frameworks
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index dd152b5dd2f33..976b1c39621d6 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
private static final String TAG = "SDL";
private static final int SDL_MAJOR_VERSION = 2;
private static final int SDL_MINOR_VERSION = 30;
- private static final int SDL_MICRO_VERSION = 5;
+ private static final int SDL_MICRO_VERSION = 6;
/*
// Display InputType.SOURCE/CLASS of events and devices
//
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index 57a281ce0200a..8fa24a81aeb65 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -1377,12 +1377,13 @@ endmacro()
macro(CheckLibUDev)
if(SDL_LIBUDEV)
- check_include_file("libudev.h" have_libudev_header)
- if(have_libudev_header)
+ check_include_file("libudev.h" HAVE_LIBUDEV_HEADER)
+ if(HAVE_LIBUDEV_HEADER)
set(HAVE_LIBUDEV_H TRUE)
FindLibraryAndSONAME(udev)
if(UDEV_LIB_SONAME)
set(SDL_UDEV_DYNAMIC "\"${UDEV_LIB_SONAME}\"")
+ set(HAVE_LIBUDEV TRUE)
endif()
endif()
endif()
diff --git a/configure b/configure
index c12fef7e75115..12713bf9385cc 100755
--- a/configure
+++ b/configure
@@ -3508,7 +3508,7 @@ orig_CFLAGS="$CFLAGS"
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=30
-SDL_MICRO_VERSION=5
+SDL_MICRO_VERSION=6
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
diff --git a/configure.ac b/configure.ac
index 907d1d082df72..9ffae908396d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,7 +13,7 @@ dnl Set various version strings - taken gratefully from the GTk sources
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=30
-SDL_MICRO_VERSION=5
+SDL_MICRO_VERSION=6
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
diff --git a/docs/README-macos.md b/docs/README-macos.md
index 634d456bf862a..bcf695627b442 100644
--- a/docs/README-macos.md
+++ b/docs/README-macos.md
@@ -261,10 +261,10 @@ Some things that may be of interest about how it all works...
## Working directory
In SDL 1.2, the working directory of your SDL app is by default set to its
-parent, but this is no longer the case in SDL 2.0. SDL2 does change the
-working directory, which means it'll be whatever the command line prompt
-that launched the program was using, or if launched by double-clicking in
-the finger, it will be "/", the _root of the filesystem_. Plan accordingly!
+parent, but this is no longer the case in SDL 2.0 and later. SDL2 does not
+change the working directory, which means it'll be whatever the command line
+prompt that launched the program was using, or if launched by double-clicking
+in the Finder, it will be "/", the _root of the filesystem_. Plan accordingly!
You can use SDL_GetBasePath() to find where the program is running from and
chdir() there directly.
diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h
index 45e2a7830aae2..8113f453f3b37 100644
--- a/include/SDL_stdinc.h
+++ b/include/SDL_stdinc.h
@@ -377,9 +377,12 @@ typedef uint64_t Uint64;
#ifndef SDL_COMPILE_TIME_ASSERT
#if defined(__cplusplus)
+/* Keep C++ case alone: Some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode. */
#if (__cplusplus >= 201103L)
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
#endif
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
+#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
#endif
diff --git a/include/SDL_version.h b/include/SDL_version.h
index 00436603afb68..759ce4e95227e 100644
--- a/include/SDL_version.h
+++ b/include/SDL_version.h
@@ -59,7 +59,7 @@ typedef struct SDL_version
*/
#define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 30
-#define SDL_PATCHLEVEL 5
+#define SDL_PATCHLEVEL 6
/**
* Macro to determine SDL version program was compiled against.
diff --git a/src/SDL.c b/src/SDL.c
index c96641100f5cb..36429acca1d03 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -29,9 +29,6 @@
#endif
#if defined(__OS2__)
#include "core/os2/SDL_os2.h"
-#ifdef SDL_THREAD_OS2
-#include "thread/os2/SDL_systls_c.h"
-#endif
#endif
/* this checks for HAVE_DBUS_DBUS_H internally. */
@@ -54,6 +51,7 @@
#include "haptic/SDL_haptic_c.h"
#include "joystick/SDL_joystick_c.h"
#include "sensor/SDL_sensor_c.h"
+#include "thread/SDL_thread_c.h"
/* Initialization/Cleanup routines */
#ifndef SDL_TIMERS_DISABLED
@@ -118,6 +116,7 @@ static SDL_bool SDL_MainIsReady = SDL_FALSE;
#else
static SDL_bool SDL_MainIsReady = SDL_TRUE;
#endif
+static SDL_bool SDL_main_thread_initialized = SDL_FALSE;
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
static Uint8 SDL_SubsystemRefCount[32];
#ifdef __WEBOS__
@@ -186,6 +185,36 @@ void SDL_SetMainReady(void)
SDL_MainIsReady = SDL_TRUE;
}
+void SDL_InitMainThread(void)
+{
+ if (SDL_main_thread_initialized) {
+ return;
+ }
+
+ SDL_InitTLSData();
+#ifndef SDL_TIMERS_DISABLED
+ SDL_TicksInit();
+#endif
+ SDL_LogInit();
+
+ SDL_main_thread_initialized = SDL_TRUE;
+}
+
+static void SDL_QuitMainThread(void)
+{
+ if (!SDL_main_thread_initialized) {
+ return;
+ }
+
+ SDL_LogQuit();
+#ifndef SDL_TIMERS_DISABLED
+ SDL_TicksQuit();
+#endif
+ SDL_QuitTLSData();
+
+ SDL_main_thread_initialized = SDL_FALSE;
+}
+
int SDL_InitSubSystem(Uint32 flags)
{
Uint32 flags_initialized = 0;
@@ -194,8 +223,6 @@ int SDL_InitSubSystem(Uint32 flags)
return SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
}
- SDL_LogInit();
-
/* Clear the error message */
SDL_ClearError();
@@ -217,10 +244,6 @@ int SDL_InitSubSystem(Uint32 flags)
}
#endif
-#ifdef SDL_THREAD_OS2
- SDL_OS2TLSAlloc(); /* thread/os2/SDL_systls.c */
-#endif
-
#ifdef SDL_VIDEO_DRIVER_WINDOWS
if (flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK)) {
if (SDL_HelperWindowCreate() < 0) {
@@ -229,10 +252,6 @@ int SDL_InitSubSystem(Uint32 flags)
}
#endif
-#ifndef SDL_TIMERS_DISABLED
- SDL_TicksInit();
-#endif
-
/* Initialize the event subsystem */
if (flags & SDL_INIT_EVENTS) {
#ifndef SDL_EVENTS_DISABLED
@@ -397,9 +416,6 @@ int SDL_Init(Uint32 flags)
void SDL_QuitSubSystem(Uint32 flags)
{
#if defined(__OS2__)
-#ifdef SDL_THREAD_OS2
- SDL_OS2TLSFree(); /* thread/os2/SDL_systls.c */
-#endif
SDL_OS2Quit();
#endif
@@ -523,10 +539,6 @@ void SDL_Quit(void)
#endif
SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
-#ifndef SDL_TIMERS_DISABLED
- SDL_TicksQuit();
-#endif
-
#ifdef SDL_USE_LIBDBUS
SDL_DBus_Quit();
#endif
@@ -538,14 +550,12 @@ void SDL_Quit(void)
SDL_ClearHints();
SDL_AssertionsQuit();
- SDL_LogQuit();
-
/* Now that every subsystem has been quit, we reset the subsystem refcount
* and the list of initialized subsystems.
*/
SDL_memset(SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount));
- SDL_TLSCleanup();
+ SDL_QuitMainThread();
SDL_bInMainQuit = SDL_FALSE;
}
diff --git a/src/SDL_internal.h b/src/SDL_internal.h
index b193edef62f27..511c652407320 100644
--- a/src/SDL_internal.h
+++ b/src/SDL_internal.h
@@ -208,6 +208,8 @@
#include "SDL_assert.h"
#include "SDL_log.h"
+extern void SDL_InitMainThread(void);
+
#endif /* SDL_internal_h_ */
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c
index da91997a20cef..6e088d116dbd3 100644
--- a/src/audio/arts/SDL_artsaudio.c
+++ b/src/audio/arts/SDL_artsaudio.c
@@ -86,7 +86,7 @@ static struct
#undef SDL_ARTS_SYM
-static void UnloadARTSLibrary()
+static void UnloadARTSLibrary(void)
{
if (arts_handle) {
SDL_UnloadObject(arts_handle);
@@ -119,7 +119,7 @@ static int LoadARTSLibrary(void)
#else
-static void UnloadARTSLibrary()
+static void UnloadARTSLibrary(void)
{
return;
}
diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c
index 596f51a330993..10ecdfdf9d9da 100644
--- a/src/audio/esd/SDL_esdaudio.c
+++ b/src/audio/esd/SDL_esdaudio.c
@@ -64,7 +64,7 @@ static struct
#undef SDL_ESD_SYM
-static void UnloadESDLibrary()
+static void UnloadESDLibrary(void)
{
if (esd_handle) {
SDL_UnloadObject(esd_handle);
@@ -96,7 +96,7 @@ static int LoadESDLibrary(void)
#else
-static void UnloadESDLibrary()
+static void UnloadESDLibrary(void)
{
return;
}
diff --git a/src/audio/fusionsound/SDL_fsaudio.c b/src/audio/fusionsound/SDL_fsaudio.c
index 5abab2e7c128e..b05b5d4857b89 100644
--- a/src/audio/fusionsound/SDL_fsaudio.c
+++ b/src/audio/fusionsound/SDL_fsaudio.c
@@ -77,7 +77,7 @@ static struct
#undef SDL_FS_SYM
-static void UnloadFusionSoundLibrary()
+static void UnloadFusionSoundLibrary(void)
{
if (fs_handle) {
SDL_UnloadObject(fs_handle);
@@ -110,7 +110,7 @@ static int LoadFusionSoundLibrary(void)
#else
-static void UnloadFusionSoundLibrary()
+static void UnloadFusionSoundLibrary(void)
{
return;
}
diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c
index 4fbe9af9193b2..b473a318ca782 100644
--- a/src/audio/pipewire/SDL_pipewire.c
+++ b/src/audio/pipewire/SDL_pipewire.c
@@ -142,13 +142,13 @@ static int pipewire_dlsym(const char *fn, void **addr)
return -1; \
}
-static int load_pipewire_library()
+static int load_pipewire_library(void)
{
pipewire_handle = SDL_LoadObject(pipewire_library);
return pipewire_handle ? 0 : -1;
}
-static void unload_pipewire_library()
+static void unload_pipewire_library(void)
{
if (pipewire_handle) {
SDL_UnloadObject(pipewire_handle);
@@ -160,18 +160,18 @@ static void unload_pipewire_library()
#define SDL_PIPEWIRE_SYM(x) PIPEWIRE_##x = x
-static int load_pipewire_library()
+static int load_pipewire_library(void)
{
return 0;
}
-static void unload_pipewire_library()
+static void unload_pipewire_library(void)
{ /* Nothing to do */
}
#endif /* SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC */
-static int load_pipewire_syms()
+static int load_pipewire_syms(void)
{
SDL_PIPEWIRE_SYM(pw_get_library_version);
SDL_PIPEWIRE_SYM(pw_init);
@@ -212,7 +212,7 @@ SDL_FORCE_INLINE SDL_bool pipewire_version_at_least(int major, int minor, int pa
(pipewire_version_major > major || pipewire_version_minor > minor || pipewire_version_patch >= patch);
}
-static int init_pipewire_library()
+static int init_pipewire_library(void)
{
if (!load_pipewire_library()) {
if (!load_pipewire_syms()) {
@@ -234,7 +234,7 @@ static int init_pipewire_library()
return -1;
}
-static void deinit_pipewire_library()
+static void deinit_pipewire_library(void)
{
PIPEWIRE_pw_deinit();
unload_pipewire_library();
@@ -340,7 +340,7 @@ static void io_list_remove(Uint32 id)
}
}
-static void io_list_sort()
+static void io_list_sort(void)
{
struct io_node *default_sink = NULL, *default_source = NULL;
struct io_node *n, *temp;
@@ -365,7 +365,7 @@ static void io_list_sort()
}
}
-static void io_list_clear()
+static void io_list_clear(void)
{
struct io_node *n, *temp;
@@ -426,7 +426,7 @@ static void pending_list_remove(Uint32 id)
}
}
-static void pending_list_clear()
+static void pending_list_clear(void)
{
struct node_object *node, *temp;
@@ -751,7 +751,7 @@ static const struct pw_registry_events registry_events = { PW_VERSION_REGISTRY_E
.global_remove = registry_event_remove_callback };
/* The hotplug thread */
-static int hotplug_loop_init()
+static int hotplug_loop_init(void)
{
int res;
@@ -794,7 +794,7 @@ static int hotplug_loop_init()
return 0;
}
-static void hotplug_loop_destroy()
+static void hotplug_loop_destroy(void)
{
if (hotplug_loop) {
PIPEWIRE_pw_thread_loop_stop(hotplug_loop);
@@ -836,7 +836,7 @@ static void hotplug_loop_destroy()
}
}
-static void PIPEWIRE_DetectDevices()
+static void PIPEWIRE_DetectDevices(void)
{
struct io_node *io;
@@ -1342,7 +1342,7 @@ static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int is
return ret;
}
-static void PIPEWIRE_Deinitialize()
+static void PIPEWIRE_Deinitialize(void)
{
if (pipewire_initialized) {
hotplug_loop_destroy();
diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c
index 5e2bb6f160ccb..5039d0547a2ea 100644
--- a/src/audio/pulseaudio/SDL_pulseaudio.c
+++ b/src/audio/pulseaudio/SDL_pulseaudio.c
@@ -885,7 +885,7 @@ static int SDLCALL HotplugThread(void *data)
return 0;
}
-static void PULSEAUDIO_DetectDevices()
+static void PULSEAUDIO_DetectDevices(void)
{
SDL_sem *ready_sem = SDL_CreateSemaphore(0);
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 60620d814e16c..25b75f51e3f0b 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -842,18 +842,18 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)(
}
/* Lock / Unlock Mutex */
-void Android_ActivityMutex_Lock()
+void Android_ActivityMutex_Lock(void)
{
SDL_LockMutex(Android_ActivityMutex);
}
-void Android_ActivityMutex_Unlock()
+void Android_ActivityMutex_Unlock(void)
{
SDL_UnlockMutex(Android_ActivityMutex);
}
/* Lock the Mutex when the Activity is in its 'Running' state */
-void Android_ActivityMutex_Lock_Running()
+void Android_ActivityMutex_Lock_Running(void)
{
int pauseSignaled = 0;
int resumeSignaled = 0;
@@ -1439,13 +1439,13 @@ void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint)
(*env)->DeleteLocalRef(env, jhint);
}
-void Android_JNI_MinizeWindow()
+void Android_JNI_MinizeWindow(void)
{
JNIEnv *env = Android_JNI_GetEnv();
(*env)->CallStaticVoidMethod(env, mActivityClass, midMinimizeWindow);
}
-SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss()
+SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void)
{
JNIEnv *env = Android_JNI_GetEnv();
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midShouldMinimizeOnFocusLoss);
@@ -1879,7 +1879,7 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
return SDL_FALSE;
}
-static void Internal_Android_Create_AssetManager()
+static void Internal_Android_Create_AssetManager(void)
{
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
@@ -1918,7 +1918,7 @@ static void Internal_Android_Create_AssetManager()
LocalReferenceHolder_Cleanup(&refs);
}
-static void Internal_Android_Destroy_AssetManager()
+static void Internal_Android_Destroy_AssetManager(void)
{
JNIEnv *env = Android_JNI_GetEnv();
@@ -2153,7 +2153,7 @@ int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seco
}
/* Add all touch devices */
-void Android_JNI_InitTouch()
+void Android_JNI_InitTouch(void)
{
JNIEnv *env = Android_JNI_GetEnv();
(*env)->CallStaticVoidMethod(env, mActivityClass, midInitTouch);
diff --git a/src/core/freebsd/SDL_evdev_kbd_freebsd.c b/src/core/freebsd/SDL_evdev_kbd_freebsd.c
index a3c3456876cfc..1d54bab128db1 100644
--- a/src/core/freebsd/SDL_evdev_kbd_freebsd.c
+++ b/src/core/freebsd/SDL_evdev_kbd_freebsd.c
@@ -134,7 +134,7 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontex
SDL_EVDEV_kbd_reraise_signal(signum);
}
-static void kbd_unregister_emerg_cleanup()
+static void kbd_unregister_emerg_cleanup(void)
{
int tabidx, signum;
diff --git a/src/core/linux/SDL_evdev_kbd.c b/src/core/linux/SDL_evdev_kbd.c
index 0aaefa0354f38..3f2c7203a6a41 100644
--- a/src/core/linux/SDL_evdev_kbd.c
+++ b/src/core/linux/SDL_evdev_kbd.c
@@ -214,7 +214,7 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontex
SDL_EVDEV_kbd_reraise_signal(signum);
}
-static void kbd_unregister_emerg_cleanup()
+static void kbd_unregister_emerg_cleanup(void)
{
int tabidx, signum;
diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c
index f948fc98b2816..cfbf70b8eb4d3 100644
--- a/src/core/linux/SDL_fcitx.c
+++ b/src/core/linux/SDL_fcitx.c
@@ -55,7 +55,7 @@ typedef struct _FcitxClient
static FcitxClient fcitx_client;
-static char *GetAppName()
+static char *GetAppName(void)
{
#if defined(__LINUX__) || defined(__FREEBSD__)
char *spot;
@@ -368,7 +368,7 @@ static Uint32 Fcitx_ModState(void)
return fcitx_mods;
}
-SDL_bool SDL_Fcitx_Init()
+SDL_bool SDL_Fcitx_Init(void)
{
fcitx_client.dbus = SDL_DBus_GetContext();
@@ -380,7 +380,7 @@ SDL_bool SDL_Fcitx_Init()
return FcitxClientCreateIC(&fcitx_client);
}
-void SDL_Fcitx_Quit()
+void SDL_Fcitx_Quit(void)
{
FcitxClientICCallMethod(&fcitx_client, "DestroyIC");
if (fcitx_client.ic_path) {
diff --git a/src/core/linux/SDL_ime.c b/src/core/linux/SDL_ime.c
index 6c28e5f6b59f6..2a87a7a00cce4 100644
--- a/src/core/linux/SDL_ime.c
+++ b/src/core/linux/SDL_ime.c
@@ -40,7 +40,7 @@ static _SDL_IME_ProcessKeyEvent SDL_IME_ProcessKeyEvent_Real = NULL;
static _SDL_IME_UpdateTextRect SDL_IME_UpdateTextRect_Real = NULL;
static _SDL_IME_PumpEvents SDL_IME_PumpEvents_Real = NULL;
-static void InitIME()
+static void InitIME(void)
{
static SDL_bool inited = SDL_FALSE;
#ifdef HAVE_FCITX
@@ -142,7 +142,7 @@ void SDL_IME_UpdateTextRect(const SDL_Rect *rect)
}
}
-void SDL_IME_PumpEvents()
+void SDL_IME_PumpEvents(void)
{
if (SDL_IME_PumpEvents_Real) {
SDL_IME_PumpEvents_Real();
diff --git a/src/core/linux/SDL_threadprio.c b/src/core/linux/SDL_threadprio.c
index 80d448e47262f..ec0d4c914e7c1 100644
--- a/src/core/linux/SDL_threadprio.c
+++ b/src/core/linux/SDL_threadprio.c
@@ -79,7 +79,7 @@ static SDL_bool realtime_portal_supported(DBusConnection *conn)
"RTTimeUSecMax", DBUS_TYPE_INT64, &res);
}
-static void set_rtkit_interface()
+static void set_rtkit_interface(void)
{
SDL_DBusContext *dbus = SDL_DBus_GetContext();
@@ -108,7 +108,7 @@ static DBusConnection *get_rtkit_dbus_connection()
return NULL;
}
-static void rtkit_initialize()
+static void rtkit_initialize(void)
{
DBusConnection *dbus_conn;
@@ -134,7 +134,7 @@ static void rtkit_initialize()
}
}
-static SDL_bool rtkit_initialize_realtime_thread()
+static SDL_bool rtkit_initialize_realtime_thread(void)
{
// Following is an excerpt from rtkit README that outlines the requirements
// a thread must meet before making rtkit requests:
diff --git a/src/core/openbsd/SDL_wscons_kbd.c b/src/core/openbsd/SDL_wscons_kbd.c
index 975ba823631ff..0a79cb711afac 100644
--- a/src/core/openbsd/SDL_wscons_kbd.c
+++ b/src/core/openbsd/SDL_wscons_kbd.c
@@ -449,7 +449,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev)
return input;
}
-void SDL_WSCONS_Init()
+void SDL_WSCONS_Init(void)
{
inputs[0] = SDL_WSCONS_Init_Keyboard("/dev/wskbd0");
inputs[1] = SDL_WSCONS_Init_Keyboard("/dev/wskbd1");
@@ -460,7 +460,7 @@ void SDL_WSCONS_Init()
return;
}
-void SDL_WSCONS_Quit()
+void SDL_WSCONS_Quit(void)
{
int i = 0;
SDL_WSCONS_input_data *input = NULL;
@@ -921,7 +921,7 @@ static void updateKeyboard(SDL_WSCONS_input_data *input)
}
}
-void SDL_WSCONS_PumpEvents()
+void SDL_WSCONS_PumpEvents(void)
{
int i = 0;
for (i = 0; i < 4; i++) {
diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c
index 34aa424eb37d0..1664b2e89a1fe 100644
--- a/src/cpuinfo/SDL_cpuinfo.c
+++ b/src/cpuinfo/SDL_cpuinfo.c
@@ -1239,7 +1239,7 @@ void SDL_SIMDFree(void *ptr)
#include
-int main()
+int main(void)
{
printf("CPU count: %d\n", SDL_GetCPUCount());
printf("CPU type: %s\n", SDL_GetCPUType());
diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c
index ed99ca5a6c9cf..ab8f500a151a8 100644
--- a/src/hidapi/SDL_hidapi.c
+++ b/src/hidapi/SDL_hidapi.c
@@ -945,9 +945,9 @@ IsInWhitelist(Uint16 vendor, Uint16 product)
}
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND
-static const SDL_bool use_libusb_whitelist_default = SDL_TRUE;
+ #define use_libusb_whitelist_default SDL_TRUE
#else
-static const SDL_bool use_libusb_whitelist_default = SDL_FALSE;
+ #define use_libusb_whitelist_default SDL_FALSE
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND */
static SDL_bool use_libusb_whitelist = use_libusb_whitelist_default;
diff --git a/src/hidapi/libusb/hid.c b/src/hidapi/libusb/hid.c
index 7da8a959f44b6..2485bbf9be328 100644
--- a/src/hidapi/libusb/hid.c
+++ b/src/hidapi/libusb/hid.c
@@ -519,7 +519,7 @@ static struct usb_string_cache_entry *usb_string_cache = NULL;
static size_t usb_string_cache_size = 0;
static size_t usb_string_cache_insert_pos = 0;
-static int usb_string_cache_grow()
+static int usb_string_cache_grow(void)
{
struct usb_string_cache_entry *new_cache;
size_t allocSize;
@@ -537,7 +537,7 @@ static int usb_string_cache_grow()
return 0;
}
-static void usb_string_cache_destroy()
+static void usb_string_cache_destroy(void)
{
size_t i;
for (i = 0; i < usb_string_cache_insert_pos; i++) {
diff --git a/src/hidapi/mac/hid.c b/src/hidapi/mac/hid.c
index bbb5c625da103..0dbe4227d21c3 100644
--- a/src/hidapi/mac/hid.c
+++ b/src/hidapi/mac/hid.c
@@ -504,7 +504,7 @@ int HID_API_EXPORT hid_exit(void)
return 0;
}
-static void process_pending_events() {
+static void process_pending_events(void) {
SInt32 res;
do {
res = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.001, FALSE);
diff --git a/src/hidapi/windows/hid.c b/src/hidapi/windows/hid.c
index 3d8a2302ea8f8..54843d4865885 100644
--- a/src/hidapi/windows/hid.c
+++ b/src/hidapi/windows/hid.c
@@ -264,7 +264,7 @@ static void register_error(hid_device *device, const char *op)
}
#ifndef HIDAPI_USE_DDK
-static int lookup_functions()
+static int lookup_functions(void)
{
lib_handle = LoadLibrary(TEXT("hid.dll"));
if (lib_handle) {
diff --git a/src/joystick/SDL_gamecontrollerdb.h b/src/joystick/SDL_gamecontrollerdb.h
index 22979210f1b52..e1474b321ac45 100644
--- a/src/joystick/SDL_gamecontrollerdb.h
+++ b/src/joystick/SDL_gamecontrollerdb.h
@@ -324,6 +324,7 @@ static const char *s_ControllerMappings[] = {
"030000009b2800000500000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,",
"030000008f0e00000800000000000000,SpeedLink Strike FX,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
"03000000c01100000591000000000000,Speedlink Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
+ "030000004c0500006802000000000000,SplitFish Game Controller,crc:5628,a:b0,b:b16,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,leftshoulder:b17,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b10,",
"03000000de280000ff11000000000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"03000000110100003114000000000000,SteelSeries Stratus Duo,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,",
"03000000381000001814000000000000,SteelSeries Stratus XL,a:b0,b:b1,back:b18,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b19,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b2,y:b3,",
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index d3aee17066801..75c62b187af86 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -397,7 +397,7 @@ static Uint32 initial_wheel_devices[] = {
MAKE_VIDPID(0x2433, 0xf301), /* Asetek SimSports Forte Wheelbase */
MAKE_VIDPID(0x2433, 0xf303), /* Asetek SimSports La Prima Wheelbase */
MAKE_VIDPID(0x2433, 0xf306), /* Asetek SimSports Tony Kannan Wheelbase */
- MAKE_VIDPID(0x3416, 0x0301), /* Cammus C5 Wheelbase */
+ MAKE_VIDPID(0x3416, 0x0301), /* Cammus C5 Wheelbase */
MAKE_VIDPID(0x346e, 0x0000), /* Moza R16/R21 Wheelbase */
MAKE_VIDPID(0x346e, 0x0002), /* Moza R9 Wheelbase */
MAKE_VIDPID(0x346e, 0x0004), /* Moza R5 Wheelbase */
@@ -1415,9 +1415,13 @@ int SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint
retval = 0;
} else {
retval = joystick->driver->Rumble(joystick, low_frequency_rumble, high_frequency_rumble);
- joystick->rumble_resend = SDL_GetTicks() + SDL_RUMBLE_RESEND_MS;
- if (!joystick->rumble_resend) {
- joystick->rumble_resend = 1;
+ if (retval == 0) {
+ joystick->rumble_resend = SDL_GetTicks() + SDL_RUMBLE_RESEND_MS;
+ if (joystick->rumble_resend == 0) {
+ joystick->rumble_resend = 1;
+ }
+ } else {
+ joystick->rumble_resend = 0;
}
}
@@ -2180,12 +2184,14 @@ void SDL_JoystickUpdate(void)
#endif /* SDL_JOYSTICK_HIDAPI */
for (joystick = SDL_joysticks; joystick; joystick = joystick->next) {
- if (joystick->attached) {
- joystick->driver->Update(joystick);
+ if (!joystick->attached) {
+ continue;
+ }
- if (joystick->delayed_guide_button) {
- SDL_GameControllerHandleDelayedGuideButton(joystick);
- }
+ joystick->driver->Update(joystick);
+
+ if (joystick->delayed_guide_button) {
+ SDL_GameControllerHandleDelayedGuideButton(joystick);
}
now = SDL_GetTicks();
diff --git a/src/joystick/hidapi/SDL_hidapi_steamdeck.c b/src/joystick/hidapi/SDL_hidapi_steamdeck.c
index c26b3e6db4787..20554edc605ec 100644
--- a/src/joystick/hidapi/SDL_hidapi_steamdeck.c
+++ b/src/joystick/hidapi/SDL_hidapi_steamdeck.c
@@ -134,6 +134,89 @@ static SDL_bool FeedDeckLizardWatchdog(SDL_hid_device *dev)
return SDL_TRUE;
}
+static void HIDAPI_DriverSteamDeck_HandleState(SDL_HIDAPI_Device *device,
+ SDL_Joystick *joystick,
+ ValveInReport_t *pInReport)
+{
+ float values[3];
+ SDL_DriverSteamDeck_Context *ctx = (SDL_DriverSteamDeck_Context *)device->context;
+
+ if (pInReport->payload.deckState.ulButtons != ctx->last_button_state) {
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_A) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_B,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_B) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_X,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_X) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_Y,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_Y) ? SDL_PRESSED : SDL_RELEASED);
+
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_L) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_R) ? SDL_PRESSED : SDL_RELEASED);
+
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_VIEW) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_MENU) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_STEAM) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1,
+ (pInReport->payload.deckState.ulButtonsH & STEAMDECK_HBUTTON_QAM) ? SDL_PRESSED : SDL_RELEASED);
+
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_L3) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_R3) ? SDL_PRESSED : SDL_RELEASED);
+
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE1,
+ (pInReport->payload.deckState.ulButtonsH & STEAMDECK_HBUTTON_R4) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE2,
+ (pInReport->payload.deckState.ulButtonsH & STEAMDECK_HBUTTON_L4) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE3,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_R5) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE4,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_L5) ? SDL_PRESSED : SDL_RELEASED);
+
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_UP) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_DOWN) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_LEFT) ? SDL_PRESSED : SDL_RELEASED);
+ SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
+ (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_RIGHT) ? SDL_PRESSED : SDL_RELEASED);
+ ctx->last_button_state = pInReport->payload.deckState.ulButtons;
+ }
+
+ SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT,
+ (int)pInReport->payload.deckState.sTriggerRawL * 2 - 32768);
+ SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
+ (int)pInReport->payload.deckState.sTriggerRawR * 2 - 32768);
+
+ SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX,
+ pInReport->payload.deckState.sLeftStickX);
+ SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY,
+ -pInReport->payload.deckState.sLeftStickY);
+ SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX,
+ pInReport->payload.deckState.sRightStickX);
+ SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY,
+ -pInReport->payload.deckState.sRightStickY);
+
+ ctx->sensor_timestamp_us += ctx->update_rate_us;
+
+ values[0] = (pInReport->payload.deckState.sGyroX / 32768.0f) * (2000.0f * ((float)M_PI / 180.0f));
+ values[1] = (pInReport->payload.deckState.sGyroZ / 32768.0f) * (2000.0f * ((float)M_PI / 180.0f));
+ values[2] = (-pInReport->payload.deckState.sGyroY / 32768.0f) * (2000.0f * ((float)M_PI / 180.0f));
+ SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, ctx->sensor_timestamp_us, values, 3);
+
+ values[0] = (pInReport->payload.deckState.sAccelX / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
+ values[1] = (pInReport->payload.deckState.sAccelZ / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
+ values[2] = (-pInReport->payload.deckState.sAccelY / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
+ SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, ctx->sensor_timestamp_us, values, 3);
+}
+
/*****************************************************************************************************/
static void HIDAPI_DriverSteamDeck_RegisterHints(SDL_HintCallback callback, void *userdata)
@@ -179,8 +262,8 @@ static SDL_bool HIDAPI_DriverSteamDeck_InitDevice(SDL_HIDAPI_Device *device)
return SDL_FALSE;
}
- // Always 1kHz according to USB descriptor
- ctx->update_rate_us = 1000;
+ // Always 1kHz according to USB descriptor, but actually about 4 ms.
+ ctx->update_rate_us = 4000;
device->context = ctx;
@@ -214,7 +297,6 @@ static SDL_bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device)
SDL_Joystick *joystick = NULL;
int r;
uint8_t data[64];
- float values[3];
ValveInReport_t *pInReport = (ValveInReport_t *)data;
if (device->num_joysticks > 0) {
@@ -233,95 +315,21 @@ static SDL_bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device)
}
SDL_memset(data, 0, sizeof(data));
- r = SDL_hid_read(device->dev, data, sizeof(data));
- if (r == 0) {
- return SDL_FALSE;
- } else if (r <= 0) {
- /* Failed to read from controller */
- HIDAPI_JoystickDisconnected(device, device->joysticks[0]);
- return SDL_FALSE;
- }
-
- if (!(r == 64 && pInReport->header.unReportVersion == k_ValveInReportMsgVersion && pInReport->header.ucType == ID_CONTROLLER_DECK_STATE && pInReport->header.ucLength == 64)) {
- return SDL_FALSE;
- }
- // Uint64 timestamp = SDL_GetTicksNS();
+ do {
+ r = SDL_hid_read(device->dev, data, sizeof(data));
- if (pInReport->payload.deckState.ulButtons != ctx->last_button_state) {
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_A) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_B,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_B) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_X,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_X) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_Y,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_Y) ? SDL_PRESSED : SDL_RELEASED);
-
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_L) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_R) ? SDL_PRESSED : SDL_RELEASED);
-
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_VIEW) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_MENU) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_STEAM) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1,
- (pInReport->payload.deckState.ulButtonsH & STEAMDECK_HBUTTON_QAM) ? SDL_PRESSED : SDL_RELEASED);
-
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_L3) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_R3) ? SDL_PRESSED : SDL_RELEASED);
-
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE1,
- (pInReport->payload.deckState.ulButtonsH & STEAMDECK_HBUTTON_R4) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE2,
- (pInReport->payload.deckState.ulButtonsH & STEAMDECK_HBUTTON_L4) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE3,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_R5) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE4,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_L5) ? SDL_PRESSED : SDL_RELEASED);
-
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_UP) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_DOWN) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_LEFT) ? SDL_PRESSED : SDL_RELEASED);
- SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
- (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_RIGHT) ? SDL_PRESSED : SDL_RELEASED);
- ctx->last_button_state = pInReport->payload.deckState.ulButtons;
- }
-
- SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT,
- (int)pInReport->payload.deckState.sTriggerRawL * 2 - 32768);
- SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
- (int)pInReport->payload.deckState.sTriggerRawR * 2 - 32768);
-
- SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX,
- pInReport->payload.deckState.sLeftStickX);
- SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY,
- -pInReport->payload.deckState.sLeftStickY);
- SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX,
- pInReport->payload.deckState.sRightStickX);
- SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY,
- -pInReport->payload.deckState.sRightStickY);
-
- ctx->sensor_timestamp_us += ctx->update_rate_us;
-
- values[0] = (pInReport->payload.deckState.sGyroX / 32768.0f) * (2000.0f * ((float)M_PI / 180.0f));
- values[1] = (pInReport->payload.deckState.sGyroZ / 32768.0f) * (2000.0f * ((float)M_PI / 180.0f));
- values[2] = (-pInReport->payload.deckState.sGyroY / 32768.0f) * (2000.0f * ((float)M_PI / 180.0f));
- SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, ctx->sensor_timestamp_us, values, 3);
-
- values[0] = (pInReport->payload.deckState.sAccelX / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
- values[1] = (pInReport->payload.deckState.sAccelZ / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
- values[2] = (-pInReport->payload.deckState.sAccelY / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
- SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, ctx->sensor_timestamp_us, values, 3);
+ if (r < 0) {
+ /* Failed to read from controller */
+ HIDAPI_JoystickDisconnected(device, device->joysticks[0]);
+ return SDL_FALSE;
+ } else if (r == 64 &&
+ pInReport->header.unReportVersion == k_ValveInReportMsgVersion &&
+ pInReport->header.ucType == ID_CONTROLLER_DECK_STATE &&
+ pInReport->header.ucLength == 64) {
+ HIDAPI_DriverSteamDeck_HandleState(device, joystick, pInReport);
+ }
+ } while (r > 0);
return SDL_TRUE;
}
diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index 45a2260d1b035..ce9b15c0aeb08 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -332,12 +332,28 @@ typedef struct
static int ReadInput(SDL_DriverSwitch_Context *ctx)
{
+ int result;
+
/* Make sure we don't try to read at the same time a write is happening */
if (SDL_AtomicGet(&ctx->device->rumble_pending) > 0) {
return 0;
}
- return SDL_hid_read_timeout(ctx->device->dev, ctx->m_rgucReadBuffer, sizeof(ctx->m_rgucReadBuffer), 0);
+ result = SDL_hid_read_timeout(ctx->device->dev, ctx->m_rgucReadBuffer, sizeof(ctx->m_rgucReadBuffer), 0);
+
+ /* See if we can guess the initial input mode */
+ if (result > 0 && !ctx->m_bInputOnly && !ctx->m_nInitialInputMode) {
+ switch (ctx->m_rgucReadBuffer[0]) {
+ case k_eSwitchInputReportIDs_FullControllerState:
+ case k_eSwitchInputReportIDs_FullControllerAndMcuState:
+ case k_eSwitchInputReportIDs_SimpleControllerState:
+ ctx->m_nInitialInputMode = ctx->m_rgucReadBuffer[0];
+ break;
+ default:
+ break;
+ }
+ }
+ return result;
}
static int WriteOutput(SDL_DriverSwitch_Context *ctx, const Uint8 *data, int size)
@@ -727,14 +743,12 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c
}
}
-static Uint8 GetInitialInputMode(SDL_DriverSwitch_Context *ctx)
+static void GetInitialInputMode(SDL_DriverSwitch_Context *ctx)
{
- Uint8 input_mode = 0;
-
- if (ReadInput(ctx) > 0) {
- input_mode = ctx->m_rgucReadBuffer[0];
+ if (!ctx->m_nInitialInputMode) {
+ /* This will set the initial input mode if it can */
+ ReadInput(ctx);
}
- return input_mode;
}
static Uint8 GetDefaultInputMode(SDL_DriverSwitch_Context *ctx)
@@ -1412,7 +1426,7 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_
ctx->m_bSyncWrite = SDL_TRUE;
if (!ctx->m_bInputOnly) {
- ctx->m_nInitialInputMode = GetInitialInputMode(ctx);
+ GetInitialInputMode(ctx);
ctx->m_nCurrentInputMode = ctx->m_nInitialInputMode;
/* Initialize rumble data */
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 0db0cbb1c34d9..863785eec0bb2 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -1008,7 +1008,7 @@ static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device)
}
}
-static SDL_bool HIDAPI_CreateCombinedJoyCons()
+static SDL_bool HIDAPI_CreateCombinedJoyCons(void)
{
SDL_HIDAPI_Device *device, *combined;
SDL_HIDAPI_Device *joycons[2] = { NULL, NULL };
diff --git a/src/joystick/ps2/SDL_sysjoystick.c b/src/joystick/ps2/SDL_sysjoystick.c
index 8c0edb7a56690..d67d241985c44 100644
--- a/src/joystick/ps2/SDL_sysjoystick.c
+++ b/src/joystick/ps2/SDL_sysjoystick.c
@@ -133,13 +133,13 @@ static int PS2_JoystickInit(void)
}
/* Function to return the number of joystick devices plugged in right now */
-static int PS2_JoystickGetCount()
+static int PS2_JoystickGetCount(void)
{
return (int)enabled_pads;
}
/* Function to cause any queued joystick insertions to be processed */
-static void PS2_JoystickDetect()
+static void PS2_JoystickDetect(void)
{
}
diff --git a/src/joystick/vita/SDL_sysjoystick.c b/src/joystick/vita/SDL_sysjoystick.c
index 9da62c2b3d701..7f12392f0a1d2 100644
--- a/src/joystick/vita/SDL_sysjoystick.c
+++ b/src/joystick/vita/SDL_sysjoystick.c
@@ -145,12 +145,12 @@ int VITA_JoystickInit(void)
return SDL_numjoysticks;
}
-int VITA_JoystickGetCount()
+int VITA_JoystickGetCount(void)
{
return SDL_numjoysticks;
}
-void VITA_JoystickDetect()
+void VITA_JoystickDetect(void)
{
}
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index c911efdb91506..2e107082b8704 100644
--- a/src/joystick/windows/SDL_rawinputjoystick.c
+++ b/src/joystick/windows/SDL_rawinputjoystick.c
@@ -331,7 +331,7 @@ static struct
static SDL_bool xinput_device_change = SDL_TRUE;
static SDL_bool xinput_state_dirty = SDL_TRUE;
-static void RAWINPUT_UpdateXInput()
+static void RAWINPUT_UpdateXInput(void)
{
DWORD user_index;
if (xinput_device_change) {
@@ -371,7 +371,7 @@ static void RAWINPUT_MarkXInputSlotFree(Uint8 xinput_slot)
xinput_state[xinput_slot].used = SDL_FALSE;
}
}
-static SDL_bool RAWINPUT_MissingXInputSlot()
+static SDL_bool RAWINPUT_MissingXInputSlot(void)
{
int ii;
for (ii = 0; ii < SDL_arraysize(xinput_state); ii++) {
@@ -556,7 +556,7 @@ static void RAWINPUT_MarkWindowsGamingInputSlotFree(WindowsGamingInputGamepadSta
wgi_slot->correlated_context = NULL;
}
-static SDL_bool RAWINPUT_MissingWindowsGamingInputSlot()
+static SDL_bool RAWINPUT_MissingWindowsGamingInputSlot(void)
{
int ii;
for (ii = 0; ii < wgi_state.per_gamepad_count; ii++) {
@@ -567,7 +567,7 @@ static SDL_bool RAWINPUT_MissingWindowsGamingInputSlot()
return SDL_FALSE;
}
-static void RAWINPUT_UpdateWindowsGamingInput()
+static void RAWINPUT_UpdateWindowsGamingInput(void)
{
int ii;
if (!wgi_state.gamepad_statics) {
@@ -1050,7 +1050,7 @@ static int RAWINPUT_JoystickGetCount(void)
return SDL_RAWINPUT_numjoysticks;
}
-SDL_bool RAWINPUT_IsEnabled()
+SDL_bool RAWINPUT_IsEnabled(void)
{
return SDL_RAWINPUT_inited && !SDL_RAWINPUT_remote_desktop;
}
@@ -2087,7 +2087,7 @@ int RAWINPUT_RegisterNotifications(HWND hWnd)
return 0;
}
-int RAWINPUT_UnregisterNotifications()
+int RAWINPUT_UnregisterNotifications(void)
{
int i;
RAWINPUTDEVICE rid[SDL_arraysize(subscribed_devices)];
diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c
index 656f742a8e09a..86c708ac9df3b 100644
--- a/src/joystick/windows/SDL_windows_gaming_input.c
+++ b/src/joystick/windows/SDL_windows_gaming_input.c
@@ -216,7 +216,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product)
return SDL_FALSE;
}
-static void WGI_LoadRawGameControllerStatics()
+static void WGI_LoadRawGameControllerStatics(void)
{
WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = NULL;
RoGetActivationFactory_t RoGetActivationFactoryFunc = NULL;
@@ -247,7 +247,7 @@ static void WGI_LoadRawGameControllerStatics()
}
}
-static void WGI_LoadOtherControllerStatics()
+static void WGI_LoadOtherControllerStatics(void)
{
WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = NULL;
RoGetActivationFactory_t RoGetActivationFactoryFunc = NULL;
diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c
index 38c27d80de2ad..ca6585312eb6c 100644
--- a/src/joystick/windows/SDL_xinputjoystick.c
+++ b/src/joystick/windows/SDL_xinputjoystick.c
@@ -41,7 +41,7 @@ extern "C" {
*/
static SDL_bool s_bXInputEnabled = SDL_TRUE;
-static SDL_bool SDL_XInputUseOldJoystickMapping()
+static SDL_bool SDL_XInputUseOldJoystickMapping(void)
{
#ifdef __WINRT__
/* TODO: remove this __WINRT__ block, but only after integrating with UWP/WinRT's HID API */
diff --git a/src/main/ps2/SDL_ps2_main.c b/src/main/ps2/SDL_ps2_main.c
index b237eea8c64f4..14fb0d704fc96 100644
--- a/src/main/ps2/SDL_ps2_main.c
+++ b/src/main/ps2/SDL_ps2_main.c
@@ -23,7 +23,7 @@
#undef main
#endif
-__attribute__((weak)) void reset_IOP()
+__attribute__((weak)) void reset_IOP(void)
{
SifInitRpc(0);
while (!SifIopReset(NULL, 0)) {
@@ -32,7 +32,7 @@ __attribute__((weak)) void reset_IOP()
}
}
-static void prepare_IOP()
+static void prepare_IOP(void)
{
reset_IOP();
SifInitRpc(0);
@@ -41,12 +41,12 @@ static void prepare_IOP()
sbv_patch_fileio();
}
-static void init_drivers()
+static void init_drivers(void)
{
init_ps2_filesystem_driver();
}
-static void deinit_drivers()
+static void deinit_drivers(void)
{
deinit_ps2_filesystem_driver();
}
diff --git a/src/main/windows/version.rc b/src/main/windows/version.rc
index 69e6a8e17fb40..bd4ee89ade669 100644
--- a/src/main/windows/version.rc
+++ b/src/main/windows/version.rc
@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 2,30,5,0
- PRODUCTVERSION 2,30,5,0
+ FILEVERSION 2,30,6,0
+ PRODUCTVERSION 2,30,6,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
- VALUE "FileVersion", "2, 30, 5, 0\0"
+ VALUE "FileVersion", "2, 30, 6, 0\0"
VALUE "InternalName", "SDL\0"
VALUE "LegalCopyright", "Copyright (C) 2024 Sam Lantinga\0"
VALUE "OriginalFilename", "SDL2.dll\0"
VALUE "ProductName", "Simple DirectMedia Layer\0"
- VALUE "ProductVersion", "2, 30, 5, 0\0"
+ VALUE "ProductVersion", "2, 30, 6, 0\0"
END
END
BLOCK "VarFileInfo"
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index f117bd664d137..2a54c6147543d 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -1610,7 +1610,12 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->driverdata = data;
SDL_VERSION(&windowinfo.version);
- SDL_GetWindowWMInfo(window, &windowinfo);
+ if (!SDL_GetWindowWMInfo(window, &windowinfo) ||
+ windowinfo.subsystem != SDL_SYSWM_WINDOWS) {
+ SDL_free(data);
+ SDL_SetError("Couldn't get window handle");
+ return NULL;
+ }
window_flags = SDL_GetWindowFlags(window);
SDL_GetWindowSizeInPixels(window, &w, &h);
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index 8249256faff8e..72b713d01bd5a 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -813,7 +813,12 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
#if defined(__WIN32__) || defined(__WINGDK__)
SDL_SysWMinfo windowinfo;
SDL_VERSION(&windowinfo.version);
- SDL_GetWindowWMInfo(renderer->window, &windowinfo);
+ if (!SDL_GetWindowWMInfo(renderer->window, &windowinfo) ||
+ windowinfo.subsystem != SDL_SYSWM_WINDOWS) {
+ SDL_SetError("Couldn't get window handle");
+ result = E_FAIL;
+ goto done;
+ }
result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory,
(IUnknown *)data->d3dDevice,
diff --git a/src/render/ps2/SDL_render_ps2.c b/src/render/ps2/SDL_render_ps2.c
index ec17323cd43cb..2d3dfa1998024 100644
--- a/src/render/ps2/SDL_render_ps2.c
+++ b/src/render/ps2/SDL_render_ps2.c
@@ -55,7 +55,7 @@ typedef struct
static int vsync_sema_id = 0;
/* PRIVATE METHODS */
-static int vsync_handler()
+static int vsync_handler(void)
{
iSignalSema(vsync_sema_id);
diff --git a/src/stdlib/SDL_malloc.c b/src/stdlib/SDL_malloc.c
index 4c266611bafc7..6edd912b6721e 100644
--- a/src/stdlib/SDL_malloc.c
+++ b/src/stdlib/SDL_malloc.c
@@ -4472,7 +4472,7 @@ struct mallinfo dlmallinfo(void) {
}
#endif /* NO_MALLINFO */
-void dlmalloc_stats() {
+void dlmalloc_stats(void) {
internal_malloc_stats(gm);
}
diff --git a/src/test/SDL_test_assert.c b/src/test/SDL_test_assert.c
index e8d0ff0d18bf2..1932f69de7904 100644
--- a/src/test/SDL_test_assert.c
+++ b/src/test/SDL_test_assert.c
@@ -107,7 +107,7 @@ void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,
/*
* Resets the assert summary counters to zero.
*/
-void SDLTest_ResetAssertSummary()
+void SDLTest_ResetAssertSummary(void)
{
SDLTest_AssertsPassed = 0;
SDLTest_AssertsFailed = 0;
@@ -117,7 +117,7 @@ void SDLTest_ResetAssertSummary()
* Logs summary of all assertions (total, pass, fail) since last reset
* as INFO (failed==0) or ERROR (failed > 0).
*/
-void SDLTest_LogAssertSummary()
+void SDLTest_LogAssertSummary(void)
{
int totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed;
if (SDLTest_AssertsFailed == 0) {
@@ -130,7 +130,7 @@ void SDLTest_LogAssertSummary()
/*
* Converts the current assert state into a test result
*/
-int SDLTest_AssertSummaryToTestResult()
+int SDLTest_AssertSummaryToTestResult(void)
{
if (SDLTest_AssertsFailed > 0) {
return TEST_RESULT_FAILED;
diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c
index a04eee05ed042..784eee2bf7150 100644
--- a/src/test/SDL_test_fuzzer.c
+++ b/src/test/SDL_test_fuzzer.c
@@ -68,54 +68,54 @@ void SDLTest_FuzzerInit(Uint64 execKey)
fuzzerInvocationCounter = 0;
}
-int SDLTest_GetFuzzerInvocationCount()
+int SDLTest_GetFuzzerInvocationCount(void)
{
return fuzzerInvocationCounter;
}
-Uint8 SDLTest_RandomUint8()
+Uint8 SDLTest_RandomUint8(void)
{
fuzzerInvocationCounter++;
return (Uint8)SDLTest_RandomInt(&rndContext) & 0x000000FF;
}
-Sint8 SDLTest_RandomSint8()
+Sint8 SDLTest_RandomSint8(void)
{
fuzzerInvocationCounter++;
return (Sint8)SDLTest_RandomInt(&rndContext) & 0x000000FF;
}
-Uint16 SDLTest_RandomUint16()
+Uint16 SDLTest_RandomUint16(void)
{
fuzzerInvocationCounter++;
return (Uint16)SDLTest_RandomInt(&rndContext) & 0x0000FFFF;
}
-Sint16 SDLTest_RandomSint16()
+Sint16 SDLTest_RandomSint16(void)
{
fuzzerInvocationCounter++;
return (Sint16)SDLTest_RandomInt(&rndContext) & 0x0000FFFF;
}
-Sint32 SDLTest_RandomSint32()
+Sint32 SDLTest_RandomSint32(void)
{
fuzzerInvocationCounter++;
return (Sint32)SDLTest_RandomInt(&rndContext);
}
-Uint32 SDLTest_RandomUint32()
+Uint32 SDLTest_RandomUint32(void)
{
fuzzerInvocationCounter++;
return (Uint32)SDLTest_RandomInt(&rndContext);
}
-Uint64 SDLTest_RandomUint64()
+Uint64 SDLTest_RandomUint64(void)
{
union
{
@@ -132,7 +132,7 @@ Uint64 SDLTest_RandomUint64()
return value.v64;
}
-Sint64 SDLTest_RandomSint64()
+Sint64 SDLTest_RandomSint64(void)
{
union
{
@@ -425,24 +425,24 @@ Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL
validDomain);
}
-float SDLTest_RandomUnitFloat()
+float SDLTest_RandomUnitFloat(void)
{
return SDLTest_RandomUint32() / (float)UINT_MAX;
}
-float SDLTest_RandomFloat()
+float SDLTest_RandomFloat(void)
{
return (float)(SDLTest_RandomUnitDouble() * 2.0 * (double)FLT_MAX - (double)(FLT_MAX));
}
double
-SDLTest_RandomUnitDouble()
+SDLTest_RandomUnitDouble(void)
{
return (double)(SDLTest_RandomUint64() >> 11) * (1.0 / 9007199254740992.0);
}
double
-SDLTest_RandomDouble()
+SDLTest_RandomDouble(void)
{
double r = 0.0;
double s = 1.0;
@@ -456,7 +456,7 @@ SDLTest_RandomDouble()
return r;
}
-char *SDLTest_RandomAsciiString()
+char *SDLTest_RandomAsciiString(void)
{
return SDLTest_RandomAsciiStringWithMaximumLength(255);
}
diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c
index 460e694f8c48e..ac1cb09c5dde2 100644
--- a/src/test/SDL_test_harness.c
+++ b/src/test/SDL_test_harness.c
@@ -339,7 +339,7 @@ static void SDLTest_LogTestSuiteSummary(SDLTest_TestSuiteReference *testSuites)
#endif
/* Gets a timer value in seconds */
-static float GetClock()
+static float GetClock(void)
{
float currentClock = SDL_GetPerformanceCounter() / (float)SDL_GetPerformanceFrequency();
return currentClock;
diff --git a/src/test/SDL_test_imageBlit.c b/src/test/SDL_test_imageBlit.c
index bf1cf2fce2830..82cfb029e3b3f 100644
--- a/src/test/SDL_test_imageBlit.c
+++ b/src/test/SDL_test_imageBlit.c
@@ -540,7 +540,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlit = {
/**
* \brief Returns the Blit test image as SDL_Surface.
*/
-SDL_Surface *SDLTest_ImageBlit()
+SDL_Surface *SDLTest_ImageBlit(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlit.pixel_data,
@@ -1014,7 +1014,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = {
/**
* \brief Returns the BlitColor test image as SDL_Surface.
*/
-SDL_Surface *SDLTest_ImageBlitColor()
+SDL_Surface *SDLTest_ImageBlitColor(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitColor.pixel_data,
@@ -1651,7 +1651,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = {
/**
* \brief Returns the BlitAlpha test image as SDL_Surface.
*/
-SDL_Surface *SDLTest_ImageBlitAlpha()
+SDL_Surface *SDLTest_ImageBlitAlpha(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitAlpha.pixel_data,
diff --git a/src/test/SDL_test_imageBlitBlend.c b/src/test/SDL_test_imageBlitBlend.c
index 520cfffdd00a5..4fa09deb1bc5c 100644
--- a/src/test/SDL_test_imageBlitBlend.c
+++ b/src/test/SDL_test_imageBlitBlend.c
@@ -580,7 +580,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = {
/**
* \brief Returns the BlitBlendAdd test image as SDL_Surface.
*/
-SDL_Surface *SDLTest_ImageBlitBlendAdd()
+SDL_Surface *SDLTest_ImageBlitBlendAdd(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitBlendAdd.pixel_data,
@@ -1171,7 +1171,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = {
/**
* \brief Returns the BlitBlend test image as SDL_Surface.
*/
-SDL_Surface *SDLTest_ImageBlitBlend()
+SDL_Surface *SDLTest_ImageBlitBlend(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitBlend.pixel_data,
@@ -1592,7 +1592,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = {
/**
* \brief Returns the BlitBlendMod test image as SDL_Surface.
*/
-SDL_Surface *SDLTest_ImageBlitBlendMod()
+SDL_Surface *SDLTest_ImageBlitBlendMod(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitBlendMod.pixel_data,
@@ -2396,7 +2396,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = {
/**
* \brief Returns the BlitBlendNone test image as SDL_Surface.
*/
-SDL_Surface *SDLTest_ImageBlitBlendNone()
+SDL_Surface *SDLTest_ImageBlitBlendNone(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitBlendNone.pixel_data,
@@ -2932,7 +2932,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = {
/**
* \brief Returns the BlitBlendAll test image as SDL_Surface.
*/
-SDL_Surface *SDLTest_ImageBlitBlendAll()
+SDL_Surface *SDLTest_ImageBlitBlendAll(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageBlitBlendAll.pixel_data,
diff --git a/src/test/SDL_test_imageFace.c b/src/test/SDL_test_imageFace.c
index 255acaddee132..b9c6bfa16ac16 100644
--- a/src/test/SDL_test_imageFace.c
+++ b/src/test/SDL_test_imageFace.c
@@ -223,7 +223,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageFace = {
/**
* \brief Returns the Face test image as SDL_Surface.
*/
-SDL_Surface *SDLTest_ImageFace()
+SDL_Surface *SDLTest_ImageFace(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imageFace.pixel_data,
diff --git a/src/test/SDL_test_imagePrimitives.c b/src/test/SDL_test_imagePrimitives.c
index 6ef05c5547e39..6d26ff71ffee2 100644
--- a/src/test/SDL_test_imagePrimitives.c
+++ b/src/test/SDL_test_imagePrimitives.c
@@ -504,7 +504,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitives = {
/**
* \brief Returns the Primitives test image as SDL_Surface.
*/
-SDL_Surface *SDLTest_ImagePrimitives()
+SDL_Surface *SDLTest_ImagePrimitives(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imagePrimitives.pixel_data,
diff --git a/src/test/SDL_test_imagePrimitivesBlend.c b/src/test/SDL_test_imagePrimitivesBlend.c
index 8ee9f41775708..659ae257405ef 100644
--- a/src/test/SDL_test_imagePrimitivesBlend.c
+++ b/src/test/SDL_test_imagePrimitivesBlend.c
@@ -677,7 +677,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitivesBlend = {
/**
* \brief Returns the PrimitivesBlend test image as SDL_Surface.
*/
-SDL_Surface *SDLTest_ImagePrimitivesBlend()
+SDL_Surface *SDLTest_ImagePrimitivesBlend(void)
{
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
(void *)SDLTest_imagePrimitivesBlend.pixel_data,
diff --git a/src/test/SDL_test_memory.c b/src/test/SDL_test_memory.c
index ffd3eaac87d7f..e998094a7a61d 100644
--- a/src/test/SDL_test_memory.c
+++ b/src/test/SDL_test_memory.c
@@ -195,7 +195,7 @@ static void SDLCALL SDLTest_TrackedFree(void *ptr)
SDL_free_orig(ptr);
}
-int SDLTest_TrackAllocations()
+int SDLTest_TrackAllocations(void)
{
if (SDL_malloc_orig) {
return 0;
@@ -220,7 +220,7 @@ int SDLTest_TrackAllocations()
return 0;
}
-void SDLTest_LogAllocations()
+void SDLTest_LogAllocations(void)
{
char *message = NULL;
size_t message_size = 0;
diff --git a/src/thread/SDL_systhread.h b/src/thread/SDL_systhread.h
index b56eaf4da2507..28c9d407d2bf0 100644
--- a/src/thread/SDL_systhread.h
+++ b/src/thread/SDL_systhread.h
@@ -59,12 +59,18 @@ extern void SDL_SYS_WaitThread(SDL_Thread *thread);
/* Mark thread as cleaned up as soon as it exits, without joining. */
extern void SDL_SYS_DetachThread(SDL_Thread *thread);
+/* Initialize the global TLS data */
+extern void SDL_SYS_InitTLSData(void);
+
/* Get the thread local storage for this thread */
extern SDL_TLSData *SDL_SYS_GetTLSData(void);
/* Set the thread local storage for this thread */
extern int SDL_SYS_SetTLSData(SDL_TLSData *data);
+/* Quit the global TLS data */
+extern void SDL_SYS_QuitTLSData(void);
+
/* This is for internal SDL use, so we don't need #ifdefs everywhere. */
extern SDL_Thread *
SDL_CreateThreadInternal(int(SDLCALL *fn)(void *), const char *name,
diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c
index 55c2902442883..c1f4f2fc48683 100644
--- a/src/thread/SDL_thread.c
+++ b/src/thread/SDL_thread.c
@@ -28,6 +28,15 @@
#include "SDL_hints.h"
#include "../SDL_error_c.h"
+/* The storage is local to the thread, but the IDs are global for the process */
+
+static SDL_atomic_t SDL_tls_allocated;
+
+void SDL_InitTLSData(void)
+{
+ SDL_SYS_InitTLSData();
+}
+
SDL_TLSID SDL_TLSCreate(void)
{
static SDL_atomic_t SDL_tls_id;
@@ -53,6 +62,13 @@ int SDL_TLSSet(SDL_TLSID id, const void *value, void(SDLCALL *destructor)(void *
return SDL_InvalidParamError("id");
}
+ /* Make sure TLS is initialized.
+ * There's a race condition here if you are calling this from non-SDL threads
+ * and haven't called SDL_Init() on your main thread, but such is life.
+ */
+ SDL_InitTLSData();
+
+ /* Get the storage for the current thread */
storage = SDL_SYS_GetTLSData();
if (!storage || (id > storage->limit)) {
unsigned int i, oldlimit, newlimit;
@@ -69,8 +85,10 @@ int SDL_TLSSet(SDL_TLSID id, const void *value, void(SDLCALL *destructor)(void *
storage->array[i].destructor = NULL;
}
if (SDL_SYS_SetTLSData(storage) != 0) {
+ SDL_free(storage);
return -1;
}
+ SDL_AtomicIncRef(&SDL_tls_allocated);
}
storage->array[id - 1].data = SDL_const_cast(void *, value);
@@ -82,6 +100,7 @@ void SDL_TLSCleanup(void)
{
SDL_TLSData *storage;
+ /* Cleanup the storage for the current thread */
storage = SDL_SYS_GetTLSData();
if (storage) {
unsigned int i;
@@ -92,6 +111,18 @@ void SDL_TLSCleanup(void)
}
SDL_SYS_SetTLSData(NULL);
SDL_free(storage);
+ (void)SDL_AtomicDecRef(&SDL_tls_allocated);
+ }
+}
+
+void SDL_QuitTLSData(void)
+{
+ SDL_TLSCleanup();
+
+ if (SDL_AtomicGet(&SDL_tls_allocated) == 0) {
+ SDL_SYS_QuitTLSData();
+ } else {
+ /* Some thread hasn't called SDL_CleanupTLS() */
}
}
@@ -113,40 +144,27 @@ typedef struct SDL_TLSEntry
static SDL_mutex *SDL_generic_TLS_mutex;
static SDL_TLSEntry *SDL_generic_TLS;
+void SDL_Generic_InitTLSData(void)
+{
+ if (!SDL_generic_TLS_mutex) {
+ SDL_generic_TLS_mutex = SDL_CreateMutex();
+ }
+}
+
SDL_TLSData *SDL_Generic_GetTLSData(void)
{
SDL_threadID thread = SDL_ThreadID();
SDL_TLSEntry *entry;
SDL_TLSData *storage = NULL;
-#ifndef SDL_THREADS_DISABLED
- if (!SDL_generic_TLS_mutex) {
- static SDL_SpinLock tls_lock;
- SDL_AtomicLock(&tls_lock);
- if (!SDL_generic_TLS_mutex) {
- SDL_mutex *mutex = SDL_CreateMutex();
- SDL_MemoryBarrierRelease();
- SDL_generic_TLS_mutex = mutex;
- if (!SDL_generic_TLS_mutex) {
- SDL_AtomicUnlock(&tls_lock);
- return NULL;
- }
- }
- SDL_AtomicUnlock(&tls_lock);
- }
- SDL_MemoryBarrierAcquire();
SDL_LockMutex(SDL_generic_TLS_mutex);
-#endif /* SDL_THREADS_DISABLED */
-
for (entry = SDL_generic_TLS; entry; entry = entry->next) {
if (entry->thread == thread) {
storage = entry->storage;
break;
}
}
-#ifndef SDL_THREADS_DISABLED
SDL_UnlockMutex(SDL_generic_TLS_mutex);
-#endif
return storage;
}
@@ -155,8 +173,8 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data)
{
SDL_threadID thread = SDL_ThreadID();
SDL_TLSEntry *prev, *entry;
+ int retval = 0;
- /* SDL_Generic_GetTLSData() is always called first, so we can assume SDL_generic_TLS_mutex */
SDL_LockMutex(SDL_generic_TLS_mutex);
prev = NULL;
for (entry = SDL_generic_TLS; entry; entry = entry->next) {
@@ -175,21 +193,44 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data)
}
prev = entry;
}
- if (!entry) {
+ if (!entry && data) {
entry = (SDL_TLSEntry *)SDL_malloc(sizeof(*entry));
if (entry) {
entry->thread = thread;
entry->storage = data;
entry->next = SDL_generic_TLS;
SDL_generic_TLS = entry;
+ } else {
+ retval = SDL_OutOfMemory();
}
}
SDL_UnlockMutex(SDL_generic_TLS_mutex);
- if (!entry) {
- return SDL_OutOfMemory();
+ return retval;
+}
+
+void SDL_Generic_QuitTLSData(void)
+{
+ SDL_TLSEntry *entry;
+
+ /* This should have been cleaned up by the time we get here */
+ SDL_assert(!SDL_generic_TLS);
+ if (SDL_generic_TLS) {
+ SDL_LockMutex(SDL_generic_TLS_mutex);
+ for (entry = SDL_generic_TLS; entry; ) {
+ SDL_TLSEntry *next = entry->next;
+ SDL_free(entry->storage);
+ SDL_free(entry);
+ entry = next;
+ }
+ SDL_generic_TLS = NULL;
+ SDL_UnlockMutex(SDL_generic_TLS_mutex);
+ }
+
+ if (SDL_generic_TLS_mutex) {
+ SDL_DestroyMutex(SDL_generic_TLS_mutex);
+ SDL_generic_TLS_mutex = NULL;
}
- return 0;
}
/* Non-thread-safe global error variable */
@@ -328,6 +369,8 @@ SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *),
SDL_Thread *thread;
int ret;
+ SDL_InitMainThread();
+
/* Allocate memory for the thread info structure */
thread = (SDL_Thread *)SDL_calloc(1, sizeof(*thread));
if (!thread) {
diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h
index 985a51996af12..619edd981966e 100644
--- a/src/thread/SDL_thread_c.h
+++ b/src/thread/SDL_thread_c.h
@@ -93,17 +93,17 @@ typedef struct
/* This is how many TLS entries we allocate at once */
#define TLS_ALLOC_CHUNKSIZE 4
-/* Get cross-platform, slow, thread local storage for this thread.
- This is only intended as a fallback if getting real thread-local
- storage fails or isn't supported on this platform.
- */
-extern SDL_TLSData *SDL_Generic_GetTLSData(void);
+extern void SDL_InitTLSData(void);
+extern void SDL_QuitTLSData(void);
-/* Set cross-platform, slow, thread local storage for this thread.
+/* Generic TLS support.
This is only intended as a fallback if getting real thread-local
storage fails or isn't supported on this platform.
*/
+extern void SDL_Generic_InitTLSData(void);
+extern SDL_TLSData *SDL_Generic_GetTLSData(void);
extern int SDL_Generic_SetTLSData(SDL_TLSData *data);
+extern void SDL_Generic_QuitTLSData(void);
#endif /* SDL_thread_c_h_ */
diff --git a/src/thread/generic/SDL_systls.c b/src/thread/generic/SDL_systls.c
index 1d100e0325d48..cc0aadfe7dbff 100644
--- a/src/thread/generic/SDL_systls.c
+++ b/src/thread/generic/SDL_systls.c
@@ -22,6 +22,11 @@
#include "../../SDL_internal.h"
#include "../SDL_thread_c.h"
+void SDL_SYS_InitTLSData(void)
+{
+ SDL_Generic_InitTLSData();
+}
+
SDL_TLSData *SDL_SYS_GetTLSData(void)
{
return SDL_Generic_GetTLSData();
@@ -32,4 +37,9 @@ int SDL_SYS_SetTLSData(SDL_TLSData *data)
return SDL_Generic_SetTLSData(data);
}
+void SDL_SYS_QuitTLSData(void)
+{
+ SDL_Generic_QuitTLSData();
+}
+
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/os2/SDL_systls.c b/src/thread/os2/SDL_systls.c
index 5c380dd7f8fc2..75ed562ded31f 100644
--- a/src/thread/os2/SDL_systls.c
+++ b/src/thread/os2/SDL_systls.c
@@ -34,45 +34,22 @@
SDL_TLSData **ppSDLTLSData = NULL;
-static ULONG cTLSAlloc = 0;
-
-/* SDL_OS2TLSAlloc() called from SDL_InitSubSystem() */
-void SDL_OS2TLSAlloc(void)
+void SDL_SYS_InitTLSData(void)
{
ULONG ulRC;
- if (cTLSAlloc == 0 || !ppSDLTLSData) {
- /* First call - allocate the thread local memory (1 DWORD) */
+ if (!ppSDLTLSData) {
+ /* Allocate the thread local memory (1 DWORD) */
ulRC = DosAllocThreadLocalMemory(1, (PULONG *)&ppSDLTLSData);
if (ulRC != NO_ERROR) {
debug_os2("DosAllocThreadLocalMemory() failed, rc = %u", ulRC);
}
}
- cTLSAlloc++;
-}
-
-/* SDL_OS2TLSFree() called from SDL_QuitSubSystem() */
-void SDL_OS2TLSFree(void)
-{
- ULONG ulRC;
-
- if (cTLSAlloc != 0)
- cTLSAlloc--;
-
- if (cTLSAlloc == 0 && ppSDLTLSData) {
- /* Last call - free the thread local memory */
- ulRC = DosFreeThreadLocalMemory((PULONG)ppSDLTLSData);
- if (ulRC != NO_ERROR) {
- debug_os2("DosFreeThreadLocalMemory() failed, rc = %u", ulRC);
- } else {
- ppSDLTLSData = NULL;
- }
- }
}
SDL_TLSData *SDL_SYS_GetTLSData(void)
{
- return (!ppSDLTLSData)? NULL : *ppSDLTLSData;
+ return ppSDLTLSData ? *ppSDLTLSData : NULL;
}
int SDL_SYS_SetTLSData(SDL_TLSData *data)
@@ -84,6 +61,21 @@ int SDL_SYS_SetTLSData(SDL_TLSData *data)
return 0;
}
+void SDL_SYS_QuitTLSData(void)
+{
+ ULONG ulRC;
+
+ if (ppSDLTLSData) {
+ /* Free the thread local memory */
+ ulRC = DosFreeThreadLocalMemory((PULONG)ppSDLTLSData);
+ if (ulRC != NO_ERROR) {
+ debug_os2("DosFreeThreadLocalMemory() failed, rc = %u", ulRC);
+ } else {
+ ppSDLTLSData = NULL;
+ }
+ }
+}
+
#endif /* SDL_THREAD_OS2 */
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/os2/SDL_systls_c.h b/src/thread/os2/SDL_systls_c.h
index bb39443794e50..ad4fcefad98b3 100644
--- a/src/thread/os2/SDL_systls_c.h
+++ b/src/thread/os2/SDL_systls_c.h
@@ -27,12 +27,4 @@
extern SDL_TLSData **ppSDLTLSData;
-/* SDL_OS2TLSAlloc() called from SDL_InitSubSystem() */
-void SDL_OS2TLSAlloc(void);
-
-/* SDL_OS2TLSFree() called from SDL_QuitSubSystem() */
-void SDL_OS2TLSFree(void);
-
#endif /* SDL_THREAD_OS2 */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/pthread/SDL_syscond.c b/src/thread/pthread/SDL_syscond.c
index a1a2e63b90129..c7583dcfef61e 100644
--- a/src/thread/pthread/SDL_syscond.c
+++ b/src/thread/pthread/SDL_syscond.c
@@ -114,7 +114,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
abstime.tv_sec = delta.tv_sec + (ms / 1000);
abstime.tv_nsec = (long)(delta.tv_usec + (ms % 1000) * 1000) * 1000;
#endif
- if (abstime.tv_nsec > 1000000000) {
+ if (abstime.tv_nsec >= 1000000000) {
abstime.tv_sec += 1;
abstime.tv_nsec -= 1000000000;
}
diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c
index 6d0cdd5c2a858..9894bab4dd4c2 100644
--- a/src/thread/pthread/SDL_syssem.c
+++ b/src/thread/pthread/SDL_syssem.c
@@ -141,7 +141,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
#endif
/* Wrap the second if needed */
- if (ts_timeout.tv_nsec > 1000000000) {
+ if (ts_timeout.tv_nsec >= 1000000000) {
ts_timeout.tv_sec += 1;
ts_timeout.tv_nsec -= 1000000000;
}
diff --git a/src/thread/pthread/SDL_systls.c b/src/thread/pthread/SDL_systls.c
index 0618cb3c59226..6f9ad8c509440 100644
--- a/src/thread/pthread/SDL_systls.c
+++ b/src/thread/pthread/SDL_systls.c
@@ -30,27 +30,27 @@
static pthread_key_t thread_local_storage = INVALID_PTHREAD_KEY;
static SDL_bool generic_local_storage = SDL_FALSE;
-SDL_TLSData *SDL_SYS_GetTLSData(void)
+void SDL_SYS_InitTLSData(void)
{
if (thread_local_storage == INVALID_PTHREAD_KEY && !generic_local_storage) {
- static SDL_SpinLock lock;
- SDL_AtomicLock(&lock);
- if (thread_local_storage == INVALID_PTHREAD_KEY && !generic_local_storage) {
- pthread_key_t storage;
- if (pthread_key_create(&storage, NULL) == 0) {
- SDL_MemoryBarrierRelease();
- thread_local_storage = storage;
- } else {
- generic_local_storage = SDL_TRUE;
- }
+ if (pthread_key_create(&thread_local_storage, NULL) != 0) {
+ thread_local_storage = INVALID_PTHREAD_KEY;
+ SDL_Generic_InitTLSData();
+ generic_local_storage = SDL_TRUE;
}
- SDL_AtomicUnlock(&lock);
}
+}
+
+SDL_TLSData *SDL_SYS_GetTLSData(void)
+{
if (generic_local_storage) {
return SDL_Generic_GetTLSData();
}
- SDL_MemoryBarrierAcquire();
- return (SDL_TLSData *)pthread_getspecific(thread_local_storage);
+
+ if (thread_local_storage != INVALID_PTHREAD_KEY) {
+ return (SDL_TLSData *)pthread_getspecific(thread_local_storage);
+ }
+ return NULL;
}
int SDL_SYS_SetTLSData(SDL_TLSData *data)
@@ -58,10 +58,24 @@ int SDL_SYS_SetTLSData(SDL_TLSData *data)
if (generic_local_storage) {
return SDL_Generic_SetTLSData(data);
}
+
if (pthread_setspecific(thread_local_storage, data) != 0) {
return SDL_SetError("pthread_setspecific() failed");
}
return 0;
}
+void SDL_SYS_QuitTLSData(void)
+{
+ if (generic_local_storage) {
+ SDL_Generic_QuitTLSData();
+ generic_local_storage = SDL_FALSE;
+ } else {
+ if (thread_local_storage != INVALID_PTHREAD_KEY) {
+ pthread_key_delete(thread_local_storage);
+ thread_local_storage = INVALID_PTHREAD_KEY;
+ }
+ }
+}
+
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/stdcpp/SDL_systhread.cpp b/src/thread/stdcpp/SDL_systhread.cpp
index 5b052bf373656..502fabc454bb7 100644
--- a/src/thread/stdcpp/SDL_systhread.cpp
+++ b/src/thread/stdcpp/SDL_systhread.cpp
@@ -157,16 +157,29 @@ SDL_SYS_DetachThread(SDL_Thread *thread)
}
}
-extern "C" SDL_TLSData *
-SDL_SYS_GetTLSData(void)
+static thread_local SDL_TLSData *thread_local_storage;
+
+extern "C"
+void SDL_SYS_InitTLSData(void)
{
- return SDL_Generic_GetTLSData();
}
-extern "C" int
-SDL_SYS_SetTLSData(SDL_TLSData *data)
+extern "C"
+SDL_TLSData * SDL_SYS_GetTLSData(void)
+{
+ return thread_local_storage;
+}
+
+extern "C"
+int SDL_SYS_SetTLSData(SDL_TLSData *data)
+{
+ thread_local_storage = data;
+ return 0;
+}
+
+extern "C"
+void SDL_SYS_QuitTLSData(void)
{
- return SDL_Generic_SetTLSData(data);
}
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/windows/SDL_systls.c b/src/thread/windows/SDL_systls.c
index 9ae61b39eaf0d..08a9cfbe9343b 100644
--- a/src/thread/windows/SDL_systls.c
+++ b/src/thread/windows/SDL_systls.c
@@ -43,27 +43,27 @@
static DWORD thread_local_storage = TLS_OUT_OF_INDEXES;
static SDL_bool generic_local_storage = SDL_FALSE;
-SDL_TLSData *SDL_SYS_GetTLSData(void)
+void SDL_SYS_InitTLSData(void)
{
if (thread_local_storage == TLS_OUT_OF_INDEXES && !generic_local_storage) {
- static SDL_SpinLock lock;
- SDL_AtomicLock(&lock);
- if (thread_local_storage == TLS_OUT_OF_INDEXES && !generic_local_storage) {
- DWORD storage = TlsAlloc();
- if (storage != TLS_OUT_OF_INDEXES) {
- SDL_MemoryBarrierRelease();
- thread_local_storage = storage;
- } else {
- generic_local_storage = SDL_TRUE;
- }
+ thread_local_storage = TlsAlloc();
+ if (thread_local_storage == TLS_OUT_OF_INDEXES) {
+ SDL_Generic_InitTLSData();
+ generic_local_storage = SDL_TRUE;
}
- SDL_AtomicUnlock(&lock);
}
+}
+
+SDL_TLSData *SDL_SYS_GetTLSData(void)
+{
if (generic_local_storage) {
return SDL_Generic_GetTLSData();
}
- SDL_MemoryBarrierAcquire();
- return (SDL_TLSData *)TlsGetValue(thread_local_storage);
+
+ if (thread_local_storage != TLS_OUT_OF_INDEXES) {
+ return (SDL_TLSData *)TlsGetValue(thread_local_storage);
+ }
+ return NULL;
}
int SDL_SYS_SetTLSData(SDL_TLSData *data)
@@ -71,12 +71,26 @@ int SDL_SYS_SetTLSData(SDL_TLSData *data)
if (generic_local_storage) {
return SDL_Generic_SetTLSData(data);
}
+
if (!TlsSetValue(thread_local_storage, data)) {
- return SDL_SetError("TlsSetValue() failed");
+ return WIN_SetError("TlsSetValue()");
}
return 0;
}
+void SDL_SYS_QuitTLSData(void)
+{
+ if (generic_local_storage) {
+ SDL_Generic_QuitTLSData();
+ generic_local_storage = SDL_FALSE;
+ } else {
+ if (thread_local_storage != TLS_OUT_OF_INDEXES) {
+ TlsFree(thread_local_storage);
+ thread_local_storage = TLS_OUT_OF_INDEXES;
+ }
+ }
+}
+
#endif /* SDL_THREAD_WINDOWS */
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c
index 19d47a17f8557..b54d04cf221cb 100644
--- a/src/video/SDL_blit.c
+++ b/src/video/SDL_blit.c
@@ -103,7 +103,7 @@ static int SDLCALL SDL_SoftBlit(SDL_Surface *src, SDL_Rect *srcrect,
#ifdef __MACOSX__
#include
-static SDL_bool SDL_UseAltivecPrefetch()
+static SDL_bool SDL_UseAltivecPrefetch(void)
{
const char key[] = "hw.l3cachesize";
u_int64_t result = 0;
diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c
index a2bae057820f7..dbeabc4644a25 100644
--- a/src/video/SDL_stretch.c
+++ b/src/video/SDL_stretch.c
@@ -367,7 +367,7 @@ static void printf_128(const char *str, __m128i var)
}
#endif
-static SDL_INLINE int hasSSE2()
+static SDL_INLINE int hasSSE2(void)
{
static int val = -1;
if (val != -1) {
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index f171ff4a36e5c..66fa3f4e0ccf3 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -2688,14 +2688,6 @@ static SDL_bool ShouldAttemptTextureFramebuffer(void)
attempt_texture_framebuffer = SDL_FALSE;
#endif
}
-
- if (attempt_texture_framebuffer) {
- /* Using a software renderer will try to display on a window surface, so avoid recursion here */
- hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
- if (hint && SDL_strcasecmp(hint, "software") == 0) {
- attempt_texture_framebuffer = SDL_FALSE;
- }
- }
return attempt_texture_framebuffer;
}
diff --git a/src/video/android/SDL_androidmouse.c b/src/video/android/SDL_androidmouse.c
index 29ee05e356430..19a70044c677c 100644
--- a/src/video/android/SDL_androidmouse.c
+++ b/src/video/android/SDL_androidmouse.c
@@ -78,7 +78,7 @@ static SDL_Cursor *Android_WrapCursor(int custom_cursor, int system_cursor)
return cursor;
}
-static SDL_Cursor *Android_CreateDefaultCursor()
+static SDL_Cursor *Android_CreateDefaultCursor(void)
{
return Android_WrapCursor(0, SDL_SYSTEM_CURSOR_ARROW);
}
@@ -116,7 +116,7 @@ static void Android_FreeCursor(SDL_Cursor *cursor)
SDL_free(cursor);
}
-static SDL_Cursor *Android_CreateEmptyCursor()
+static SDL_Cursor *Android_CreateEmptyCursor(void)
{
if (!empty_cursor) {
SDL_Surface *empty_surface = SDL_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888);
@@ -129,7 +129,7 @@ static SDL_Cursor *Android_CreateEmptyCursor()
return empty_cursor;
}
-static void Android_DestroyEmptyCursor()
+static void Android_DestroyEmptyCursor(void)
{
if (empty_cursor) {
Android_FreeCursor(empty_cursor);
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 828366095c5da..8e22a0c17c462 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -933,11 +933,13 @@ - (void)windowDidChangeScreenProfile:(NSNotification *)aNotification
- (void)windowDidChangeScreen:(NSNotification *)aNotification
{
/*printf("WINDOWDIDCHANGESCREEN\n");*/
+#ifdef SDL_VIDEO_OPENGL
if (_data && _data.nscontexts) {
for (SDLOpenGLContext *context in _data.nscontexts) {
[context movedToNewScreen];
}
}
+#endif /* SDL_VIDEO_OPENGL */
}
- (void)windowWillEnterFullScreen:(NSNotification *)aNotification
@@ -2346,7 +2348,10 @@ void Cocoa_DestroyWindow(_THIS, SDL_Window * window)
SDL_WindowData *data = (SDL_WindowData *) CFBridgingRelease(window->driverdata);
if (data) {
+#ifdef SDL_VIDEO_OPENGL
NSArray *contexts;
+#endif
+
if ([data.listener isInFullscreenSpace]) {
[NSMenu setMenuBarVisible:YES];
}
@@ -2358,15 +2363,13 @@ void Cocoa_DestroyWindow(_THIS, SDL_Window * window)
[data.nswindow close];
}
- #ifdef SDL_VIDEO_OPENGL
-
+#ifdef SDL_VIDEO_OPENGL
contexts = [data.nscontexts copy];
for (SDLOpenGLContext *context in contexts) {
/* Calling setWindow:NULL causes the context to remove itself from the context list. */
[context setWindow:NULL];
}
-
- #endif /* SDL_VIDEO_OPENGL */
+#endif /* SDL_VIDEO_OPENGL */
if (window->shaper) {
CFBridgingRelease(window->shaper->driverdata);
diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c
index 0d96f860021a6..7fe4b81af7444 100644
--- a/src/video/directfb/SDL_DirectFB_render.c
+++ b/src/video/directfb/SDL_DirectFB_render.c
@@ -561,7 +561,7 @@ static void DirectFB_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * textur
}
}
-static void DirectFB_SetTextureScaleMode()
+static void DirectFB_SetTextureScaleMode(void)
{
}
diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c
index 930e9891215e6..6387379eb149d 100644
--- a/src/video/dummy/SDL_nullvideo.c
+++ b/src/video/dummy/SDL_nullvideo.c
@@ -131,7 +131,7 @@ VideoBootStrap DUMMY_evdev_bootstrap = {
NULL /* no ShowMessageBox implementation */
};
void SDL_EVDEV_Init(void);
-void SDL_EVDEV_Poll();
+void SDL_EVDEV_Poll(void);
void SDL_EVDEV_Quit(void);
static void DUMMY_EVDEV_Poll(_THIS)
{
diff --git a/src/video/emscripten/SDL_emscriptenmouse.c b/src/video/emscripten/SDL_emscriptenmouse.c
index d189e5393cbfa..7d4601f42b0f5 100644
--- a/src/video/emscripten/SDL_emscriptenmouse.c
+++ b/src/video/emscripten/SDL_emscriptenmouse.c
@@ -222,7 +222,7 @@ static int Emscripten_SetRelativeMouseMode(SDL_bool enabled)
return -1;
}
-void Emscripten_InitMouse()
+void Emscripten_InitMouse(void)
{
SDL_Mouse *mouse = SDL_GetMouse();
@@ -236,7 +236,7 @@ void Emscripten_InitMouse()
SDL_SetDefaultCursor(Emscripten_CreateDefaultCursor());
}
-void Emscripten_FiniMouse()
+void Emscripten_FiniMouse(void)
{
}
diff --git a/src/video/kmsdrm/SDL_kmsdrmsym.h b/src/video/kmsdrm/SDL_kmsdrmsym.h
index 49680448984c1..7a99e1b6a3302 100644
--- a/src/video/kmsdrm/SDL_kmsdrmsym.h
+++ b/src/video/kmsdrm/SDL_kmsdrmsym.h
@@ -133,6 +133,7 @@ SDL_KMSDRM_SYM(uint64_t,gbm_bo_get_modifier,(struct gbm_bo *bo))
SDL_KMSDRM_SYM(int,gbm_bo_get_plane_count,(struct gbm_bo *bo))
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane))
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo, int plane))
+SDL_KMSDRM_SYM(union gbm_bo_handle,gbm_bo_get_handle_for_plane,(struct gbm_bo *bo, int plane);)
#undef SDL_KMSDRM_MODULE
#undef SDL_KMSDRM_SYM
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index 2dab65cbccc0e..e4457921c46ae 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -368,16 +368,29 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
num_planes = KMSDRM_gbm_bo_get_plane_count(bo);
for (int i = 0; i < num_planes; i++) {
strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i);
- handles[i] = KMSDRM_gbm_bo_get_handle(bo).u32;
+ handles[i] = KMSDRM_gbm_bo_get_handle_for_plane(bo, i).u32;
offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i);
modifiers[i] = modifiers[0];
}
- if (modifiers[0]) {
+ if (modifiers[0] && modifiers[0] != DRM_FORMAT_MOD_INVALID) {
flags = DRM_MODE_FB_MODIFIERS;
}
ret = KMSDRM_drmModeAddFB2WithModifiers(viddata->drm_fd, w, h, format, handles, strides, offsets, modifiers, &fb_info->fb_id, flags);
+
+ if (ret) {
+ handles[0] = KMSDRM_gbm_bo_get_handle(bo).u32;
+ strides[0] = KMSDRM_gbm_bo_get_stride(bo);
+ offsets[0] = 0;
+ for (int i = 1; i<4; i++) {
+ handles[i] = 0;
+ strides[i] = 0;
+ offsets[i] = 0;
+ }
+ ret = KMSDRM_drmModeAddFB2(viddata->drm_fd, w, h, format, handles, strides, offsets, &fb_info->fb_id, 0);
+ }
+
if (ret) {
SDL_free(fb_info);
return NULL;
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h
index 096f00cd162d6..1fe77f697b5e3 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.h
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h
@@ -33,6 +33,10 @@
#include
#include
+#ifndef DRM_FORMAT_MOD_INVALID
+#define DRM_FORMAT_MOD_INVALID 0x00ffffffffffffffULL
+#endif
+
#ifndef DRM_MODE_FB_MODIFIERS
#define DRM_MODE_FB_MODIFIERS 2
#endif
diff --git a/src/video/n3ds/SDL_n3dsswkb.c b/src/video/n3ds/SDL_n3dsswkb.c
index 9a35d272b6e6a..1543c0b004e2d 100644
--- a/src/video/n3ds/SDL_n3dsswkb.c
+++ b/src/video/n3ds/SDL_n3dsswkb.c
@@ -30,17 +30,17 @@
static SwkbdState sw_keyboard;
const static size_t BUFFER_SIZE = 256;
-void N3DS_SwkbInit()
+void N3DS_SwkbInit(void)
{
swkbdInit(&sw_keyboard, SWKBD_TYPE_NORMAL, 2, -1);
}
-void N3DS_SwkbPoll()
+void N3DS_SwkbPoll(void)
{
return;
}
-void N3DS_SwkbQuit()
+void N3DS_SwkbQuit(void)
{
return;
}
diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c
index 1442607b1c911..1bcddc3b83c45 100644
--- a/src/video/raspberry/SDL_rpivideo.c
+++ b/src/video/raspberry/SDL_rpivideo.c
@@ -56,7 +56,7 @@ static void RPI_Destroy(SDL_VideoDevice *device)
SDL_free(device);
}
-static int RPI_GetRefreshRate()
+static int RPI_GetRefreshRate(void)
{
TV_DISPLAY_STATE_T tvstate;
if (vc_tv_get_display_state(&tvstate) == 0) {
diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c
index ab78b33930f98..9aff010470a74 100644
--- a/src/video/wayland/SDL_waylandmouse.c
+++ b/src/video/wayland/SDL_waylandmouse.c
@@ -202,7 +202,6 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa
int size = 0;
SDL_Window *focus;
- SDL_WindowData *focusdata;
int i;
#ifdef SDL_VIDEO_DRIVER_WAYLAND_WEBOS
@@ -286,16 +285,17 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa
}
/* First, find the appropriate theme based on the current scale... */
focus = SDL_GetMouse()->focus;
- if (!focus) {
- /* Nothing to see here, bail. */
- return SDL_FALSE;
+ if (focus) {
+ SDL_WindowData *focusdata = (SDL_WindowData*)focus->driverdata;
+
+ /* Cursors use integer scaling. */
+ *scale = SDL_ceilf(focusdata->scale_factor);
+ } else {
+ *scale = 1.0f;
}
- focusdata = focus->driverdata;
- /* Cursors use integer scaling. */
- *scale = SDL_ceilf(focusdata->scale_factor);
- size *= *scale;
- for (i = 0; i < vdata->num_cursor_themes; i += 1) {
+ size *= (int)*scale;
+ for (i = 0; i < vdata->num_cursor_themes; ++i) {
if (vdata->cursor_themes[i].size == size) {
theme = vdata->cursor_themes[i].theme;
break;
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index be20415c157c7..873700de95c56 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -87,7 +87,7 @@ static void Wayland_VideoQuit(_THIS);
/* Find out what class name we should use
* Based on src/video/x11/SDL_x11video.c */
-static char *get_classname()
+static char *get_classname(void)
{
/* !!! FIXME: this is probably wrong, albeit harmless in many common cases. From protocol spec:
"The surface class identifies the general class of applications
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 35bae2596a504..75feb5cbee763 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -327,7 +327,7 @@ static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
}
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
-static SDL_bool WIN_ShouldIgnoreFocusClick()
+static SDL_bool WIN_ShouldIgnoreFocusClick(void)
{
return !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE);
}
@@ -1794,7 +1794,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
-static void WIN_UpdateClipCursorForWindows()
+static void WIN_UpdateClipCursorForWindows(void)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
SDL_Window *window;
@@ -1816,7 +1816,7 @@ static void WIN_UpdateClipCursorForWindows()
}
}
-static void WIN_UpdateMouseCapture()
+static void WIN_UpdateMouseCapture(void)
{
SDL_Window *focusWindow = SDL_GetKeyboardFocus();
@@ -2090,7 +2090,7 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
}
/* Unregisters the windowclass registered in SDL_RegisterApp above. */
-void SDL_UnregisterApp()
+void SDL_UnregisterApp(void)
{
WNDCLASSEX wcex;
diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c
index 1ae4fe00bccee..9e6acac2fc46b 100644
--- a/src/video/windows/SDL_windowskeyboard.c
+++ b/src/video/windows/SDL_windowskeyboard.c
@@ -166,7 +166,7 @@ void WIN_QuitKeyboard(_THIS)
#endif /* !SDL_DISABLE_WINDOWS_IME */
}
-void WIN_ResetDeadKeys()
+void WIN_ResetDeadKeys(void)
{
/*
if a deadkey has been typed, but not the next character (which the deadkey might modify),
@@ -367,7 +367,7 @@ static void UILess_ReleaseSinks(SDL_VideoData *videodata);
static void UILess_EnableUIUpdates(SDL_VideoData *videodata);
static void UILess_DisableUIUpdates(SDL_VideoData *videodata);
-static SDL_bool WIN_ShouldShowNativeUI()
+static SDL_bool WIN_ShouldShowNativeUI(void)
{
return SDL_GetHintBoolean(SDL_HINT_IME_SHOW_UI, SDL_FALSE);
}
diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c
index 214197b6b0d01..127bdc6895788 100644
--- a/src/video/windows/SDL_windowsmouse.c
+++ b/src/video/windows/SDL_windowsmouse.c
@@ -474,7 +474,7 @@ static void WIN_SetLinearMouseScale(int mouse_speed)
}
}
-void WIN_UpdateMouseSystemScale()
+void WIN_UpdateMouseSystemScale(void)
{
int mouse_speed;
int params[3] = { 0, 0, 0 };
diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c
index ba505f1e78206..4cbebed934a86 100644
--- a/src/video/windows/SDL_windowsopengl.c
+++ b/src/video/windows/SDL_windowsopengl.c
@@ -642,6 +642,7 @@ static int WIN_GL_SetupWindowInternal(_THIS, SDL_Window *window)
}
if (_this->gl_config.floatbuffers) {
+ *iAttr++ = WGL_PIXEL_TYPE_ARB;
*iAttr++ = WGL_TYPE_RGBA_FLOAT_ARB;
}
diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c
index 30563fc6e9bef..da252615f0b74 100644
--- a/src/video/x11/SDL_x11opengl.c
+++ b/src/video/x11/SDL_x11opengl.c
@@ -575,6 +575,7 @@ static int X11_GL_GetAttributes(_THIS, Display *display, int screen, int *attrib
}
if (_this->gl_config.floatbuffers) {
+ attribs[i++] = GLX_RENDER_TYPE;
attribs[i++] = GLX_RGBA_FLOAT_TYPE_ARB;
}
diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c
index 6a543c186c9be..2377f2b7939b8 100644
--- a/src/video/x11/SDL_x11video.c
+++ b/src/video/x11/SDL_x11video.c
@@ -50,7 +50,7 @@ static int X11_VideoInit(_THIS);
static void X11_VideoQuit(_THIS);
/* Find out what class name we should use */
-static char *get_classname()
+static char *get_classname(void)
{
char *spot;
#if defined(__LINUX__) || defined(__FREEBSD__)
diff --git a/src/video/x11/SDL_x11xfixes.c b/src/video/x11/SDL_x11xfixes.c
index 6ae7e053ff818..e624f16e1c288 100644
--- a/src/video/x11/SDL_x11xfixes.c
+++ b/src/video/x11/SDL_x11xfixes.c
@@ -74,12 +74,12 @@ void X11_InitXfixes(_THIS)
xfixes_initialized = 1;
}
-int X11_XfixesIsInitialized()
+int X11_XfixesIsInitialized(void)
{
return xfixes_initialized;
}
-int X11_GetXFixesSelectionNotifyEvent()
+int X11_GetXFixesSelectionNotifyEvent(void)
{
return xfixes_selection_notify_event;
}
diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c
index afed858174422..9d673b5f69c0c 100644
--- a/src/video/x11/SDL_x11xinput2.c
+++ b/src/video/x11/SDL_x11xinput2.c
@@ -453,7 +453,7 @@ void X11_Xinput2SelectTouch(_THIS, SDL_Window *window)
#endif
}
-int X11_Xinput2IsInitialized()
+int X11_Xinput2IsInitialized(void)
{
#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2
return xinput2_initialized;
@@ -462,7 +462,7 @@ int X11_Xinput2IsInitialized()
#endif
}
-int X11_Xinput2IsMultitouchSupported()
+int X11_Xinput2IsMultitouchSupported(void)
{
#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
return xinput2_initialized && xinput2_multitouch_supported;
diff --git a/test/checkkeys.c b/test/checkkeys.c
index f546900c50794..f37f3c489c8e4 100644
--- a/test/checkkeys.c
+++ b/test/checkkeys.c
@@ -107,7 +107,7 @@ print_modifiers(char **text, size_t *maxlen)
}
static void
-PrintModifierState()
+PrintModifierState(void)
{
char message[512];
char *spot;
@@ -166,7 +166,7 @@ PrintText(const char *eventtype, const char *text)
SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text);
}
-void loop()
+void loop(void)
{
SDL_Event event;
/* Check for events */
diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c
index efd654875f935..fe0408c450d3d 100644
--- a/test/checkkeysthreads.c
+++ b/test/checkkeysthreads.c
@@ -103,7 +103,7 @@ print_modifiers(char **text, size_t *maxlen)
}
static void
-PrintModifierState()
+PrintModifierState(void)
{
char message[512];
char *spot;
@@ -162,7 +162,7 @@ PrintText(const char *eventtype, const char *text)
SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text);
}
-void loop()
+void loop(void)
{
SDL_Event event;
/* Check for events */
diff --git a/test/loopwave.c b/test/loopwave.c
index 15f13658c5ea0..eb98c74df7a5c 100644
--- a/test/loopwave.c
+++ b/test/loopwave.c
@@ -46,7 +46,7 @@ quit(int rc)
}
static void
-close_audio()
+close_audio(void)
{
if (device != 0) {
SDL_CloseAudioDevice(device);
@@ -55,7 +55,7 @@ close_audio()
}
static void
-open_audio()
+open_audio(void)
{
/* Initialize fillerup() variables */
device = SDL_OpenAudioDevice(NULL, SDL_FALSE, &wave.spec, NULL, 0);
@@ -70,7 +70,7 @@ open_audio()
}
#ifndef __EMSCRIPTEN__
-static void reopen_audio()
+static void reopen_audio(void)
{
close_audio();
open_audio();
@@ -103,7 +103,7 @@ fillerup(void *unused, Uint8 *stream, int len)
static int done = 0;
#ifdef __EMSCRIPTEN__
-void loop()
+void loop(void)
{
if (done || (SDL_GetAudioDeviceStatus(device) != SDL_AUDIO_PLAYING)) {
emscripten_cancel_main_loop();
diff --git a/test/loopwavequeue.c b/test/loopwavequeue.c
index 01b6ece3e39c3..68c0b01e77e52 100644
--- a/test/loopwavequeue.c
+++ b/test/loopwavequeue.c
@@ -48,7 +48,7 @@ void poked(int sig)
done = 1;
}
-void loop()
+void loop(void)
{
#ifdef __EMSCRIPTEN__
if (done || (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING)) {
diff --git a/test/testatomic.c b/test/testatomic.c
index 1a599101ec339..c19415ac16a4d 100644
--- a/test/testatomic.c
+++ b/test/testatomic.c
@@ -31,7 +31,7 @@ tf(SDL_bool _tf)
return f;
}
-static void RunBasicTest()
+static void RunBasicTest(void)
{
int value;
SDL_SpinLock lock = 0;
@@ -153,7 +153,7 @@ static void runAdder(void)
SDL_Log("Finished in %f sec\n", (end - start) / 1000.f);
}
-static void RunEpicTest()
+static void RunEpicTest(void)
{
int b;
atomicValue v;
diff --git a/test/testaudiocapture.c b/test/testaudiocapture.c
index 523385b3ae484..c09c40086c833 100644
--- a/test/testaudiocapture.c
+++ b/test/testaudiocapture.c
@@ -24,7 +24,7 @@ static SDL_AudioDeviceID devid_in = 0;
static SDL_AudioDeviceID devid_out = 0;
static void
-loop()
+loop(void)
{
SDL_bool please_quit = SDL_FALSE;
SDL_Event e;
diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c
index 354d4644f3c0e..692bada915966 100644
--- a/test/testaudiohotplug.c
+++ b/test/testaudiohotplug.c
@@ -81,7 +81,7 @@ devtypestr(int iscapture)
}
static void
-iteration()
+iteration(void)
{
SDL_Event e;
SDL_AudioDeviceID dev;
@@ -124,7 +124,7 @@ iteration()
}
#ifdef __EMSCRIPTEN__
-void loop()
+void loop(void)
{
if (done)
emscripten_cancel_main_loop();
diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c
index 16ab753e9787d..1564f05541f2b 100644
--- a/test/testautomation_audio.c
+++ b/test/testautomation_audio.c
@@ -96,7 +96,7 @@ static SDL_bool DriverIsProblematic(const char *driver)
* \sa https://wiki.libsdl.org/SDL_QuitSubSystem
* \sa https://wiki.libsdl.org/SDL_InitSubSystem
*/
-int audio_quitInitAudioSubSystem()
+int audio_quitInitAudioSubSystem(void)
{
/* Stop SDL audio subsystem */
SDL_QuitSubSystem(SDL_INIT_AUDIO);
@@ -114,7 +114,7 @@ int audio_quitInitAudioSubSystem()
* \sa https://wiki.libsdl.org/SDL_InitAudio
* \sa https://wiki.libsdl.org/SDL_QuitAudio
*/
-int audio_initQuitAudio()
+int audio_initQuitAudio(void)
{
int result;
int i, iMax;
@@ -195,7 +195,7 @@ int audio_initQuitAudio()
* \sa https://wiki.libsdl.org/SDL_CloseAudio
* \sa https://wiki.libsdl.org/SDL_QuitAudio
*/
-int audio_initOpenCloseQuitAudio()
+int audio_initOpenCloseQuitAudio(void)
{
int result, expectedResult;
int i, iMax, j, k;
@@ -318,7 +318,7 @@ int audio_initOpenCloseQuitAudio()
*
* \sa https://wiki.libsdl.org/SDL_PauseAudio
*/
-int audio_pauseUnpauseAudio()
+int audio_pauseUnpauseAudio(void)
{
int result;
int i, iMax, j, k, l;
@@ -474,7 +474,7 @@ int audio_pauseUnpauseAudio()
* \sa https://wiki.libsdl.org/SDL_GetNumAudioDevices
* \sa https://wiki.libsdl.org/SDL_GetAudioDeviceName
*/
-int audio_enumerateAndNameAudioDevices()
+int audio_enumerateAndNameAudioDevices(void)
{
int t, tt;
int i, n, nn;
@@ -532,7 +532,7 @@ int audio_enumerateAndNameAudioDevices()
* \sa https://wiki.libsdl.org/SDL_GetNumAudioDevices
* \sa https://wiki.libsdl.org/SDL_GetAudioDeviceName
*/
-int audio_enumerateAndNameAudioDevicesNegativeTests()
+int audio_enumerateAndNameAudioDevicesNegativeTests(void)
{
int t;
int i, j, no, nc;
@@ -578,7 +578,7 @@ int audio_enumerateAndNameAudioDevicesNegativeTests()
* \sa https://wiki.libsdl.org/SDL_GetNumAudioDrivers
* \sa https://wiki.libsdl.org/SDL_GetAudioDriver
*/
-int audio_printAudioDrivers()
+int audio_printAudioDrivers(void)
{
int i, n;
const char *name;
@@ -608,7 +608,7 @@ int audio_printAudioDrivers()
*
* \sa https://wiki.libsdl.org/SDL_GetCurrentAudioDriver
*/
-int audio_printCurrentAudioDriver()
+int audio_printCurrentAudioDriver(void)
{
/* Check current audio driver */
const char *name = SDL_GetCurrentAudioDriver();
@@ -639,7 +639,7 @@ int _audioFrequencies[] = { 11025, 22050, 44100, 48000 };
*
* \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
*/
-int audio_buildAudioCVT()
+int audio_buildAudioCVT(void)
{
int result;
SDL_AudioCVT cvt;
@@ -703,7 +703,7 @@ int audio_buildAudioCVT()
*
* \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
*/
-int audio_buildAudioCVTNegative()
+int audio_buildAudioCVTNegative(void)
{
const char *expectedError = "Parameter 'cvt' is invalid";
const char *error;
@@ -798,7 +798,7 @@ int audio_buildAudioCVTNegative()
*
* \sa https://wiki.libsdl.org/SDL_GetAudioStatus
*/
-int audio_getAudioStatus()
+int audio_getAudioStatus(void)
{
SDL_AudioStatus result;
@@ -817,7 +817,7 @@ int audio_getAudioStatus()
*
* \sa https://wiki.libsdl.org/SDL_GetAudioStatus
*/
-int audio_openCloseAndGetAudioStatus()
+int audio_openCloseAndGetAudioStatus(void)
{
SDL_AudioStatus result;
int i;
@@ -878,7 +878,7 @@ int audio_openCloseAndGetAudioStatus()
* \sa https://wiki.libsdl.org/SDL_LockAudioDevice
* \sa https://wiki.libsdl.org/SDL_UnlockAudioDevice
*/
-int audio_lockUnlockOpenAudioDevice()
+int audio_lockUnlockOpenAudioDevice(void)
{
int i;
int count;
@@ -942,7 +942,7 @@ int audio_lockUnlockOpenAudioDevice()
* \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
* \sa https://wiki.libsdl.org/SDL_ConvertAudio
*/
-int audio_convertAudio()
+int audio_convertAudio(void)
{
int result;
SDL_AudioCVT cvt;
@@ -1043,7 +1043,7 @@ int audio_convertAudio()
*
* \sa https://wiki.libsdl.org/SDL_AudioDeviceConnected
*/
-int audio_openCloseAudioDeviceConnected()
+int audio_openCloseAudioDeviceConnected(void)
{
int result = -1;
int i;
@@ -1118,7 +1118,7 @@ static double sine_wave_sample(const Sint64 idx, const Sint64 rate, const Sint64
* \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
* \sa https://wiki.libsdl.org/SDL_ConvertAudio
*/
-int audio_resampleLoss()
+int audio_resampleLoss(void)
{
/* Note: always test long input time (>= 5s from experience) in some test
* cases because an improper implementation may suffer from low resampling
diff --git a/test/testautomation_keyboard.c b/test/testautomation_keyboard.c
index 5ed9207bca5f6..d59f2fdd8c3ba 100644
--- a/test/testautomation_keyboard.c
+++ b/test/testautomation_keyboard.c
@@ -102,7 +102,7 @@ int keyboard_getKeyFromName(void *arg)
/*
* Local helper to check for the invalid scancode error message
*/
-void _checkInvalidScancodeError()
+void _checkInvalidScancodeError(void)
{
const char *expectedError = "Parameter 'scancode' is invalid";
const char *error;
@@ -574,7 +574,7 @@ int keyboard_getScancodeFromName(void *arg)
/*
* Local helper to check for the invalid scancode error message
*/
-void _checkInvalidNameError()
+void _checkInvalidNameError(void)
{
const char *expectedError = "Parameter 'name' is invalid";
const char *error;
diff --git a/test/testautomation_log.c b/test/testautomation_log.c
index 4edb487ea3102..1ad1894e6d393 100644
--- a/test/testautomation_log.c
+++ b/test/testautomation_log.c
@@ -21,7 +21,7 @@ static void EnableTestLog(int *message_count)
SDL_LogSetOutputFunction(TestLogOutput, message_count);
}
-static void DisableTestLog()
+static void DisableTestLog(void)
{
SDL_LogSetOutputFunction(original_function, original_userdata);
}
diff --git a/test/testautomation_subsystems.c b/test/testautomation_subsystems.c
index d25edeeb7ce82..15b17535904f4 100644
--- a/test/testautomation_subsystems.c
+++ b/test/testautomation_subsystems.c
@@ -40,7 +40,7 @@ static void subsystemsTearDown(void *arg)
* \sa SDL_QuitSubSystem
*
*/
-static int subsystems_referenceCount()
+static int subsystems_referenceCount(void)
{
const int system = SDL_INIT_VIDEO;
int result;
@@ -90,7 +90,7 @@ static int subsystems_referenceCount()
* \sa SDL_QuitSubSystem
*
*/
-static int subsystems_dependRefCountInitAllQuitByOne()
+static int subsystems_dependRefCountInitAllQuitByOne(void)
{
int result;
/* Ensure that we start with reset subsystems. */
@@ -128,7 +128,7 @@ static int subsystems_dependRefCountInitAllQuitByOne()
* \sa SDL_QuitSubSystem
*
*/
-static int subsystems_dependRefCountInitByOneQuitAll()
+static int subsystems_dependRefCountInitByOneQuitAll(void)
{
int result;
/* Ensure that we start with reset subsystems. */
@@ -163,7 +163,7 @@ static int subsystems_dependRefCountInitByOneQuitAll()
* \sa SDL_QuitSubSystem
*
*/
-static int subsystems_dependRefCountWithExtraInit()
+static int subsystems_dependRefCountWithExtraInit(void)
{
int result;
/* Ensure that we start with reset subsystems. */
diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c
index e86704a6b2ddf..575ebcfb41060 100644
--- a/test/testautomation_surface.c
+++ b/test/testautomation_surface.c
@@ -81,7 +81,7 @@ void _surfaceTearDown(void *arg)
/**
* Helper that clears the test surface
*/
-void _clearTestSurface()
+void _clearTestSurface(void)
{
int ret;
Uint32 color;
diff --git a/test/testautomation_video.c b/test/testautomation_video.c
index af49c0041cc8a..bf24bbb089a0e 100644
--- a/test/testautomation_video.c
+++ b/test/testautomation_video.c
@@ -624,7 +624,7 @@ int video_getWindowDisplayMode(void *arg)
}
/* Helper function that checks for an 'Invalid window' error */
-void _checkInvalidWindowError()
+void _checkInvalidWindowError(void)
{
const char *invalidWindowError = "Invalid window";
char *lastError;
@@ -1300,7 +1300,7 @@ int video_getSetWindowPosition(void *arg)
}
/* Helper function that checks for an 'Invalid parameter' error */
-void _checkInvalidParameterError()
+void _checkInvalidParameterError(void)
{
const char *invalidParameterError = "Parameter";
char *lastError;
diff --git a/test/testcustomcursor.c b/test/testcustomcursor.c
index aec3c78aa3e2b..985f20fbe0d70 100644
--- a/test/testcustomcursor.c
+++ b/test/testcustomcursor.c
@@ -148,7 +148,7 @@ quit(int rc)
exit(rc);
}
-void loop()
+void loop(void)
{
int i;
SDL_Event event;
diff --git a/test/testdraw2.c b/test/testdraw2.c
index 43aa1843b1816..26053d56b3a83 100644
--- a/test/testdraw2.c
+++ b/test/testdraw2.c
@@ -174,7 +174,7 @@ void DrawRects(SDL_Renderer *renderer)
}
}
-void loop()
+void loop(void)
{
Uint32 now;
int i;
diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c
index 4dffe06bd764a..6f0362fdb5ba6 100644
--- a/test/testdrawchessboard.c
+++ b/test/testdrawchessboard.c
@@ -28,7 +28,7 @@ SDL_Renderer *renderer;
SDL_Surface *surface;
int done;
-void DrawChessBoard()
+void DrawChessBoard(void)
{
int row = 0, column = 0, x = 0;
SDL_Rect rect, darea;
@@ -53,7 +53,7 @@ void DrawChessBoard()
SDL_RenderPresent(renderer);
}
-void loop()
+void loop(void)
{
SDL_Event e;
while (SDL_PollEvent(&e)) {
diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c
index 52d3b2d853ba3..bf41257887dc6 100644
--- a/test/testgamecontroller.c
+++ b/test/testgamecontroller.c
@@ -107,7 +107,7 @@ static int virtual_axis_start_x;
static int virtual_axis_start_y;
static SDL_GameControllerButton virtual_button_active = SDL_CONTROLLER_BUTTON_INVALID;
-static void UpdateWindowTitle()
+static void UpdateWindowTitle(void)
{
if (!window) {
return;
@@ -329,7 +329,7 @@ typedef struct
Uint8 ucLedBlue; /* 46 */
} DS5EffectsState_t;
-static void CyclePS5TriggerEffect()
+static void CyclePS5TriggerEffect(void)
{
DS5EffectsState_t state;
@@ -351,7 +351,7 @@ static void CyclePS5TriggerEffect()
SDL_GameControllerSendEffect(gamecontroller, &state, sizeof(state));
}
-static SDL_bool ShowingFront()
+static SDL_bool ShowingFront(void)
{
SDL_bool showing_front = SDL_TRUE;
int i;
@@ -394,7 +394,7 @@ static int SDLCALL VirtualControllerSetLED(void *userdata, Uint8 red, Uint8 gree
return 0;
}
-static void OpenVirtualController()
+static void OpenVirtualController(void)
{
SDL_VirtualJoystickDesc desc;
int virtual_index;
@@ -420,7 +420,7 @@ static void OpenVirtualController()
}
}
-static void CloseVirtualController()
+static void CloseVirtualController(void)
{
int i;
diff --git a/test/testgeometry.c b/test/testgeometry.c
index e09c38332f8b6..f8c46993fcc37 100644
--- a/test/testgeometry.c
+++ b/test/testgeometry.c
@@ -62,7 +62,7 @@ int LoadSprite(const char *file)
return 0;
}
-void loop()
+void loop(void)
{
int i;
SDL_Event event;
diff --git a/test/testgl2.c b/test/testgl2.c
index d14ae1675183b..a4fdacb5a75e7 100644
--- a/test/testgl2.c
+++ b/test/testgl2.c
@@ -78,7 +78,7 @@ quit(int rc)
}
static void
-Render()
+Render(void)
{
static float color[8][3] = {
{ 1.0, 1.0, 0.0 },
diff --git a/test/testgles.c b/test/testgles.c
index b1577cd8ef23b..63861edc135a1 100644
--- a/test/testgles.c
+++ b/test/testgles.c
@@ -49,7 +49,7 @@ quit(int rc)
}
static void
-Render()
+Render(void)
{
static GLubyte color[8][4] = { { 255, 0, 0, 0 },
{ 255, 0, 0, 255 },
diff --git a/test/testgles2.c b/test/testgles2.c
index bafc524ef4be7..e4b08642098da 100644
--- a/test/testgles2.c
+++ b/test/testgles2.c
@@ -569,7 +569,7 @@ render_thread_fn(void *render_ctx)
}
static void
-loop_threaded()
+loop_threaded(void)
{
SDL_Event event;
int i;
@@ -598,7 +598,7 @@ loop_threaded()
#endif
static void
-loop()
+loop(void)
{
SDL_Event event;
int i;
diff --git a/test/testgles2_sdf.c b/test/testgles2_sdf.c
index 3b15f7298f0a7..6f96338ac1c5b 100644
--- a/test/testgles2_sdf.c
+++ b/test/testgles2_sdf.c
@@ -325,7 +325,7 @@ int done;
Uint32 frames;
shader_data *datas;
-void loop()
+void loop(void)
{
SDL_Event event;
int i;
diff --git a/test/testime.c b/test/testime.c
index c12f1452e7bf0..ea71580854eb4 100644
--- a/test/testime.c
+++ b/test/testime.c
@@ -333,7 +333,7 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_Rect *dst
return unifontGlyph[codepoint].width;
}
-static void unifont_cleanup()
+static void unifont_cleanup(void)
{
int i, j;
for (i = 0; i < state->num_windows; ++i) {
@@ -425,12 +425,12 @@ Uint32 utf8_decode(char *p, size_t len)
return codepoint;
}
-void usage()
+void usage(void)
{
SDL_Log("usage: testime [--font fontfile]\n");
}
-void InitInput()
+void InitInput(void)
{
/* Prepare a rect for text input */
textRect.x = textRect.y = 100;
@@ -444,7 +444,7 @@ void InitInput()
SDL_StartTextInput();
}
-void CleanupVideo()
+void CleanupVideo(void)
{
SDL_StopTextInput();
#ifdef HAVE_SDL_TTF
@@ -597,7 +597,7 @@ void _Redraw(int rendererID)
SDL_SetTextInputRect(&markedRect);
}
-void Redraw()
+void Redraw(void)
{
int i;
for (i = 0; i < state->num_windows; ++i) {
diff --git a/test/testintersections.c b/test/testintersections.c
index bb95fbe937fba..20488bbac07f3 100644
--- a/test/testintersections.c
+++ b/test/testintersections.c
@@ -208,7 +208,7 @@ DrawRectRectIntersections(SDL_Renderer *renderer)
}
}
-void loop()
+void loop(void)
{
int i;
SDL_Event event;
diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c
index 593942038c370..bd3ee0db3dc19 100644
--- a/test/testmultiaudio.c
+++ b/test/testmultiaudio.c
@@ -53,7 +53,7 @@ play_through_once(void *arg, Uint8 *stream, int len)
}
}
-void loop()
+void loop(void)
{
if (SDL_AtomicGet(&cbd[0].done)) {
#ifdef __EMSCRIPTEN__
diff --git a/test/testoffscreen.c b/test/testoffscreen.c
index 09ef7fcdd772b..917a32ec5cc9b 100644
--- a/test/testoffscreen.c
+++ b/test/testoffscreen.c
@@ -32,7 +32,7 @@ static int width = 640;
static int height = 480;
static unsigned int max_frames = 200;
-void draw()
+void draw(void)
{
SDL_Rect Rect;
@@ -50,7 +50,7 @@ void draw()
SDL_RenderPresent(renderer);
}
-void save_surface_to_bmp()
+void save_surface_to_bmp(void)
{
SDL_Surface *surface;
Uint32 r_mask, g_mask, b_mask, a_mask;
@@ -71,7 +71,7 @@ void save_surface_to_bmp()
SDL_FreeSurface(surface);
}
-void loop()
+void loop(void)
{
SDL_Event event;
diff --git a/test/testoverlay2.c b/test/testoverlay2.c
index ccfa8e5b40240..236458d88336c 100644
--- a/test/testoverlay2.c
+++ b/test/testoverlay2.c
@@ -178,7 +178,7 @@ PrintUsage(char *argv0)
SDL_Log("\n");
}
-void loop()
+void loop(void)
{
SDL_Event event;
diff --git a/test/testrelative.c b/test/testrelative.c
index 3f777cd83d878..12ba6eb7938bc 100644
--- a/test/testrelative.c
+++ b/test/testrelative.c
@@ -35,7 +35,7 @@ DrawRects(SDL_Renderer *renderer)
}
static void
-loop()
+loop(void)
{
/* Check for events */
while (SDL_PollEvent(&event)) {
diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c
index 832101aa376b2..2363ec59e2d43 100644
--- a/test/testrendercopyex.c
+++ b/test/testrendercopyex.c
@@ -87,7 +87,7 @@ void Draw(DrawState *s)
/* SDL_Delay(10); */
}
-void loop()
+void loop(void)
{
int i;
SDL_Event event;
diff --git a/test/testrendertarget.c b/test/testrendertarget.c
index 9693df4f84fb9..6562133987c00 100644
--- a/test/testrendertarget.c
+++ b/test/testrendertarget.c
@@ -173,7 +173,7 @@ Draw(DrawState *s)
return SDL_TRUE;
}
-void loop()
+void loop(void)
{
int i;
SDL_Event event;
diff --git a/test/testscale.c b/test/testscale.c
index 3659c91490783..83978123fc552 100644
--- a/test/testscale.c
+++ b/test/testscale.c
@@ -78,7 +78,7 @@ void Draw(DrawState *s)
SDL_RenderPresent(s->renderer);
}
-void loop()
+void loop(void)
{
int i;
SDL_Event event;
diff --git a/test/testshader.c b/test/testshader.c
index 48535dca78d2d..7ca10f1fb24ab 100644
--- a/test/testshader.c
+++ b/test/testshader.c
@@ -11,6 +11,7 @@
*/
/* This is a simple example of using GLSL shaders with SDL */
+#include
#include "SDL.h"
#ifdef HAVE_OPENGL
@@ -228,7 +229,7 @@ static void DestroyShaderProgram(ShaderData *data)
}
}
-static SDL_bool InitShaders()
+static SDL_bool InitShaders(void)
{
int i;
@@ -282,7 +283,7 @@ static SDL_bool InitShaders()
return SDL_TRUE;
}
-static void QuitShaders()
+static void QuitShaders(void)
{
int i;
diff --git a/test/testsprite2.c b/test/testsprite2.c
index 71b565678b211..8be33907d28e8 100644
--- a/test/testsprite2.c
+++ b/test/testsprite2.c
@@ -392,7 +392,7 @@ void MoveSprites(SDL_Renderer *renderer, SDL_Texture *sprite)
SDL_RenderPresent(renderer);
}
-static void MoveAllSprites()
+static void MoveAllSprites(void)
{
int i;
@@ -404,7 +404,7 @@ static void MoveAllSprites()
}
}
-void loop()
+void loop(void)
{
Uint32 now;
SDL_Event event;
diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c
index b81101eb5d05b..56f626324a814 100644
--- a/test/testspriteminimal.c
+++ b/test/testspriteminimal.c
@@ -43,7 +43,7 @@ quit(int rc)
exit(rc);
}
-void MoveSprites()
+void MoveSprites(void)
{
int i;
int window_w = WINDOW_WIDTH;
@@ -77,7 +77,7 @@ void MoveSprites()
SDL_RenderPresent(renderer);
}
-void loop()
+void loop(void)
{
SDL_Event event;
diff --git a/test/teststreaming.c b/test/teststreaming.c
index 45202a7797d14..7931d22819661 100644
--- a/test/teststreaming.c
+++ b/test/teststreaming.c
@@ -94,7 +94,7 @@ void UpdateTexture(SDL_Texture *texture)
SDL_UnlockTexture(texture);
}
-void loop()
+void loop(void)
{
SDL_Event event;
diff --git a/test/testviewport.c b/test/testviewport.c
index ee76a3782f9b6..1e866d34246b4 100644
--- a/test/testviewport.c
+++ b/test/testviewport.c
@@ -95,7 +95,7 @@ void DrawOnViewport(SDL_Renderer *renderer)
SDL_RenderSetClipRect(renderer, NULL);
}
-void loop()
+void loop(void)
{
SDL_Event event;
int i;
diff --git a/test/testwm2.c b/test/testwm2.c
index 5236a7f5b97c2..6d8e02542cac0 100644
--- a/test/testwm2.c
+++ b/test/testwm2.c
@@ -143,7 +143,7 @@ draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_Rect viewport)
}
}
-void loop()
+void loop(void)
{
int i;
SDL_Event event;