Skip to content

Commit

Permalink
OpenXR - BT/OTG support and hardcode native resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
lvonasek authored Jul 14, 2024
1 parent af91882 commit 05457b6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<uses-feature android:name="android.hardware.vr.headtracking" android:required="false" />
<uses-feature android:name="com.oculus.feature.PASSTHROUGH" android:required="false" />
<uses-feature android:name="oculus.software.handtracking" android:required="false" />
<uses-feature android:name="oculus.software.overlay_keyboard" android:required="false" />

<application
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/com/termux/x11/LorieView.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ void getDimensionsFromSettings() {
Prefs prefs = MainActivity.getPrefs();
int width = getMeasuredWidth();
int height = getMeasuredHeight();
if (XrActivity.isEnabled()) {
width = 1024;
height = 768;
}
int w = width;
int h = height;
switch(prefs.displayResolutionMode.get()) {
Expand Down Expand Up @@ -180,8 +184,11 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (prefs.displayStretch.get()
|| "native".equals(prefs.displayResolutionMode.get())
|| "scaled".equals(prefs.displayResolutionMode.get())) {
getHolder().setSizeFromLayout();
return;

if (!XrActivity.isEnabled()) {
getHolder().setSizeFromLayout();
return;
}
}

getDimensionsFromSettings();
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/com/termux/x11/XrActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.util.Log;
import android.view.Display;
Expand Down Expand Up @@ -48,6 +49,7 @@ public enum RenderParam {

private boolean isImmersive = false;
private boolean isSBS = false;
private boolean keyboardDisabled;
private long lastEnter;
private final float[] lastAxes = new float[ControllerAxis.values().length];
private final boolean[] lastButtons = new boolean[ControllerButton.values().length];
Expand Down Expand Up @@ -183,8 +185,27 @@ public void onDrawFrame(GL10 gl10) {
}
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
keyboardDisabled = true;
new Handler().postDelayed(() -> keyboardDisabled = false, 250);
}
}

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// Ignore event madness when disabling software keyboard
if (keyboardDisabled) {
return true;
}

// Bluetooth/OTG keyboards work properly with the standard flow
if (hasWindowFocus()) {
return super.dispatchKeyEvent(event);
}

// Meta HorizonOS sends up event only (as for in v66)
if (event.getAction() == KeyEvent.ACTION_UP) {

Expand Down

0 comments on commit 05457b6

Please sign in to comment.