Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Disable the SDL event pump after the SDL main routine returns, since …
Browse files Browse the repository at this point in the history
…events will be dispatched by the Cocoa event loop.
  • Loading branch information
slouken committed Jun 25, 2012
1 parent 276a3e4 commit 9c69433
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/SDL_system.h
Expand Up @@ -43,6 +43,7 @@ extern "C" {
#include "SDL_video.h"

extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);

extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardShow(SDL_Window * window);
extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardHide(SDL_Window * window);
Expand Down
3 changes: 3 additions & 0 deletions src/video/uikit/SDL_uikitappdelegate.m
Expand Up @@ -26,6 +26,7 @@
#import "SDL_assert.h"
#import "SDL_hints.h"
#import "../../SDL_hints_c.h"
#import "SDL_system.h"

#import "SDL_uikitappdelegate.h"
#import "SDL_uikitopenglview.h"
Expand Down Expand Up @@ -105,7 +106,9 @@ - (void)postFinishLaunch
SDL_RegisterHintChangedCb(SDL_HINT_IDLE_TIMER_DISABLED, &SDL_IdleTimerDisabledChanged);

/* run the user's application, passing argc and argv */
SDL_iPhoneSetEventPump(SDL_TRUE);
exit_status = SDL_main(forward_argc, forward_argv);
SDL_iPhoneSetEventPump(SDL_FALSE);

/* exit, passing the return status from the user's application */
// We don't actually exit to support applications that do setup in
Expand Down
11 changes: 11 additions & 0 deletions src/video/uikit/SDL_uikitevents.m
Expand Up @@ -30,9 +30,20 @@
#import <Foundation/Foundation.h>
#include "jumphack.h"

static BOOL UIKit_EventPumpEnabled = YES;

void
SDL_iPhoneSetEventPump(SDL_bool enabled)
{
UIKit_EventPumpEnabled = enabled;
}

void
UIKit_PumpEvents(_THIS)
{
if (!UIKit_EventPumpEnabled)
return;

/*
When the user presses the 'home' button on the iPod
the application exits -- immediatly.
Expand Down

0 comments on commit 9c69433

Please sign in to comment.