Initial Apple TV / tvOS support.

The Apple TV remote is currently exposed as a joystick with its touch surface treated as two axes. Key presses are also generated when its buttons and touch surface are used.

A new hint has been added to help deal with deciding whether to background the app when the remote's menu button is pressed: SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS.
This commit is contained in:
Alex Szpakowski
2016-09-13 22:18:06 -03:00
parent 86708c3cd8
commit f050576665
21 changed files with 1191 additions and 62 deletions

View File

@@ -30,6 +30,7 @@
#include "SDL_assert.h"
#include "SDL_syspower.h"
#if !TARGET_OS_TV
/* turn off the battery monitor if it's been more than X ms since last check. */
static const int BATTERY_MONITORING_TIMEOUT = 3000;
static Uint32 SDL_UIKitLastPowerInfoQuery = 0;
@@ -46,10 +47,22 @@ SDL_UIKit_UpdateBatteryMonitoring(void)
}
}
}
#else
void
SDL_UIKit_UpdateBatteryMonitoring(void)
{
/* Do nothing. */
}
#endif /* !TARGET_OS_TV */
SDL_bool
SDL_GetPowerInfo_UIKit(SDL_PowerState * state, int *seconds, int *percent)
{
#if TARGET_OS_TV
*state = SDL_POWERSTATE_NO_BATTERY;
*seconds = -1;
*percent = -1;
#else /* TARGET_OS_TV */
@autoreleasepool {
UIDevice *uidev = [UIDevice currentDevice];
@@ -88,8 +101,10 @@ SDL_GetPowerInfo_UIKit(SDL_PowerState * state, int *seconds, int *percent)
const float level = uidev.batteryLevel;
*percent = ( (level < 0.0f) ? -1 : ((int) ((level * 100) + 0.5f)) );
return SDL_TRUE; /* always the definitive answer on iOS. */
}
#endif /* TARGET_OS_TV */
return SDL_TRUE; /* always the definitive answer on iOS. */
}
#endif /* SDL_POWER_UIKIT */