src/video/uikit/SDL_uikitevents.m
author Sam Lantinga
Sat, 04 Oct 2008 06:46:59 +0000
changeset 2765 f55c87ae336b
child 2859 99210400e8b9
permissions -rw-r--r--
Final merge of Google Summer of Code 2008 work...

Bring SDL to iPhone and iPod Touch
by Holmes Futrell, mentored by Sam Lantinga
slouken@2765
     1
/*
slouken@2765
     2
    SDL - Simple DirectMedia Layer
slouken@2765
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@2765
     4
slouken@2765
     5
    This library is free software; you can redistribute it and/or
slouken@2765
     6
    modify it under the terms of the GNU Lesser General Public
slouken@2765
     7
    License as published by the Free Software Foundation; either
slouken@2765
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@2765
     9
slouken@2765
    10
    This library is distributed in the hope that it will be useful,
slouken@2765
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@2765
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@2765
    13
    Lesser General Public License for more details.
slouken@2765
    14
slouken@2765
    15
    You should have received a copy of the GNU Lesser General Public
slouken@2765
    16
    License along with this library; if not, write to the Free Software
slouken@2765
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@2765
    18
slouken@2765
    19
    Sam Lantinga
slouken@2765
    20
    slouken@libsdl.org
slouken@2765
    21
*/
slouken@2765
    22
#include "SDL_config.h"
slouken@2765
    23
slouken@2765
    24
#include "SDL.h"
slouken@2765
    25
#include "../../events/SDL_sysevents.h"
slouken@2765
    26
#include "../../events/SDL_events_c.h"
slouken@2765
    27
slouken@2765
    28
#include "SDL_uikitvideo.h"
slouken@2765
    29
#include "SDL_uikitevents.h"
slouken@2765
    30
slouken@2765
    31
#import <Foundation/Foundation.h>
slouken@2765
    32
#include "jumphack.h"
slouken@2765
    33
slouken@2765
    34
void
slouken@2765
    35
UIKit_PumpEvents(_THIS)
slouken@2765
    36
{
slouken@2765
    37
	/* 
slouken@2765
    38
		When the user presses the 'home' button on the iPod
slouken@2765
    39
		the application exits -- immediatly.
slouken@2765
    40
	 
slouken@2765
    41
		Unlike in Mac OS X, it appears there is no way to cancel the termination.
slouken@2765
    42
	 
slouken@2765
    43
		This doesn't give the SDL user's application time to respond to an SDL_Quit event.
slouken@2765
    44
		So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelegate),
slouken@2765
    45
		when the delegate receives the ApplicationWillTerminate message, we execute
slouken@2765
    46
		a longjmp statement to get back here, preventing an immediate exit.
slouken@2765
    47
	 */	
slouken@2765
    48
	if (setjmp(*jump_env()) == 0) {
slouken@2765
    49
		/* if we're setting the jump, rather than jumping back */
slouken@2765
    50
		SInt32 result;
slouken@2765
    51
		do {
slouken@2765
    52
			result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE);
slouken@2765
    53
		} while(result == kCFRunLoopRunHandledSource);
slouken@2765
    54
	}
slouken@2765
    55
slouken@2765
    56
}
slouken@2765
    57
slouken@2765
    58
/* vi: set ts=4 sw=4 expandtab: */