From 25ce87979dc571e4e85090fcb747639a0db85173 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 27 Sep 2023 06:11:09 +0200 Subject: [PATCH] Always provide an implementation for all SDL3 symbols --- Android.mk | 1 + VisualC-GDK/SDL/SDL.vcxproj | 4 + VisualC-GDK/SDL/SDL.vcxproj.filters | 13 ++ VisualC-WinRT/SDL-UWP.vcxproj | 4 + VisualC-WinRT/SDL-UWP.vcxproj.filters | 12 ++ VisualC/SDL/SDL.vcxproj | 4 + VisualC/SDL/SDL.vcxproj.filters | 14 +- src/core/SDL_core_unsupported.c | 218 +++++++++++++++++++++++ src/render/SDL_render_unsupported.c | 49 +++++ src/render/direct3d12/SDL_render_d3d12.c | 6 +- src/video/SDL_video_unsupported.c | 83 +++++++++ 11 files changed, 404 insertions(+), 4 deletions(-) create mode 100644 src/core/SDL_core_unsupported.c create mode 100644 src/render/SDL_render_unsupported.c create mode 100644 src/video/SDL_video_unsupported.c diff --git a/Android.mk b/Android.mk index 4c26d3c98..3779eb534 100644 --- a/Android.mk +++ b/Android.mk @@ -24,6 +24,7 @@ LOCAL_SRC_FILES := \ $(wildcard $(LOCAL_PATH)/src/audio/openslES/*.c) \ $(LOCAL_PATH)/src/atomic/SDL_atomic.c.arm \ $(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \ + $(wildcard $(LOCAL_PATH)/src/core/*.c) \ $(wildcard $(LOCAL_PATH)/src/core/android/*.c) \ $(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \ $(wildcard $(LOCAL_PATH)/src/dynapi/*.c) \ diff --git a/VisualC-GDK/SDL/SDL.vcxproj b/VisualC-GDK/SDL/SDL.vcxproj index 7df28485f..bb003d0f0 100644 --- a/VisualC-GDK/SDL/SDL.vcxproj +++ b/VisualC-GDK/SDL/SDL.vcxproj @@ -557,6 +557,8 @@ + + @@ -699,6 +701,7 @@ + @@ -767,6 +770,7 @@ + diff --git a/VisualC-GDK/SDL/SDL.vcxproj.filters b/VisualC-GDK/SDL/SDL.vcxproj.filters index 19b7eb904..bbdc75985 100644 --- a/VisualC-GDK/SDL/SDL.vcxproj.filters +++ b/VisualC-GDK/SDL/SDL.vcxproj.filters @@ -885,6 +885,13 @@ atomic + + core + + + core + + core\windows @@ -1182,6 +1189,9 @@ video + + video + video @@ -1308,6 +1318,9 @@ render + + render + render diff --git a/VisualC-WinRT/SDL-UWP.vcxproj b/VisualC-WinRT/SDL-UWP.vcxproj index c911765b9..372a28339 100644 --- a/VisualC-WinRT/SDL-UWP.vcxproj +++ b/VisualC-WinRT/SDL-UWP.vcxproj @@ -250,6 +250,8 @@ true true + + @@ -383,6 +385,7 @@ + @@ -512,6 +515,7 @@ + true diff --git a/VisualC-WinRT/SDL-UWP.vcxproj.filters b/VisualC-WinRT/SDL-UWP.vcxproj.filters index 7b90f411f..92e6f4a8d 100644 --- a/VisualC-WinRT/SDL-UWP.vcxproj.filters +++ b/VisualC-WinRT/SDL-UWP.vcxproj.filters @@ -498,6 +498,12 @@ Source Files + + Source Files + + + Source Files + Source Files @@ -606,6 +612,9 @@ Source Files + + Source Files + Source Files @@ -786,6 +795,9 @@ Source Files + + Source Files + Source Files diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj index f4d4dc002..5a63ba770 100644 --- a/VisualC/SDL/SDL.vcxproj +++ b/VisualC/SDL/SDL.vcxproj @@ -484,6 +484,8 @@ + + @@ -578,6 +580,7 @@ + @@ -642,6 +645,7 @@ + diff --git a/VisualC/SDL/SDL.vcxproj.filters b/VisualC/SDL/SDL.vcxproj.filters index f72de3a0a..b2e57b4fa 100644 --- a/VisualC/SDL/SDL.vcxproj.filters +++ b/VisualC/SDL/SDL.vcxproj.filters @@ -419,7 +419,7 @@ audio - + core\windows @@ -864,6 +864,12 @@ atomic + + core + + + core + core\windows @@ -1161,6 +1167,9 @@ video + + video + video @@ -1290,6 +1299,9 @@ render + + render + render diff --git a/src/core/SDL_core_unsupported.c b/src/core/SDL_core_unsupported.c new file mode 100644 index 000000000..5e1f82834 --- /dev/null +++ b/src/core/SDL_core_unsupported.c @@ -0,0 +1,218 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef __LINUX__ + +DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority); +int SDL_LinuxSetThreadPriority(Sint64 threadID, int priority) +{ + (void)threadID; + (void)priority; + return SDL_Unsupported(); +} + +DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy); +int SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy) +{ + (void)threadID; + (void)sdlPriority; + (void)schedPolicy; + return SDL_Unsupported(); +} + +#endif + +#ifndef __GDK__ + +DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void); +void SDL_GDKSuspendComplete(void) +{ + SDL_Unsupported(); +} + +DECLSPEC int SDLCALL SDL_GDKGetDefaultUser(void *outUserHandle); /* XUserHandle *outUserHandle */ +int SDL_GDKGetDefaultUser(void *outUserHandle) +{ + return SDL_Unsupported(); +} + +#endif + +#if !(defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)) + +DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst); +int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) +{ + (void)name; + (void)style; + (void)hInst; + return SDL_Unsupported(); +} + +DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(void *callback, void *userdata); /* SDL_WindowsMessageHook callback */ +void SDL_SetWindowsMessageHook(void *callback, void *userdata) +{ + (void)callback; + (void)userdata; + SDL_Unsupported(); +} + +DECLSPEC void SDLCALL SDL_UnregisterApp(void); +void SDL_UnregisterApp(void) +{ + SDL_Unsupported(); +} + +#endif + +#ifndef __WINRT__ + +/* Returns SDL_WinRT_DeviceFamily enum */ +DECLSPEC int SDLCALL SDL_WinRTGetDeviceFamily(void); +int SDL_WinRTGetDeviceFamily() +{ + SDL_Unsupported(); + return 0; /* SDL_WINRT_DEVICEFAMILY_UNKNOWN */ +} + +DECLSPEC const wchar_t *SDLCALL SDL_WinRTGetFSPathUNICODE(int pathType); /* SDL_WinRT_Path pathType */ +const wchar_t *SDL_WinRTGetFSPathUNICODE(int pathType) +{ + (void)pathType; + SDL_Unsupported(); + return NULL; +} + +DECLSPEC const char *SDLCALL SDL_WinRTGetFSPathUTF8(int pathType); /* SDL_WinRT_Path pathType */ +const char *SDL_WinRTGetFSPathUTF8(int pathType) +{ + (void)pathType; + SDL_Unsupported(); + return NULL; +} +#endif + +#ifndef __ANDROID__ + +DECLSPEC void SDLCALL SDL_AndroidBackButton(void); +void SDL_AndroidBackButton() +{ + SDL_Unsupported(); +} + +DECLSPEC void *SDLCALL SDL_AndroidGetActivity(void); +void *SDL_AndroidGetActivity() +{ + SDL_Unsupported(); + return NULL; +} + +DECLSPEC const char *SDLCALL SDL_AndroidGetExternalStoragePath(void); +const char* SDL_AndroidGetExternalStoragePath() +{ + SDL_Unsupported(); + return NULL; +} + +DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState(Uint32 *state); +int SDL_AndroidGetExternalStorageState(Uint32 *state) +{ + (void)state; + return SDL_Unsupported(); +} +DECLSPEC const char *SDLCALL SDL_AndroidGetInternalStoragePath(void); +const char *SDL_AndroidGetInternalStoragePath() +{ + SDL_Unsupported(); + return NULL; +} + +DECLSPEC void *SDLCALL SDL_AndroidGetJNIEnv(void); +void *SDL_AndroidGetJNIEnv() +{ + SDL_Unsupported(); + return NULL; +} + +DECLSPEC SDL_bool SDLCALL SDL_AndroidRequestPermission(const char *permission); +SDL_bool SDL_AndroidRequestPermission(const char *permission) +{ + (void)permission; + SDL_Unsupported(); + return SDL_FALSE; +} + +DECLSPEC int SDLCALL SDL_AndroidSendMessage(Uint32 command, int param); +int SDL_AndroidSendMessage(Uint32 command, int param) +{ + (void)command; + (void)param; + return SDL_Unsupported(); +} + +DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int duration, int gravity, int xoffset, int yoffset); +int SDL_AndroidShowToast(const char* message, int duration, int gravity, int xoffset, int yoffset) +{ + (void)message; + (void)duration; + (void)gravity; + (void)xoffset; + (void)yoffset; + return SDL_Unsupported(); +} + +DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void); +int SDL_GetAndroidSDKVersion() +{ + return SDL_Unsupported(); +} + +DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void); +SDL_bool SDL_IsAndroidTV() +{ + SDL_Unsupported(); + return SDL_FALSE; +} + +DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void); +SDL_bool SDL_IsChromebook() +{ + SDL_Unsupported(); + return SDL_FALSE; +} + +DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void); +SDL_bool SDL_IsDeXMode(void) +{ + SDL_Unsupported(); + return SDL_FALSE; +} + +DECLSPEC Sint32 SDLCALL JNI_OnLoad(void *vm, void *reserved); +Sint32 JNI_OnLoad(void *vm, void *reserved) +{ + (void)vm; + (void)reserved; + SDL_Unsupported(); + return -1; /* JNI_ERR */ +} +#endif diff --git a/src/render/SDL_render_unsupported.c b/src/render/SDL_render_unsupported.c new file mode 100644 index 000000000..4d223895f --- /dev/null +++ b/src/render/SDL_render_unsupported.c @@ -0,0 +1,49 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if !(defined(__WIN32__) || defined(__WINGDK__)) + +DECLSPEC void *SDLCALL SDL_GetRenderD3D9Device(SDL_Renderer *renderer); /* returns IDirect3DDevice9 * */ +void *SDL_GetRenderD3D9Device(SDL_Renderer *renderer) +{ + (void)renderer; + SDL_Unsupported(); + return NULL; +} + +DECLSPEC void *SDLCALL SDL_GetRenderD3D11Device(SDL_Renderer *renderer); /* returns ID3D11Device * */ +void *SDL_GetRenderD3D11Device(SDL_Renderer *renderer) +{ + (void)renderer; + SDL_Unsupported(); + return NULL; +} + +DECLSPEC void *SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer *renderer); /* return ID3D12Device * */ +void *SDL_RenderGetD3D12Device(SDL_Renderer *renderer) +{ + (void)renderer; + SDL_Unsupported(); + return NULL; +} + +#endif diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index fb18838dc..0a5ddca37 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -3051,9 +3051,9 @@ SDL_RenderDriver D3D12_RenderDriver = { #ifdef __cplusplus extern "C" #endif - /* This function needs to always exist on Windows, for the Dynamic API. */ - ID3D12Device * - SDL_RenderGetD3D12Device(SDL_Renderer *renderer) +/* This function needs to always exist on Windows, for the Dynamic API. */ +ID3D12Device * +SDL_RenderGetD3D12Device(SDL_Renderer *renderer) { ID3D12Device *device = NULL; diff --git a/src/video/SDL_video_unsupported.c b/src/video/SDL_video_unsupported.c new file mode 100644 index 000000000..66be30101 --- /dev/null +++ b/src/video/SDL_video_unsupported.c @@ -0,0 +1,83 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_VIDEO_DRIVER_WINDOWS + +DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex); +SDL_bool SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex) +{ + (void)displayID; + (void)adapterIndex; + (void)outputIndex; + SDL_Unsupported(); + return SDL_FALSE; +} + +DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID); +int SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID) +{ + (void)displayID; + return SDL_Unsupported(); +} + +#endif + +#ifndef SDL_GDK_TEXTINPUT + +DECLSPEC int SDLCALL SDL_GDKGetTaskQueue(void *outTaskQueue); +int SDL_GDKGetTaskQueue(void *outTaskQueue) +{ + (void)outTaskQueue; + return SDL_Unsupported(); +} + +#endif + +#ifndef SDL_VIDEO_DRIVER_UIKIT + +DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void); +void SDL_OnApplicationDidChangeStatusBarOrientation(void) +{ + SDL_Unsupported(); +} + +#endif + +#ifndef SDL_VIDEO_DRIVER_UIKIT + +DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window *window, int interval, void (*callback)(void *), void *callbackParam); +int SDL_iPhoneSetAnimationCallback(SDL_Window *window, int interval, void (*callback)(void *), void *callbackParam) +{ + (void)window; + (void)interval; + (void)callback; + (void)callbackParam; + return SDL_Unsupported(); +} + +DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); +void SDL_iPhoneSetEventPump(SDL_bool enabled) +{ + (void)enabled; + SDL_Unsupported(); +} +#endif