mirror of
https://github.com/overte-org/overte.git
synced 2025-06-16 11:40:16 +02:00
use slightly more advanced event handling in native glue main
This commit is contained in:
parent
05cab9a3ba
commit
785f309512
1 changed files with 38 additions and 4 deletions
|
@ -12,12 +12,46 @@
|
||||||
#include <android_native_app_glue.h>
|
#include <android_native_app_glue.h>
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
|
||||||
#define APPNAME "Interface"
|
// usage of log
|
||||||
|
#define APP_NAME "Interface"
|
||||||
|
|
||||||
|
// usage of log
|
||||||
|
#define LOGINFO(x...) __android_log_print(ANDROID_LOG_INFO, APP_NAME, x)
|
||||||
|
|
||||||
|
// handle commands
|
||||||
|
static void custom_handle_cmd(struct android_app* app, int32_t cmd) {
|
||||||
|
switch(cmd) {
|
||||||
|
case APP_CMD_INIT_WINDOW:
|
||||||
|
LOGINFO("GearVR Interface, reporting for duty");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void android_main(struct android_app* state) {
|
void android_main(struct android_app* state) {
|
||||||
|
// Make sure glue isn't stripped.
|
||||||
app_dummy();
|
app_dummy();
|
||||||
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, APPNAME, "GearVR Interface, reporting for duty");
|
int events;
|
||||||
|
|
||||||
ANativeActivity_finish(state->activity);
|
// set up so when commands happen we call our custom handler
|
||||||
|
state->onAppCmd = custom_handle_cmd;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
struct android_poll_source* source;
|
||||||
|
|
||||||
|
// we block for events
|
||||||
|
while (ALooper_pollAll(-1, NULL, &events, (void**)&source) >= 0) {
|
||||||
|
|
||||||
|
// Process this event.
|
||||||
|
if (source != NULL) {
|
||||||
|
source->process(state, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we are exiting.
|
||||||
|
if (state->destroyRequested != 0) {
|
||||||
|
LOGINFO("We are exiting");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue