|
|
@@ -18,6 +18,9 @@
|
|
|
misrepresented as being the original software.
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
*/
|
|
|
+
|
|
|
+// Modified by Lasse Öörni for Urho3D
|
|
|
+
|
|
|
#include "SDL_config.h"
|
|
|
|
|
|
#if SDL_VIDEO_DRIVER_UIKIT
|
|
|
@@ -29,7 +32,7 @@
|
|
|
|
|
|
#import "SDL_uikitappdelegate.h"
|
|
|
#import "SDL_uikitopenglview.h"
|
|
|
-#import "SDL_events_c.h"
|
|
|
+#import "../../events/SDL_events_c.h"
|
|
|
#import "jumphack.h"
|
|
|
|
|
|
#ifdef main
|
|
|
@@ -40,6 +43,7 @@ extern int SDL_main(int argc, char *argv[]);
|
|
|
static int forward_argc;
|
|
|
static char **forward_argv;
|
|
|
static int exit_status;
|
|
|
+static char *resource_dir = 0;
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
|
@@ -68,6 +72,27 @@ int main(int argc, char **argv)
|
|
|
return exit_status;
|
|
|
}
|
|
|
|
|
|
+// Urho3D: added function
|
|
|
+void SDL_IOS_LogMessage(const char *message)
|
|
|
+{
|
|
|
+ #ifdef XCODE_DEBUG_CONFIGURATION
|
|
|
+ NSLog(@"%@", [NSString stringWithUTF8String: message]);
|
|
|
+ #endif
|
|
|
+}
|
|
|
+
|
|
|
+// Urho3D: added function
|
|
|
+const char* SDL_IOS_GetResourceDir()
|
|
|
+{
|
|
|
+ if (!resource_dir)
|
|
|
+ {
|
|
|
+ const char *temp = [[[NSBundle mainBundle] resourcePath] UTF8String];
|
|
|
+ resource_dir = malloc(strlen(temp + 1));
|
|
|
+ strcpy(resource_dir, temp);
|
|
|
+ }
|
|
|
+
|
|
|
+ return resource_dir;
|
|
|
+}
|
|
|
+
|
|
|
static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, const char *newValue)
|
|
|
{
|
|
|
SDL_assert(SDL_strcmp(name, SDL_HINT_IDLE_TIMER_DISABLED) == 0);
|
|
|
@@ -120,100 +145,99 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue,
|
|
|
|
|
|
return YES;
|
|
|
}
|
|
|
-
|
|
|
-- (void)applicationWillTerminate:(UIApplication *)application
|
|
|
-{
|
|
|
- SDL_Event event;
|
|
|
- event.type=SDL_SYSEVENT_TERMINATE;
|
|
|
- event.sysevent.data=NULL;
|
|
|
- if (SDL_SysEventHandler)
|
|
|
- SDL_SysEventHandler(&event);
|
|
|
- else SDL_SendQuit();
|
|
|
- /* hack to prevent automatic termination. See SDL_uikitevents.m for details */
|
|
|
- longjmp(*(jump_env()), 1);
|
|
|
-}
|
|
|
-
|
|
|
-- (void) applicationWillResignActive:(UIApplication*)application
|
|
|
-{
|
|
|
- //NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
|
- SDL_Event event;
|
|
|
- event.type=SDL_SYSEVENT_WILL_SUSPEND;
|
|
|
- event.sysevent.data=NULL;
|
|
|
- if (SDL_SysEventHandler)
|
|
|
- SDL_SysEventHandler(&event);
|
|
|
- else {
|
|
|
- // Send every window on every screen a MINIMIZED event.
|
|
|
- SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
|
|
- if (!_this) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- SDL_Window *window;
|
|
|
- for (window = _this->windows; window != nil; window = window->next) {
|
|
|
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
|
|
|
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-- (void)applicationDidEnterBackground:(UIApplication*)application
|
|
|
-{
|
|
|
- //NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
|
-
|
|
|
- SDL_Event event;
|
|
|
- event.type=SDL_SYSEVENT_SUSPEND;
|
|
|
- event.sysevent.data=NULL;
|
|
|
- if (SDL_SysEventHandler)
|
|
|
- SDL_SysEventHandler(&event);
|
|
|
-}
|
|
|
-
|
|
|
-- (void)applicationWillEnterForeground:(UIApplication*)application
|
|
|
-{
|
|
|
- //NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
|
-
|
|
|
- SDL_Event event;
|
|
|
- event.type=SDL_SYSEVENT_WILL_RESUME;
|
|
|
- event.sysevent.data=NULL;
|
|
|
- if (SDL_SysEventHandler)
|
|
|
- SDL_SysEventHandler(&event);
|
|
|
-}
|
|
|
-
|
|
|
-- (void) applicationDidBecomeActive:(UIApplication*)application
|
|
|
-{
|
|
|
- //NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
|
-
|
|
|
- SDL_Event event;
|
|
|
- event.type=SDL_SYSEVENT_RESUME;
|
|
|
- event.sysevent.data=NULL;
|
|
|
- if (SDL_SysEventHandler)
|
|
|
- SDL_SysEventHandler(&event);
|
|
|
- else {
|
|
|
- // Send every window on every screen a RESTORED event.
|
|
|
- SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
|
|
- if (!_this) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- SDL_Window *window;
|
|
|
- for (window = _this->windows; window != nil; window = window->next) {
|
|
|
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
|
|
|
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application
|
|
|
-{
|
|
|
- //NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
|
-
|
|
|
- SDL_Event event;
|
|
|
- event.type=SDL_SYSEVENT_LOWMEMORY;
|
|
|
- event.sysevent.data=NULL;
|
|
|
- if (SDL_SysEventHandler)
|
|
|
- SDL_SysEventHandler(&event);
|
|
|
-}
|
|
|
-@end
|
|
|
-
|
|
|
-#endif /* SDL_VIDEO_DRIVER_UIKIT */
|
|
|
+
|
|
|
+- (void)applicationWillTerminate:(UIApplication *)application
|
|
|
+{
|
|
|
+ SDL_Event event;
|
|
|
+ event.type=SDL_SYSEVENT_TERMINATE;
|
|
|
+ event.sysevent.data=NULL;
|
|
|
+ if (SDL_SysEventHandler)
|
|
|
+ SDL_SysEventHandler(&event);
|
|
|
+ else
|
|
|
+ SDL_SendQuit();
|
|
|
+}
|
|
|
+
|
|
|
+- (void) applicationWillResignActive:(UIApplication*)application
|
|
|
+{
|
|
|
+ //NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
|
+ SDL_Event event;
|
|
|
+ event.type=SDL_SYSEVENT_WILL_SUSPEND;
|
|
|
+ event.sysevent.data=NULL;
|
|
|
+ if (SDL_SysEventHandler)
|
|
|
+ SDL_SysEventHandler(&event);
|
|
|
+ else {
|
|
|
+ // Send every window on every screen a MINIMIZED event.
|
|
|
+ SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
|
|
+ if (!_this) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ SDL_Window *window;
|
|
|
+ for (window = _this->windows; window != nil; window = window->next) {
|
|
|
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
|
|
|
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)applicationDidEnterBackground:(UIApplication*)application
|
|
|
+{
|
|
|
+ //NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
|
+
|
|
|
+ SDL_Event event;
|
|
|
+ event.type=SDL_SYSEVENT_SUSPEND;
|
|
|
+ event.sysevent.data=NULL;
|
|
|
+ if (SDL_SysEventHandler)
|
|
|
+ SDL_SysEventHandler(&event);
|
|
|
+}
|
|
|
+
|
|
|
+- (void)applicationWillEnterForeground:(UIApplication*)application
|
|
|
+{
|
|
|
+ //NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
|
+
|
|
|
+ SDL_Event event;
|
|
|
+ event.type=SDL_SYSEVENT_WILL_RESUME;
|
|
|
+ event.sysevent.data=NULL;
|
|
|
+ if (SDL_SysEventHandler)
|
|
|
+ SDL_SysEventHandler(&event);
|
|
|
+}
|
|
|
+
|
|
|
+- (void) applicationDidBecomeActive:(UIApplication*)application
|
|
|
+{
|
|
|
+ //NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
|
+
|
|
|
+ SDL_Event event;
|
|
|
+ event.type=SDL_SYSEVENT_RESUME;
|
|
|
+ event.sysevent.data=NULL;
|
|
|
+ if (SDL_SysEventHandler)
|
|
|
+ SDL_SysEventHandler(&event);
|
|
|
+ else {
|
|
|
+ // Send every window on every screen a RESTORED event.
|
|
|
+ SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
|
|
+ if (!_this) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ SDL_Window *window;
|
|
|
+ for (window = _this->windows; window != nil; window = window->next) {
|
|
|
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
|
|
|
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application
|
|
|
+{
|
|
|
+ //NSLog(@"%@", NSStringFromSelector(_cmd));
|
|
|
+
|
|
|
+ SDL_Event event;
|
|
|
+ event.type=SDL_SYSEVENT_LOWMEMORY;
|
|
|
+ event.sysevent.data=NULL;
|
|
|
+ if (SDL_SysEventHandler)
|
|
|
+ SDL_SysEventHandler(&event);
|
|
|
+}
|
|
|
+@end
|
|
|
+
|
|
|
+#endif /* SDL_VIDEO_DRIVER_UIKIT */
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|