From b9ea2dde443f35a18c065f10665a0b1f7820f3ab Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 27 Jan 2024 11:04:06 -0800 Subject: [PATCH] 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. --- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 6 ++- include/SDL3/SDL_platform_defines.h | 7 +++- include/build_config/SDL_build_config_ios.h | 2 +- src/audio/coreaudio/SDL_coreaudio.m | 6 +-- src/filesystem/cocoa/SDL_sysfilesystem.m | 8 ++-- src/joystick/apple/SDL_mfijoystick.m | 28 ++++++------- src/misc/ios/SDL_sysurl.m | 2 +- src/power/uikit/SDL_syspower.m | 10 ++--- src/video/SDL_video_capture_apple.m | 2 +- src/video/uikit/SDL_uikitappdelegate.m | 32 +++++++-------- src/video/uikit/SDL_uikitclipboard.m | 8 ++-- src/video/uikit/SDL_uikitevents.m | 4 +- src/video/uikit/SDL_uikitmessagebox.m | 2 +- src/video/uikit/SDL_uikitmetalview.m | 2 +- src/video/uikit/SDL_uikitmodes.h | 10 ++--- src/video/uikit/SDL_uikitmodes.m | 44 ++++++++++----------- src/video/uikit/SDL_uikitvideo.h | 2 +- src/video/uikit/SDL_uikitvideo.m | 10 ++--- src/video/uikit/SDL_uikitview.h | 4 +- src/video/uikit/SDL_uikitview.m | 24 +++++------ src/video/uikit/SDL_uikitviewcontroller.h | 4 +- src/video/uikit/SDL_uikitviewcontroller.m | 26 ++++++------ src/video/uikit/SDL_uikitwindow.m | 34 ++++++++-------- 23 files changed, 141 insertions(+), 136 deletions(-) diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index a846955a6..1cfb27f26 100644 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -2784,9 +2784,10 @@ PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL3; PRODUCT_NAME = SDL3; 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; TVOS_DEPLOYMENT_TARGET = 9.0; + XROS_DEPLOYMENT_TARGET = 1.0; }; name = Release; }; @@ -2841,9 +2842,10 @@ PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL3; PRODUCT_NAME = SDL3; 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; TVOS_DEPLOYMENT_TARGET = 9.0; + XROS_DEPLOYMENT_TARGET = 1.0; }; name = Debug; }; diff --git a/include/SDL3/SDL_platform_defines.h b/include/SDL3/SDL_platform_defines.h index 9a2154a8e..8083619d8 100644 --- a/include/SDL3/SDL_platform_defines.h +++ b/include/SDL3/SDL_platform_defines.h @@ -86,13 +86,16 @@ #ifndef TARGET_OS_SIMULATOR #define TARGET_OS_SIMULATOR 0 #endif -#ifndef TARGET_OS_XR -#define TARGET_OS_XR 0 +#ifndef TARGET_OS_VISION +#define TARGET_OS_VISION 0 #endif #if TARGET_OS_TV #define SDL_PLATFORM_TVOS 1 #endif +#if TARGET_OS_VISION +#define SDL_PLATFORM_VISIONOS 1 +#endif #if TARGET_OS_IPHONE #define SDL_PLATFORM_IOS 1 #else diff --git a/include/build_config/SDL_build_config_ios.h b/include/build_config/SDL_build_config_ios.h index fe5dea8af..e79ca4ce2 100644 --- a/include/build_config/SDL_build_config_ios.h +++ b/include/build_config/SDL_build_config_ios.h @@ -170,7 +170,7 @@ #define SDL_VIDEO_DRIVER_DUMMY 1 /* Enable OpenGL ES */ -#if !TARGET_OS_MACCATALYST +#if !TARGET_OS_MACCATALYST && !TARGET_OS_VISION #define SDL_VIDEO_OPENGL_ES2 1 #define SDL_VIDEO_OPENGL_ES 1 #define SDL_VIDEO_RENDER_OGL_ES2 1 diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m index 73762acf4..e376e82bd 100644 --- a/src/audio/coreaudio/SDL_coreaudio.m +++ b/src/audio/coreaudio/SDL_coreaudio.m @@ -417,7 +417,7 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b category = AVAudioSessionCategoryRecord; } - #if !TARGET_OS_TV + #ifndef SDL_PLATFORM_TVOS if (category == AVAudioSessionCategoryPlayAndRecord) { options |= AVAudioSessionCategoryOptionDefaultToSpeaker; } @@ -846,7 +846,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device) AVAudioSession *session = [AVAudioSession sharedInstance]; [session setPreferredSampleRate:device->spec.freq error:nil]; device->spec.freq = (int)session.sampleRate; - #if TARGET_OS_TV + #ifdef SDL_PLATFORM_TVOS if (device->iscapture) { [session setPreferredInputNumberOfChannels:device->spec.channels error:nil]; device->spec.channels = session.preferredInputNumberOfChannels; @@ -856,7 +856,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device) } #else // Calling setPreferredOutputNumberOfChannels seems to break audio output on iOS - #endif // TARGET_OS_TV + #endif /* SDL_PLATFORM_TVOS */ } #endif diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index 71f674fae..aef0217d2 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -75,7 +75,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) org = ""; } -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); #else /* 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); -#endif /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ if ([array count] > 0) { /* we only want the first item in the list. */ NSString *str = [array objectAtIndex:0]; @@ -129,7 +129,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) char *SDL_GetUserFolder(SDL_Folder folder) { @autoreleasepool { -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS SDL_SetError("tvOS does not have persistent storage"); return NULL; #else @@ -224,7 +224,7 @@ char *SDL_GetUserFolder(SDL_Folder folder) mkdir(retval, 0700); return retval; -#endif /* TARGET_OS_TV */ +#endif /* SDL_PLATFORM_TVOS */ } } diff --git a/src/joystick/apple/SDL_mfijoystick.m b/src/joystick/apple/SDL_mfijoystick.m index eae3ef415..3accd8b30 100644 --- a/src/joystick/apple/SDL_mfijoystick.m +++ b/src/joystick/apple/SDL_mfijoystick.m @@ -30,7 +30,7 @@ #include "SDL_mfijoystick_c.h" -#if TARGET_OS_IOS +#if defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_TVOS) #define SDL_JOYSTICK_iOS_ACCELEROMETER #import #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 */ return TRUE; } -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS /* The OS uses the home button, it's not available to apps */ return TRUE; #endif @@ -484,7 +484,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle vendor = USB_VENDOR_APPLE; product = 2; subtype = 2; -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS } else if (controller.microGamepad) { vendor = USB_VENDOR_APPLE; product = 3; @@ -541,7 +541,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle } #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 */ if (elements[GCInputButtonMenu] && !elements[@"Button Home"]) { device->pause_button_index = [device->buttons indexOfObject:GCInputButtonMenu]; @@ -588,7 +588,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle 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 */ if ((device->button_mask & (1 << SDL_GAMEPAD_BUTTON_BACK)) == 0) { has_direct_menu = FALSE; @@ -620,7 +620,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle device->nhats = 1; /* d-pad */ device->nbuttons = nbuttons; } -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS else if (controller.microGamepad) { int nbuttons = 0; @@ -786,7 +786,7 @@ static SDL_JoystickDeviceItem *IOS_RemoveJoystickDevice(SDL_JoystickDeviceItem * 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) { 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) { @@ -843,10 +843,10 @@ static int IOS_JoystickInit(void) IOS_AddJoystickDevice(controller, SDL_FALSE); } -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS SDL_AddHintCallback(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, SDL_AppleTVRemoteRotationHintChanged, NULL); -#endif /* TARGET_OS_TV */ +#endif /* SDL_PLATFORM_TVOS */ center = [NSNotificationCenter defaultCenter]; @@ -1248,7 +1248,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) SDL_small_free(buttons, isstack); } -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS else if (controller.microGamepad) { GCMicroGamepad *gamepad = controller.microGamepad; @@ -1271,7 +1271,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) SDL_SendJoystickButton(timestamp, joystick, i, buttons[i]); } } -#endif /* TARGET_OS_TV */ +#endif /* SDL_PLATFORM_TVOS */ if (joystick->nhats > 0) { SDL_SendJoystickHat(timestamp, joystick, 0, hatstate); @@ -1799,10 +1799,10 @@ static void IOS_JoystickQuit(void) disconnectObserver = nil; } -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS SDL_DelHintCallback(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, SDL_AppleTVRemoteRotationHintChanged, NULL); -#endif /* TARGET_OS_TV */ +#endif /* SDL_PLATFORM_TVOS */ #endif /* SDL_JOYSTICK_MFI */ while (deviceList != NULL) { diff --git a/src/misc/ios/SDL_sysurl.m b/src/misc/ios/SDL_sysurl.m index 7ec00c858..8038bc732 100644 --- a/src/misc/ios/SDL_sysurl.m +++ b/src/misc/ios/SDL_sysurl.m @@ -30,7 +30,7 @@ int SDL_SYS_OpenURL(const char *url) { @autoreleasepool { -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS return SDL_Unsupported(); // openURL is not suported on visionOS #else NSString *nsstr = [NSString stringWithUTF8String:url]; diff --git a/src/power/uikit/SDL_syspower.m b/src/power/uikit/SDL_syspower.m index 3049c1e0c..bca259f32 100644 --- a/src/power/uikit/SDL_syspower.m +++ b/src/power/uikit/SDL_syspower.m @@ -27,7 +27,7 @@ #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. */ static const int BATTERY_MONITORING_TIMEOUT = 3000; static Uint64 SDL_UIKitLastPowerInfoQuery = 0; @@ -48,15 +48,15 @@ void SDL_UIKit_UpdateBatteryMonitoring(void) { /* Do nothing. */ } -#endif /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ 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; *seconds = -1; *percent = -1; -#else /* TARGET_OS_TV */ +#else /* SDL_PLATFORM_TVOS */ @autoreleasepool { 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; *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. */ } diff --git a/src/video/SDL_video_capture_apple.m b/src/video/SDL_video_capture_apple.m index e63ce3099..40561263b 100644 --- a/src/video/SDL_video_capture_apple.m +++ b/src/video/SDL_video_capture_apple.m @@ -33,7 +33,7 @@ #undef HAVE_COREMEDIA #endif -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS #undef HAVE_COREMEDIA #endif diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index d8c3a9e0c..0ab30234c 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -30,7 +30,7 @@ #include "../../events/SDL_events_c.h" -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS #include #ifndef __IPHONE_13_0 @@ -79,7 +79,7 @@ int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserv 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. */ 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 didMoveToParentViewController:self]; -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS UIApplication.sharedApplication.statusBarHidden = self.prefersStatusBarHidden; UIApplication.sharedApplication.statusBarStyle = self.preferredStatusBarStyle; #endif @@ -170,11 +170,11 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) } @end -#endif /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ @interface SDLLaunchScreenController () -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS - (NSUInteger)supportedInterfaceOrientations; #endif @@ -213,7 +213,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) NSString *imagename = nil; UIImage *image = nil; -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS int screenw = SDL_XR_SCREENWIDTH; int screenh = SDL_XR_SCREENHEIGHT; #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; /* 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; NSString *orientstring = dict[@"UILaunchImageOrientation"]; @@ -282,7 +282,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) image = [UIImage imageNamed:imagename]; } } -#if !TARGET_OS_TV && !TARGET_OS_XR +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) else { imagename = [bundle objectForInfoDictionaryKey:@"UILaunchImageFile"]; @@ -297,7 +297,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) #endif if (image) { -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS CGRect viewFrame = CGRectMake(0, 0, screenw, screenh); #else CGRect viewFrame = [UIScreen mainScreen].bounds; @@ -305,7 +305,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) UIImageView *view = [[UIImageView alloc] initWithFrame:viewFrame]; 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. */ if (UIInterfaceOrientationIsLandscape(curorient)) { if (image.size.width < image.size.height) { @@ -337,7 +337,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) /* Do nothing. */ } -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS - (BOOL)shouldAutorotate { /* 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.) */ return UIInterfaceOrientationMaskAll; } -#endif /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ @end @@ -434,7 +434,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) NSString *screenname = nil; /* 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"]; if (screenname) { @@ -457,7 +457,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) } if (vc.view) { -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS CGRect viewFrame = CGRectMake(0, 0, SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT); #else CGRect viewFrame = [UIScreen mainScreen].bounds; @@ -517,7 +517,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) 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 *)options { diff --git a/src/video/uikit/SDL_uikitclipboard.m b/src/video/uikit/SDL_uikitclipboard.m index cc5a757c4..e53e72c84 100644 --- a/src/video/uikit/SDL_uikitclipboard.m +++ b/src/video/uikit/SDL_uikitclipboard.m @@ -29,7 +29,7 @@ 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"); #else @autoreleasepool { @@ -41,7 +41,7 @@ int UIKit_SetClipboardText(SDL_VideoDevice *_this, const char *text) char *UIKit_GetClipboardText(SDL_VideoDevice *_this) { -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS return SDL_strdup(""); // Unsupported. #else @autoreleasepool { @@ -60,7 +60,7 @@ char *UIKit_GetClipboardText(SDL_VideoDevice *_this) SDL_bool UIKit_HasClipboardText(SDL_VideoDevice *_this) { @autoreleasepool { -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS if ([UIPasteboard generalPasteboard].string != nil) { return SDL_TRUE; } @@ -71,7 +71,7 @@ SDL_bool UIKit_HasClipboardText(SDL_VideoDevice *_this) void UIKit_InitClipboard(SDL_VideoDevice *_this) { -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS @autoreleasepool { SDL_UIKitVideoData *data = (__bridge SDL_UIKitVideoData *)_this->driverdata; NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; diff --git a/src/video/uikit/SDL_uikitevents.m b/src/video/uikit/SDL_uikitevents.m index 00af2cc42..223f5565e 100644 --- a/src/video/uikit/SDL_uikitevents.m +++ b/src/video/uikit/SDL_uikitevents.m @@ -57,7 +57,7 @@ static BOOL UIKit_EventPumpEnabled = YES; [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(applicationDidReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; -#if !TARGET_OS_TV && !TARGET_OS_XR +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) [notificationCenter addObserver:self selector:@selector(applicationDidChangeStatusBarOrientation) name:UIApplicationDidChangeStatusBarOrientationNotification @@ -99,7 +99,7 @@ static BOOL UIKit_EventPumpEnabled = YES; SDL_OnApplicationDidReceiveMemoryWarning(); } -#if !TARGET_OS_TV && !TARGET_OS_XR +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) - (void)applicationDidChangeStatusBarOrientation { SDL_OnApplicationDidChangeStatusBarOrientation(); diff --git a/src/video/uikit/SDL_uikitmessagebox.m b/src/video/uikit/SDL_uikitmessagebox.m index 55b69b31c..cc977695b 100644 --- a/src/video/uikit/SDL_uikitmessagebox.m +++ b/src/video/uikit/SDL_uikitmessagebox.m @@ -98,7 +98,7 @@ static BOOL UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messag } if (window == nil || window.rootViewController == nil) { -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS alertwindow = [[UIWindow alloc] init]; #else alertwindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; diff --git a/src/video/uikit/SDL_uikitmetalview.m b/src/video/uikit/SDL_uikitmetalview.m index a8d34d49f..71be59e49 100644 --- a/src/video/uikit/SDL_uikitmetalview.m +++ b/src/video/uikit/SDL_uikitmetalview.m @@ -79,7 +79,7 @@ SDL_MetalView UIKit_Metal_CreateView(SDL_VideoDevice *_this, SDL_Window *window) CGFloat scale = 1.0; SDL_uikitmetalview *metalview; -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { /* Set the scale to the natural scale factor of the screen - then * the backing dimensions of the Metal view will match the pixel diff --git a/src/video/uikit/SDL_uikitmodes.h b/src/video/uikit/SDL_uikitmodes.h index a71713972..e8f4b0371 100644 --- a/src/video/uikit/SDL_uikitmodes.h +++ b/src/video/uikit/SDL_uikitmodes.h @@ -27,7 +27,7 @@ @interface SDL_UIKitDisplayData : NSObject -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS - (instancetype)initWithScreen:(UIScreen *)screen; @property(nonatomic, strong) UIScreen *uiscreen; #endif @@ -35,18 +35,18 @@ @end @interface SDL_UIKitDisplayModeData : NSObject -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS @property(nonatomic, strong) UIScreenMode *uiscreenmode; #endif @end -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS extern SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen); #endif 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 void UIKit_DelDisplay(UIScreen *uiscreen); #endif @@ -57,7 +57,7 @@ extern int UIKit_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay // because visionOS does not have a screen // 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_SCREENHEIGHT 1080 #endif diff --git a/src/video/uikit/SDL_uikitmodes.m b/src/video/uikit/SDL_uikitmodes.m index 9d0f479c3..90e6be16d 100644 --- a/src/video/uikit/SDL_uikitmodes.m +++ b/src/video/uikit/SDL_uikitmodes.m @@ -30,7 +30,7 @@ @implementation SDL_UIKitDisplayData -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS - (instancetype)initWithScreen:(UIScreen *)screen { if (self = [super init]) { @@ -45,7 +45,7 @@ @implementation SDL_UIKitDisplayModeData -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS @synthesize uiscreenmode; #endif @@ -54,7 +54,7 @@ @interface SDL_DisplayWatch : NSObject @end -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS @implementation SDL_DisplayWatch + (void)start @@ -98,7 +98,7 @@ @end #endif -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS static int UIKit_AllocateDisplayModeData(SDL_DisplayMode *mode, 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) { #ifdef __IPHONE_10_3 @@ -229,7 +229,7 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) } SDL_zero(display); -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS if (uiscreen == [UIScreen mainScreen]) { /* The natural orientation (used by sensors) is portrait */ display.natural_orientation = SDL_ORIENTATION_PORTRAIT; @@ -243,7 +243,7 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) display.desktop_mode = mode; /* Allocate the display data */ -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS SDL_UIKitDisplayData *data = [[SDL_UIKitDisplayData alloc] init]; #else SDL_UIKitDisplayData *data = [[SDL_UIKitDisplayData alloc] initWithScreen:uiscreen]; @@ -261,7 +261,7 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) } #endif -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS int UIKit_AddDisplay(SDL_bool send_event){ CGSize size = CGSizeMake(SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT); SDL_VideoDisplay display; @@ -293,7 +293,7 @@ int UIKit_AddDisplay(SDL_bool send_event){ } #endif -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS void UIKit_DelDisplay(UIScreen *uiscreen) { @@ -318,11 +318,11 @@ void UIKit_DelDisplay(UIScreen *uiscreen) SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen) { -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS if (uiscreen == [UIScreen mainScreen]) { return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation); } else -#endif /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ { CGSize size = uiscreen.bounds.size; return (size.width > size.height); @@ -332,7 +332,7 @@ SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen) int UIKit_InitModes(SDL_VideoDevice *_this) { @autoreleasepool { -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS UIKit_AddDisplay(SDL_FALSE); #else for (UIScreen *uiscreen in [UIScreen screens]) { @@ -342,11 +342,11 @@ int UIKit_InitModes(SDL_VideoDevice *_this) } #endif -#if !TARGET_OS_TV && !TARGET_OS_XR +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) SDL_OnApplicationDidChangeStatusBarOrientation(); #endif -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS [SDL_DisplayWatch start]; #endif } @@ -356,7 +356,7 @@ int UIKit_InitModes(SDL_VideoDevice *_this) int UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) { -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS @autoreleasepool { 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]); NSArray *availableModes = nil; -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS addRotation = SDL_FALSE; availableModes = @[ data.uiscreen.currentMode ]; #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) { -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS @autoreleasepool { SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->driverdata; -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS SDL_UIKitDisplayModeData *modedata = (__bridge SDL_UIKitDisplayModeData *)mode->driverdata; [data.uiscreen setCurrentMode:modedata.uiscreenmode]; #endif @@ -424,7 +424,7 @@ int UIKit_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *displ { @autoreleasepool { 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); #else CGRect frame = data.uiscreen.bounds; @@ -447,7 +447,7 @@ int UIKit_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *displ void UIKit_QuitModes(SDL_VideoDevice *_this) { -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS [SDL_DisplayWatch stop]; #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) { BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation); @@ -523,6 +523,6 @@ void SDL_OnApplicationDidChangeStatusBarOrientation(void) SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_ORIENTATION, orientation); } } -#endif /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ #endif /* SDL_VIDEO_DRIVER_UIKIT */ diff --git a/src/video/uikit/SDL_uikitvideo.h b/src/video/uikit/SDL_uikitvideo.h index 4022cfbb1..b57e0a6f6 100644 --- a/src/video/uikit/SDL_uikitvideo.h +++ b/src/video/uikit/SDL_uikitvideo.h @@ -33,7 +33,7 @@ @end -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS CGRect UIKit_ComputeViewFrame(SDL_Window *window); #else CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen); diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index 5551312f2..151611194 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -186,7 +186,7 @@ SDL_bool UIKit_IsSystemVersionAtLeast(double version) SDL_SystemTheme UIKit_GetSystemTheme(void) { -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS if (@available(iOS 12.0, tvOS 10.0, *)) { switch ([UIScreen mainScreen].traitCollection.userInterfaceStyle) { case UIUserInterfaceStyleDark: @@ -201,7 +201,7 @@ SDL_SystemTheme UIKit_GetSystemTheme(void) return SDL_SYSTEM_THEME_UNKNOWN; } -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS CGRect UIKit_ComputeViewFrame(SDL_Window *window){ 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; } -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS /* 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 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) { -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS /* Force the main SDL window to re-evaluate home indicator state */ SDL_Window *focus = SDL_GetKeyboardFocus(); if (focus) { @@ -263,7 +263,7 @@ void UIKit_ForceUpdateHomeIndicator(void) #pragma clang diagnostic pop } } -#endif /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ } /* diff --git a/src/video/uikit/SDL_uikitview.h b/src/video/uikit/SDL_uikitview.h index 2e239ae74..0d720da72 100644 --- a/src/video/uikit/SDL_uikitview.h +++ b/src/video/uikit/SDL_uikitview.h @@ -23,7 +23,7 @@ #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 #else @interface SDL_uikitview : UIView @@ -33,7 +33,7 @@ - (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)); - (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4)); #endif diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index f24f0318c..232be71b9 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -52,7 +52,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS /* Apple TV Remote touchpad swipe gestures. */ UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)]; swipeUp.direction = UISwipeGestureRecognizerDirectionUp; @@ -77,12 +77,12 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; directTouchId = 1; indirectTouchId = 2; -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS self.multipleTouchEnabled = YES; SDL_AddTouch(directTouchId, SDL_TOUCH_DEVICE_DIRECT, ""); #endif -#if !TARGET_OS_TV && defined(__IPHONE_13_4) +#if !defined(SDL_PLATFORM_TVOS) && defined(__IPHONE_13_4) if (@available(iOS 13.4, *)) { [self addInteraction:[[UIPointerInteraction alloc] initWithDelegate:self]]; } @@ -148,7 +148,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; 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)) { if (request != nil && !SDL_GCMouseRelativeMode()) { @@ -171,7 +171,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; return [UIPointerStyle hiddenPointerStyle]; } } -#endif /* !TARGET_OS_TV && __IPHONE_13_4 */ +#endif /* !defined(SDL_PLATFORM_TVOS) && __IPHONE_13_4 */ - (SDL_TouchDeviceType)touchTypeForTouch:(UITouch *)touch { @@ -226,7 +226,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; for (UITouch *touch in touches) { 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 (touch.type == UITouchTypeIndirectPointer) { if (!SDL_HasGCMouse()) { @@ -282,7 +282,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; for (UITouch *touch in touches) { 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 (touch.type == UITouchTypeIndirectPointer) { if (!SDL_HasGCMouse()) { @@ -343,7 +343,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; for (UITouch *touch in touches) { 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 (touch.type == UITouchTypeIndirectPointer) { /* 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 { #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 { /* Swipe gestures don't trigger begin states. */ @@ -485,7 +485,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; #endif /* !SDL_JOYSTICK_DISABLED */ } } -#endif /* TARGET_OS_TV */ +#endif /* SDL_PLATFORM_TVOS */ @end diff --git a/src/video/uikit/SDL_uikitviewcontroller.h b/src/video/uikit/SDL_uikitviewcontroller.h index 5c1887693..23d93f876 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.h +++ b/src/video/uikit/SDL_uikitviewcontroller.h @@ -24,7 +24,7 @@ #include "../SDL_sysvideo.h" -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS #import #define SDLRootViewController GCEventViewController #else @@ -59,7 +59,7 @@ - (void)loadView; - (void)viewDidLayoutSubviews; -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS - (NSUInteger)supportedInterfaceOrientations; - (BOOL)prefersStatusBarHidden; - (BOOL)prefersHomeIndicatorAutoHidden; diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index 9874b93cf..0d0b614f9 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -33,7 +33,7 @@ #include "SDL_uikitwindow.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) { @autoreleasepool { @@ -43,7 +43,7 @@ static void SDLCALL SDL_AppleTVControllerUIHintChanged(void *userdata, const cha } #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) { @autoreleasepool { @@ -104,13 +104,13 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char rotatingOrientation = NO; #endif -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS SDL_AddHintCallback(SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS, SDL_AppleTVControllerUIHintChanged, (__bridge void *)self); #endif -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS SDL_AddHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR, SDL_HideHomeIndicatorHintChanged, (__bridge void *)self); @@ -125,13 +125,13 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char [self deinitKeyboard]; #endif -#if TARGET_OS_TV +#ifdef SDL_PLATFORM_TVOS SDL_DelHintCallback(SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS, SDL_AppleTVControllerUIHintChanged, (__bridge void *)self); #endif -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS SDL_DelHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR, SDL_HideHomeIndicatorHintChanged, (__bridge void *)self); @@ -162,7 +162,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char { 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 #elif defined(__IPHONE_10_3) 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); } -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS - (NSUInteger)supportedInterfaceOrientations { return UIKit_GetSupportedOrientations(window); @@ -257,7 +257,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char return SDL_GCMouseRelativeMode() ? YES : NO; } -#endif /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ /* ---- Keyboard related functionality below this line ---- @@ -291,7 +291,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char keyboardVisible = NO; NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS [center addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification @@ -374,7 +374,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char - (void)deinitKeyboard { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS [center removeObserver:self name:UIKeyboardWillShowNotification object:nil]; @@ -430,7 +430,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char } showingKeyboard = YES; -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS CGRect kbrect = [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue]; /* 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; CGPoint offset = CGPointMake(0.0, 0.0); -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS CGRect frame = UIKit_ComputeViewFrame(window); #else CGRect frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen); diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index f16ef5b0e..2006ec943 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -63,7 +63,7 @@ - (void)layoutSubviews { -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS /* Workaround to fix window orientation issues in iOS 8. */ /* 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 @@ -85,7 +85,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow SDL_UIKitDisplayData *displaydata = (__bridge SDL_UIKitDisplayData *)display->driverdata; SDL_uikitview *view; -#if TARGET_OS_XR +#ifdef SDL_PLATFORM_VISIONOS CGRect frame = UIKit_ComputeViewFrame(window); #else CGRect frame = UIKit_ComputeViewFrame(window, displaydata.uiscreen); @@ -103,7 +103,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow data.uiwindow = uiwindow; -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS if (displaydata.uiscreen != [UIScreen mainScreen]) { window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizable */ 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 -#if !TARGET_OS_TV && !TARGET_OS_XR +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) if (displaydata.uiscreen == [UIScreen mainScreen]) { NSUInteger orients = UIKit_GetSupportedOrientations(window); BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0; @@ -124,7 +124,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow 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 */ 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 * user, so it's in standby), try to force the display to a resolution * 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; if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) { const SDL_DisplayMode *bestmode; @@ -196,18 +196,18 @@ int UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie [UIApplication sharedApplication].statusBarHidden = NO; } } -#endif /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ /* ignore the size user requested, and make a fullscreen window */ /* !!! 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)]; #else UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:data.uiscreen.bounds]; #endif /* put the window on an external display if appropriate. */ -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS if (data.uiscreen != [UIScreen mainScreen]) { [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 */ SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); SDL_UIKitDisplayData *displaydata = (__bridge SDL_UIKitDisplayData *)display->driverdata; -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS if (displaydata.uiscreen == [UIScreen mainScreen]) #endif { @@ -270,7 +270,7 @@ static void UIKit_UpdateWindowBorder(SDL_VideoDevice *_this, SDL_Window *window) SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->driverdata; 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 (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) { [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. */ viewcontroller.view.frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen); -#endif /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ #ifdef SDL_IPHONE_KEYBOARD /* 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) { -#if !TARGET_OS_TV +#ifndef SDL_PLATFORM_TVOS #if defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0 @autoreleasepool { 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 /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ } 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; CGFloat scale = 1.0; -#if !TARGET_OS_XR +#ifndef SDL_PLATFORM_VISIONOS if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { 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 UIKit_GetSupportedOrientations(SDL_Window *window) { @@ -452,7 +452,7 @@ UIKit_GetSupportedOrientations(SDL_Window *window) return orientationMask; } -#endif /* !TARGET_OS_TV */ +#endif /* !SDL_PLATFORM_TVOS */ int SDL_iPhoneSetAnimationCallback(SDL_Window *window, int interval, void (*callback)(void *), void *callbackParam) {