|
|
@@ -778,6 +778,7 @@ int Platform::enterMessagePump()
|
|
|
int domain;
|
|
|
mtouch_event_t touchEvent;
|
|
|
int touchId = 0;
|
|
|
+ bool suspended = false;
|
|
|
|
|
|
// Get the initial time.
|
|
|
clock_gettime(CLOCK_REALTIME, &__timespec);
|
|
|
@@ -950,6 +951,23 @@ int Platform::enterMessagePump()
|
|
|
case NAVIGATOR_SWIPE_DOWN:
|
|
|
_game->menu();
|
|
|
break;
|
|
|
+ case NAVIGATOR_WINDOW_STATE:
|
|
|
+ {
|
|
|
+ navigator_window_state_t state = navigator_event_get_window_state(event);
|
|
|
+ switch (state)
|
|
|
+ {
|
|
|
+ case NAVIGATOR_WINDOW_FULLSCREEN:
|
|
|
+ _game->resume();
|
|
|
+ suspended = false;
|
|
|
+ break;
|
|
|
+ case NAVIGATOR_WINDOW_THUMBNAIL:
|
|
|
+ case NAVIGATOR_WINDOW_INVISIBLE:
|
|
|
+ _game->pause();
|
|
|
+ suspended = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
case NAVIGATOR_EXIT:
|
|
|
_game->exit();
|
|
|
break;
|
|
|
@@ -957,13 +975,11 @@ int Platform::enterMessagePump()
|
|
|
}
|
|
|
else if (domain == sensor_get_domain())
|
|
|
{
|
|
|
- if (bps_event_get_code(event) == SENSOR_AZIMUTH_PITCH_ROLL_READING)
|
|
|
- {
|
|
|
- float azimuth;
|
|
|
- sensor_event_get_apr(event, &azimuth, &__pitch, &__roll);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+ if (bps_event_get_code(event) == SENSOR_AZIMUTH_PITCH_ROLL_READING)
|
|
|
+ {
|
|
|
+ float azimuth;
|
|
|
+ sensor_event_get_apr(event, &azimuth, &__pitch, &__roll);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -971,27 +987,30 @@ int Platform::enterMessagePump()
|
|
|
if (_game->getState() == Game::UNINITIALIZED)
|
|
|
break;
|
|
|
|
|
|
- _game->frame();
|
|
|
-
|
|
|
- // Post the new frame to the display.
|
|
|
- // Note that there are a couple cases where eglSwapBuffers could fail
|
|
|
- // with an error code that requires a certain level of re-initialization:
|
|
|
- //
|
|
|
- // 1) EGL_BAD_NATIVE_WINDOW - Called when the surface we're currently using
|
|
|
- // is invalidated. This would require us to destroy our EGL surface,
|
|
|
- // close our OpenKODE window, and start again.
|
|
|
- //
|
|
|
- // 2) EGL_CONTEXT_LOST - Power management event that led to our EGL context
|
|
|
- // being lost. Requires us to re-create and re-initalize our EGL context
|
|
|
- // and all OpenGL ES state.
|
|
|
- //
|
|
|
- // For now, if we get these, we'll simply exit.
|
|
|
- rc = eglSwapBuffers(__eglDisplay, __eglSurface);
|
|
|
- if (rc != EGL_TRUE)
|
|
|
+ if (!suspended)
|
|
|
{
|
|
|
- _game->exit();
|
|
|
- perror("eglSwapBuffers");
|
|
|
- break;
|
|
|
+ _game->frame();
|
|
|
+
|
|
|
+ // Post the new frame to the display.
|
|
|
+ // Note that there are a couple cases where eglSwapBuffers could fail
|
|
|
+ // with an error code that requires a certain level of re-initialization:
|
|
|
+ //
|
|
|
+ // 1) EGL_BAD_NATIVE_WINDOW - Called when the surface we're currently using
|
|
|
+ // is invalidated. This would require us to destroy our EGL surface,
|
|
|
+ // close our OpenKODE window, and start again.
|
|
|
+ //
|
|
|
+ // 2) EGL_CONTEXT_LOST - Power management event that led to our EGL context
|
|
|
+ // being lost. Requires us to re-create and re-initalize our EGL context
|
|
|
+ // and all OpenGL ES state.
|
|
|
+ //
|
|
|
+ // For now, if we get these, we'll simply exit.
|
|
|
+ rc = eglSwapBuffers(__eglDisplay, __eglSurface);
|
|
|
+ if (rc != EGL_TRUE)
|
|
|
+ {
|
|
|
+ _game->exit();
|
|
|
+ perror("eglSwapBuffers");
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|