Enable SDL_LoadObject on iOS 8+ and tvOS.

This commit is contained in:
Alex Szpakowski 2016-09-25 15:02:06 -03:00
parent 77bacfd72d
commit f31c7086d8
6 changed files with 30 additions and 15 deletions

View File

@ -119,11 +119,7 @@
#define SDL_JOYSTICK_MFI 1 #define SDL_JOYSTICK_MFI 1
/* Enable Unix style SO loading */ /* Enable Unix style SO loading */
/* Technically this works, but violates the iOS dev agreement prior to iOS 8 */ #define SDL_LOADSO_DLOPEN 1
/* #define SDL_LOADSO_DLOPEN 1 */
/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
#define SDL_LOADSO_DISABLED 1
/* Enable various threading systems */ /* Enable various threading systems */
#define SDL_THREAD_PTHREAD 1 #define SDL_THREAD_PTHREAD 1

View File

@ -150,8 +150,8 @@
#ifndef SDL_VIDEO_RENDER_OGL_ES2 #ifndef SDL_VIDEO_RENDER_OGL_ES2
#define SDL_VIDEO_RENDER_OGL_ES2 1 #define SDL_VIDEO_RENDER_OGL_ES2 1
#endif #endif
#ifndef SDL_LOADSO_DISABLED #ifndef SDL_LOADSO_DLOPEN
#define SDL_LOADSO_DISABLED 1 #define SDL_LOADSO_DLOPEN 1
#endif #endif
#ifndef SDL_HAPTIC_DISABLED #ifndef SDL_HAPTIC_DISABLED
#define SDL_HAPTIC_DISABLED 1 #define SDL_HAPTIC_DISABLED 1

View File

@ -369,7 +369,7 @@ SDL_project "SDL2"
["SDL_AUDIO_DRIVER_COREAUDIO"] = 1, ["SDL_AUDIO_DRIVER_COREAUDIO"] = 1,
["SDL_JOYSTICK_MFI"] = 1, ["SDL_JOYSTICK_MFI"] = 1,
["SDL_HAPTIC_DISABLED"] = 1, ["SDL_HAPTIC_DISABLED"] = 1,
["SDL_LOADSO_DISABLED"] = 1, ["SDL_LOADSO_DLOPEN"] = 1,
["SDL_THREAD_PTHREAD"] = 1, ["SDL_THREAD_PTHREAD"] = 1,
["SDL_THREAD_PTHREAD_RECURSIVE_MUTEX"] = 1, ["SDL_THREAD_PTHREAD_RECURSIVE_MUTEX"] = 1,
["SDL_TIMER_UNIX"] = 1, ["SDL_TIMER_UNIX"] = 1,

View File

@ -30,11 +30,25 @@
#include "SDL_loadso.h" #include "SDL_loadso.h"
#if SDL_VIDEO_DRIVER_UIKIT
#include "../../video/uikit/SDL_uikitvideo.h"
#endif
void * void *
SDL_LoadObject(const char *sofile) SDL_LoadObject(const char *sofile)
{ {
void *handle = dlopen(sofile, RTLD_NOW|RTLD_LOCAL); void *handle;
const char *loaderror = (char *) dlerror(); const char *loaderror;
#if SDL_VIDEO_DRIVER_UIKIT
if (!UIKit_IsSystemVersionAtLeast(8.0)) {
SDL_SetError("SDL_LoadObject requires iOS 8+");
return NULL;
}
#endif
handle = dlopen(sofile, RTLD_NOW|RTLD_LOCAL);
loaderror = (char *) dlerror();
if (handle == NULL) { if (handle == NULL) {
SDL_SetError("Failed loading %s: %s", sofile, loaderror); SDL_SetError("Failed loading %s: %s", sofile, loaderror);
} }

View File

@ -21,20 +21,25 @@
#ifndef _SDL_uikitvideo_h #ifndef _SDL_uikitvideo_h
#define _SDL_uikitvideo_h #define _SDL_uikitvideo_h
#include <UIKit/UIKit.h>
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
#ifdef __OBJC__
#include <UIKit/UIKit.h>
@interface SDL_VideoData : NSObject @interface SDL_VideoData : NSObject
@property (nonatomic) id pasteboardObserver; @property (nonatomic) id pasteboardObserver;
@end @end
CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
#endif /* __OBJC__ */
void UIKit_SuspendScreenSaver(_THIS); void UIKit_SuspendScreenSaver(_THIS);
BOOL UIKit_IsSystemVersionAtLeast(double version); SDL_bool UIKit_IsSystemVersionAtLeast(double version);
CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
#endif /* _SDL_uikitvideo_h */ #endif /* _SDL_uikitvideo_h */

View File

@ -167,7 +167,7 @@ UIKit_SuspendScreenSaver(_THIS)
} }
} }
BOOL SDL_bool
UIKit_IsSystemVersionAtLeast(double version) UIKit_IsSystemVersionAtLeast(double version)
{ {
return [[UIDevice currentDevice].systemVersion doubleValue] >= version; return [[UIDevice currentDevice].systemVersion doubleValue] >= version;