Added mobile application events, with implementations for iOS and Android
This commit is contained in:
parent
2ff60371f5
commit
2ac8624930
9 changed files with 182 additions and 44 deletions
|
@ -228,42 +228,48 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue,
|
|||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application
|
||||
{
|
||||
SDL_SendQuit();
|
||||
/* hack to prevent automatic termination. See SDL_uikitevents.m for details */
|
||||
longjmp(*(jump_env()), 1);
|
||||
SDL_SendAppEvent(SDL_APP_TERMINATING);
|
||||
}
|
||||
|
||||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
|
||||
{
|
||||
SDL_SendAppEvent(SDL_APP_LOWMEMORY);
|
||||
}
|
||||
|
||||
- (void) applicationWillResignActive:(UIApplication*)application
|
||||
{
|
||||
//NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||
|
||||
// Send every window on every screen a MINIMIZED event.
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
if (!_this) {
|
||||
return;
|
||||
if (_this) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND);
|
||||
}
|
||||
|
||||
- (void) applicationWillEnterForeground:(UIApplication*)application
|
||||
{
|
||||
SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
|
||||
}
|
||||
|
||||
- (void) applicationDidBecomeActive:(UIApplication*)application
|
||||
{
|
||||
//NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||
SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
|
||||
|
||||
// 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);
|
||||
if (_this) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,8 +91,10 @@ void UIKit_GL_SwapWindow(_THIS, SDL_Window * window)
|
|||
}
|
||||
[data->view swapBuffers];
|
||||
|
||||
/* we need to let the event cycle run, or the OS won't update the OpenGL view! */
|
||||
SDL_PumpEvents();
|
||||
/* You need to pump events in order for the OS to make changes visible.
|
||||
We don't pump events here because we don't want iOS application events
|
||||
(low memory, terminate, etc.) to happen inside low level rendering.
|
||||
*/
|
||||
}
|
||||
|
||||
SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue