Add SDL_IsTV() (#11004)

Moved SDL_IsAndroidTV() out of public API, to match SDL_IsAndroidTablet().

Added SDL_IsTV(), to mirror existing SDL_IsTablet().
This commit is contained in:
Anthony 2024-10-01 17:20:00 +01:00 committed by GitHub
parent 6bcf2f919a
commit 5f5379dc99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 41 additions and 20 deletions

View File

@ -3699,3 +3699,8 @@ identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAltern
@@
- SDL_FALSE
+ false
@@
@@
- SDL_IsAndroidTV
+ SDL_IsTV
(...)

View File

@ -1888,6 +1888,8 @@ SDL_RequestAndroidPermission is no longer a blocking call; the caller now provid
SDL_iPhoneSetAnimationCallback() and SDL_iPhoneSetEventPump() have been renamed to SDL_SetiOSAnimationCallback() and SDL_SetiOSEventPump(), respectively. SDL2 has had macros to provide this new name with the old symbol since the introduction of the iPad, but now the correctly-named symbol is the only option.
SDL_IsAndroidTV() has been renamed SDL_IsTV() and is no longer Android-specific; an app running on an Apple TV device will also return true, for example.
The following functions have been removed:
* SDL_GetWinRTFSPathUNICODE() - WinRT support was removed in SDL3.
* SDL_GetWinRTFSPathUTF8() - WinRT support was removed in SDL3.
@ -1911,6 +1913,7 @@ The following functions have been renamed:
* SDL_Direct3D9GetAdapterIndex() => SDL_GetDirect3D9AdapterIndex()
* SDL_GDKGetDefaultUser() => SDL_GetGDKDefaultUser(), returns bool
* SDL_GDKGetTaskQueue() => SDL_GetGDKTaskQueue(), returns bool
* SDL_IsAndroidTV() => SDL_IsTV()
* SDL_LinuxSetThreadPriority() => SDL_SetLinuxThreadPriority(), returns bool
* SDL_LinuxSetThreadPriorityAndPolicy() => SDL_SetLinuxThreadPriorityAndPolicy(), returns bool
* SDL_OnApplicationDidBecomeActive() => SDL_OnApplicationDidEnterForeground()

View File

@ -346,15 +346,6 @@ extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidActivity(void);
*/
extern SDL_DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void);
/**
* Query if the application is running on Android TV.
*
* \returns true if this is Android TV, false otherwise.
*
* \since This function is available since SDL 3.0.0.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_IsAndroidTV(void);
/**
* Query if the application is running on a Chromebook.
*
@ -563,6 +554,17 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SendAndroidMessage(Uint32 command, int para
*/
extern SDL_DECLSPEC bool SDLCALL SDL_IsTablet(void);
/**
* Query if the current device is a TV.
*
* If SDL can't determine this, it will return false.
*
* \returns true if the device is a TV, false otherwise.
*
* \since This function is available since SDL 3.0.0.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_IsTV(void);
/* Functions used by iOS app delegates to notify SDL about state changes. */
/**

View File

@ -721,6 +721,19 @@ bool SDL_IsTablet(void)
#endif
}
bool SDL_IsTV(void)
{
#ifdef SDL_PLATFORM_ANDROID
extern bool SDL_IsAndroidTV(void);
return SDL_IsAndroidTV();
#elif defined(SDL_PLATFORM_IOS)
extern bool SDL_IsAppleTV(void);
return SDL_IsAppleTV();
#else
return false;
#endif
}
#ifdef SDL_PLATFORM_WIN32
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)

View File

@ -188,13 +188,6 @@ int SDL_GetAndroidSDKVersion(void)
return SDL_Unsupported();
}
SDL_DECLSPEC bool SDLCALL SDL_IsAndroidTV(void);
bool SDL_IsAndroidTV(void)
{
SDL_Unsupported();
return false;
}
SDL_DECLSPEC bool SDLCALL SDL_IsChromebook(void);
bool SDL_IsChromebook(void)
{

View File

@ -594,7 +594,6 @@ SDL3_0.0.0 {
SDL_InitHapticRumble;
SDL_InitSubSystem;
SDL_InsertGPUDebugLabel;
SDL_IsAndroidTV;
SDL_IsChromebook;
SDL_IsDeXMode;
SDL_IsGamepad;
@ -602,6 +601,7 @@ SDL3_0.0.0 {
SDL_IsJoystickVirtual;
SDL_IsMouseHaptic;
SDL_IsTablet;
SDL_IsTV;
SDL_JoystickConnected;
SDL_JoystickEventsEnabled;
SDL_KillProcess;

View File

@ -619,7 +619,6 @@
#define SDL_InitHapticRumble SDL_InitHapticRumble_REAL
#define SDL_InitSubSystem SDL_InitSubSystem_REAL
#define SDL_InsertGPUDebugLabel SDL_InsertGPUDebugLabel_REAL
#define SDL_IsAndroidTV SDL_IsAndroidTV_REAL
#define SDL_IsChromebook SDL_IsChromebook_REAL
#define SDL_IsDeXMode SDL_IsDeXMode_REAL
#define SDL_IsGamepad SDL_IsGamepad_REAL
@ -627,6 +626,7 @@
#define SDL_IsJoystickVirtual SDL_IsJoystickVirtual_REAL
#define SDL_IsMouseHaptic SDL_IsMouseHaptic_REAL
#define SDL_IsTablet SDL_IsTablet_REAL
#define SDL_IsTV SDL_IsTV_REAL
#define SDL_JoystickConnected SDL_JoystickConnected_REAL
#define SDL_JoystickEventsEnabled SDL_JoystickEventsEnabled_REAL
#define SDL_KillProcess SDL_KillProcess_REAL

View File

@ -639,7 +639,6 @@ SDL_DYNAPI_PROC(bool,SDL_Init,(SDL_InitFlags a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_InitHapticRumble,(SDL_Haptic *a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_InitSubSystem,(SDL_InitFlags a),(a),return)
SDL_DYNAPI_PROC(void,SDL_InsertGPUDebugLabel,(SDL_GPUCommandBuffer *a, const char *b),(a,b),)
SDL_DYNAPI_PROC(bool,SDL_IsAndroidTV,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_IsChromebook,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_IsDeXMode,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_IsGamepad,(SDL_JoystickID a),(a),return)
@ -647,6 +646,7 @@ SDL_DYNAPI_PROC(bool,SDL_IsJoystickHaptic,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_IsJoystickVirtual,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_IsMouseHaptic,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_IsTablet,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_IsTV,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_JoystickConnected,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(bool,SDL_JoystickEventsEnabled,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_KillProcess,(SDL_Process *a, bool b),(a,b),return)

View File

@ -297,7 +297,7 @@ void SDL_NSLog(const char *prefix, const char *text)
#endif // SDL_VIDEO_DRIVER_COCOA
/*
* iOS Tablet detection
* iOS Tablet, etc, detection
*
* This doesn't really have anything to do with the interfaces of the SDL video
* subsystem, but we need to stuff this into an Objective-C source code file.
@ -307,4 +307,9 @@ bool SDL_IsIPad(void)
return ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad);
}
bool SDL_IsAppleTV(void)
{
return ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomTV);
}
#endif // SDL_VIDEO_DRIVER_UIKIT