Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Prevent Gecko from consuming Pico confirm key (#3170)
Browse files Browse the repository at this point in the history
Fixes #3167
  • Loading branch information
bluemarvin authored Apr 16, 2020
1 parent a604148 commit 0c87393
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Runnable> mPendingEvents = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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");
Expand Down
16 changes: 11 additions & 5 deletions app/src/picovr/java/org/mozilla/vrbrowser/PlatformActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down

0 comments on commit 0c87393

Please sign in to comment.