Skip to content

Commit

Permalink
Add SDL_IsTV() (libsdl-org#11004)
Browse files Browse the repository at this point in the history
Moved SDL_IsAndroidTV() out of public API, to match SDL_IsAndroidTablet().

Added SDL_IsTV(), to mirror existing SDL_IsTablet().
  • Loading branch information
AntTheAlchemist authored Oct 1, 2024
1 parent 6bcf2f9 commit 5f5379d
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 20 deletions.
5 changes: 5 additions & 0 deletions build-scripts/SDL_migration.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -3699,3 +3699,8 @@ identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAltern
@@
- SDL_FALSE
+ false
@@
@@
- SDL_IsAndroidTV
+ SDL_IsTV
(...)
3 changes: 3 additions & 0 deletions docs/README-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
Expand Down
20 changes: 11 additions & 9 deletions include/SDL3/SDL_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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. */

/**
Expand Down
13 changes: 13 additions & 0 deletions src/SDL.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions src/core/SDL_core_unsupported.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/dynapi/SDL_dynapi.sym
Original file line number Diff line number Diff line change
Expand Up @@ -594,14 +594,14 @@ SDL3_0.0.0 {
SDL_InitHapticRumble;
SDL_InitSubSystem;
SDL_InsertGPUDebugLabel;
SDL_IsAndroidTV;
SDL_IsChromebook;
SDL_IsDeXMode;
SDL_IsGamepad;
SDL_IsJoystickHaptic;
SDL_IsJoystickVirtual;
SDL_IsMouseHaptic;
SDL_IsTablet;
SDL_IsTV;
SDL_JoystickConnected;
SDL_JoystickEventsEnabled;
SDL_KillProcess;
Expand Down
2 changes: 1 addition & 1 deletion src/dynapi/SDL_dynapi_overrides.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,14 +619,14 @@
#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
#define SDL_IsJoystickHaptic SDL_IsJoystickHaptic_REAL
#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
Expand Down
2 changes: 1 addition & 1 deletion src/dynapi/SDL_dynapi_procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,14 @@ 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)
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)
Expand Down
7 changes: 6 additions & 1 deletion src/video/uikit/SDL_uikitvideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

0 comments on commit 5f5379d

Please sign in to comment.