*/}}
Jelajahi Sumber

android events

YimingWu 6 bulan lalu
induk
melakukan
89e72ca748
1 mengubah file dengan 35 tambahan dan 5 penghapusan
  1. 35 5
      la_kernel.c

+ 35 - 5
la_kernel.c

@@ -1834,7 +1834,12 @@ void la_MakeSpecialKeyBit(SYSWINDOW hwnd,laWindow*wnd,laEvent *e,int use_last_po
 }
 void la_SaveEvent(SYSWINDOW hwnd, laEvent *e, int use_last_pos){
     laListHandle *wl = &MAIN.Windows;
-    laWindow* wnd = lstFindItem(hwnd, la_IsThisSysWindow, wl);
+    laWindow* wnd;
+#ifdef LAGUI_ANDROID
+    wnd = MAIN.Windows.pFirst;
+#else
+    wnd = lstFindItem(hwnd, la_IsThisSysWindow, wl);
+#endif
     if (!wnd){ memFree(e); return; }
     laListHandle *el = &wnd->EventList;
 
@@ -8062,9 +8067,6 @@ void laMainLoop(){
             la_DrawWindow(w);
         }
         for(w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
-#ifdef LAGUI_ANDROID
-            eglSwapBuffers(MAIN.egl_dpy, MAIN.egl_surf);
-#endif
             if(!w->RedrawTouched) continue; w->RedrawTouched=0;
 #ifdef LA_LINUX
     #ifdef LA_USE_GLES
@@ -8075,6 +8077,9 @@ void laMainLoop(){
 #endif
 #ifdef _WIN32
             SwapBuffers(w->hdc);
+#endif
+#ifdef LAGUI_ANDROID
+            eglSwapBuffers(MAIN.egl_dpy, MAIN.egl_surf);
 #endif
         }
         MAIN.GLDebugNeedsUpdate=0;
@@ -8104,6 +8109,8 @@ int la_AndroidInitGraphics(void){
     MAIN.AppWidth=ANativeWindow_getWidth(MAIN.app->window);
     MAIN.AppHeight=ANativeWindow_getHeight(MAIN.app->window);
 
+    la_CommandResizeWindow(0,0,0,MAIN.AppWidth,MAIN.AppHeight);
+
     EGLint samples = 0;
     EGLint sampleBuffer = 0;
 
@@ -8229,8 +8236,31 @@ static int32_t la_AndroidInputCallback(struct android_app *app, AInputEvent *eve
 {
     __android_log_print(ANDROID_LOG_DEBUG, "huh 5678", "123 input");
     if(!MAIN.AppEnabled){return 0;}
-    laRedrawAllWindows();
+    //laRedrawAllWindows();
     
+    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;
+    }
+    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);
+    }
+    else if (flags == AMOTION_EVENT_ACTION_CANCEL){
+        la_SendMouseEvent(0,LA_L_MOUSE_UP,x,y);
+    }
+
     //static float r=0;
     //eglMakeCurrent(MAIN.egl_dpy, MAIN.egl_surf, MAIN.egl_surf, MAIN.glc);
     //glViewport(0,0,MAIN.AppWidth,MAIN.AppHeight);