ecere/Android: Latest Android fixes
authorJerome St-Louis <jerome@ecere.com>
Tue, 28 Jun 2016 00:42:42 +0000 (20:42 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 28 Jul 2016 22:23:20 +0000 (18:23 -0400)
- CheckExtension() was not being called and not setting up pow2textures and max texture size
- Fixes to handle up pointer with 0 touch count
- Support for window capture
- Extra 64 bit checks which get defined on ARM64 (__LP64__)
- Disabling memory manager
- Fixes to sample to reflect new crossplatform.mk commands

ecere/src/com/instance.ec
ecere/src/gui/Window.ec
ecere/src/gui/drivers/AndroidInterface.ec
samples/android/android/AndroidManifest.xml
samples/android/helloAndroid.epj

index d90d650..97499d5 100644 (file)
@@ -2,6 +2,10 @@
 
 namespace com;
 
+#if defined(__ANDROID__)
+ #define DISABLE_MEMMGR
+#endif
+
 #if defined(__EMSCRIPTEN__)
  #define DISABLE_MEMMGR
  #define _NOMUTEX
@@ -708,7 +712,7 @@ static class MemInfo : BTNode //struct
          printf("Object of class %s\n", _class);
       printf("   Allocation Stack:\n");
       for(c = 0; c<MAX_MEMORY_LOC; c++)
-#if (defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__)
+#if (defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__) || defined(_M_X64) || defined(_WIN64) || defined(__LP64__) || defined(__LLP64__)
          if(allocLoc[c] && allocLoc[c] != (void *)0xabababababababab)
 #else
          if(allocLoc[c] && allocLoc[c] != (void *)0xabababab)
@@ -4829,7 +4833,7 @@ public dllexport void eInstance_Delete(Instance instance)
       bool ownVtbl;
 
 #ifdef MEMINFO
-#if (defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__)
+#if (defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__) || defined(_M_X64) || defined(_WIN64) || defined(__LP64__) || defined(__LLP64__)
       if(instance._class == (void *)0xecececececececec)
 #else
       if(instance._class == (void *)0xecececec)
@@ -5660,7 +5664,7 @@ static Module Module_Load(Module fromModule, const char * name, AccessMode impor
       }
       incref module;
    }
-#if defined(_DEBUG)
+#if defined(_DEBUG) && !defined(__ANDROID__)
    InternalModuleLoadBreakpoint();
 #endif
    return module;
