summaryrefslogtreecommitdiffstats
path: root/platform/android/java/src/org/godotengine/godot/Godot.java
diff options
context:
space:
mode:
authorfhuya <fhuyakou@gmail.com>2019-08-26 17:47:13 -0700
committerfhuya <fhuyakou@gmail.com>2019-08-26 18:48:54 -0700
commit5eaaabceaf1403b8348b95830bd177df8a01ef72 (patch)
tree2b5f7c3edf48e14a135b9c39edd9a20d27dfe422 /platform/android/java/src/org/godotengine/godot/Godot.java
parentbe99e7b68f554fbdb7d9f979265542f4bd6724bd (diff)
downloadredot-engine-5eaaabceaf1403b8348b95830bd177df8a01ef72.tar.gz
Update the fallback input mapping for the Oculus mobile devices.
Diffstat (limited to 'platform/android/java/src/org/godotengine/godot/Godot.java')
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java68
1 files changed, 31 insertions, 37 deletions
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java
index f493b5f33f..7f71430805 100644
--- a/platform/android/java/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/src/org/godotengine/godot/Godot.java
@@ -58,6 +58,7 @@ import android.os.Environment;
import android.os.Messenger;
import android.os.Vibrator;
import android.provider.Settings.Secure;
+import android.support.annotation.Keep;
import android.support.v4.content.ContextCompat;
import android.view.Display;
import android.view.KeyEvent;
@@ -101,7 +102,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
static final int REQUEST_CAMERA_PERMISSION = 2;
static final int REQUEST_VIBRATE_PERMISSION = 3;
private IStub mDownloaderClientStub;
- private IDownloaderService mRemoteService;
private TextView mStatusText;
private TextView mProgressFraction;
private TextView mProgressPercent;
@@ -224,15 +224,9 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
private Sensor mMagnetometer;
private Sensor mGyroscope;
- public FrameLayout layout;
-
public static GodotIO io;
- public static void setWindowTitle(String title) {
- //setTitle(title);
- }
-
- static SingletonBase singletons[] = new SingletonBase[MAX_SINGLETONS];
+ static SingletonBase[] singletons = new SingletonBase[MAX_SINGLETONS];
static int singleton_count = 0;
public interface ResultCallback {
@@ -268,13 +262,14 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
}
};
- public void onVideoInit() {
+ /**
+ * Used by the native code (java_godot_lib_jni.cpp) to complete initialization of the GLSurfaceView view and renderer.
+ */
+ @Keep
+ private void onVideoInit() {
boolean use_gl3 = getGLESVersionCode() >= 0x00030000;
- //mView = new GodotView(getApplication(),io,use_gl3);
- //setContentView(mView);
-
- layout = new FrameLayout(this);
+ final FrameLayout layout = new FrameLayout(this);
layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
setContentView(layout);
@@ -326,11 +321,16 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
});
}
- public void vibrate(int p_duration_ms) {
+ /**
+ * Used by the native code (java_godot_wrapper.h) to vibrate the device.
+ * @param durationMs
+ */
+ @Keep
+ private void vibrate(int durationMs) {
if (requestPermission("VIBRATE")) {
Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) {
- v.vibrate(p_duration_ms);
+ v.vibrate(durationMs);
}
}
}
@@ -416,6 +416,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
/**
* Used by the native code (java_godot_wrapper.h) to check whether the activity is resumed or paused.
*/
+ @Keep
private boolean isActivityResumed() {
return activityResumed;
}
@@ -423,10 +424,20 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
/**
* Used by the native code (java_godot_wrapper.h) to access the Android surface.
*/
+ @Keep
private Surface getSurface() {
return mView.getHolder().getSurface();
}
+ /**
+ * Used by the native code (java_godot_wrapper.h) to access the input fallback mapping.
+ * @return The input fallback mapping for the current XR mode.
+ */
+ @Keep
+ private String getInputFallbackMapping() {
+ return xrMode.inputFallbackMapping;
+ }
+
String expansion_pack_path;
private void initializeGodot() {
@@ -474,8 +485,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
@Override
public void onServiceConnected(Messenger m) {
- mRemoteService = DownloaderServiceMarshaller.CreateProxy(m);
- mRemoteService.onClientUpdated(mDownloaderClientStub.getMessenger());
+ IDownloaderService remoteService = DownloaderServiceMarshaller.CreateProxy(m);
+ remoteService.onClientUpdated(mDownloaderClientStub.getMessenger());
}
@Override
@@ -483,7 +494,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
super.onCreate(icicle);
Window window = getWindow();
- //window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
mClipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
@@ -609,7 +619,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mWiFiSettingsButton = (Button)findViewById(com.godot.game.R.id.wifiSettingsButton);
return;
- } else {
}
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
@@ -621,8 +630,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mCurrentIntent = getIntent();
initializeGodot();
-
- //instanceSingleton( new GodotFacebook(this) );
}
@Override
@@ -831,8 +838,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
}
}
- public void forceQuit() {
-
+ private void forceQuit() {
System.exit(0);
}
@@ -879,7 +885,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
}
}
- //@Override public boolean dispatchTouchEvent (MotionEvent event) {
public boolean gotTouchEvent(final MotionEvent event) {
final int evcount = event.getPointerCount();
@@ -950,8 +955,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
for (int i = cc.length; --i >= 0; cnt += cc[i] != 0 ? 1 : 0)
;
if (cnt == 0) return super.onKeyMultiple(inKeyCode, repeatCount, event);
- final Activity me = this;
- queueEvent(new Runnable() {
+ mView.queueEvent(new Runnable() {
// This method will be called on the rendering thread:
public void run() {
for (int i = 0, n = cc.length; i < n; i++) {
@@ -967,20 +971,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
return true;
}
- private void queueEvent(Runnable runnable) {
- // TODO Auto-generated method stub
- }
-
public PaymentsManager getPaymentsManager() {
return mPaymentsManager;
}
- /*
- public void setPaymentsManager(PaymentsManager mPaymentsManager) {
- this.mPaymentsManager = mPaymentsManager;
- }
- */
-
public boolean requestPermission(String p_name) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// Not necessary, asked on install already
@@ -1025,7 +1019,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
switch (newState) {
case IDownloaderClient.STATE_IDLE:
// STATE_IDLE means the service is listening, so it's
- // safe to start making calls via mRemoteService.
+ // safe to start making remote service calls.
paused = false;
indeterminate = true;
break;