diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 8386f471d9..84c76e970b 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -42,7 +42,6 @@ static std::map pspKeys; // key can be virtual, so not using the enu static int vr3DGeometryCount = 0; static long vrCompat[VR_COMPAT_MAX]; -static bool vrEnabled = false; static bool vrFlatForced = false; static bool vrFlatGame = false; static double vrFov[2] = {}; @@ -130,8 +129,10 @@ VR app flow integration */ bool IsVREnabled() { + // For now, let the OPENXR build flag control enablement. + // This will change. #ifdef OPENXR - return vrEnabled; + return true; #else return false; #endif @@ -204,10 +205,6 @@ void SetVRCallbacks(void (*axis)(const AxisInput *axis, size_t count), bool(*key cbNativeTouch = touch; } -void SetVREnabled(bool enabled) { - vrEnabled = enabled; -} - /* ================================================================================ diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 11455ed83c..b78000e4e1 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -33,7 +33,6 @@ void InitVROnAndroid(void* vm, void* activity, const char* system, int version, void EnterVR(bool firstStart, void* vulkanContext); void GetVRResolutionPerEye(int* width, int* height); void SetVRCallbacks(void(*axis)(const AxisInput *axis, size_t count), bool(*key)(const KeyInput &key), void(*touch)(const TouchInput &touch)); -void SetVREnabled(bool enabled); // VR input integration void SetVRAppMode(VRAppMode mode); diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 367648925a..a073d82392 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -16,8 +16,6 @@ - - @@ -118,10 +116,6 @@ - - - - diff --git a/android/VRManifest.xml b/android/VRManifest.xml new file mode 100644 index 0000000000..dc1a3aa1eb --- /dev/null +++ b/android/VRManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + diff --git a/android/build.gradle b/android/build.gradle index 91cd9c3a35..157ca6ca14 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -109,6 +109,9 @@ android { gold { res.srcDirs = ['gold/res'] } + vr { + manifest.srcFile 'VRManifest.xml' + } } productFlavors { normal { @@ -121,8 +124,7 @@ android { '-DANDROID_PLATFORM=android-16', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_CPP_FEATURES=', - '-DANDROID_STL=c++_static', - '-DOPENXR=TRUE' + '-DANDROID_STL=c++_static' } } ndk { @@ -141,14 +143,33 @@ android { '-DANDROID_CPP_FEATURES=', '-DANDROID_STL=c++_static', '-DANDROID_ARM_NEON=TRUE', - '-DGOLD=TRUE', - '-DOPENXR=TRUE' + '-DGOLD=TRUE' } } ndk { abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' } } + vr { + applicationId 'org.ppsspp.ppssppvr' + dimension "variant" + targetSdkVersion 29 // Do not upgrade this, we depend on not requiring scoped storage on Oculus. + externalNativeBuild { + cmake { + // Available arguments listed at https://developer.android.com/ndk/guides/cmake.html + arguments '-DANDROID=true', + '-DANDROID_PLATFORM=android-16', + '-DANDROID_TOOLCHAIN=clang', + '-DANDROID_CPP_FEATURES=', + '-DANDROID_STL=c++_static', + '-DANDROID_ARM_NEON=TRUE', + '-DOPENXR=TRUE' + } + } + ndk { + abiFilters 'arm64-v8a' + } + } } variantFilter { variant -> def needed = variant.name in [ @@ -156,6 +177,9 @@ android { 'normalOptimized', // for testing 'normalRelease', // for Google Play releases 'goldRelease', // for Google Play releases + 'vrDebug', // for VR debugging + 'vrOptimized', // for VR testing + 'vrRelease', // for VR releases ] variant.setIgnore(!needed) } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 81ac9e08b9..6dcb3d79a5 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -508,12 +508,12 @@ bool System_GetPropertyBool(SystemProperty prop) { case SYSPROP_HAS_FILE_BROWSER: // It's only really needed with scoped storage, but why not make it available // as far back as possible - works just fine. - return (androidVersion >= 19); // when ACTION_OPEN_DOCUMENT was added + return (androidVersion >= 19) && (deviceType != DEVICE_TYPE_VR); // when ACTION_OPEN_DOCUMENT was added case SYSPROP_HAS_FOLDER_BROWSER: // Uses OPEN_DOCUMENT_TREE to let you select a folder. // Doesn't actually mean it's usable though, in many early versions of Android // this dialog is complete garbage and only lets you select subfolders of the Downloads folder. - return (androidVersion >= 21); // when ACTION_OPEN_DOCUMENT_TREE was added + return (androidVersion >= 21) && (deviceType != DEVICE_TYPE_VR); // when ACTION_OPEN_DOCUMENT_TREE was added case SYSPROP_SUPPORTS_OPEN_FILE_IN_EDITOR: return false; // Update if we add support in FileUtil.cpp: OpenFileInEditor case SYSPROP_APP_GOLD: @@ -733,9 +733,6 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init exitRenderLoop = false; androidVersion = jAndroidVersion; deviceType = jdeviceType; - if (deviceType == DEVICE_TYPE_VR) { - SetVREnabled(true); - } Path apkPath(GetJavaString(env, japkpath)); g_VFS.Register("", ZipFileReader::Create(apkPath, "assets/")); diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index 45150e7c79..9f68f904d1 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -615,7 +615,7 @@ public abstract class NativeActivity extends Activity { if (javaGL) { mGLSurfaceView = new NativeGLView(this); nativeRenderer = new NativeRenderer(this); - mGLSurfaceView.setEGLContextClientVersion(2); + mGLSurfaceView.setEGLContextClientVersion(isVRDevice() ? 3 : 2); sizeManager.setSurfaceView(mGLSurfaceView); // Setup the GLSurface and ask android for the correct @@ -1670,15 +1670,6 @@ public abstract class NativeActivity extends Activity { } public static boolean isVRDevice() { - String manufacturer = Build.MANUFACTURER; - if (manufacturer.compareToIgnoreCase("meta") == 0) { - return true; - } else if (manufacturer.compareToIgnoreCase("oculus") == 0) { - return true; - } else if (manufacturer.compareToIgnoreCase("pico") == 0) { - return true; - } else { - return false; - } + return BuildConfig.FLAVOR.startsWith("vr"); } }