update android project

This commit is contained in:
2019-07-11 13:34:21 +02:00
parent d453e854b1
commit 92dd00d910
3 changed files with 49 additions and 40 deletions

View File

@@ -560,7 +560,6 @@ static int engine_init_display(struct engine* engine) {
}
}
FILE* file = popen("getprop", "r");
std::map<std::string, std::string> os_props;
if (file)
@@ -593,15 +592,6 @@ static int engine_init_display(struct engine* engine) {
LOG("PROP Maker: %s", os_props["ro.product.manufacturer"].c_str());
LOG("PROP Mode: %s", os_props["ro.product.model"].c_str());
// Initialize GL state.
android_async_lock(engine);
//glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
//glEnable(GL_CULL_FACE);
//glShadeModel(GL_SMOOTH);
glDisable(GL_DEPTH_TEST);
//glEnableClientState(GL_VERTEX_ARRAY);
Asset::m_am = engine->app->activity->assetManager;
App::I.and_app = engine->app;
App::I.and_engine = engine;
@@ -630,13 +620,16 @@ static int engine_init_display(struct engine* engine) {
App::I.width = w;
App::I.height = h;
App::I.redraw = true;
App::I.init();
// give control to the render thread
LOG("release egl context");
eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
LOG("start render threads");
App::I.render_thread_start();
LOG("start ui thread");
App::I.ui_thread_start();
#endif
LOG("All ready");
engine->animating = 1;
android_async_unlock(engine);
return 0;
}
@@ -644,6 +637,7 @@ static int engine_init_display(struct engine* engine) {
* Just the current frame in the display.
*/
static void engine_draw_frame(struct engine* engine) {
return;
static auto start = std::chrono::high_resolution_clock::now();
static float elapsed = 0;
static float elapsed_1s = 0;
@@ -719,7 +713,7 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
int32_t eventType = AInputEvent_getType(event);
//LOG("event type: %d", eventType);
locker _locker{engine};
//locker _locker{engine};
App::I.redraw = true;
switch (eventType) {
@@ -769,7 +763,9 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
float pressure = AMotionEvent_getPressure(event, 0);
kEventSource source = tool_type == AMOTION_EVENT_TOOL_TYPE_STYLUS ?
kEventSource::Stylus : kEventSource::Touch;
App::I.mouse_down(0, x, y, pressure, source, 0);
App::I.ui_task_async([=]{
App::I.mouse_down(0, x, y, pressure, source, 0);
});
tracked = 1;
//LOG("first down");
return 1;
@@ -787,9 +783,11 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
p0.pos.x = AMotionEvent_getX(event, 0);
p0.pos.y = AMotionEvent_getY(event, 0);
//LOG("second down");
if (tracked == 1)
App::I.mouse_cancel(0);
App::I.gesture_start(p0.pos, p1.pos);
App::I.ui_task_async([=] {
if (tracked == 1)
App::I.mouse_cancel(0);
App::I.gesture_start(p0.pos, p1.pos);
});
tracked = 2;
}
return 1;
@@ -805,7 +803,11 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
kEventSource source = tool_type == AMOTION_EVENT_TOOL_TYPE_STYLUS ?
kEventSource::Stylus : kEventSource::Touch;
if (tracked == 1)
App::I.mouse_up(0, x, y, source, 0);
{
App::I.ui_task_async([=] {
App::I.mouse_up(0, x, y, source, 0);
});
}
tracked = 0;
//LOG("first up");
return 1;
@@ -815,14 +817,18 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
{
p1.id = -1;
//LOG("second up");
App::I.gesture_end();
App::I.ui_task_async([=] {
App::I.gesture_end();
});
}
return 1;
case AMOTION_EVENT_ACTION_HOVER_MOVE: // pen move before touching
{
float y = AMotionEvent_getY(event, 0);
float x = AMotionEvent_getX(event, 0);
App::I.mouse_move(x, y, 0, kEventSource::Stylus, 0);
App::I.ui_task_async([=] {
App::I.mouse_move(x, y, 0, kEventSource::Stylus, 0);
});
//LOG("single move");
return 1;
}
@@ -835,7 +841,9 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
float pressure = AMotionEvent_getPressure(event, 0);
kEventSource source = tool_type == AMOTION_EVENT_TOOL_TYPE_STYLUS ?
kEventSource::Stylus : kEventSource::Touch;
App::I.mouse_move(x, y, pressure, source, 0);
App::I.ui_task_async([=] {
App::I.mouse_move(x, y, pressure, source, 0);
});
//LOG("single move");
}
else if (count == 2)
@@ -856,7 +864,9 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
float y = AMotionEvent_getY(event, 1);
p1.pos = {x, y};
}
App::I.gesture_move(p0.pos, p1.pos);
App::I.ui_task_async([=] {
App::I.gesture_move(p0.pos, p1.pos);
});
}
return 1;
default:
@@ -879,17 +889,23 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
case AKEY_EVENT_ACTION_MULTIPLE:
LOG("Received key multi event: %d\n", key_val);
if (uniValue > 32 && uniValue < 127) //printable ascii range
App::I.key_char(uniValue);
App::I.ui_task_async([=] {
App::I.key_char(uniValue);
});
break;
case AKEY_EVENT_ACTION_DOWN:
LOG("Received key down event: %d\n", key_val);
App::I.key_down(convert_key(key_val));
App::I.ui_task_async([=] {
App::I.key_down(convert_key(key_val));
});
break;
case AKEY_EVENT_ACTION_UP:
LOG("Received key up event: %d\n", key_val);
App::I.key_up(convert_key(key_val));
if (uniValue > 32 && uniValue < 127) //printable ascii range
App::I.key_char(uniValue);
App::I.ui_task_async([=] {
App::I.key_up(convert_key(key_val));
if (uniValue > 32 && uniValue < 127) //printable ascii range
App::I.key_char(uniValue);
});
break;
}
return 1;