@@ -6355,7 +6359,7 @@ public bool LocateModule(const char * name, const char * fileName)
 }
 
 /*
-#if (defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__)
+#if (defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__) || defined(_M_X64) || defined(_WIN64) || defined(__LP64__) || defined(__LLP64__)
 #define _64BIT 1
 #else
 #define _64BIT 0
@@ -6598,8 +6602,11 @@ public dllexport Application __ecere_COM_Initialize(bool guiApp, int argc, char
 
 #ifdef __ANDROID__
    // Clean up global variables
+#if !defined(DISABLE_MEMMGR)
    memoryInitialized = false;
    pools = null;
+#endif
+
 #ifdef MEMINFO
    memset(&memStacks, 0, sizeof(BinaryTree));
    memoryErrorsCount = 0;
index f854850..55baee9 100644 (file)
@@ -4086,14 +4086,14 @@ private:
    public bool MultiTouchMessage(TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers * mods, bool consequential, bool activate)
    {
       bool result = true;
-      if(infos.count)
+      if((infos && infos.count) || (event == up || event == pointerUp))
       {
          Window w = null;
          while(result && w != this)
          {
             // TODO: How to handle this?
-            int x = infos[0].point.x;
-            int y = infos[0].point.y;
+            int x = (infos && infos.count) ? infos[0].point.x : 0;
+            int y = (infos && infos.count) ? infos[0].point.y : 0;
             Window msgWindow = GetAtPosition(x,y, false, true, w);
             Window window;
             delete w;
@@ -4101,6 +4101,14 @@ private:
             if(w) incref w;
             window = (w && !w.disabled) ? w : null;
 
+            if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
+            {
+               if(!guiApp.windowCaptured.isEnabled)
+                  guiApp.windowCaptured.ReleaseCapture();
+               else
+                  window = guiApp.windowCaptured;
+            }
+
             if(consequential) mods->isSideEffect = true;
             if(!result || (window && window.destroyed)) window = null;
 
@@ -4108,16 +4116,20 @@ private:
             {
                if(window.OnMultiTouch && !window.disabled)
                {
-                  Array<TouchPointerInfo> in { size = infos.size };
-                  memcpy(in.array, infos.array, sizeof(TouchPointerInfo) * infos.size);
-
-                  for(i : in)
+                  Array<TouchPointerInfo> in = null;
+                  if(infos && infos.count)
                   {
-                     i.point.x -= (window.absPosition.x + window.clientStart.x);
-                     i.point.y -= (window.absPosition.y + window.clientStart.y);
+                     in = { size = infos.size };
+                     memcpy(in.array, infos.array, sizeof(TouchPointerInfo) * infos.size);
+
+                     for(i : in)
+                     {
+                        i.point.x -= (window.absPosition.x + window.clientStart.x);
+                        i.point.y -= (window.absPosition.y + window.clientStart.y);
 
-                     i.point.x = Max(Min(i.point.x, 32767),-32768);
-                     i.point.y = Max(Min(i.point.y, 32767),-32768);
+                        i.point.x = Max(Min(i.point.x, 32767),-32768);
+                        i.point.y = Max(Min(i.point.y, 32767),-32768);
+                     }
                   }
 
                   incref window;
index a79b8a3..c4f6e74 100644 (file)
@@ -1113,14 +1113,18 @@ static Key keyCodeTable[] =
 static Array<TouchPointerInfo> buildPointerInfo(AInputEvent * event)
 {
    uint count = (uint)AMotionEvent_getPointerCount(event);
-   Array<TouchPointerInfo> infos { size = count };
-   int i;
-   for(i = 0; i < count; i++)
+   Array<TouchPointerInfo> infos = null;
+   if(count)
    {
-      infos[i].point = { (int)AMotionEvent_getX(event, i), (int)AMotionEvent_getY(event, i) };
-      infos[i].id = (int)AMotionEvent_getPointerId(event, i);
-      infos[i].pressure = AMotionEvent_getPressure(event, i);
-      infos[i].size = AMotionEvent_getSize(event, i);
+      int i;
+      infos = { size = count };
+      for(i = 0; i < count; i++)
+      {
+         infos[i].point = { (int)AMotionEvent_getX(event, i), (int)AMotionEvent_getY(event, i) };
+         infos[i].id = (int)AMotionEvent_getPointerId(event, i);
+         infos[i].pressure = AMotionEvent_getPressure(event, i);
+         infos[i].size = AMotionEvent_getSize(event, i);
+      }
    }
    return infos;
 }
@@ -1155,8 +1159,9 @@ class AndroidActivity : AndroidAppGlue
          //int64 eventTime = AMotionEvent_getDownTime(event);
          //float axis;
          Modifiers keyFlags = 0;
-         int x = (int)AMotionEvent_getX(event, 0);
-         int y = (int)AMotionEvent_getY(event, 0);
+         uint count = (uint)AMotionEvent_getPointerCount(event);
+         int x = count ? (int)AMotionEvent_getX(event, 0) : 0;
+         int y = count ? (int)AMotionEvent_getY(event, 0) : 0;
          bool shift = (meta & AMETA_SHIFT_ON) ? true : false;
          bool alt = (meta & AMETA_ALT_ON) ? true : false;
          //bool sym = (meta & AMETA_SYM_ON) ? true : false;
index 4c4ccc3..6ad2745 100644 (file)
@@ -1,18 +1,24 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- BEGIN_INCLUDE(manifest) -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-        package="com.ecere.Hello"
+        package="com.ecere.hello"
         android:versionCode="1"
         android:versionName="1.0">
 
     <!-- This is the platform API where NativeActivity was introduced. -->
     <uses-sdk android:minSdkVersion="9" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 
-    <!-- This .apk has no Java code itself, so set hasCode to false. -->
-    <application android:label="@string/app_name" android:hasCode="false">
+    <application
+      android:label="@string/app_name"
+      android:hasCode="true"
+      android:debuggable="true"
+      android:hardwareAccelerated="true">
 
         <!-- Our activity is the built-in NativeActivity framework class. This will take care of integrating with our NDK code. -->
-        <activity android:name="android.app.NativeActivity"
+        <activity android:name="hello"
                   android:label="@string/app_name"
                   android:configChanges="orientation|keyboardHidden">
             <!-- Tell NativeActivity the name of our .so -->
index 6c07812..c2d7123 100644 (file)
@@ -1,10 +1,10 @@
 {
    "Version" : 0.2,
-   "ModuleName" : "Hello",
+   "ModuleName" : "hello",
    "Options" : {
       "Warnings" : "All",
       "TargetType" : "SharedLibrary",
-      "TargetFileName" : "Hello",
+      "TargetFileName" : "hello",
       "Libraries" : [
          "ecere",
          "log",
          "GLESv1_CM"
       ],
       "PostbuildCommands" : [
-         "$(call mkdir,$(OBJ)apk/lib/armeabi)",
-         "$(call mkdir,$(OBJ)apk/lib/x86)",
-         "$(call cp,../../ecere/obj/android.linux.$(COMPILER)/libecere.so,$(OBJ)apk/lib/armeabi)",
-         "$(call cp,$(TARGET),$(OBJ)apk/lib/armeabi)",
-         "aapt package -v -f -m -M android/AndroidManifest.xml -F $(OBJ)$(MODULE)-unsigned.apk -I C:/android-sdk/platforms/android-20/android.jar -S android/res $(OBJ)apk",
-         "jarsigner -storepass android -sigalg MD5withRSA -digestalg SHA1 $(OBJ)$(MODULE)-unsigned.apk -keystore C:/Users/Jerome/debug.keystore androiddebugkey -signedjar $(OBJ)$(MODULE).apk",
-         "adb uninstall com.ecere.Hello",
+         "$(call mkdir,$(OBJ)classes)",
+         "$(call mkdir,$(OBJ)apk/lib/arm64-v8a)",
+         "javac -verbose -d $(OBJ)/classes -classpath C:/android-sdk/platforms/android-22/android.jar;$(OBJ) -sourcepath . $(MODULE).java",
+         "dx --dex --verbose --output=$(OBJ)apk/classes.dex $(OBJ)classes",
+         "$(call cp,../../ecere/obj/android.linux.$(COMPILER)/libecere.so,$(OBJ)apk/lib/arm64-v8a)",
+         "$(call cp,$(TARGET),$(OBJ)apk/lib/arm64-v8a)",
+         "aapt package -v -f -m -M android/AndroidManifest.xml -F $(OBJ)$(MODULE)-unsigned.apk -I C:/android-sdk/platforms/android-22/android.jar -S android/res $(OBJ)apk",
+         "jarsigner -sigalg MD5withRSA -digestalg SHA1 -keystore C:/android-sdk/debug.keystore -storepass android $(OBJ)$(MODULE)-unsigned.apk androiddebugkey -signedjar $(OBJ)$(MODULE).apk",
+         "adb uninstall com.ecere.$(MODULE)",
          "adb install $(OBJ)$(MODULE).apk",
-         "adb shell am start -a android.intent.action.MAIN -n com.ecere.Hello/android.app.NativeActivity"
+         "adb shell am start -a android.intent.action.MAIN -n com.ecere.$(MODULE)/.hello"
       ]
    },
    "Configurations" : [
@@ -63,7 +65,8 @@
          ]
       },
       "helloAndroid.ec",
-      "note.txt"
+      "note.txt",
+      "hello.java"
    ],
    "ResourcesPath" : "",
    "Resources" : [