|
|
|
@ -197,26 +197,29 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
|
|
|
|
struct engine* engine = (struct engine*)app->userData;
|
|
|
|
struct engine* engine = (struct engine*)app->userData;
|
|
|
|
if (type == AINPUT_EVENT_TYPE_MOTION) {
|
|
|
|
if (type == AINPUT_EVENT_TYPE_MOTION) {
|
|
|
|
int32_t subtype = AMotionEvent_getAction (event);
|
|
|
|
int32_t subtype = AMotionEvent_getAction (event);
|
|
|
|
gevent.mousepos.x = AMotionEvent_getX(event, 0);
|
|
|
|
gevent.scr_mpos.x = AMotionEvent_getX(event, 0);
|
|
|
|
gevent.mousepos.y = AMotionEvent_getY(event, 0);
|
|
|
|
gevent.scr_mpos.y = AMotionEvent_getY(event, 0);
|
|
|
|
|
|
|
|
|
|
|
|
if (subtype == AMOTION_EVENT_ACTION_MOVE) {
|
|
|
|
if (subtype == AMOTION_EVENT_ACTION_MOVE) {
|
|
|
|
gevent.event = EGUI_MOUSEMOVE;
|
|
|
|
gevent.event = EGUI_MOUSEMOVE;
|
|
|
|
|
|
|
|
|
|
|
|
if (gui_event (gevent) == 0) draw_mousemove (gevent.mousepos.x, gevent.mousepos.y, 0);
|
|
|
|
// if (gui_event (gevent) == 0) draw_mousemove (gevent.scr_mpos.x, gevent.scr_mpos.y, 0);
|
|
|
|
|
|
|
|
gui_event (gevent);
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (subtype == AMOTION_EVENT_ACTION_UP) {
|
|
|
|
else if (subtype == AMOTION_EVENT_ACTION_UP) {
|
|
|
|
gevent.mousebtn = 1;
|
|
|
|
gevent.mousebtn = 1;
|
|
|
|
gevent.event = EGUI_MOUSERELEASED;
|
|
|
|
gevent.event = EGUI_MOUSERELEASED;
|
|
|
|
if (gui_event (gevent) == 0) draw_mousebtnup (gevent.mousepos.x, gevent.mousepos.y, 1);
|
|
|
|
// if (gui_event (gevent) == 0) draw_mousebtnup (gevent.scr_mpos.x, gevent.scr_mpos.y, 1);
|
|
|
|
|
|
|
|
gui_event (gevent);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (subtype == AMOTION_EVENT_ACTION_DOWN) {
|
|
|
|
else if (subtype == AMOTION_EVENT_ACTION_DOWN) {
|
|
|
|
char *tmp;
|
|
|
|
char *tmp;
|
|
|
|
gevent.mousebtn = 1;
|
|
|
|
gevent.mousebtn = 1;
|
|
|
|
gevent.event = EGUI_MOUSEPRESSED;
|
|
|
|
gevent.event = EGUI_MOUSEPRESSED;
|
|
|
|
if (gui_event (gevent) == 0) draw_mousebtndown (gevent.mousepos.x, gevent.mousepos.y, 1);
|
|
|
|
// if (gui_event (gevent) == 0) draw_mousebtndown (gevent.scr_mpos.x, gevent.scr_mpos.y, 1);
|
|
|
|
|
|
|
|
gui_event (gevent);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -295,18 +298,64 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main_event () {
|
|
|
|
|
|
|
|
// Read all pending events.
|
|
|
|
|
|
|
|
time_t t1 = time(NULL), t2 = time(NULL);
|
|
|
|
|
|
|
|
struct gps_data *gpspos;
|
|
|
|
|
|
|
|
int ident;
|
|
|
|
|
|
|
|
int events;
|
|
|
|
|
|
|
|
struct android_poll_source* source;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If not animating, we will block forever waiting for events.
|
|
|
|
|
|
|
|
// If animating, we loop until all events are read, then continue
|
|
|
|
|
|
|
|
// to draw the next frame of animation.
|
|
|
|
|
|
|
|
while ((ident=ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Process this event.
|
|
|
|
|
|
|
|
if (source != NULL) {
|
|
|
|
|
|
|
|
source->process(engine.app, source);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If a sensor has data, process it now.
|
|
|
|
|
|
|
|
if (ident == LOOPER_ID_USER) {
|
|
|
|
|
|
|
|
if (engine.accelerometerSensor != NULL) {
|
|
|
|
|
|
|
|
ASensorEvent event;
|
|
|
|
|
|
|
|
while (ASensorEventQueue_getEvents(engine.sensorEventQueue,
|
|
|
|
|
|
|
|
&event, 1) > 0) {
|
|
|
|
|
|
|
|
// LOGI("accelerometer: x=%f y=%f z=%f",
|
|
|
|
|
|
|
|
// event.acceleration.x, event.acceleration.y,
|
|
|
|
|
|
|
|
// event.acceleration.z);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if we are exiting.
|
|
|
|
|
|
|
|
if (engine.app->destroyRequested != 0) {
|
|
|
|
|
|
|
|
engine_term_display(&engine);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
t1 = time(NULL);
|
|
|
|
|
|
|
|
if (t1 != t2) {
|
|
|
|
|
|
|
|
t2 = t1;
|
|
|
|
|
|
|
|
if (gps_isrunning () > 0) {
|
|
|
|
|
|
|
|
if ((gpspos = gps_loop ())) {
|
|
|
|
|
|
|
|
drawgps_set_pos (gpspos);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This is the main entry point of a native application that is using
|
|
|
|
* This is the main entry point of a native application that is using
|
|
|
|
* android_native_app_glue. It runs in its own thread, with its own
|
|
|
|
* android_native_app_glue. It runs in its own thread, with its own
|
|
|
|
* event loop for receiving input events and doing other things.
|
|
|
|
* event loop for receiving input events and doing other things.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void android_main(struct android_app* state) {
|
|
|
|
void android_main(struct android_app* state) {
|
|
|
|
time_t t1 = time(NULL), t2 = time(NULL);
|
|
|
|
|
|
|
|
struct gps_data *gpspos;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure glue isn't stripped.
|
|
|
|
// Make sure glue isn't stripped.
|
|
|
|
app_dummy();
|
|
|
|
app_dummy();
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("Android Version");
|
|
|
|
d_printf ("Android Version");
|
|
|
|
memset(&engine, 0, sizeof(engine));
|
|
|
|
memset(&engine, 0, sizeof(engine));
|
|
|
|
state->userData = &engine;
|
|
|
|
state->userData = &engine;
|
|
|
|
@ -316,7 +365,7 @@ void android_main(struct android_app* state) {
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("internal data path: %s", state->activity->internalDataPath);
|
|
|
|
d_printf ("internal data path: %s", state->activity->internalDataPath);
|
|
|
|
d_printf ("external data path: %s", state->activity->externalDataPath);
|
|
|
|
d_printf ("external data path: %s", state->activity->externalDataPath);
|
|
|
|
|
|
|
|
|
|
|
|
// Prepare to monitor accelerometer
|
|
|
|
// Prepare to monitor accelerometer
|
|
|
|
engine.sensorManager = ASensorManager_getInstance();
|
|
|
|
engine.sensorManager = ASensorManager_getInstance();
|
|
|
|
engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager,
|
|
|
|
engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager,
|
|
|
|
@ -333,61 +382,17 @@ void android_main(struct android_app* state) {
|
|
|
|
|
|
|
|
|
|
|
|
// loop waiting for stuff to do.
|
|
|
|
// loop waiting for stuff to do.
|
|
|
|
while (1) {
|
|
|
|
while (1) {
|
|
|
|
// Read all pending events.
|
|
|
|
main_event ();
|
|
|
|
int ident;
|
|
|
|
|
|
|
|
int events;
|
|
|
|
|
|
|
|
struct android_poll_source* source;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If not animating, we will block forever waiting for events.
|
|
|
|
|
|
|
|
// If animating, we loop until all events are read, then continue
|
|
|
|
|
|
|
|
// to draw the next frame of animation.
|
|
|
|
|
|
|
|
while ((ident=ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Process this event.
|
|
|
|
|
|
|
|
if (source != NULL) {
|
|
|
|
|
|
|
|
source->process(state, source);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If a sensor has data, process it now.
|
|
|
|
|
|
|
|
if (ident == LOOPER_ID_USER) {
|
|
|
|
|
|
|
|
if (engine.accelerometerSensor != NULL) {
|
|
|
|
|
|
|
|
ASensorEvent event;
|
|
|
|
|
|
|
|
while (ASensorEventQueue_getEvents(engine.sensorEventQueue,
|
|
|
|
|
|
|
|
&event, 1) > 0) {
|
|
|
|
|
|
|
|
// LOGI("accelerometer: x=%f y=%f z=%f",
|
|
|
|
|
|
|
|
// event.acceleration.x, event.acceleration.y,
|
|
|
|
|
|
|
|
// event.acceleration.z);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if we are exiting.
|
|
|
|
|
|
|
|
if (state->destroyRequested != 0) {
|
|
|
|
|
|
|
|
engine_term_display(&engine);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
t1 = time(NULL);
|
|
|
|
|
|
|
|
if (t1 != t2) {
|
|
|
|
|
|
|
|
t2 = t1;
|
|
|
|
|
|
|
|
if (gps_isrunning () > 0) {
|
|
|
|
|
|
|
|
if ((gpspos = gps_loop ())) {
|
|
|
|
|
|
|
|
drawgps_set_pos (gpspos);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
* main functions for sposmroute...
|
|
|
|
* main functions for sposmroute...
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void main_wnd_loop (long long int cur, long long int max) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main_wnd_update () {
|
|
|
|
void main_wnd_update () {
|
|
|
|
|
|
|
|
main_event ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|