mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
OpenXR - One APK for Android and standalone VR
This commit is contained in:
parent
a2fe2f49b8
commit
63307aec2e
7 changed files with 33 additions and 57 deletions
|
@ -42,6 +42,7 @@ static std::map<int, bool> 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] = {};
|
||||
|
@ -129,10 +130,8 @@ VR app flow integration
|
|||
*/
|
||||
|
||||
bool IsVREnabled() {
|
||||
// For now, let the OPENXR build flag control enablement.
|
||||
// This will change.
|
||||
#ifdef OPENXR
|
||||
return true;
|
||||
return vrEnabled;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
@ -205,6 +204,10 @@ void SetVRCallbacks(void (*axis)(const AxisInput *axis, size_t count), bool(*key
|
|||
cbNativeTouch = touch;
|
||||
}
|
||||
|
||||
void SetVREnabled(bool enabled) {
|
||||
vrEnabled = enabled;
|
||||
}
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ 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);
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
<uses-feature android:name="android.hardware.location.network" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.vr.headtracking" android:required="false" />
|
||||
<uses-feature android:name="com.oculus.feature.PASSTHROUGH" android:required="false" />
|
||||
|
||||
<!-- I tried using android:maxSdkVersion="29" on WRITE/READ_EXTERNAL_STORAGE, but that made
|
||||
it so that in legacy mode, you can't ask for permission anymore. So removed that. -->
|
||||
|
@ -116,6 +118,10 @@
|
|||
<meta-data
|
||||
android:name="xperiaplayoptimized_content"
|
||||
android:resource="@drawable/ic_launcher" />
|
||||
|
||||
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
|
||||
<meta-data android:name="com.oculus.supportedDevices" android:value="quest2|quest3|questpro"/>
|
||||
<meta-data android:name="pvr.app.type" android:value="vr" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-feature android:glEsVersion="0x00030001" />
|
||||
<uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
|
||||
<uses-feature android:name="com.oculus.feature.PASSTHROUGH" android:required="false" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:logo="@drawable/ic_banner"
|
||||
android:isGame="true"
|
||||
android:banner="@drawable/tv_banner"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:preserveLegacyExternalStorage="true">
|
||||
|
||||
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
|
||||
<meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2"/>
|
||||
<meta-data android:name="pvr.app.type" android:value="vr" />
|
||||
</application>
|
||||
</manifest>
|
|
@ -109,9 +109,6 @@ android {
|
|||
gold {
|
||||
res.srcDirs = ['gold/res']
|
||||
}
|
||||
vr {
|
||||
manifest.srcFile 'VRManifest.xml'
|
||||
}
|
||||
}
|
||||
productFlavors {
|
||||
normal {
|
||||
|
@ -124,7 +121,8 @@ android {
|
|||
'-DANDROID_PLATFORM=android-16',
|
||||
'-DANDROID_TOOLCHAIN=clang',
|
||||
'-DANDROID_CPP_FEATURES=',
|
||||
'-DANDROID_STL=c++_static'
|
||||
'-DANDROID_STL=c++_static',
|
||||
'-DOPENXR=TRUE'
|
||||
}
|
||||
}
|
||||
ndk {
|
||||
|
@ -143,31 +141,12 @@ android {
|
|||
'-DANDROID_CPP_FEATURES=',
|
||||
'-DANDROID_STL=c++_static',
|
||||
'-DANDROID_ARM_NEON=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',
|
||||
'-DGOLD=TRUE',
|
||||
'-DOPENXR=TRUE'
|
||||
}
|
||||
}
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,9 +156,6 @@ 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)
|
||||
}
|
||||
|
|
|
@ -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) && (deviceType != DEVICE_TYPE_VR); // when ACTION_OPEN_DOCUMENT was added
|
||||
return (androidVersion >= 19); // 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) && (deviceType != DEVICE_TYPE_VR); // when ACTION_OPEN_DOCUMENT_TREE was added
|
||||
return (androidVersion >= 21); // 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,6 +733,9 @@ 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/"));
|
||||
|
|
|
@ -615,7 +615,7 @@ public abstract class NativeActivity extends Activity {
|
|||
if (javaGL) {
|
||||
mGLSurfaceView = new NativeGLView(this);
|
||||
nativeRenderer = new NativeRenderer(this);
|
||||
mGLSurfaceView.setEGLContextClientVersion(isVRDevice() ? 3 : 2);
|
||||
mGLSurfaceView.setEGLContextClientVersion(2);
|
||||
sizeManager.setSurfaceView(mGLSurfaceView);
|
||||
|
||||
// Setup the GLSurface and ask android for the correct
|
||||
|
@ -1670,6 +1670,15 @@ public abstract class NativeActivity extends Activity {
|
|||
}
|
||||
|
||||
public static boolean isVRDevice() {
|
||||
return BuildConfig.FLAVOR.startsWith("vr");
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue