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

Prevent Gecko from consuming Pico confirm key #3170

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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