From 7a2698bb44021b7b51a85f2dee3c722f33924ead Mon Sep 17 00:00:00 2001 From: Martho42 Date: Sat, 4 Apr 2015 17:03:56 -0700 Subject: Fixes the accelerometer Resolves the issue of the accelerometer behaving differently across devices with landscape as default and devices with portrait as default. --- .../android/java/src/com/android/godot/Godot.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'platform/android/java') diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index 1fd37c98cd..2abb4cec53 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -571,9 +571,24 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC } @Override public void onSensorChanged(SensorEvent event) { - float x = event.values[0]; - float y = event.values[1]; - float z = event.values[2]; + Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); + int displayRotation = display.getRotation(); + + float[] adjustedValues = new float[3]; + final int axisSwap[][] = { + { 1, -1, 0, 1 }, // ROTATION_0 + {-1, -1, 1, 0 }, // ROTATION_90 + {-1, 1, 0, 1 }, // ROTATION_180 + { 1, 1, 1, 0 } }; // ROTATION_270 + + final int[] as = axisSwap[displayRotation]; + adjustedValues[0] = (float)as[0] * event.values[ as[2] ]; + adjustedValues[1] = (float)as[1] * event.values[ as[3] ]; + adjustedValues[2] = event.values[2]; + + float x = adjustedValues[0]; + float y = adjustedValues[1]; + float z = adjustedValues[2]; GodotLib.accelerometer(x,y,z); } -- cgit v1.2.3 From b56badf77b652abca012dd4dbd4932a03e4139dd Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 17 Apr 2015 16:18:46 -0300 Subject: -Added android immersive mode, fixes #303 --- .../android/java/src/com/android/godot/Godot.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'platform/android/java') diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index 2abb4cec53..7fd06a01d6 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -110,6 +110,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC private Button mWiFiSettingsButton; private boolean use_32_bits=false; + private boolean use_immersive=false; private boolean mStatePaused; private int mState; @@ -374,6 +375,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC mRemoteService.onClientUpdated(mDownloaderClientStub.getMessenger()); } + + @Override protected void onCreate(Bundle icicle) { @@ -402,6 +405,19 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC boolean has_extra = i< command_line.length -1; if (command_line[i].equals("-use_depth_32")) { use_32_bits=true; + } else if (command_line[i].equals("-use_immersive")) { + use_immersive=true; + if(Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+ + window.getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar + | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + + UiChangeListener(); + } } else if (command_line[i].equals("-use_apk_expansion")) { use_apk_expansion=true; } else if (has_extra && command_line[i].equals("-apk_expansion_md5")) { @@ -560,6 +576,16 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC mView.onResume(); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); GodotLib.focusin(); + if(use_immersive && Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+ + Window window = getWindow(); + window.getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar + | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } for(int i=0;i Date: Sat, 18 Apr 2015 14:38:54 -0300 Subject: Updated copyright year in all headers --- platform/android/java/src/com/android/godot/Godot.java | 2 +- platform/android/java/src/com/android/godot/GodotIO.java | 2 +- platform/android/java/src/com/android/godot/GodotLib.java | 2 +- platform/android/java/src/com/android/godot/GodotView.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'platform/android/java') diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index 7fd06a01d6..e0ac6b0f12 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/java/src/com/android/godot/GodotIO.java b/platform/android/java/src/com/android/godot/GodotIO.java index ff0eb5edcc..b793b8850a 100644 --- a/platform/android/java/src/com/android/godot/GodotIO.java +++ b/platform/android/java/src/com/android/godot/GodotIO.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/java/src/com/android/godot/GodotLib.java b/platform/android/java/src/com/android/godot/GodotLib.java index 6e2462b4f1..71c31e9f83 100644 --- a/platform/android/java/src/com/android/godot/GodotLib.java +++ b/platform/android/java/src/com/android/godot/GodotLib.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/java/src/com/android/godot/GodotView.java b/platform/android/java/src/com/android/godot/GodotView.java index bd81b7f9af..ad0354e624 100644 --- a/platform/android/java/src/com/android/godot/GodotView.java +++ b/platform/android/java/src/com/android/godot/GodotView.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ -- cgit v1.2.3 From c6dce44dd85c4ebae791756a76f6afbfbb0a5c28 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 28 Apr 2015 09:38:07 -0300 Subject: fixes in handling of DirAccess for resource path on Android, fixes #1447 --- .../java/src/com/android/godot/GodotIO.java | 35 +++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'platform/android/java') diff --git a/platform/android/java/src/com/android/godot/GodotIO.java b/platform/android/java/src/com/android/godot/GodotIO.java index b793b8850a..addceb1528 100644 --- a/platform/android/java/src/com/android/godot/GodotIO.java +++ b/platform/android/java/src/com/android/godot/GodotIO.java @@ -271,6 +271,7 @@ public class GodotIO { public String[] files; public int current; + public String path; } public int last_dir_id=1; @@ -281,6 +282,7 @@ public class GodotIO { AssetDir ad = new AssetDir(); ad.current=0; + ad.path=path; try { ad.files = am.list(path); @@ -290,6 +292,7 @@ public class GodotIO { return -1; } + //System.out.printf("Opened dir: %s\n",path); ++last_dir_id; dirs.put(last_dir_id,ad); @@ -297,6 +300,32 @@ public class GodotIO { } + public boolean dir_is_dir(int id) { + if (!dirs.containsKey(id)) { + System.out.printf("dir_next: invalid dir id: %d\n",id); + return false; + } + AssetDir ad = dirs.get(id); + //System.out.printf("go next: %d,%d\n",ad.current,ad.files.length); + int idx = ad.current; + if (idx>0) + idx--; + + if (idx>=ad.files.length) + return false; + String fname = ad.files[idx]; + + try { + if (ad.path.equals("")) + am.open(fname); + else + am.open(ad.path+"/"+fname); + return false; + } catch (Exception e) { + return true; + } + } + public String dir_next(int id) { if (!dirs.containsKey(id)) { @@ -305,8 +334,12 @@ public class GodotIO { } AssetDir ad = dirs.get(id); - if (ad.current>=ad.files.length) + //System.out.printf("go next: %d,%d\n",ad.current,ad.files.length); + + if (ad.current>=ad.files.length) { + ad.current++; return ""; + } String r = ad.files[ad.current]; ad.current++; return r; -- cgit v1.2.3 From 524d9fad59cd596bb291648c8c2e1b4a46fb2d02 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 1 May 2015 23:21:27 -0300 Subject: -fixed godot icon for android -added a genname option to generate the name of android app --- platform/android/java/res/drawable/icon.png | Bin 91728 -> 17135 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'platform/android/java') diff --git a/platform/android/java/res/drawable/icon.png b/platform/android/java/res/drawable/icon.png index 050a1cf930..78757e9035 100644 Binary files a/platform/android/java/res/drawable/icon.png and b/platform/android/java/res/drawable/icon.png differ -- cgit v1.2.3 From bc3afc8ed8659c1aea2fa349a7d826f7f01e39ef Mon Sep 17 00:00:00 2001 From: vipsbpig Date: Fri, 15 May 2015 12:40:34 +0800 Subject: fix multitouch release problem --- platform/android/java/src/com/android/godot/Godot.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'platform/android/java') diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index e0ac6b0f12..4f42a1a82b 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -747,7 +747,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC //} } break; case MotionEvent.ACTION_POINTER_UP: { - int pointer_idx = event.getActionIndex(); + final int indexPointUp = event.getAction() >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; + final int pointer_idx = event.getPointerId(indexPointUp); GodotLib.touch(4,pointer_idx,evcount,arr); //System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx)); } break; -- cgit v1.2.3 From 77461a126e1fe2d0586b7683bd8b58cbb700fc64 Mon Sep 17 00:00:00 2001 From: Kyle Luce Date: Sun, 31 May 2015 19:37:19 -0700 Subject: Additional Fix for Multi-touch release problem - Was duplicating the functionality of event.getActionIndex() but was missing the bitmask. - Switched back to getActionIndex() but kept the corrected getPointerId() from change #1980 https://github.com/okamstudio/godot/pull/1908 --- platform/android/java/src/com/android/godot/Godot.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'platform/android/java') diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index 4f42a1a82b..9b9b1ab2ad 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -747,7 +747,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC //} } break; case MotionEvent.ACTION_POINTER_UP: { - final int indexPointUp = event.getAction() >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; + final int indexPointUp = event.getActionIndex(); final int pointer_idx = event.getPointerId(indexPointUp); GodotLib.touch(4,pointer_idx,evcount,arr); //System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx)); -- cgit v1.2.3