|
|
|
@ -30,6 +30,13 @@
|
|
|
|
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__))
|
|
|
|
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__))
|
|
|
|
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "sposmroute", __VA_ARGS__))
|
|
|
|
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "sposmroute", __VA_ARGS__))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX_EVENTS 128
|
|
|
|
|
|
|
|
GUIEvent eventlist[MAX_EVENTS] = {0};
|
|
|
|
|
|
|
|
int eventcnt = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int gevent_push (GUIEvent *event);
|
|
|
|
|
|
|
|
int gevent_pop (GUIEvent *event);
|
|
|
|
|
|
|
|
void gevent_clear ();
|
|
|
|
|
|
|
|
|
|
|
|
struct engine engine;
|
|
|
|
struct engine engine;
|
|
|
|
|
|
|
|
|
|
|
|
@ -189,6 +196,7 @@ static void engine_term_display(struct engine* engine) {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Process the next input event.
|
|
|
|
* Process the next input event.
|
|
|
|
|
|
|
|
* save events inside a EVENT list.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) {
|
|
|
|
static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) {
|
|
|
|
GUIEvent gevent;
|
|
|
|
GUIEvent gevent;
|
|
|
|
@ -202,25 +210,21 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
|
|
|
|
|
|
|
|
|
|
|
|
if (subtype == AMOTION_EVENT_ACTION_MOVE) {
|
|
|
|
if (subtype == AMOTION_EVENT_ACTION_MOVE) {
|
|
|
|
gevent.event = EGUI_MOUSEMOVE;
|
|
|
|
gevent.event = EGUI_MOUSEMOVE;
|
|
|
|
|
|
|
|
gevent_push (&gevent);
|
|
|
|
// 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.scr_mpos.x, gevent.scr_mpos.y, 1);
|
|
|
|
gevent_push (&gevent);
|
|
|
|
gui_event (gevent);
|
|
|
|
return 1;
|
|
|
|
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.scr_mpos.x, gevent.scr_mpos.y, 1);
|
|
|
|
gevent_push (&gevent);
|
|
|
|
gui_event (gevent);
|
|
|
|
return 1;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -305,13 +309,14 @@ void main_event () {
|
|
|
|
struct gps_data *gpspos;
|
|
|
|
struct gps_data *gpspos;
|
|
|
|
int ident;
|
|
|
|
int ident;
|
|
|
|
int events;
|
|
|
|
int events;
|
|
|
|
|
|
|
|
int t = 0;
|
|
|
|
|
|
|
|
GUIEvent event;
|
|
|
|
struct android_poll_source* source;
|
|
|
|
struct android_poll_source* source;
|
|
|
|
|
|
|
|
|
|
|
|
// If not animating, we will block forever waiting for events.
|
|
|
|
// If not animating, we will block forever waiting for events.
|
|
|
|
// If animating, we loop until all events are read, then continue
|
|
|
|
// If animating, we loop until all events are read, then continue
|
|
|
|
// to draw the next frame of animation.
|
|
|
|
// to draw the next frame of animation.
|
|
|
|
while ((ident=ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0) {
|
|
|
|
while ((ident=ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0) {
|
|
|
|
|
|
|
|
|
|
|
|
// Process this event.
|
|
|
|
// Process this event.
|
|
|
|
if (source != NULL) {
|
|
|
|
if (source != NULL) {
|
|
|
|
source->process(engine.app, source);
|
|
|
|
source->process(engine.app, source);
|
|
|
|
@ -336,6 +341,10 @@ void main_event () {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (gevent_pop(&event)) {
|
|
|
|
|
|
|
|
gui_event (event);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
t1 = time(NULL);
|
|
|
|
t1 = time(NULL);
|
|
|
|
if (t1 != t2) {
|
|
|
|
if (t1 != t2) {
|
|
|
|
t2 = t1;
|
|
|
|
t2 = t1;
|
|
|
|
@ -474,3 +483,30 @@ int gps_android_device_read (char *ptr, int ptrsize) {
|
|
|
|
(*jvm)->DetachCurrentThread(jvm);
|
|
|
|
(*jvm)->DetachCurrentThread(jvm);
|
|
|
|
return strlen (ptr);
|
|
|
|
return strlen (ptr);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int gevent_push (GUIEvent *event) {
|
|
|
|
|
|
|
|
if (eventcnt < MAX_EVENTS) {
|
|
|
|
|
|
|
|
memcpy (&eventlist[eventcnt], event, sizeof (GUIEvent));
|
|
|
|
|
|
|
|
eventcnt++;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int gevent_pop (GUIEvent *event) {
|
|
|
|
|
|
|
|
if (eventcnt > 0) {
|
|
|
|
|
|
|
|
eventcnt--;
|
|
|
|
|
|
|
|
memcpy (event, &eventlist[eventcnt], sizeof (GUIEvent));
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void gevent_clear () {
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset (eventlist, 0x0, MAX_EVENTS * sizeof (GUIEvent));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|