Added VisionOS as a supported target to the Xcode project

Also added SDL_PLATFORM_VISIONOS to the platform definitions and generally switched from TARGET_OS_* macros to SDL_PLATFORM_* macros.
This commit is contained in:
Sam Lantinga
2024-01-27 11:04:06 -08:00
parent 7a7875c904
commit b9ea2dde44
23 changed files with 141 additions and 136 deletions
+4 -2
View File
@@ -2784,9 +2784,10 @@
PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL3; PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL3;
PRODUCT_NAME = SDL3; PRODUCT_NAME = SDL3;
STRIP_STYLE = "non-global"; STRIP_STYLE = "non-global";
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos driverkit appletvsimulator appletvos"; SUPPORTED_PLATFORMS = "xrsimulator xros macosx iphonesimulator iphoneos appletvsimulator appletvos";
SUPPORTS_MACCATALYST = YES; SUPPORTS_MACCATALYST = YES;
TVOS_DEPLOYMENT_TARGET = 9.0; TVOS_DEPLOYMENT_TARGET = 9.0;
XROS_DEPLOYMENT_TARGET = 1.0;
}; };
name = Release; name = Release;
}; };
@@ -2841,9 +2842,10 @@
PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL3; PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL3;
PRODUCT_NAME = SDL3; PRODUCT_NAME = SDL3;
STRIP_INSTALLED_PRODUCT = NO; STRIP_INSTALLED_PRODUCT = NO;
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos driverkit appletvsimulator appletvos"; SUPPORTED_PLATFORMS = "xrsimulator xros macosx iphonesimulator iphoneos appletvsimulator appletvos";
SUPPORTS_MACCATALYST = YES; SUPPORTS_MACCATALYST = YES;
TVOS_DEPLOYMENT_TARGET = 9.0; TVOS_DEPLOYMENT_TARGET = 9.0;
XROS_DEPLOYMENT_TARGET = 1.0;
}; };
name = Debug; name = Debug;
}; };
+5 -2
View File
@@ -86,13 +86,16 @@
#ifndef TARGET_OS_SIMULATOR #ifndef TARGET_OS_SIMULATOR
#define TARGET_OS_SIMULATOR 0 #define TARGET_OS_SIMULATOR 0
#endif #endif
#ifndef TARGET_OS_XR #ifndef TARGET_OS_VISION
#define TARGET_OS_XR 0 #define TARGET_OS_VISION 0
#endif #endif
#if TARGET_OS_TV #if TARGET_OS_TV
#define SDL_PLATFORM_TVOS 1 #define SDL_PLATFORM_TVOS 1
#endif #endif
#if TARGET_OS_VISION
#define SDL_PLATFORM_VISIONOS 1
#endif
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
#define SDL_PLATFORM_IOS 1 #define SDL_PLATFORM_IOS 1
#else #else
+1 -1
View File
@@ -170,7 +170,7 @@
#define SDL_VIDEO_DRIVER_DUMMY 1 #define SDL_VIDEO_DRIVER_DUMMY 1
/* Enable OpenGL ES */ /* Enable OpenGL ES */
#if !TARGET_OS_MACCATALYST #if !TARGET_OS_MACCATALYST && !TARGET_OS_VISION
#define SDL_VIDEO_OPENGL_ES2 1 #define SDL_VIDEO_OPENGL_ES2 1
#define SDL_VIDEO_OPENGL_ES 1 #define SDL_VIDEO_OPENGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES2 1 #define SDL_VIDEO_RENDER_OGL_ES2 1
+3 -3
View File
@@ -417,7 +417,7 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b
category = AVAudioSessionCategoryRecord; category = AVAudioSessionCategoryRecord;
} }
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
if (category == AVAudioSessionCategoryPlayAndRecord) { if (category == AVAudioSessionCategoryPlayAndRecord) {
options |= AVAudioSessionCategoryOptionDefaultToSpeaker; options |= AVAudioSessionCategoryOptionDefaultToSpeaker;
} }
@@ -846,7 +846,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device)
AVAudioSession *session = [AVAudioSession sharedInstance]; AVAudioSession *session = [AVAudioSession sharedInstance];
[session setPreferredSampleRate:device->spec.freq error:nil]; [session setPreferredSampleRate:device->spec.freq error:nil];
device->spec.freq = (int)session.sampleRate; device->spec.freq = (int)session.sampleRate;
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
if (device->iscapture) { if (device->iscapture) {
[session setPreferredInputNumberOfChannels:device->spec.channels error:nil]; [session setPreferredInputNumberOfChannels:device->spec.channels error:nil];
device->spec.channels = session.preferredInputNumberOfChannels; device->spec.channels = session.preferredInputNumberOfChannels;
@@ -856,7 +856,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device)
} }
#else #else
// Calling setPreferredOutputNumberOfChannels seems to break audio output on iOS // Calling setPreferredOutputNumberOfChannels seems to break audio output on iOS
#endif // TARGET_OS_TV #endif /* SDL_PLATFORM_TVOS */
} }
#endif #endif
+4 -4
View File
@@ -75,7 +75,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
org = ""; org = "";
} }
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
#else #else
/* tvOS does not have persistent local storage! /* tvOS does not have persistent local storage!
@@ -95,7 +95,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
} }
array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
if ([array count] > 0) { /* we only want the first item in the list. */ if ([array count] > 0) { /* we only want the first item in the list. */
NSString *str = [array objectAtIndex:0]; NSString *str = [array objectAtIndex:0];
@@ -129,7 +129,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_GetUserFolder(SDL_Folder folder) char *SDL_GetUserFolder(SDL_Folder folder)
{ {
@autoreleasepool { @autoreleasepool {
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
SDL_SetError("tvOS does not have persistent storage"); SDL_SetError("tvOS does not have persistent storage");
return NULL; return NULL;
#else #else
@@ -224,7 +224,7 @@ char *SDL_GetUserFolder(SDL_Folder folder)
mkdir(retval, 0700); mkdir(retval, 0700);
return retval; return retval;
#endif /* TARGET_OS_TV */ #endif /* SDL_PLATFORM_TVOS */
} }
} }
+14 -14
View File
@@ -30,7 +30,7 @@
#include "SDL_mfijoystick_c.h" #include "SDL_mfijoystick_c.h"
#if TARGET_OS_IOS #if defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_TVOS)
#define SDL_JOYSTICK_iOS_ACCELEROMETER #define SDL_JOYSTICK_iOS_ACCELEROMETER
#import <CoreMotion/CoreMotion.h> #import <CoreMotion/CoreMotion.h>
#endif #endif
@@ -325,7 +325,7 @@ static BOOL ElementAlreadyHandled(SDL_JoystickDeviceItem *device, NSString *elem
/* The Nintendo Switch JoyCon home button doesn't ever show as being held down */ /* The Nintendo Switch JoyCon home button doesn't ever show as being held down */
return TRUE; return TRUE;
} }
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
/* The OS uses the home button, it's not available to apps */ /* The OS uses the home button, it's not available to apps */
return TRUE; return TRUE;
#endif #endif
@@ -484,7 +484,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
vendor = USB_VENDOR_APPLE; vendor = USB_VENDOR_APPLE;
product = 2; product = 2;
subtype = 2; subtype = 2;
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
} else if (controller.microGamepad) { } else if (controller.microGamepad) {
vendor = USB_VENDOR_APPLE; vendor = USB_VENDOR_APPLE;
product = 3; product = 3;
@@ -541,7 +541,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
} }
#endif /* DEBUG_CONTROLLER_PROFILE */ #endif /* DEBUG_CONTROLLER_PROFILE */
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
/* tvOS turns the menu button into a system gesture, so we grab it here instead */ /* tvOS turns the menu button into a system gesture, so we grab it here instead */
if (elements[GCInputButtonMenu] && !elements[@"Button Home"]) { if (elements[GCInputButtonMenu] && !elements[@"Button Home"]) {
device->pause_button_index = [device->buttons indexOfObject:GCInputButtonMenu]; device->pause_button_index = [device->buttons indexOfObject:GCInputButtonMenu];
@@ -588,7 +588,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
has_direct_menu = TRUE; has_direct_menu = TRUE;
} }
} }
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
/* The single menu button isn't very reliable, at least as of tvOS 16.1 */ /* The single menu button isn't very reliable, at least as of tvOS 16.1 */
if ((device->button_mask & (1 << SDL_GAMEPAD_BUTTON_BACK)) == 0) { if ((device->button_mask & (1 << SDL_GAMEPAD_BUTTON_BACK)) == 0) {
has_direct_menu = FALSE; has_direct_menu = FALSE;
@@ -620,7 +620,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
device->nhats = 1; /* d-pad */ device->nhats = 1; /* d-pad */
device->nbuttons = nbuttons; device->nbuttons = nbuttons;
} }
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
else if (controller.microGamepad) { else if (controller.microGamepad) {
int nbuttons = 0; int nbuttons = 0;
@@ -786,7 +786,7 @@ static SDL_JoystickDeviceItem *IOS_RemoveJoystickDevice(SDL_JoystickDeviceItem *
return next; return next;
} }
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
static void SDLCALL SDL_AppleTVRemoteRotationHintChanged(void *udata, const char *name, const char *oldValue, const char *newValue) static void SDLCALL SDL_AppleTVRemoteRotationHintChanged(void *udata, const char *name, const char *oldValue, const char *newValue)
{ {
BOOL allowRotation = newValue != NULL && *newValue != '0'; BOOL allowRotation = newValue != NULL && *newValue != '0';
@@ -799,7 +799,7 @@ static void SDLCALL SDL_AppleTVRemoteRotationHintChanged(void *udata, const char
} }
} }
} }
#endif /* TARGET_OS_TV */ #endif /* SDL_PLATFORM_TVOS */
static int IOS_JoystickInit(void) static int IOS_JoystickInit(void)
{ {
@@ -843,10 +843,10 @@ static int IOS_JoystickInit(void)
IOS_AddJoystickDevice(controller, SDL_FALSE); IOS_AddJoystickDevice(controller, SDL_FALSE);
} }
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
SDL_AddHintCallback(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, SDL_AddHintCallback(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION,
SDL_AppleTVRemoteRotationHintChanged, NULL); SDL_AppleTVRemoteRotationHintChanged, NULL);
#endif /* TARGET_OS_TV */ #endif /* SDL_PLATFORM_TVOS */
center = [NSNotificationCenter defaultCenter]; center = [NSNotificationCenter defaultCenter];
@@ -1248,7 +1248,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
SDL_small_free(buttons, isstack); SDL_small_free(buttons, isstack);
} }
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
else if (controller.microGamepad) { else if (controller.microGamepad) {
GCMicroGamepad *gamepad = controller.microGamepad; GCMicroGamepad *gamepad = controller.microGamepad;
@@ -1271,7 +1271,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
SDL_SendJoystickButton(timestamp, joystick, i, buttons[i]); SDL_SendJoystickButton(timestamp, joystick, i, buttons[i]);
} }
} }
#endif /* TARGET_OS_TV */ #endif /* SDL_PLATFORM_TVOS */
if (joystick->nhats > 0) { if (joystick->nhats > 0) {
SDL_SendJoystickHat(timestamp, joystick, 0, hatstate); SDL_SendJoystickHat(timestamp, joystick, 0, hatstate);
@@ -1799,10 +1799,10 @@ static void IOS_JoystickQuit(void)
disconnectObserver = nil; disconnectObserver = nil;
} }
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
SDL_DelHintCallback(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, SDL_DelHintCallback(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION,
SDL_AppleTVRemoteRotationHintChanged, NULL); SDL_AppleTVRemoteRotationHintChanged, NULL);
#endif /* TARGET_OS_TV */ #endif /* SDL_PLATFORM_TVOS */
#endif /* SDL_JOYSTICK_MFI */ #endif /* SDL_JOYSTICK_MFI */
while (deviceList != NULL) { while (deviceList != NULL) {
+1 -1
View File
@@ -30,7 +30,7 @@ int SDL_SYS_OpenURL(const char *url)
{ {
@autoreleasepool { @autoreleasepool {
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
return SDL_Unsupported(); // openURL is not suported on visionOS return SDL_Unsupported(); // openURL is not suported on visionOS
#else #else
NSString *nsstr = [NSString stringWithUTF8String:url]; NSString *nsstr = [NSString stringWithUTF8String:url];
+5 -5
View File
@@ -27,7 +27,7 @@
#include "SDL_syspower.h" #include "SDL_syspower.h"
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
/* turn off the battery monitor if it's been more than X ms since last check. */ /* turn off the battery monitor if it's been more than X ms since last check. */
static const int BATTERY_MONITORING_TIMEOUT = 3000; static const int BATTERY_MONITORING_TIMEOUT = 3000;
static Uint64 SDL_UIKitLastPowerInfoQuery = 0; static Uint64 SDL_UIKitLastPowerInfoQuery = 0;
@@ -48,15 +48,15 @@ void SDL_UIKit_UpdateBatteryMonitoring(void)
{ {
/* Do nothing. */ /* Do nothing. */
} }
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percent) SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percent)
{ {
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
*state = SDL_POWERSTATE_NO_BATTERY; *state = SDL_POWERSTATE_NO_BATTERY;
*seconds = -1; *seconds = -1;
*percent = -1; *percent = -1;
#else /* TARGET_OS_TV */ #else /* SDL_PLATFORM_TVOS */
@autoreleasepool { @autoreleasepool {
UIDevice *uidev = [UIDevice currentDevice]; UIDevice *uidev = [UIDevice currentDevice];
@@ -96,7 +96,7 @@ SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percen
const float level = uidev.batteryLevel; const float level = uidev.batteryLevel;
*percent = ((level < 0.0f) ? -1 : ((int)((level * 100) + 0.5f))); *percent = ((level < 0.0f) ? -1 : ((int)((level * 100) + 0.5f)));
} }
#endif /* TARGET_OS_TV */ #endif /* SDL_PLATFORM_TVOS */
return SDL_TRUE; /* always the definitive answer on iOS. */ return SDL_TRUE; /* always the definitive answer on iOS. */
} }
+1 -1
View File
@@ -33,7 +33,7 @@
#undef HAVE_COREMEDIA #undef HAVE_COREMEDIA
#endif #endif
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
#undef HAVE_COREMEDIA #undef HAVE_COREMEDIA
#endif #endif
+16 -16
View File
@@ -30,7 +30,7 @@
#include "../../events/SDL_events_c.h" #include "../../events/SDL_events_c.h"
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
#include <AvailabilityVersions.h> #include <AvailabilityVersions.h>
#ifndef __IPHONE_13_0 #ifndef __IPHONE_13_0
@@ -79,7 +79,7 @@ int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserv
return exit_status; return exit_status;
} }
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
/* Load a launch image using the old UILaunchImageFile-era naming rules. */ /* Load a launch image using the old UILaunchImageFile-era naming rules. */
static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
{ {
@@ -142,7 +142,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
self.storyboardViewController.view.frame = self.view.bounds; self.storyboardViewController.view.frame = self.view.bounds;
[self.storyboardViewController didMoveToParentViewController:self]; [self.storyboardViewController didMoveToParentViewController:self];
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
UIApplication.sharedApplication.statusBarHidden = self.prefersStatusBarHidden; UIApplication.sharedApplication.statusBarHidden = self.prefersStatusBarHidden;
UIApplication.sharedApplication.statusBarStyle = self.preferredStatusBarStyle; UIApplication.sharedApplication.statusBarStyle = self.preferredStatusBarStyle;
#endif #endif
@@ -170,11 +170,11 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
} }
@end @end
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
@interface SDLLaunchScreenController () @interface SDLLaunchScreenController ()
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
- (NSUInteger)supportedInterfaceOrientations; - (NSUInteger)supportedInterfaceOrientations;
#endif #endif
@@ -213,7 +213,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
NSString *imagename = nil; NSString *imagename = nil;
UIImage *image = nil; UIImage *image = nil;
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
int screenw = SDL_XR_SCREENWIDTH; int screenw = SDL_XR_SCREENWIDTH;
int screenh = SDL_XR_SCREENHEIGHT; int screenh = SDL_XR_SCREENHEIGHT;
#else #else
@@ -223,7 +223,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation; UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
/* We always want portrait-oriented size, to match UILaunchImageSize. */ /* We always want portrait-oriented size, to match UILaunchImageSize. */
@@ -253,7 +253,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
} }
} }
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
UIInterfaceOrientationMask orientmask = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; UIInterfaceOrientationMask orientmask = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
NSString *orientstring = dict[@"UILaunchImageOrientation"]; NSString *orientstring = dict[@"UILaunchImageOrientation"];
@@ -282,7 +282,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
image = [UIImage imageNamed:imagename]; image = [UIImage imageNamed:imagename];
} }
} }
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
else { else {
imagename = [bundle objectForInfoDictionaryKey:@"UILaunchImageFile"]; imagename = [bundle objectForInfoDictionaryKey:@"UILaunchImageFile"];
@@ -297,7 +297,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
#endif #endif
if (image) { if (image) {
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
CGRect viewFrame = CGRectMake(0, 0, screenw, screenh); CGRect viewFrame = CGRectMake(0, 0, screenw, screenh);
#else #else
CGRect viewFrame = [UIScreen mainScreen].bounds; CGRect viewFrame = [UIScreen mainScreen].bounds;
@@ -305,7 +305,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
UIImageView *view = [[UIImageView alloc] initWithFrame:viewFrame]; UIImageView *view = [[UIImageView alloc] initWithFrame:viewFrame];
UIImageOrientation imageorient = UIImageOrientationUp; UIImageOrientation imageorient = UIImageOrientationUp;
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
/* Bugs observed / workaround tested in iOS 8.3. */ /* Bugs observed / workaround tested in iOS 8.3. */
if (UIInterfaceOrientationIsLandscape(curorient)) { if (UIInterfaceOrientationIsLandscape(curorient)) {
if (image.size.width < image.size.height) { if (image.size.width < image.size.height) {
@@ -337,7 +337,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
/* Do nothing. */ /* Do nothing. */
} }
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
- (BOOL)shouldAutorotate - (BOOL)shouldAutorotate
{ {
/* If YES, the launch image will be incorrectly rotated in some cases. */ /* If YES, the launch image will be incorrectly rotated in some cases. */
@@ -351,7 +351,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
* the ones set here (it will cause an exception in that case.) */ * the ones set here (it will cause an exception in that case.) */
return UIInterfaceOrientationMaskAll; return UIInterfaceOrientationMaskAll;
} }
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
@end @end
@@ -434,7 +434,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
NSString *screenname = nil; NSString *screenname = nil;
/* tvOS only uses a plain launch image. */ /* tvOS only uses a plain launch image. */
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"]; screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
if (screenname) { if (screenname) {
@@ -457,7 +457,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
} }
if (vc.view) { if (vc.view) {
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
CGRect viewFrame = CGRectMake(0, 0, SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT); CGRect viewFrame = CGRectMake(0, 0, SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT);
#else #else
CGRect viewFrame = [UIScreen mainScreen].bounds; CGRect viewFrame = [UIScreen mainScreen].bounds;
@@ -517,7 +517,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
SDL_SendDropComplete(NULL); SDL_SendDropComplete(NULL);
} }
#if TARGET_OS_TV || (defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0) #if defined(SDL_PLATFORM_TVOS) || (defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0)
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
{ {
+4 -4
View File
@@ -29,7 +29,7 @@
int UIKit_SetClipboardText(SDL_VideoDevice *_this, const char *text) int UIKit_SetClipboardText(SDL_VideoDevice *_this, const char *text)
{ {
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
return SDL_SetError("The clipboard is not available on tvOS"); return SDL_SetError("The clipboard is not available on tvOS");
#else #else
@autoreleasepool { @autoreleasepool {
@@ -41,7 +41,7 @@ int UIKit_SetClipboardText(SDL_VideoDevice *_this, const char *text)
char *UIKit_GetClipboardText(SDL_VideoDevice *_this) char *UIKit_GetClipboardText(SDL_VideoDevice *_this)
{ {
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
return SDL_strdup(""); // Unsupported. return SDL_strdup(""); // Unsupported.
#else #else
@autoreleasepool { @autoreleasepool {
@@ -60,7 +60,7 @@ char *UIKit_GetClipboardText(SDL_VideoDevice *_this)
SDL_bool UIKit_HasClipboardText(SDL_VideoDevice *_this) SDL_bool UIKit_HasClipboardText(SDL_VideoDevice *_this)
{ {
@autoreleasepool { @autoreleasepool {
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
if ([UIPasteboard generalPasteboard].string != nil) { if ([UIPasteboard generalPasteboard].string != nil) {
return SDL_TRUE; return SDL_TRUE;
} }
@@ -71,7 +71,7 @@ SDL_bool UIKit_HasClipboardText(SDL_VideoDevice *_this)
void UIKit_InitClipboard(SDL_VideoDevice *_this) void UIKit_InitClipboard(SDL_VideoDevice *_this)
{ {
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
@autoreleasepool { @autoreleasepool {
SDL_UIKitVideoData *data = (__bridge SDL_UIKitVideoData *)_this->driverdata; SDL_UIKitVideoData *data = (__bridge SDL_UIKitVideoData *)_this->driverdata;
NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+2 -2
View File
@@ -57,7 +57,7 @@ static BOOL UIKit_EventPumpEnabled = YES;
[notificationCenter addObserver:self selector:@selector(applicationWillEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil]; [notificationCenter addObserver:self selector:@selector(applicationWillEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil];
[notificationCenter addObserver:self selector:@selector(applicationWillTerminate) name:UIApplicationWillTerminateNotification object:nil]; [notificationCenter addObserver:self selector:@selector(applicationWillTerminate) name:UIApplicationWillTerminateNotification object:nil];
[notificationCenter addObserver:self selector:@selector(applicationDidReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; [notificationCenter addObserver:self selector:@selector(applicationDidReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
[notificationCenter addObserver:self [notificationCenter addObserver:self
selector:@selector(applicationDidChangeStatusBarOrientation) selector:@selector(applicationDidChangeStatusBarOrientation)
name:UIApplicationDidChangeStatusBarOrientationNotification name:UIApplicationDidChangeStatusBarOrientationNotification
@@ -99,7 +99,7 @@ static BOOL UIKit_EventPumpEnabled = YES;
SDL_OnApplicationDidReceiveMemoryWarning(); SDL_OnApplicationDidReceiveMemoryWarning();
} }
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
- (void)applicationDidChangeStatusBarOrientation - (void)applicationDidChangeStatusBarOrientation
{ {
SDL_OnApplicationDidChangeStatusBarOrientation(); SDL_OnApplicationDidChangeStatusBarOrientation();
+1 -1
View File
@@ -98,7 +98,7 @@ static BOOL UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messag
} }
if (window == nil || window.rootViewController == nil) { if (window == nil || window.rootViewController == nil) {
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
alertwindow = [[UIWindow alloc] init]; alertwindow = [[UIWindow alloc] init];
#else #else
alertwindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; alertwindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
+1 -1
View File
@@ -79,7 +79,7 @@ SDL_MetalView UIKit_Metal_CreateView(SDL_VideoDevice *_this, SDL_Window *window)
CGFloat scale = 1.0; CGFloat scale = 1.0;
SDL_uikitmetalview *metalview; SDL_uikitmetalview *metalview;
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) {
/* Set the scale to the natural scale factor of the screen - then /* Set the scale to the natural scale factor of the screen - then
* the backing dimensions of the Metal view will match the pixel * the backing dimensions of the Metal view will match the pixel
+5 -5
View File
@@ -27,7 +27,7 @@
@interface SDL_UIKitDisplayData : NSObject @interface SDL_UIKitDisplayData : NSObject
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
- (instancetype)initWithScreen:(UIScreen *)screen; - (instancetype)initWithScreen:(UIScreen *)screen;
@property(nonatomic, strong) UIScreen *uiscreen; @property(nonatomic, strong) UIScreen *uiscreen;
#endif #endif
@@ -35,18 +35,18 @@
@end @end
@interface SDL_UIKitDisplayModeData : NSObject @interface SDL_UIKitDisplayModeData : NSObject
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
@property(nonatomic, strong) UIScreenMode *uiscreenmode; @property(nonatomic, strong) UIScreenMode *uiscreenmode;
#endif #endif
@end @end
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
extern SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen); extern SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen);
#endif #endif
extern int UIKit_InitModes(SDL_VideoDevice *_this); extern int UIKit_InitModes(SDL_VideoDevice *_this);
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
extern int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event); extern int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event);
extern void UIKit_DelDisplay(UIScreen *uiscreen); extern void UIKit_DelDisplay(UIScreen *uiscreen);
#endif #endif
@@ -57,7 +57,7 @@ extern int UIKit_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay
// because visionOS does not have a screen // because visionOS does not have a screen
// we create a fake 1080p display to maintain compatibility. // we create a fake 1080p display to maintain compatibility.
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
#define SDL_XR_SCREENWIDTH 1920 #define SDL_XR_SCREENWIDTH 1920
#define SDL_XR_SCREENHEIGHT 1080 #define SDL_XR_SCREENHEIGHT 1080
#endif #endif
+22 -22
View File
@@ -30,7 +30,7 @@
@implementation SDL_UIKitDisplayData @implementation SDL_UIKitDisplayData
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
- (instancetype)initWithScreen:(UIScreen *)screen - (instancetype)initWithScreen:(UIScreen *)screen
{ {
if (self = [super init]) { if (self = [super init]) {
@@ -45,7 +45,7 @@
@implementation SDL_UIKitDisplayModeData @implementation SDL_UIKitDisplayModeData
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
@synthesize uiscreenmode; @synthesize uiscreenmode;
#endif #endif
@@ -54,7 +54,7 @@
@interface SDL_DisplayWatch : NSObject @interface SDL_DisplayWatch : NSObject
@end @end
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
@implementation SDL_DisplayWatch @implementation SDL_DisplayWatch
+ (void)start + (void)start
@@ -98,7 +98,7 @@
@end @end
#endif #endif
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
static int UIKit_AllocateDisplayModeData(SDL_DisplayMode *mode, static int UIKit_AllocateDisplayModeData(SDL_DisplayMode *mode,
UIScreenMode *uiscreenmode) UIScreenMode *uiscreenmode)
{ {
@@ -128,7 +128,7 @@ static void UIKit_FreeDisplayModeData(SDL_DisplayMode *mode)
} }
} }
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
static float UIKit_GetDisplayModeRefreshRate(UIScreen *uiscreen) static float UIKit_GetDisplayModeRefreshRate(UIScreen *uiscreen)
{ {
#ifdef __IPHONE_10_3 #ifdef __IPHONE_10_3
@@ -229,7 +229,7 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event)
} }
SDL_zero(display); SDL_zero(display);
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
if (uiscreen == [UIScreen mainScreen]) { if (uiscreen == [UIScreen mainScreen]) {
/* The natural orientation (used by sensors) is portrait */ /* The natural orientation (used by sensors) is portrait */
display.natural_orientation = SDL_ORIENTATION_PORTRAIT; display.natural_orientation = SDL_ORIENTATION_PORTRAIT;
@@ -243,7 +243,7 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event)
display.desktop_mode = mode; display.desktop_mode = mode;
/* Allocate the display data */ /* Allocate the display data */
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
SDL_UIKitDisplayData *data = [[SDL_UIKitDisplayData alloc] init]; SDL_UIKitDisplayData *data = [[SDL_UIKitDisplayData alloc] init];
#else #else
SDL_UIKitDisplayData *data = [[SDL_UIKitDisplayData alloc] initWithScreen:uiscreen]; SDL_UIKitDisplayData *data = [[SDL_UIKitDisplayData alloc] initWithScreen:uiscreen];
@@ -261,7 +261,7 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event)
} }
#endif #endif
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
int UIKit_AddDisplay(SDL_bool send_event){ int UIKit_AddDisplay(SDL_bool send_event){
CGSize size = CGSizeMake(SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT); CGSize size = CGSizeMake(SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT);
SDL_VideoDisplay display; SDL_VideoDisplay display;
@@ -293,7 +293,7 @@ int UIKit_AddDisplay(SDL_bool send_event){
} }
#endif #endif
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
void UIKit_DelDisplay(UIScreen *uiscreen) void UIKit_DelDisplay(UIScreen *uiscreen)
{ {
@@ -318,11 +318,11 @@ void UIKit_DelDisplay(UIScreen *uiscreen)
SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen) SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen)
{ {
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
if (uiscreen == [UIScreen mainScreen]) { if (uiscreen == [UIScreen mainScreen]) {
return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation); return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
} else } else
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
{ {
CGSize size = uiscreen.bounds.size; CGSize size = uiscreen.bounds.size;
return (size.width > size.height); return (size.width > size.height);
@@ -332,7 +332,7 @@ SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen)
int UIKit_InitModes(SDL_VideoDevice *_this) int UIKit_InitModes(SDL_VideoDevice *_this)
{ {
@autoreleasepool { @autoreleasepool {
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
UIKit_AddDisplay(SDL_FALSE); UIKit_AddDisplay(SDL_FALSE);
#else #else
for (UIScreen *uiscreen in [UIScreen screens]) { for (UIScreen *uiscreen in [UIScreen screens]) {
@@ -342,11 +342,11 @@ int UIKit_InitModes(SDL_VideoDevice *_this)
} }
#endif #endif
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
SDL_OnApplicationDidChangeStatusBarOrientation(); SDL_OnApplicationDidChangeStatusBarOrientation();
#endif #endif
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
[SDL_DisplayWatch start]; [SDL_DisplayWatch start];
#endif #endif
} }
@@ -356,7 +356,7 @@ int UIKit_InitModes(SDL_VideoDevice *_this)
int UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) int UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
{ {
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
@autoreleasepool { @autoreleasepool {
SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->driverdata; SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->driverdata;
@@ -364,7 +364,7 @@ int UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
SDL_bool addRotation = (data.uiscreen == [UIScreen mainScreen]); SDL_bool addRotation = (data.uiscreen == [UIScreen mainScreen]);
NSArray *availableModes = nil; NSArray *availableModes = nil;
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
addRotation = SDL_FALSE; addRotation = SDL_FALSE;
availableModes = @[ data.uiscreen.currentMode ]; availableModes = @[ data.uiscreen.currentMode ];
#else #else
@@ -392,11 +392,11 @@ int UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
int UIKit_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) int UIKit_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{ {
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
@autoreleasepool { @autoreleasepool {
SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->driverdata; SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->driverdata;
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
SDL_UIKitDisplayModeData *modedata = (__bridge SDL_UIKitDisplayModeData *)mode->driverdata; SDL_UIKitDisplayModeData *modedata = (__bridge SDL_UIKitDisplayModeData *)mode->driverdata;
[data.uiscreen setCurrentMode:modedata.uiscreenmode]; [data.uiscreen setCurrentMode:modedata.uiscreenmode];
#endif #endif
@@ -424,7 +424,7 @@ int UIKit_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *displ
{ {
@autoreleasepool { @autoreleasepool {
SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->driverdata; SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->driverdata;
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
CGRect frame = CGRectMake(0, 0, SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT); CGRect frame = CGRectMake(0, 0, SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT);
#else #else
CGRect frame = data.uiscreen.bounds; CGRect frame = data.uiscreen.bounds;
@@ -447,7 +447,7 @@ int UIKit_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *displ
void UIKit_QuitModes(SDL_VideoDevice *_this) void UIKit_QuitModes(SDL_VideoDevice *_this)
{ {
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
[SDL_DisplayWatch stop]; [SDL_DisplayWatch stop];
#endif #endif
@@ -471,7 +471,7 @@ void UIKit_QuitModes(SDL_VideoDevice *_this)
} }
} }
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
void SDL_OnApplicationDidChangeStatusBarOrientation(void) void SDL_OnApplicationDidChangeStatusBarOrientation(void)
{ {
BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation); BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
@@ -523,6 +523,6 @@ void SDL_OnApplicationDidChangeStatusBarOrientation(void)
SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_ORIENTATION, orientation); SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_ORIENTATION, orientation);
} }
} }
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
#endif /* SDL_VIDEO_DRIVER_UIKIT */ #endif /* SDL_VIDEO_DRIVER_UIKIT */
+1 -1
View File
@@ -33,7 +33,7 @@
@end @end
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
CGRect UIKit_ComputeViewFrame(SDL_Window *window); CGRect UIKit_ComputeViewFrame(SDL_Window *window);
#else #else
CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen); CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
+5 -5
View File
@@ -186,7 +186,7 @@ SDL_bool UIKit_IsSystemVersionAtLeast(double version)
SDL_SystemTheme UIKit_GetSystemTheme(void) SDL_SystemTheme UIKit_GetSystemTheme(void)
{ {
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
if (@available(iOS 12.0, tvOS 10.0, *)) { if (@available(iOS 12.0, tvOS 10.0, *)) {
switch ([UIScreen mainScreen].traitCollection.userInterfaceStyle) { switch ([UIScreen mainScreen].traitCollection.userInterfaceStyle) {
case UIUserInterfaceStyleDark: case UIUserInterfaceStyleDark:
@@ -201,7 +201,7 @@ SDL_SystemTheme UIKit_GetSystemTheme(void)
return SDL_SYSTEM_THEME_UNKNOWN; return SDL_SYSTEM_THEME_UNKNOWN;
} }
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
CGRect UIKit_ComputeViewFrame(SDL_Window *window){ CGRect UIKit_ComputeViewFrame(SDL_Window *window){
return CGRectMake(window->x, window->y, window->w, window->h); return CGRectMake(window->x, window->y, window->w, window->h);
} }
@@ -218,7 +218,7 @@ CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
frame = data.uiwindow.bounds; frame = data.uiwindow.bounds;
} }
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
/* iOS 10 seems to have a bug where, in certain conditions, putting the /* iOS 10 seems to have a bug where, in certain conditions, putting the
* device to sleep with the a landscape-only app open, re-orienting the * device to sleep with the a landscape-only app open, re-orienting the
* device to portrait, and turning it back on will result in the screen * device to portrait, and turning it back on will result in the screen
@@ -248,7 +248,7 @@ CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
void UIKit_ForceUpdateHomeIndicator(void) void UIKit_ForceUpdateHomeIndicator(void)
{ {
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
/* Force the main SDL window to re-evaluate home indicator state */ /* Force the main SDL window to re-evaluate home indicator state */
SDL_Window *focus = SDL_GetKeyboardFocus(); SDL_Window *focus = SDL_GetKeyboardFocus();
if (focus) { if (focus) {
@@ -263,7 +263,7 @@ void UIKit_ForceUpdateHomeIndicator(void)
#pragma clang diagnostic pop #pragma clang diagnostic pop
} }
} }
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
} }
/* /*
+2 -2
View File
@@ -23,7 +23,7 @@
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
#if !TARGET_OS_TV && defined(__IPHONE_13_4) #if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
@interface SDL_uikitview : UIView <UIPointerInteractionDelegate> @interface SDL_uikitview : UIView <UIPointerInteractionDelegate>
#else #else
@interface SDL_uikitview : UIView @interface SDL_uikitview : UIView
@@ -33,7 +33,7 @@
- (void)setSDLWindow:(SDL_Window *)window; - (void)setSDLWindow:(SDL_Window *)window;
#if !TARGET_OS_TV && defined(__IPHONE_13_4) #if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
- (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4)); - (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4));
- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4)); - (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4));
#endif #endif
+12 -12
View File
@@ -52,7 +52,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
{ {
if ((self = [super initWithFrame:frame])) { if ((self = [super initWithFrame:frame])) {
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
/* Apple TV Remote touchpad swipe gestures. */ /* Apple TV Remote touchpad swipe gestures. */
UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)]; UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp; swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
@@ -77,12 +77,12 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
directTouchId = 1; directTouchId = 1;
indirectTouchId = 2; indirectTouchId = 2;
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
self.multipleTouchEnabled = YES; self.multipleTouchEnabled = YES;
SDL_AddTouch(directTouchId, SDL_TOUCH_DEVICE_DIRECT, ""); SDL_AddTouch(directTouchId, SDL_TOUCH_DEVICE_DIRECT, "");
#endif #endif
#if !TARGET_OS_TV && defined(__IPHONE_13_4) #if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) { if (@available(iOS 13.4, *)) {
[self addInteraction:[[UIPointerInteraction alloc] initWithDelegate:self]]; [self addInteraction:[[UIPointerInteraction alloc] initWithDelegate:self]];
} }
@@ -148,7 +148,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
sdlwindow = window; sdlwindow = window;
} }
#if !TARGET_OS_TV && defined(__IPHONE_13_4) #if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
- (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4)) - (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4))
{ {
if (request != nil && !SDL_GCMouseRelativeMode()) { if (request != nil && !SDL_GCMouseRelativeMode()) {
@@ -171,7 +171,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
return [UIPointerStyle hiddenPointerStyle]; return [UIPointerStyle hiddenPointerStyle];
} }
} }
#endif /* !TARGET_OS_TV && __IPHONE_13_4 */ #endif /* !defined(SDL_PLATFORM_TVOS) && __IPHONE_13_4 */
- (SDL_TouchDeviceType)touchTypeForTouch:(UITouch *)touch - (SDL_TouchDeviceType)touchTypeForTouch:(UITouch *)touch
{ {
@@ -226,7 +226,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
BOOL handled = NO; BOOL handled = NO;
#if !TARGET_OS_TV && defined(__IPHONE_13_4) #if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) { if (@available(iOS 13.4, *)) {
if (touch.type == UITouchTypeIndirectPointer) { if (touch.type == UITouchTypeIndirectPointer) {
if (!SDL_HasGCMouse()) { if (!SDL_HasGCMouse()) {
@@ -282,7 +282,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
BOOL handled = NO; BOOL handled = NO;
#if !TARGET_OS_TV && defined(__IPHONE_13_4) #if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) { if (@available(iOS 13.4, *)) {
if (touch.type == UITouchTypeIndirectPointer) { if (touch.type == UITouchTypeIndirectPointer) {
if (!SDL_HasGCMouse()) { if (!SDL_HasGCMouse()) {
@@ -343,7 +343,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
BOOL handled = NO; BOOL handled = NO;
#if !TARGET_OS_TV && defined(__IPHONE_13_4) #if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) { if (@available(iOS 13.4, *)) {
if (touch.type == UITouchTypeIndirectPointer) { if (touch.type == UITouchTypeIndirectPointer) {
/* Already handled in pointerInteraction callback */ /* Already handled in pointerInteraction callback */
@@ -368,7 +368,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
} }
} }
#if TARGET_OS_TV || defined(__IPHONE_9_1) #if defined(SDL_PLATFORM_TVOS) || defined(__IPHONE_9_1)
- (SDL_Scancode)scancodeFromPress:(UIPress *)press - (SDL_Scancode)scancodeFromPress:(UIPress *)press
{ {
#ifdef __IPHONE_13_4 #ifdef __IPHONE_13_4
@@ -456,9 +456,9 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
} }
} }
#endif /* TARGET_OS_TV || defined(__IPHONE_9_1) */ #endif /* defined(SDL_PLATFORM_TVOS) || defined(__IPHONE_9_1) */
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
- (void)swipeGesture:(UISwipeGestureRecognizer *)gesture - (void)swipeGesture:(UISwipeGestureRecognizer *)gesture
{ {
/* Swipe gestures don't trigger begin states. */ /* Swipe gestures don't trigger begin states. */
@@ -485,7 +485,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
#endif /* !SDL_JOYSTICK_DISABLED */ #endif /* !SDL_JOYSTICK_DISABLED */
} }
} }
#endif /* TARGET_OS_TV */ #endif /* SDL_PLATFORM_TVOS */
@end @end
+2 -2
View File
@@ -24,7 +24,7 @@
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
#import <GameController/GameController.h> #import <GameController/GameController.h>
#define SDLRootViewController GCEventViewController #define SDLRootViewController GCEventViewController
#else #else
@@ -59,7 +59,7 @@
- (void)loadView; - (void)loadView;
- (void)viewDidLayoutSubviews; - (void)viewDidLayoutSubviews;
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
- (NSUInteger)supportedInterfaceOrientations; - (NSUInteger)supportedInterfaceOrientations;
- (BOOL)prefersStatusBarHidden; - (BOOL)prefersStatusBarHidden;
- (BOOL)prefersHomeIndicatorAutoHidden; - (BOOL)prefersHomeIndicatorAutoHidden;
+13 -13
View File
@@ -33,7 +33,7 @@
#include "SDL_uikitwindow.h" #include "SDL_uikitwindow.h"
#include "SDL_uikitopengles.h" #include "SDL_uikitopengles.h"
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
static void SDLCALL SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) static void SDLCALL SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{ {
@autoreleasepool { @autoreleasepool {
@@ -43,7 +43,7 @@ static void SDLCALL SDL_AppleTVControllerUIHintChanged(void *userdata, const cha
} }
#endif #endif
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{ {
@autoreleasepool { @autoreleasepool {
@@ -104,13 +104,13 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
rotatingOrientation = NO; rotatingOrientation = NO;
#endif #endif
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
SDL_AddHintCallback(SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS, SDL_AddHintCallback(SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS,
SDL_AppleTVControllerUIHintChanged, SDL_AppleTVControllerUIHintChanged,
(__bridge void *)self); (__bridge void *)self);
#endif #endif
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
SDL_AddHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR, SDL_AddHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR,
SDL_HideHomeIndicatorHintChanged, SDL_HideHomeIndicatorHintChanged,
(__bridge void *)self); (__bridge void *)self);
@@ -125,13 +125,13 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
[self deinitKeyboard]; [self deinitKeyboard];
#endif #endif
#if TARGET_OS_TV #ifdef SDL_PLATFORM_TVOS
SDL_DelHintCallback(SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS, SDL_DelHintCallback(SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS,
SDL_AppleTVControllerUIHintChanged, SDL_AppleTVControllerUIHintChanged,
(__bridge void *)self); (__bridge void *)self);
#endif #endif
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
SDL_DelHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR, SDL_DelHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR,
SDL_HideHomeIndicatorHintChanged, SDL_HideHomeIndicatorHintChanged,
(__bridge void *)self); (__bridge void *)self);
@@ -162,7 +162,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
{ {
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(doLoop:)]; displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(doLoop:)];
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
displayLink.preferredFramesPerSecond = 90 / animationInterval; //TODO: Get frame max frame rate on visionOS displayLink.preferredFramesPerSecond = 90 / animationInterval; //TODO: Get frame max frame rate on visionOS
#elif defined(__IPHONE_10_3) #elif defined(__IPHONE_10_3)
SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->driverdata; SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->driverdata;
@@ -213,7 +213,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, w, h); SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, w, h);
} }
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
- (NSUInteger)supportedInterfaceOrientations - (NSUInteger)supportedInterfaceOrientations
{ {
return UIKit_GetSupportedOrientations(window); return UIKit_GetSupportedOrientations(window);
@@ -257,7 +257,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
return SDL_GCMouseRelativeMode() ? YES : NO; return SDL_GCMouseRelativeMode() ? YES : NO;
} }
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
/* /*
---- Keyboard related functionality below this line ---- ---- Keyboard related functionality below this line ----
@@ -291,7 +291,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
keyboardVisible = NO; keyboardVisible = NO;
NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
[center addObserver:self [center addObserver:self
selector:@selector(keyboardWillShow:) selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification name:UIKeyboardWillShowNotification
@@ -374,7 +374,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
- (void)deinitKeyboard - (void)deinitKeyboard
{ {
NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
[center removeObserver:self [center removeObserver:self
name:UIKeyboardWillShowNotification name:UIKeyboardWillShowNotification
object:nil]; object:nil];
@@ -430,7 +430,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
} }
showingKeyboard = YES; showingKeyboard = YES;
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
CGRect kbrect = [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue]; CGRect kbrect = [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue];
/* The keyboard rect is in the coordinate space of the screen/window, but we /* The keyboard rect is in the coordinate space of the screen/window, but we
@@ -515,7 +515,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
CGAffineTransform t = self.view.transform; CGAffineTransform t = self.view.transform;
CGPoint offset = CGPointMake(0.0, 0.0); CGPoint offset = CGPointMake(0.0, 0.0);
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
CGRect frame = UIKit_ComputeViewFrame(window); CGRect frame = UIKit_ComputeViewFrame(window);
#else #else
CGRect frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen); CGRect frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen);
+17 -17
View File
@@ -63,7 +63,7 @@
- (void)layoutSubviews - (void)layoutSubviews
{ {
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
/* Workaround to fix window orientation issues in iOS 8. */ /* Workaround to fix window orientation issues in iOS 8. */
/* As of July 1 2019, I haven't been able to reproduce any orientation /* As of July 1 2019, I haven't been able to reproduce any orientation
* issues with this disabled on iOS 12. The issue this is meant to fix might * issues with this disabled on iOS 12. The issue this is meant to fix might
@@ -85,7 +85,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow
SDL_UIKitDisplayData *displaydata = (__bridge SDL_UIKitDisplayData *)display->driverdata; SDL_UIKitDisplayData *displaydata = (__bridge SDL_UIKitDisplayData *)display->driverdata;
SDL_uikitview *view; SDL_uikitview *view;
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
CGRect frame = UIKit_ComputeViewFrame(window); CGRect frame = UIKit_ComputeViewFrame(window);
#else #else
CGRect frame = UIKit_ComputeViewFrame(window, displaydata.uiscreen); CGRect frame = UIKit_ComputeViewFrame(window, displaydata.uiscreen);
@@ -103,7 +103,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow
data.uiwindow = uiwindow; data.uiwindow = uiwindow;
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
if (displaydata.uiscreen != [UIScreen mainScreen]) { if (displaydata.uiscreen != [UIScreen mainScreen]) {
window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizable */ window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizable */
window->flags &= ~SDL_WINDOW_INPUT_FOCUS; /* never has input focus */ window->flags &= ~SDL_WINDOW_INPUT_FOCUS; /* never has input focus */
@@ -111,7 +111,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow
} }
#endif #endif
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
if (displaydata.uiscreen == [UIScreen mainScreen]) { if (displaydata.uiscreen == [UIScreen mainScreen]) {
NSUInteger orients = UIKit_GetSupportedOrientations(window); NSUInteger orients = UIKit_GetSupportedOrientations(window);
BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0; BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0;
@@ -124,7 +124,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow
height = temp; height = temp;
} }
} }
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
#if 0 /* Don't set the x/y position, it's already placed on a display */ #if 0 /* Don't set the x/y position, it's already placed on a display */
window->x = 0; window->x = 0;
@@ -169,7 +169,7 @@ int UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie
/* If monitor has a resolution of 0x0 (hasn't been explicitly set by the /* If monitor has a resolution of 0x0 (hasn't been explicitly set by the
* user, so it's in standby), try to force the display to a resolution * user, so it's in standby), try to force the display to a resolution
* that most closely matches the desired window size. */ * that most closely matches the desired window size. */
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
const CGSize origsize = data.uiscreen.currentMode.size; const CGSize origsize = data.uiscreen.currentMode.size;
if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) { if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) {
const SDL_DisplayMode *bestmode; const SDL_DisplayMode *bestmode;
@@ -196,18 +196,18 @@ int UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie
[UIApplication sharedApplication].statusBarHidden = NO; [UIApplication sharedApplication].statusBarHidden = NO;
} }
} }
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
/* ignore the size user requested, and make a fullscreen window */ /* ignore the size user requested, and make a fullscreen window */
/* !!! FIXME: can we have a smaller view? */ /* !!! FIXME: can we have a smaller view? */
#if TARGET_OS_XR #ifdef SDL_PLATFORM_VISIONOS
UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:CGRectMake(window->x, window->y, window->w, window->h)]; UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:CGRectMake(window->x, window->y, window->w, window->h)];
#else #else
UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:data.uiscreen.bounds]; UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:data.uiscreen.bounds];
#endif #endif
/* put the window on an external display if appropriate. */ /* put the window on an external display if appropriate. */
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
if (data.uiscreen != [UIScreen mainScreen]) { if (data.uiscreen != [UIScreen mainScreen]) {
[uiwindow setScreen:data.uiscreen]; [uiwindow setScreen:data.uiscreen];
} }
@@ -238,7 +238,7 @@ void UIKit_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
/* Make this window the current mouse focus for touch input */ /* Make this window the current mouse focus for touch input */
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_UIKitDisplayData *displaydata = (__bridge SDL_UIKitDisplayData *)display->driverdata; SDL_UIKitDisplayData *displaydata = (__bridge SDL_UIKitDisplayData *)display->driverdata;
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
if (displaydata.uiscreen == [UIScreen mainScreen]) if (displaydata.uiscreen == [UIScreen mainScreen])
#endif #endif
{ {
@@ -270,7 +270,7 @@ static void UIKit_UpdateWindowBorder(SDL_VideoDevice *_this, SDL_Window *window)
SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->driverdata; SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->driverdata;
SDL_uikitviewcontroller *viewcontroller = data.viewcontroller; SDL_uikitviewcontroller *viewcontroller = data.viewcontroller;
#if !TARGET_OS_TV && !TARGET_OS_XR #if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
if (data.uiwindow.screen == [UIScreen mainScreen]) { if (data.uiwindow.screen == [UIScreen mainScreen]) {
if (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) { if (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) {
[UIApplication sharedApplication].statusBarHidden = YES; [UIApplication sharedApplication].statusBarHidden = YES;
@@ -283,7 +283,7 @@ static void UIKit_UpdateWindowBorder(SDL_VideoDevice *_this, SDL_Window *window)
/* Update the view's frame to account for the status bar change. */ /* Update the view's frame to account for the status bar change. */
viewcontroller.view.frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen); viewcontroller.view.frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen);
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
#ifdef SDL_IPHONE_KEYBOARD #ifdef SDL_IPHONE_KEYBOARD
/* Make sure the view is offset correctly when the keyboard is visible. */ /* Make sure the view is offset correctly when the keyboard is visible. */
@@ -322,7 +322,7 @@ void UIKit_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bo
void UIKit_UpdatePointerLock(SDL_VideoDevice *_this, SDL_Window *window) void UIKit_UpdatePointerLock(SDL_VideoDevice *_this, SDL_Window *window)
{ {
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
#if defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0 #if defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
@autoreleasepool { @autoreleasepool {
SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->driverdata; SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->driverdata;
@@ -332,7 +332,7 @@ void UIKit_UpdatePointerLock(SDL_VideoDevice *_this, SDL_Window *window)
} }
} }
#endif /* defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0 */ #endif /* defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0 */
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
} }
void UIKit_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) void UIKit_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
@@ -373,7 +373,7 @@ void UIKit_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int
CGSize size = view.bounds.size; CGSize size = view.bounds.size;
CGFloat scale = 1.0; CGFloat scale = 1.0;
#if !TARGET_OS_XR #ifndef SDL_PLATFORM_VISIONOS
if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) {
scale = windata.uiwindow.screen.nativeScale; scale = windata.uiwindow.screen.nativeScale;
} }
@@ -386,7 +386,7 @@ void UIKit_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int
} }
} }
#if !TARGET_OS_TV #ifndef SDL_PLATFORM_TVOS
NSUInteger NSUInteger
UIKit_GetSupportedOrientations(SDL_Window *window) UIKit_GetSupportedOrientations(SDL_Window *window)
{ {
@@ -452,7 +452,7 @@ UIKit_GetSupportedOrientations(SDL_Window *window)
return orientationMask; return orientationMask;
} }
#endif /* !TARGET_OS_TV */ #endif /* !SDL_PLATFORM_TVOS */
int 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)
{ {