From 14e70e4177b02a25a75ff61196ab4f8c374f41f7 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 19 Jul 2023 01:41:20 +0300
Subject: [PATCH] updates from latest SDL2 and SDL3 trees.
---
include/SDL2/SDL_hints.h | 9 +++++++++
include/SDL2/SDL_version.h | 2 +-
src/sdl3_include_wrapper.h | 5 +++++
test/testautomation_clipboard.c | 12 ++++++------
test/testautomation_stdlib.c | 12 ++++++++++++
test/testutils.c | 13 ++++++++++---
test/testutils.h | 13 ++++++++++---
7 files changed, 53 insertions(+), 13 deletions(-)
diff --git a/include/SDL2/SDL_hints.h b/include/SDL2/SDL_hints.h
index ad3b403..c808a60 100644
--- a/include/SDL2/SDL_hints.h
+++ b/include/SDL2/SDL_hints.h
@@ -1007,6 +1007,15 @@ extern "C" {
*/
#define SDL_HINT_JOYSTICK_THREAD "SDL_JOYSTICK_THREAD"
+/**
+ * \brief A variable controlling whether Windows.Gaming.Input should be used for controller handling.
+ *
+ * This variable can be set to the following values:
+ * "0" - WGI is not used
+ * "1" - WGI is used (the default)
+ */
+#define SDL_HINT_JOYSTICK_WGI "SDL_JOYSTICK_WGI"
+
/**
* \brief Determines whether SDL enforces that DRM master is required in order
* to initialize the KMSDRM video backend.
diff --git a/include/SDL2/SDL_version.h b/include/SDL2/SDL_version.h
index 782a7ff..049719f 100644
--- a/include/SDL2/SDL_version.h
+++ b/include/SDL2/SDL_version.h
@@ -58,7 +58,7 @@ typedef struct SDL_version
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
#define SDL_MAJOR_VERSION 2
-#define SDL_MINOR_VERSION 28
+#define SDL_MINOR_VERSION 29
#define SDL_PATCHLEVEL 0
/**
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index b6e3e71..efa0dcf 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -904,6 +904,7 @@
#define SDL_wcsnlen IGNORE_THIS_VERSION_OF_SDL_wcsnlen
#define SDL_strnlen IGNORE_THIS_VERSION_OF_SDL_strnlen
#define SDL_AddGamepadMappingsFromFile IGNORE_THIS_VERSION_OF_SDL_AddGamepadMappingsFromFile
+#define SDL_ReloadGamepadMappings IGNORE_THIS_VERSION_OF_SDL_ReloadGamepadMappings
/* *** HACK HACK HACK:
* *** Avoid including SDL_thread.h: it defines SDL_CreateThread() as a macro
@@ -4466,6 +4467,10 @@ typedef void (__cdecl *pfnSDL_CurrentEndThread) (unsigned);
#undef SDL_AddGamepadMappingsFromFile
#endif
+#ifdef SDL_ReloadGamepadMappings
+#undef SDL_ReloadGamepadMappings
+#endif
+
/* undefine these macros too: */
/* redefine as SDL3_xxx, if needed. */
diff --git a/test/testautomation_clipboard.c b/test/testautomation_clipboard.c
index dbe1ef8..ce8ea1b 100644
--- a/test/testautomation_clipboard.c
+++ b/test/testautomation_clipboard.c
@@ -84,7 +84,7 @@ int clipboard_testSetClipboardText(void *arg)
char *textRef = SDLTest_RandomAsciiString();
char *text = SDL_strdup(textRef);
int result;
- result = SDL_SetClipboardText((const char *)text);
+ result = SDL_SetClipboardText(text);
SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
SDLTest_AssertCheck(
result == 0,
@@ -112,7 +112,7 @@ int clipboard_testSetPrimarySelectionText(void *arg)
char *textRef = SDLTest_RandomAsciiString();
char *text = SDL_strdup(textRef);
int result;
- result = SDL_SetPrimarySelectionText((const char *)text);
+ result = SDL_SetPrimarySelectionText(text);
SDLTest_AssertPass("Call to SDL_SetPrimarySelectionText succeeded");
SDLTest_AssertCheck(
result == 0,
@@ -149,7 +149,7 @@ int clipboard_testClipboardTextFunctions(void *arg)
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
if (boolResult == SDL_TRUE) {
- intResult = SDL_SetClipboardText((const char *)NULL);
+ intResult = SDL_SetClipboardText(NULL);
SDLTest_AssertPass("Call to SDL_SetClipboardText(NULL) succeeded");
SDLTest_AssertCheck(
intResult == 0,
@@ -176,7 +176,7 @@ int clipboard_testClipboardTextFunctions(void *arg)
charResult[0] == '\0', /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
"Verify SDL_GetClipboardText returned string with length 0, got length %i",
(int)SDL_strlen(charResult));
- intResult = SDL_SetClipboardText((const char *)text);
+ intResult = SDL_SetClipboardText(text);
SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
SDLTest_AssertCheck(
intResult == 0,
@@ -227,7 +227,7 @@ int clipboard_testPrimarySelectionTextFunctions(void *arg)
boolResult = SDL_HasPrimarySelectionText();
SDLTest_AssertPass("Call to SDL_HasPrimarySelectionText succeeded");
if (boolResult == SDL_TRUE) {
- intResult = SDL_SetPrimarySelectionText((const char *)NULL);
+ intResult = SDL_SetPrimarySelectionText(NULL);
SDLTest_AssertPass("Call to SDL_SetPrimarySelectionText(NULL) succeeded");
SDLTest_AssertCheck(
intResult == 0,
@@ -254,7 +254,7 @@ int clipboard_testPrimarySelectionTextFunctions(void *arg)
charResult[0] == '\0', /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
"Verify SDL_GetPrimarySelectionText returned string with length 0, got length %i",
(int)SDL_strlen(charResult));
- intResult = SDL_SetPrimarySelectionText((const char *)text);
+ intResult = SDL_SetPrimarySelectionText(text);
SDLTest_AssertPass("Call to SDL_SetPrimarySelectionText succeeded");
SDLTest_AssertCheck(
intResult == 0,
diff --git a/test/testautomation_stdlib.c b/test/testautomation_stdlib.c
index ba7ba88..af014b7 100644
--- a/test/testautomation_stdlib.c
+++ b/test/testautomation_stdlib.c
@@ -175,6 +175,18 @@ int stdlib_snprintf(void *arg)
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text);
SDLTest_AssertCheck(result == 7, "Check result value, expected: 7, got: %d", result);
+ result = SDL_snprintf(text, sizeof(text), "%p", (void *)0x1234abcd);
+ expected = "0x1234abcd";
+ SDLTest_AssertPass("Call to SDL_snprintf(text, sizeof(text), \"%%p\", 0x1234abcd)");
+ SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text);
+ SDLTest_AssertCheck(result == SDL_strlen(expected), "Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result);
+
+ result = SDL_snprintf(text, sizeof(text), "A %p B", (void *)0x1234abcd);
+ expected = "A 0x1234abcd B";
+ SDLTest_AssertPass("Call to SDL_snprintf(text, sizeof(text), \"A %%p B\", 0x1234abcd)");
+ SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text);
+ SDLTest_AssertCheck(result == SDL_strlen(expected), "Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result);
+
return TEST_COMPLETED;
}
diff --git a/test/testutils.c b/test/testutils.c
index 360c32a..20efef0 100644
--- a/test/testutils.c
+++ b/test/testutils.c
@@ -1,7 +1,14 @@
/*
-Copyright 1997-2023 Sam Lantinga
-Copyright 2022 Collabora Ltd.
-SPDX-License-Identifier: Zlib
+ Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
+ Copyright 2022 Collabora Ltd.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely.
*/
#include "testutils.h"
diff --git a/test/testutils.h b/test/testutils.h
index c8ce55d..1f69673 100644
--- a/test/testutils.h
+++ b/test/testutils.h
@@ -1,7 +1,14 @@
/*
-Copyright 1997-2023 Sam Lantinga
-Copyright 2022 Collabora Ltd.
-SPDX-License-Identifier: Zlib
+ Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
+ Copyright 2022 Collabora Ltd.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely.
*/
#ifndef TESTUTILS_H