These files contain the events related functions for the UIKit video driver. Right now this is just UIKit_PumpEvents. gsoc2008_iphone
authorHolmes Futrell <hfutrell@umail.ucsb.edu>
Thu, 17 Jul 2008 22:48:23 +0000
branchgsoc2008_iphone
changeset 2355eec14ed2bb18
parent 2354 2e4fea4a4416
child 2356 5c27688b08cf
These files contain the events related functions for the UIKit video driver. Right now this is just UIKit_PumpEvents.
src/video/uikit/SDL_uikitevents.h
src/video/uikit/SDL_uikitevents.m
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/uikit/SDL_uikitevents.h	Thu Jul 17 22:48:23 2008 +0000
     1.3 @@ -0,0 +1,28 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997-2006 Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Lesser General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2.1 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Lesser General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Lesser General Public
    1.19 +    License along with this library; if not, write to the Free Software
    1.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@libsdl.org
    1.24 +*/
    1.25 +#include "SDL_config.h"
    1.26 +
    1.27 +#include "SDL_uikitvideo.h"
    1.28 +
    1.29 +extern void UIKit_PumpEvents(_THIS);
    1.30 +
    1.31 +/* vi: set ts=4 sw=4 expandtab: */
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/video/uikit/SDL_uikitevents.m	Thu Jul 17 22:48:23 2008 +0000
     2.3 @@ -0,0 +1,65 @@
     2.4 +/*
     2.5 +    SDL - Simple DirectMedia Layer
     2.6 +    Copyright (C) 1997-2006 Sam Lantinga
     2.7 +
     2.8 +    This library is free software; you can redistribute it and/or
     2.9 +    modify it under the terms of the GNU Lesser General Public
    2.10 +    License as published by the Free Software Foundation; either
    2.11 +    version 2.1 of the License, or (at your option) any later version.
    2.12 +
    2.13 +    This library is distributed in the hope that it will be useful,
    2.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.16 +    Lesser General Public License for more details.
    2.17 +
    2.18 +    You should have received a copy of the GNU Lesser General Public
    2.19 +    License along with this library; if not, write to the Free Software
    2.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2.21 +
    2.22 +    Sam Lantinga
    2.23 +    slouken@libsdl.org
    2.24 +*/
    2.25 +#include "SDL_config.h"
    2.26 +
    2.27 +/* Being a null driver, there's no event stream. We just define stubs for
    2.28 +   most of the API. */
    2.29 +
    2.30 +#include "SDL.h"
    2.31 +#include "../../events/SDL_sysevents.h"
    2.32 +#include "../../events/SDL_events_c.h"
    2.33 +
    2.34 +#include "SDL_uikitvideo.h"
    2.35 +#include "SDL_uikitevents.h"
    2.36 +
    2.37 +#import <Foundation/Foundation.h>
    2.38 +#include "jump.h"
    2.39 +
    2.40 +void
    2.41 +UIKit_PumpEvents(_THIS)
    2.42 +{
    2.43 +	/* 
    2.44 +		When the user presses the 'home' button on the iPod
    2.45 +		the application exits -- immediatly.
    2.46 +	 
    2.47 +		Unlike in Mac OS X, it appears there is no way to cancel the termination.
    2.48 +	 
    2.49 +		This doesn't give the SDL user's application time to respond to an SDL_Quit event.
    2.50 +		So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelegate),
    2.51 +		when the delegate receives the ApplicationWillTerminate message, we execute
    2.52 +		a longjmp statement to get back here, preventing an immediate exit.
    2.53 +	 
    2.54 +	 */	
    2.55 +	if (setjmp(*jump_env()) != 0) {
    2.56 +		NSLog(@"Bam! We're back");
    2.57 +	}
    2.58 +	else {
    2.59 +		SInt32 result;
    2.60 +		do {
    2.61 +			result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE);
    2.62 +		} while(result == kCFRunLoopRunHandledSource);
    2.63 +
    2.64 +	}
    2.65 +
    2.66 +}
    2.67 +
    2.68 +/* vi: set ts=4 sw=4 expandtab: */