From 122ad3d6f600229dbb4f52883a907699cd3a1acd Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 27 Mar 2026 05:45:36 -0700 Subject: [PATCH] Added SDL_IsPhone() --- include/SDL3/SDL_system.h | 13 +++++++++++++ src/SDL.c | 11 +++++++++++ src/dynapi/SDL_dynapi.sym | 1 + src/dynapi/SDL_dynapi_overrides.h | 1 + src/dynapi/SDL_dynapi_procs.h | 1 + 5 files changed, 27 insertions(+) diff --git a/include/SDL3/SDL_system.h b/include/SDL3/SDL_system.h index 18ad26a94c..3353bb7741 100644 --- a/include/SDL3/SDL_system.h +++ b/include/SDL3/SDL_system.h @@ -616,6 +616,19 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SendAndroidMessage(Uint32 command, int para #endif /* SDL_PLATFORM_ANDROID */ +/** + * Query if the current device is a phone. + * + * If SDL can't determine this, it will return false. + * + * \returns true if the device is a phone, false otherwise. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.6.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_IsPhone(void); + /** * Query if the current device is a tablet. * diff --git a/src/SDL.c b/src/SDL.c index b1a1a56354..cd7ec4b656 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -828,6 +828,17 @@ const char *SDL_GetPlatform(void) #endif } +bool SDL_IsPhone(void) +{ +#if defined(SDL_PLATFORM_ANDROID) || \ + (defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_VISIONOS)) + if (!SDL_IsTablet() && !SDL_IsTV()) { + return true; + } +#endif + return false; +} + bool SDL_IsTablet(void) { #ifdef SDL_PLATFORM_ANDROID diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index ef10030d26..a16d0f79c3 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -1285,6 +1285,7 @@ SDL3_0.0.0 { SDL_SetGPURenderStateStorageBuffers; SDL_GDKSuspendRenderer; SDL_GDKResumeRenderer; + SDL_IsPhone; # extra symbols go here (don't modify this line) local: *; }; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 410917721d..c60b5223d4 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -1311,3 +1311,4 @@ #define SDL_SetGPURenderStateStorageBuffers SDL_SetGPURenderStateStorageBuffers_REAL #define SDL_GDKSuspendRenderer SDL_GDKSuspendRenderer_REAL #define SDL_GDKResumeRenderer SDL_GDKResumeRenderer_REAL +#define SDL_IsPhone SDL_IsPhone_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 175f2fd4da..203d9726c8 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -1319,3 +1319,4 @@ SDL_DYNAPI_PROC(bool,SDL_SetGPURenderStateStorageTextures,(SDL_GPURenderState *a SDL_DYNAPI_PROC(bool,SDL_SetGPURenderStateStorageBuffers,(SDL_GPURenderState *a,int b,SDL_GPUBuffer *const*c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_GDKSuspendRenderer,(SDL_Renderer *a),(a),) SDL_DYNAPI_PROC(void,SDL_GDKResumeRenderer,(SDL_Renderer *a),(a),) +SDL_DYNAPI_PROC(bool,SDL_IsPhone,(void),(),return)