From 0c873935bc6c0cf2fcd733d1d985a1f66553764f Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Thu, 16 Apr 2020 00:21:02 -0700 Subject: [PATCH] Prevent Gecko from consuming Pico confirm key (#3170) Fixes #3167 --- .../org/mozilla/vrbrowser/VRBrowserActivity.java | 2 +- .../org/mozilla/vrbrowser/PlatformActivity.java | 5 +++++ .../org/mozilla/vrbrowser/PlatformActivity.java | 5 +++++ .../org/mozilla/vrbrowser/PlatformActivity.java | 16 +++++++++++----- .../org/mozilla/vrbrowser/PlatformActivity.java | 5 +++++ 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java index 4b945a95c..07b9c73a4 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java @@ -719,7 +719,7 @@ public void onBackPressed() { @Override public boolean dispatchKeyEvent(KeyEvent event) { - if (mKeyboard.dispatchKeyEvent(event)) { + if (isNotSpecialKey(event) && mKeyboard.dispatchKeyEvent(event)) { return true; } final int keyCode = event.getKeyCode(); diff --git a/app/src/noapi/java/org/mozilla/vrbrowser/PlatformActivity.java b/app/src/noapi/java/org/mozilla/vrbrowser/PlatformActivity.java index bf8d06b46..a8107c2a5 100644 --- a/app/src/noapi/java/org/mozilla/vrbrowser/PlatformActivity.java +++ b/app/src/noapi/java/org/mozilla/vrbrowser/PlatformActivity.java @@ -9,6 +9,7 @@ import android.opengl.GLSurfaceView; import android.os.Bundle; import android.util.Log; +import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.widget.TextView; @@ -31,6 +32,10 @@ public static boolean filterPermission(final String aPermission) { return false; } + public static boolean isNotSpecialKey(KeyEvent event) { + return true; + } + private GLSurfaceView mView; private TextView mFrameRate; private final ArrayList mPendingEvents = new ArrayList<>(); diff --git a/app/src/oculusvr/java/org/mozilla/vrbrowser/PlatformActivity.java b/app/src/oculusvr/java/org/mozilla/vrbrowser/PlatformActivity.java index 62dbf47e4..01ec12eb2 100644 --- a/app/src/oculusvr/java/org/mozilla/vrbrowser/PlatformActivity.java +++ b/app/src/oculusvr/java/org/mozilla/vrbrowser/PlatformActivity.java @@ -9,6 +9,7 @@ import android.Manifest; import android.os.Bundle; import android.util.Log; +import android.view.KeyEvent; import android.view.View; import android.view.WindowManager; @@ -25,6 +26,10 @@ public static boolean filterPermission(final String aPermission) { return false; } + public static boolean isNotSpecialKey(KeyEvent event) { + return true; + } + @Override protected void onCreate(Bundle savedInstanceState) { Log.e(LOGTAG,"in onCreate"); diff --git a/app/src/picovr/java/org/mozilla/vrbrowser/PlatformActivity.java b/app/src/picovr/java/org/mozilla/vrbrowser/PlatformActivity.java index 838a58546..ad279999a 100644 --- a/app/src/picovr/java/org/mozilla/vrbrowser/PlatformActivity.java +++ b/app/src/picovr/java/org/mozilla/vrbrowser/PlatformActivity.java @@ -40,18 +40,23 @@ public class PlatformActivity extends VRActivity implements RenderInterface, CVControllerListener { static String LOGTAG = SystemUtils.createLogtag(PlatformActivity.class); + private static final int CONFIRM_BUTTON = 1001; public static boolean filterPermission(final String aPermission) { - if (aPermission.equals(Manifest.permission.CAMERA)) { - return true; - } - return false; + return aPermission.equals(Manifest.permission.CAMERA); + } + + public static boolean isNotSpecialKey(KeyEvent event) { + return event.getKeyCode() != CONFIRM_BUTTON; } private BroadcastReceiver mKeysReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String s = intent.getStringExtra("reason"); + if (s == null) { + return; + } if (s.equalsIgnoreCase("recenter")) { nativeRecenter(); } @@ -71,6 +76,7 @@ public void onReceive(Context context, Intent intent) { private final int BUTTON_BY = 1 << 4; private final int BUTTON_GRIP = 1 << 5; + private static final int GAZE_INDEX = 2; @Override @@ -154,7 +160,7 @@ public void onBackPressed() { @Override public boolean dispatchKeyEvent(KeyEvent event) { - if (event.getKeyCode() == 1001) { + if (event.getKeyCode() == CONFIRM_BUTTON) { int buttons = 0; buttons |= event.getAction() == KeyEvent.ACTION_DOWN ? BUTTON_TRIGGER : 0; nativeUpdateControllerState(GAZE_INDEX, true, buttons, 0, 0, 0, false); diff --git a/app/src/wavevr/java/org/mozilla/vrbrowser/PlatformActivity.java b/app/src/wavevr/java/org/mozilla/vrbrowser/PlatformActivity.java index 19563df95..61b52e1cc 100644 --- a/app/src/wavevr/java/org/mozilla/vrbrowser/PlatformActivity.java +++ b/app/src/wavevr/java/org/mozilla/vrbrowser/PlatformActivity.java @@ -10,6 +10,7 @@ import android.Manifest; import android.content.res.AssetManager; import android.os.Bundle; +import android.view.KeyEvent; import org.mozilla.vrbrowser.utils.SystemUtils; @@ -23,6 +24,10 @@ public static boolean filterPermission(final String aPermission) { return false; } + public static boolean isNotSpecialKey(KeyEvent event) { + return true; + } + public PlatformActivity() { super.setUsingRenderBaseActivity(true); }