diff --git a/buildfiles/android/hxml/debug.hxml b/buildfiles/android/hxml/debug.hxml index d94486e90..056f93ce0 100644 --- a/buildfiles/android/hxml/debug.hxml +++ b/buildfiles/android/hxml/debug.hxml @@ -2,6 +2,8 @@ -cp ::BUILD_DIR::/android/haxe -cpp ::CPP_DIR:: -D android +-D android-9 -debug --macro allowPackage("flash") ---macro keep("::APP_MAIN::") \ No newline at end of file +--macro keep("::APP_MAIN::") +-D no-compilation \ No newline at end of file diff --git a/buildfiles/android/hxml/release.hxml b/buildfiles/android/hxml/release.hxml index 83501d46f..8547f4034 100644 --- a/buildfiles/android/hxml/release.hxml +++ b/buildfiles/android/hxml/release.hxml @@ -4,3 +4,5 @@ --macro allowPackage("flash") --macro keep("::APP_MAIN::") -D android +-D android-9 +-D no-compilation diff --git a/buildfiles/android/template/AndroidManifest.xml b/buildfiles/android/template/AndroidManifest.xml index 852d4b22b..669cd6120 100644 --- a/buildfiles/android/template/AndroidManifest.xml +++ b/buildfiles/android/template/AndroidManifest.xml @@ -9,7 +9,7 @@ - + diff --git a/buildfiles/android/template/project.properties b/buildfiles/android/template/project.properties index 838b70303..fa1bb3425 100644 --- a/buildfiles/android/template/project.properties +++ b/buildfiles/android/template/project.properties @@ -19,5 +19,5 @@ target=android-::ANDROID_TARGET_SDK_VERSION:: key.store=::KEY_STORE:: ::if (KEY_STORE_ALIAS)::key.alias=::KEY_STORE_ALIAS::::end:: ::if (KEY_STORE_PASSWORD)::key.store.password=::KEY_STORE_PASSWORD::::end:: -::if (KEY_STORE_ALIAS_PASSWORD)::key.alias.password=::KEY_STORE_ALIAS_PASSWORD::"/::end:: +::if (KEY_STORE_ALIAS_PASSWORD)::key.alias.password=::KEY_STORE_ALIAS_PASSWORD::::end:: ::end:: \ No newline at end of file diff --git a/buildfiles/android/template/src/org/haxe/nme/GameActivity.java b/buildfiles/android/template/src/org/haxe/nme/GameActivity.java index a92113340..08948a11f 100644 --- a/buildfiles/android/template/src/org/haxe/nme/GameActivity.java +++ b/buildfiles/android/template/src/org/haxe/nme/GameActivity.java @@ -13,6 +13,7 @@ import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Handler; @@ -21,6 +22,7 @@ import android.util.DisplayMetrics; import android.util.Log; import android.view.inputmethod.InputMethodManager; import android.view.View; +import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import dalvik.system.DexClassLoader; @@ -73,6 +75,7 @@ public class GameActivity extends Activity implements SensorEventListener { public Handler mHandler; + private static MainView mMainView; private MainView mView; private Sound _sound; @@ -95,17 +98,40 @@ public class GameActivity extends Activity implements SensorEventListener { //getResources().getAssets(); requestWindowFeature (Window.FEATURE_NO_TITLE); + ::if WIN_FULLSCREEN:: getWindow ().addFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + ::end:: metrics = new DisplayMetrics (); getWindowManager ().getDefaultDisplay ().getMetrics (metrics); // Pre-load these, so the C++ knows where to find them - ::foreach ndlls:: - System.loadLibrary ("::name::");::end:: - HXCPP.run ("ApplicationMain"); + //if (mMainView == null) { + + Log.d ("NME", "mMainView is NULL"); + + ::foreach ndlls:: + System.loadLibrary ("::name::");::end:: + HXCPP.run ("ApplicationMain"); + + //mMainView = new MainView (getApplication (), this); + + /*} else { + + ViewGroup parent = (ViewGroup)mMainView.getParent (); + + if (parent != null) { + + parent.removeView (mMainView); + + } + + mMainView.onResume (); + + } + mView = mMainView;*/ mView = new MainView (getApplication (), this); setContentView (mView); @@ -214,6 +240,13 @@ public class GameActivity extends Activity implements SensorEventListener { } + public static AssetManager getAssetManager () { + + return mAssets; + + } + + public static Context getContext () { return mContext; @@ -390,8 +423,8 @@ public class GameActivity extends Activity implements SensorEventListener { @Override protected void onPause () { - super.onPause (); doPause (); + super.onPause (); for (Extension extension : extensions) { @@ -456,8 +489,15 @@ public class GameActivity extends Activity implements SensorEventListener { super.onStart(); - for (Extension extension : extensions) { + ::if WIN_FULLSCREEN::::if (ANDROID_TARGET_SDK_VERSION >= 16):: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + getWindow().getDecorView().setSystemUiVisibility (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN); + + } + ::end::::end:: + + for (Extension extension : extensions) { extension.onStart (); } diff --git a/buildfiles/android/template/src/org/haxe/nme/MainView.java b/buildfiles/android/template/src/org/haxe/nme/MainView.java index 56ba5016b..186766bcd 100644 --- a/buildfiles/android/template/src/org/haxe/nme/MainView.java +++ b/buildfiles/android/template/src/org/haxe/nme/MainView.java @@ -6,8 +6,13 @@ import android.content.Context; import android.graphics.PixelFormat; import android.opengl.GLSurfaceView; import android.os.Build; +import android.os.SystemClock; +import android.text.InputType; import android.util.AttributeSet; import android.util.Log; +import android.view.inputmethod.BaseInputConnection; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputConnection; ::if (ANDROID_TARGET_SDK_VERSION > 11)::import android.view.InputDevice;::end:: import android.view.KeyCharacterMap; import android.view.KeyEvent; @@ -53,13 +58,13 @@ class MainView extends GLSurfaceView { EGLConfig[] v2_configs = new EGLConfig[1]; int[] num_config = new int[1]; - int[] attrs = { EGL10.EGL_RENDERABLE_TYPE, 4 /*EGL_OPENGL_ES2_BIT*/, EGL10.EGL_NONE }; + int[] attrs = { EGL10.EGL_RENDERABLE_TYPE, ::if DEFINE_NME_FORCE_GLES1::1::else::4::end:: /*EGL_OPENGL_ES2_BIT*/, EGL10.EGL_NONE }; egl.eglChooseConfig (display, attrs, v2_configs, 1, num_config); if (num_config[0]==1) { - eglVersion = 2; - setEGLContextClientVersion (2); + eglVersion = ::if DEFINE_NME_FORCE_GLES1::1::else::2::end::; + setEGLContextClientVersion (::if DEFINE_NME_FORCE_GLES1::1::else::2::end::); } @@ -240,6 +245,40 @@ class MainView extends GLSurfaceView { } + @Override public InputConnection onCreateInputConnection (EditorInfo outAttrs) { + + BaseInputConnection inputConnection = new BaseInputConnection (this, false) { + + @Override public boolean deleteSurroundingText (int beforeLength, int afterLength) { + + ::if (ANDROID_TARGET_SDK_VERSION > 15):: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + + if (beforeLength == 1 && afterLength == 0) { + + final long time = SystemClock.uptimeMillis (); + + super.sendKeyEvent (new KeyEvent (time, time, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE)); + super.sendKeyEvent (new KeyEvent (SystemClock.uptimeMillis(), time, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE)); + + return true; + + } + + } + ::end:: + + return super.deleteSurroundingText (beforeLength, afterLength); + + } + + }; + + return inputConnection; + + } + + ::if (ANDROID_TARGET_SDK_VERSION > 11)::@Override public boolean onGenericMotionEvent (MotionEvent event) { if ((event.getSource () & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 && event.getAction () == MotionEvent.ACTION_MOVE) { diff --git a/buildfiles/tizen/hxml/debug.hxml b/buildfiles/tizen/hxml/debug.hxml new file mode 100644 index 000000000..dd6181f0d --- /dev/null +++ b/buildfiles/tizen/hxml/debug.hxml @@ -0,0 +1,8 @@ +-main ApplicationMain ::HAXE_FLAGS:: +-cp ::BUILD_DIR::/tizen/haxe +-cpp ::CPP_DIR:: +--macro allowPackage("flash") +--macro keep("::APP_MAIN::") +-D tizen +-debug +-D no-compilation \ No newline at end of file diff --git a/buildfiles/tizen/hxml/release.hxml b/buildfiles/tizen/hxml/release.hxml new file mode 100644 index 000000000..65e177b62 --- /dev/null +++ b/buildfiles/tizen/hxml/release.hxml @@ -0,0 +1,7 @@ +-main ApplicationMain ::HAXE_FLAGS:: +-cp ::BUILD_DIR::/tizen/haxe +-cpp ::CPP_DIR:: +--macro allowPackage("flash") +--macro keep("::APP_MAIN::") +-D tizen +-D no-compilation \ No newline at end of file diff --git a/buildfiles/tizen/template/CommandLineBuild/build_data b/buildfiles/tizen/template/CommandLineBuild/build_data new file mode 100644 index 000000000..ff438fa9d --- /dev/null +++ b/buildfiles/tizen/template/CommandLineBuild/build_data @@ -0,0 +1,4 @@ +PLATFORM_VER:Tizen 2.2 +ARCHITECTURE:armel +TOOLCHAIN:GCC-4.5 +TYPE:app diff --git a/buildfiles/tizen/template/manifest.xml b/buildfiles/tizen/template/manifest.xml new file mode 100644 index 000000000..a1d563066 --- /dev/null +++ b/buildfiles/tizen/template/manifest.xml @@ -0,0 +1,23 @@ + + + ::APP_PACKAGE:: + 1.0.0 + C++App + + 2.2 + + + 2.2 + + + + + + ::APP_TITLE:: + + + mainmenu.png + + + + diff --git a/dependencies/extension-api/AndroidManifest.xml b/dependencies/extension-api/AndroidManifest.xml new file mode 100644 index 000000000..6293d0331 --- /dev/null +++ b/dependencies/extension-api/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/dependencies/extension-api/build.xml b/dependencies/extension-api/build.xml new file mode 100644 index 000000000..db07fcecd --- /dev/null +++ b/dependencies/extension-api/build.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/dependencies/extension-api/project.properties b/dependencies/extension-api/project.properties new file mode 100644 index 000000000..e81cd6841 --- /dev/null +++ b/dependencies/extension-api/project.properties @@ -0,0 +1,13 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +android.library=true + +# Project target. +target=android-::ANDROID_TARGET_SDK_VERSION:: diff --git a/dependencies/extension-api/src/org/haxe/HXCPP.java b/dependencies/extension-api/src/org/haxe/HXCPP.java new file mode 100644 index 000000000..4673e04fb --- /dev/null +++ b/dependencies/extension-api/src/org/haxe/HXCPP.java @@ -0,0 +1,30 @@ +package org.haxe; + + +// Wrapper for native library + + +public class HXCPP { + + + private static boolean mInit = false; + + + public static native void main (); + + + public static void run (String inClassName) { + + System.loadLibrary (inClassName); + + if (!mInit) { + + mInit = true; + main (); + + } + + } + + +} \ No newline at end of file diff --git a/dependencies/extension-api/src/org/haxe/extension/Extension.java b/dependencies/extension-api/src/org/haxe/extension/Extension.java new file mode 100644 index 000000000..428ec3aaa --- /dev/null +++ b/dependencies/extension-api/src/org/haxe/extension/Extension.java @@ -0,0 +1,109 @@ +package org.haxe.extension; + + +import android.app.Activity; +import android.content.res.AssetManager; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; + + +public class Extension { + + + public static AssetManager assetManager; + public static Handler callbackHandler; + public static Activity mainActivity; + public static Context mainContext; + + + /** + * Called when an activity you launched exits, giving you the requestCode + * you started it with, the resultCode it returned, and any additional data + * from it. + */ + public boolean onActivityResult (int requestCode, int resultCode, Intent data) { + + return true; + + } + + + /** + * Called when the activity is starting. + */ + public void onCreate (Bundle savedInstanceState) { + + + + } + + + /** + * Perform any final cleanup before an activity is destroyed. + */ + public void onDestroy () { + + + + } + + + /** + * Called as part of the activity lifecycle when an activity is going into + * the background, but has not (yet) been killed. + */ + public void onPause () { + + + + } + + + /** + * Called after {@link #onStop} when the current activity is being + * re-displayed to the user (the user has navigated back to it). + */ + public void onRestart () { + + + + } + + + /** + * Called after {@link #onRestart}, or {@link #onPause}, for your activity + * to start interacting with the user. + */ + public void onResume () { + + + + } + + + /** + * Called after {@link #onCreate} — or after {@link #onRestart} when + * the activity had been stopped, but is now again being displayed to the + * user. + */ + public void onStart () { + + + + } + + + /** + * Called when the activity is no longer visible to the user, because + * another activity has been resumed and is covering this one. + */ + public void onStop () { + + + + } + + +} \ No newline at end of file diff --git a/dependencies/extension-api/src/org/haxe/nme/HaxeObject.java b/dependencies/extension-api/src/org/haxe/nme/HaxeObject.java new file mode 100644 index 000000000..eaf4f2f02 --- /dev/null +++ b/dependencies/extension-api/src/org/haxe/nme/HaxeObject.java @@ -0,0 +1,114 @@ +package org.haxe.nme; + +import android.util.Log; +import java.lang.Boolean; +import java.lang.Byte; +import java.lang.Character; +import java.lang.Short; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Float; +import java.lang.Double; + +public class HaxeObject +{ + public long __haxeHandle; + + public HaxeObject(long value) + { + __haxeHandle = value; + } + + public static HaxeObject create(long inHandle) { return new HaxeObject(inHandle); } + + + protected void finalize() throws Throwable { + try { + NME.releaseReference(__haxeHandle); + } finally { + super.finalize(); + } + } + public Object call0(String function) + { + //Log.e("HaxeObject","Calling obj0" + function + "()" ); + return NME.callObjectFunction(__haxeHandle,function,new Object[0]); + } + public Object call1(String function,Object arg0) + { + Object[] args = new Object[1]; + args[0] = arg0; + //Log.e("HaxeObject","Calling obj1 " + function + "(" + arg0 + ")" ); + return NME.callObjectFunction(__haxeHandle,function,args); + } + public Object call2(String function,Object arg0,Object arg1) + { + Object[] args = new Object[2]; + args[0] = arg0; + args[1] = arg1; + //Log.e("HaxeObject","Calling obj2 " + function + "(" + arg0 + "," + arg1 + ")" ); + return NME.callObjectFunction(__haxeHandle,function,args); + } + public Object call3(String function,Object arg0,Object arg1,Object arg2) + { + Object[] args = new Object[3]; + args[0] = arg0; + args[1] = arg1; + args[2] = arg2; + //Log.e("HaxeObject","Calling obj3 " + function + "(" + arg0 + "," + arg1 + "," + arg2 + ")" ); + return NME.callObjectFunction(__haxeHandle,function,args); + } + public Object call4(String function,Object arg0,Object arg1,Object arg2,Object arg3) + { + Object[] args = new Object[4]; + args[0] = arg0; + args[1] = arg1; + args[2] = arg2; + args[3] = arg3; + //Log.e("HaxeObject","Calling obj4 " + function + "(" + arg0 + "," + arg1 + "," + arg2 + "," + arg3 + ")" ); + return NME.callObjectFunction(__haxeHandle,function,args); + } + + public double callD0(String function) + { + //Log.e("HaxeObject","Calling objD0 " + function + "()" ); + return NME.callNumericFunction(__haxeHandle,function,new Object[0]); + } + public double callD1(String function,Object arg0) + { + Object[] args = new Object[1]; + args[0] = arg0; + //Log.e("HaxeObject","Calling D1 " + function + "(" + arg0 + ")" ); + return NME.callNumericFunction(__haxeHandle,function,args); + } + public double callD2(String function,Object arg0,Object arg1) + { + Object[] args = new Object[2]; + args[0] = arg0; + args[1] = arg1; + //Log.e("HaxeObject","Calling D2 " + function + "(" + arg0 + "," + arg1 + ")" ); + return NME.callNumericFunction(__haxeHandle,function,args); + } + public double callD3(String function,Object arg0,Object arg1,Object arg2) + { + Object[] args = new Object[2]; + args[0] = arg0; + args[1] = arg1; + args[2] = arg2; + //Log.e("HaxeObject","Calling D3 " + function + "(" + arg0 + "," + arg1 + "," + arg2 + ")" ); + return NME.callNumericFunction(__haxeHandle,function,args); + } + + + + + + public Object call(String function, Object[] args) + { + return NME.callObjectFunction(__haxeHandle,function,args); + } + public double callD(String function, Object[] args) + { + return NME.callNumericFunction(__haxeHandle,function,args); + } +} diff --git a/dependencies/extension-api/src/org/haxe/nme/NME.java b/dependencies/extension-api/src/org/haxe/nme/NME.java new file mode 100644 index 000000000..23aa54562 --- /dev/null +++ b/dependencies/extension-api/src/org/haxe/nme/NME.java @@ -0,0 +1,34 @@ +package org.haxe.nme; + +// Wrapper for native library + +public class NME { + + static { + System.loadLibrary("openal"); + System.loadLibrary("nme"); + } + + public static final int ACTIVATE = 1; + public static final int DEACTIVATE = 2; + public static final int DESTROY = 3; + + public static native int onDeviceOrientationUpdate(int orientation); + public static native int onNormalOrientationFound(int orientation); + public static native int onOrientationUpdate(float x, float y, float z); + public static native int onAccelerate(float x, float y, float z); + public static native int onTouch(int type, float x, float y, int id, float sizeX, float sizeY); + public static native int onResize(int width, int height); + public static native int onTrackball(float x,float y); + public static native int onJoyChange(int inDeviceID, int inCode, boolean inIsDown); + public static native int onJoyMotion(int inDeviceID, int axis, float value); + public static native int onKeyChange(int inCode, boolean inIsDown); + public static native int onRender(); + public static native int onPoll(); + public static native double getNextWake(); + public static native int onActivity(int inState); + public static native void onCallback(long inHandle); + public static native Object callObjectFunction(long inHandle,String function, Object[] args); + public static native double callNumericFunction(long inHandle,String function, Object[] args); + public static native void releaseReference(long inHandle); +} diff --git a/dependencies/extension-api/src/org/haxe/nme/Value.java b/dependencies/extension-api/src/org/haxe/nme/Value.java new file mode 100644 index 000000000..9b9aca1cd --- /dev/null +++ b/dependencies/extension-api/src/org/haxe/nme/Value.java @@ -0,0 +1,18 @@ +package org.haxe.nme; + + +public class Value { + + + double mValue; + + public Value (double inValue) { mValue = inValue; } + public Value (int inValue) { mValue = inValue; } + public Value (short inValue) { mValue = inValue; } + public Value (char inValue) { mValue = inValue; } + public Value (boolean inValue) { mValue = inValue ? 1.0 : 0.0; } + + public double getDouble () { return mValue; } + + +} \ No newline at end of file diff --git a/include.xml b/include.xml index 8ee15dc44..6dd0fac08 100644 --- a/include.xml +++ b/include.xml @@ -21,6 +21,10 @@ + + + + diff --git a/lime/gl/native/GL.hx b/lime/gl/native/GL.hx index e94175139..add032bef 100644 --- a/lime/gl/native/GL.hx +++ b/lime/gl/native/GL.hx @@ -501,9 +501,9 @@ class GL { nme_gl_buffer_data(target, data.getByteBuffer(), data.getStart(), data.getLength(), usage); } - public static function bufferSubData(target:Int, offset:Int, data:IMemoryRange):Void + public static function bufferSubData(target:Int, offset:Int, data:IMemoryRange ):Void { - nme_gl_buffer_sub_data(target, offset, data.getByteBuffer(), data.getStart(), data.getLength()); + nme_gl_buffer_sub_data( target, offset, data.getByteBuffer(), data.getStart(), data.getLength() ); } public static function checkFramebufferStatus(target:Int):Int