diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 4e798faed7..3506fc0dce 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -49,9 +49,9 @@ bool ovrFramebuffer_Create( frameBuffer->Width = width; frameBuffer->Height = height; - if (strstr((const char*)glGetString(GL_EXTENSIONS), "GL_OVR_multiview") == nullptr) + if (strstr((const char*)glGetString(GL_EXTENSIONS), "GL_OVR_multiview2") == nullptr) { - ALOGE("OpenGL ES 3.0 implementation does not support GL_OVR_multiview extension.\n"); + ALOGE("OpenGL implementation does not support GL_OVR_multiview2 extension.\n"); exit(EXIT_FAILURE); } diff --git a/Common/VR/VRInput.cpp b/Common/VR/VRInput.cpp index 998547d26e..b25bc4b6ca 100644 --- a/Common/VR/VRInput.cpp +++ b/Common/VR/VRInput.cpp @@ -25,7 +25,6 @@ XrAction vibrateRightFeedback; XrActionSet runningActionSet; XrSpace leftControllerAimSpace = XR_NULL_HANDLE; XrSpace rightControllerAimSpace = XR_NULL_HANDLE; -int actionsAttached = 0; int inputInitialized = 0; int useSimpleProfile = 0; @@ -348,6 +347,14 @@ void IN_VRInit( engine_t *engine ) { suggestedBindings.countSuggestedBindings = currBinding; OXR(xrSuggestInteractionProfileBindings(engine->appState.Instance, &suggestedBindings)); + // Attach actions + XrSessionActionSetsAttachInfo attachInfo = {}; + attachInfo.type = XR_TYPE_SESSION_ACTION_SETS_ATTACH_INFO; + attachInfo.next = NULL; + attachInfo.countActionSets = 1; + attachInfo.actionSets = &runningActionSet; + OXR(xrAttachSessionActionSets(engine->appState.Session, &attachInfo)); + // Enumerate actions XrPath actionPathsBuffer[32]; char stringBuffer[256]; @@ -370,11 +377,11 @@ void IN_VRInit( engine_t *engine ) { handPoseLeftAction, handPoseRightAction }; - for (size_t i = 0; i < sizeof(actionsToEnumerate) / sizeof(actionsToEnumerate[0]); ++i) { + for (XrAction & i : actionsToEnumerate) { XrBoundSourcesForActionEnumerateInfo enumerateInfo = {}; enumerateInfo.type = XR_TYPE_BOUND_SOURCES_FOR_ACTION_ENUMERATE_INFO; enumerateInfo.next = NULL; - enumerateInfo.action = actionsToEnumerate[i]; + enumerateInfo.action = i; // Get Count uint32_t countOutput = 0; @@ -425,16 +432,6 @@ void IN_VRInit( engine_t *engine ) { } void IN_VRInputFrame( engine_t* engine ) { - // Attach to session - if (!actionsAttached) { - XrSessionActionSetsAttachInfo attachInfo = {}; - attachInfo.type = XR_TYPE_SESSION_ACTION_SETS_ATTACH_INFO; - attachInfo.next = NULL; - attachInfo.countActionSets = 1; - attachInfo.actionSets = &runningActionSet; - OXR(xrAttachSessionActionSets(engine->appState.Session, &attachInfo)); - actionsAttached = 1; - } // sync action data XrActiveActionSet activeActionSet = {}; diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index aaf9d290db..f913e62489 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -695,9 +695,6 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init renderer_inited = false; androidVersion = jAndroidVersion; deviceType = jdeviceType; -#ifdef OPENXR - deviceType = DEVICE_TYPE_VR; -#endif left_joystick_x_async = 0; left_joystick_y_async = 0; @@ -938,13 +935,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_shutdown(JNIEnv *, jclass) { // JavaEGL extern "C" bool Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * env, jobject obj) { -#ifdef OPENXR - if (!renderer_inited) { - VR_EnterVR(VR_GetEngine()); - IN_VRInit(VR_GetEngine()); - } - VR_InitRenderer(VR_GetEngine()); -#endif + bool firstStart = !renderer_inited; // We should be running on the render thread here. std::string errorMessage; @@ -1006,6 +997,14 @@ extern "C" bool Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * env, } NativeMessageReceived("recreateviews", ""); +#ifdef OPENXR + if (firstStart) { + VR_EnterVR(VR_GetEngine()); + IN_VRInit(VR_GetEngine()); + } + VR_InitRenderer(VR_GetEngine()); +#endif + return true; } @@ -1045,7 +1044,9 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_backbufferResize(JNIEnv pixel_yres = bufh; backbuffer_format = format; #ifdef OPENXR - VR_GetResolution(VR_GetEngine(), &pixel_xres, &pixel_yres); + if (VR_GetEngine()->appState.Instance) { + VR_GetResolution(VR_GetEngine(), &pixel_xres, &pixel_yres); + } #endif recalculateDpi(); @@ -1373,11 +1374,13 @@ void getDesiredBackbufferSize(int &sz_x, int &sz_y) { extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setDisplayParameters(JNIEnv *, jclass, jint xres, jint yres, jint dpi, jfloat refreshRate) { INFO_LOG(G3D, "NativeApp.setDisplayParameters(%d x %d, dpi=%d, refresh=%0.2f)", xres, yres, dpi, refreshRate); #ifdef OPENXR - int width, height; - VR_GetResolution(VR_GetEngine(), &width, &height); - xres = width; - yres = height; - dpi = 320; + if (VR_GetEngine()->appState.Instance) { + int width, height; + VR_GetResolution(VR_GetEngine(), &width, &height); + xres = width; + yres = height; + dpi = 320; + } #endif bool changed = false; diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index 9b64008b45..bbdf045c82 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -381,6 +381,9 @@ public abstract class NativeActivity extends Activity { } int deviceType = NativeApp.DEVICE_TYPE_MOBILE; + if (BuildConfig.FLAVOR.compareTo("quest") == 0) { + deviceType = NativeApp.DEVICE_TYPE_VR; + } UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE); switch (uiModeManager.getCurrentModeType()) { case Configuration.UI_MODE_TYPE_TELEVISION: diff --git a/android/src/org/ppsspp/ppsspp/NativeApp.java b/android/src/org/ppsspp/ppsspp/NativeApp.java index 9442f9b809..24a43f5b8e 100644 --- a/android/src/org/ppsspp/ppsspp/NativeApp.java +++ b/android/src/org/ppsspp/ppsspp/NativeApp.java @@ -11,6 +11,7 @@ public class NativeApp { public static final int DEVICE_TYPE_MOBILE = 0; public static final int DEVICE_TYPE_TV = 1; public static final int DEVICE_TYPE_DESKTOP = 2; + public static final int DEVICE_TYPE_VR = 3; public static native void init(String model, int deviceType, String languageRegion, String apkPath, String dataDir, String externalStorageDir, String extFilesDir, String additionalStorageDirs, String libraryDir, String cacheDir, String shortcutParam, int androidVersion, String board); public static native void audioInit();