Skip to content

Commit

Permalink
feat: Support refreshrates other than 60 (#314)
Browse files Browse the repository at this point in the history
* feat: Support refreshrates other than 60

* rebase

* lint fix

* Revert "lint fix"

This reverts commit 4fa9540.

* lint errors

* Update ALVR

* Update ALVR to v20.6.2
  • Loading branch information
ShootingKing-AM authored Apr 6, 2024
1 parent 4a5906c commit 2b76c28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions code/mobile/android/PhoneVR/app/src/main/cpp/alvr_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ void inputThread() {
// }

extern "C" JNIEXPORT void JNICALL Java_viritualisres_phonevr_ALVRActivity_initializeNative(
JNIEnv *env, jobject obj, jint screenWidth, jint screenHeight) {
JNIEnv *env, jobject obj, jint screenWidth, jint screenHeight, jfloat refreshRate) {
CTX.javaVm = jVM;
CTX.javaContext = env->NewGlobalRef(obj);

uint32_t viewWidth = std::max(screenWidth, screenHeight) / 2;
uint32_t viewHeight = std::min(screenWidth, screenHeight);

float refreshRatesBuffer[1] = {60.f};
float refreshRatesBuffer[1] = {refreshRate};

alvr_initialize((void *) CTX.javaVm,
(void *) CTX.javaContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -97,7 +98,12 @@ public void onCreate(Bundle savedInstance) {
int width = displayMetrics.widthPixels;
int height = displayMetrics.heightPixels;

initializeNative(width, height);
// get refresh rate of the device
Display display = getWindowManager().getDefaultDisplay();
float refreshRate = display.getRefreshRate();
Log.i(TAG, "Refresh rate: " + refreshRate);

initializeNative(width, height, refreshRate);

setContentView(R.layout.activity_vr);
glView = findViewById(R.id.surface_view);
Expand Down Expand Up @@ -248,7 +254,8 @@ private void setImmersiveSticky() {
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}

private native void initializeNative(int screenWidth, int screenHeight);
private native void initializeNative(
int screenWidth, int screenHeight, float screenRefreshRate);

private native void destroyNative();

Expand Down

0 comments on commit 2b76c28

Please sign in to comment.