|
@@ -60,6 +60,8 @@
|
|
|
#include <android_native_app_glue.h>
|
|
|
#include <android/window.h>
|
|
|
#include <android/asset_manager.h>
|
|
|
+#include <android/input.h>
|
|
|
+#include <android/keycodes.h>
|
|
|
|
|
|
FILE *funopen(const void *cookie, int (*readfn)(void *, char *, int), int (*writefn)(void *, const char *, int),
|
|
|
fpos_t (*seekfn)(void *, fpos_t, int), int (*closefn)(void *));
|
|
@@ -5223,7 +5225,7 @@ laUiItem *laEndCondition(laUiList *uil, laUiItem *Beginner){
|
|
|
|
|
|
return ui;
|
|
|
}
|
|
|
-laUiList* laMakeMenuPage(laUiList* uil, laColumn* c, const char* Title) {
|
|
|
+laUiList* laMakeMenuPageEx(laUiList* uil, laColumn* c, const char* Title, int flags) {
|
|
|
laUiItem* ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
laUiList* muil = memAcquireSimple(sizeof(laUiList));
|
|
|
|
|
@@ -5231,12 +5233,16 @@ laUiList* laMakeMenuPage(laUiList* uil, laColumn* c, const char* Title) {
|
|
|
strSafeSet(&ui->Display, Title);
|
|
|
ui->State = LA_UI_NORMAL; ui->Flags|=LA_TEXT_ALIGN_CENTER;
|
|
|
ui->C = c;
|
|
|
+ ui->Flags|=flags;
|
|
|
lstAppendItem(&uil->UiItems, ui);
|
|
|
|
|
|
lstAppendItem(&ui->Subs, muil);
|
|
|
|
|
|
return muil;
|
|
|
}
|
|
|
+laUiList* laMakeMenuPage(laUiList* uil, laColumn* c, const char* Title) {
|
|
|
+ return laMakeMenuPageEx(uil,c,Title,0);
|
|
|
+}
|
|
|
laUiItem *laShowSeparator(laUiList *uil, laColumn *widest){
|
|
|
laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
|
|
@@ -8264,6 +8270,7 @@ static void la_AndroidCommandCallback(struct android_app *app, int32_t cmd){
|
|
|
case APP_CMD_STOP: break;
|
|
|
case APP_CMD_DESTROY: break;
|
|
|
case APP_CMD_CONFIG_CHANGED:
|
|
|
+ case APP_CMD_WINDOW_RESIZED:
|
|
|
MAIN.AppWidth=ANativeWindow_getWidth(MAIN.app->window);
|
|
|
MAIN.AppHeight=ANativeWindow_getHeight(MAIN.app->window);
|
|
|
|
|
@@ -8272,6 +8279,19 @@ static void la_AndroidCommandCallback(struct android_app *app, int32_t cmd){
|
|
|
//print_cur_config(MAIN.app);
|
|
|
|
|
|
// Check screen orientation here!
|
|
|
+ if (MAIN.egl_dpy != EGL_NO_DISPLAY) {
|
|
|
+ eglMakeCurrent(MAIN.egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
|
+ if (MAIN.egl_surf != EGL_NO_SURFACE) {
|
|
|
+ eglDestroySurface(MAIN.egl_dpy, MAIN.egl_surf);
|
|
|
+ MAIN.egl_surf = EGL_NO_SURFACE;
|
|
|
+ }
|
|
|
+ EGLint displayFormat = 0;
|
|
|
+ eglGetConfigAttrib(MAIN.egl_dpy, MAIN.BestFBC, EGL_NATIVE_VISUAL_ID, &displayFormat);
|
|
|
+ ANativeWindow_setBuffersGeometry(app->window,MAIN.AppWidth,MAIN.AppHeight,
|
|
|
+ displayFormat);
|
|
|
+ MAIN.egl_surf = eglCreateWindowSurface(MAIN.egl_dpy, MAIN.BestFBC, app->window, NULL);
|
|
|
+ eglMakeCurrent(MAIN.egl_dpy, MAIN.egl_surf, MAIN.egl_surf, MAIN.glc);
|
|
|
+ }
|
|
|
break;
|
|
|
default: break;
|
|
|
}
|
|
@@ -8493,28 +8513,70 @@ static int32_t la_AndroidInputCallback(struct android_app *app, AInputEvent *eve
|
|
|
|
|
|
}
|
|
|
elif(type == AINPUT_EVENT_TYPE_MOTION){
|
|
|
- int pcount = AMotionEvent_getPointerCount(event); int x,y;
|
|
|
- if(pcount){
|
|
|
- real rx=AMotionEvent_getX(event, 0), ry=AMotionEvent_getY(event, 0);
|
|
|
- x=rx; y=ry;
|
|
|
- }
|
|
|
+ static real zoom_offset=1; static real temp_distance=0;
|
|
|
+ real zoom; int gesture_handled=0;
|
|
|
+ int pcount = AMotionEvent_getPointerCount(event); int x,y; static real cx=0,cy=0;
|
|
|
int32_t action = AMotionEvent_getAction(event);
|
|
|
unsigned int flags = action & AMOTION_EVENT_ACTION_MASK;
|
|
|
int32_t pointerIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
|
|
|
|
|
|
- if (flags == AMOTION_EVENT_ACTION_DOWN){
|
|
|
- la_SendMouseEvent(0,LA_MOUSEMOVE,x,y);
|
|
|
- la_SendMouseEvent(0,LA_L_MOUSE_DOWN,x,y);
|
|
|
- }
|
|
|
- else if (flags == AMOTION_EVENT_ACTION_UP){
|
|
|
- la_SendMouseEvent(0,LA_L_MOUSE_UP,x,y);
|
|
|
- }
|
|
|
- else if (flags == AMOTION_EVENT_ACTION_MOVE){
|
|
|
- la_SendMouseEvent(0,LA_MOUSEMOVE,x,y);
|
|
|
+ if(pcount){
|
|
|
+ real rx=AMotionEvent_getX(event, 0), ry=AMotionEvent_getY(event, 0);
|
|
|
+ x=rx; y=ry;
|
|
|
+ if(pcount>=2 && (flags!=AMOTION_EVENT_ACTION_UP) && (flags!=AMOTION_EVENT_ACTION_CANCEL)
|
|
|
+ && (flags!=AMOTION_EVENT_ACTION_POINTER_UP)){
|
|
|
+ real x2=AMotionEvent_getX(event, 1), y2=AMotionEvent_getY(event, 1);
|
|
|
+ real ctx=(x+x2)/2, cty=(y+y2)/2;
|
|
|
+ real distance = tnsDistIdv2(x2,y2,rx,ry);
|
|
|
+ if(temp_distance){ zoom_offset*=(distance/temp_distance); }
|
|
|
+ temp_distance = distance;
|
|
|
+
|
|
|
+ while(zoom_offset > 1.1){ zoom_offset-=0.1;
|
|
|
+ la_SendMouseEvent(0, LA_L_MOUSE_UP, x,y);
|
|
|
+ la_SendMouseEvent(0, LA_MOUSEUP|LA_KEY_MOUSE_SCROLL, x,y); gesture_handled=1;
|
|
|
+ }
|
|
|
+ while(zoom_offset < (1.0/1.1)){ zoom_offset+=(0.1/1.1);
|
|
|
+ la_SendMouseEvent(0, LA_L_MOUSE_UP, x,y);
|
|
|
+ la_SendMouseEvent(0, LA_MOUSEDOWN|LA_KEY_MOUSE_SCROLL, x,y); gesture_handled=1;
|
|
|
+ }
|
|
|
+ if(cx || cy){
|
|
|
+ if(!gesture_handled){
|
|
|
+ real dist = tnsDistIdv2(ctx,cty,cx,cy);
|
|
|
+ while(dist > LA_RH){
|
|
|
+ int udlr = fabs(cty-cy) > fabs(ctx-cx);
|
|
|
+ int direction = udlr?(cty>cy?LA_KEY_ARRUP:LA_KEY_ARRDOWN):
|
|
|
+ (ctx>cx?LA_KEY_ARRLEFT:LA_KEY_ARRRIGHT);
|
|
|
+ real fac = (real)(LA_RH)/dist;
|
|
|
+ cx=tnsLinearItp(cx,ctx,fac); cy=tnsLinearItp(cy,cty,fac);
|
|
|
+ la_SendMouseEvent(0, LA_L_MOUSE_UP, x,y);
|
|
|
+ la_SendKeyboardEvent(0, LA_KEY_DOWN, direction|LA_KEYBOARD_EVENT|LA_KEY_PANNING);
|
|
|
+ gesture_handled=1;
|
|
|
+ dist = tnsDistIdv2(ctx,cty,cx,cy);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ cx=ctx; cy=cty;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ temp_distance = 0; cx=0; cy=0;
|
|
|
+ }
|
|
|
}
|
|
|
- else if (flags == AMOTION_EVENT_ACTION_CANCEL){
|
|
|
- la_SendMouseEvent(0,LA_L_MOUSE_UP,x,y);
|
|
|
+ if(!gesture_handled){
|
|
|
+ if (flags == AMOTION_EVENT_ACTION_DOWN){
|
|
|
+ la_SendMouseEvent(0,LA_MOUSEMOVE,x,y);
|
|
|
+ la_SendMouseEvent(0,LA_L_MOUSE_DOWN,x,y);
|
|
|
+ }
|
|
|
+ else if (flags == AMOTION_EVENT_ACTION_UP){
|
|
|
+ la_SendMouseEvent(0,LA_L_MOUSE_UP,x,y);
|
|
|
+ }
|
|
|
+ else if (flags == AMOTION_EVENT_ACTION_MOVE){
|
|
|
+ la_SendMouseEvent(0,LA_MOUSEMOVE,x,y);
|
|
|
+ }
|
|
|
+ else if (flags == AMOTION_EVENT_ACTION_CANCEL){
|
|
|
+ la_SendMouseEvent(0,LA_L_MOUSE_UP,x,y);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//static float r=0;
|