Skip to content

Commit

Permalink
Merge branch 'hrydgard:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
anr2me authored Mar 25, 2024
2 parents 6e7b7cc + 7cddd09 commit cd6101b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 60 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ include(GNUInstallDirs)

add_definitions(-DASSETS_DIR="${CMAKE_INSTALL_FULL_DATADIR}/ppsspp/assets/")

if(OPENXR)
if(OPENXR AND NOT ARMV7_DEVICE)
add_definitions(-DOPENXR)
add_subdirectory(ext/OpenXR-SDK)
message("OpenXR enabled")
Expand Down Expand Up @@ -241,7 +241,7 @@ include_directories(ext/glslang)
# Anyway, glew will be going away anyway.
include_directories(ext/glew)

if(OPENXR)
if(OPENXR AND NOT ARMV7_DEVICE)
set(OPENGL_LIBRARIES GLESv3 EGL)
elseif(NOT OPENGL_LIBRARIES AND USING_GLES2)
set(OPENGL_LIBRARIES GLESv2 EGL)
Expand Down Expand Up @@ -1246,7 +1246,7 @@ set(BASISU_LIBRARIES basis_universal)
set(nativeExtra)
set(nativeExtraLibs)

if (OPENXR)
if(OPENXR AND NOT ARMV7_DEVICE)
set(nativeExtraLibs ${nativeExtraLibs} openxr_loader)
endif()

Expand Down
9 changes: 6 additions & 3 deletions Common/VR/PPSSPPVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -205,6 +204,10 @@ void SetVRCallbacks(void (*axis)(const AxisInput *axis, size_t count), bool(*key
cbNativeTouch = touch;
}

void SetVREnabled(bool enabled) {
vrEnabled = enabled;
}

/*
================================================================================
Expand Down
1 change: 1 addition & 0 deletions Common/VR/PPSSPPVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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. -->
Expand Down Expand Up @@ -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>
22 changes: 0 additions & 22 deletions android/VRManifest.xml

This file was deleted.

32 changes: 4 additions & 28 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ android {
gold {
res.srcDirs = ['gold/res']
}
vr {
manifest.srcFile 'VRManifest.xml'
}
}
productFlavors {
normal {
Expand All @@ -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 {
Expand All @@ -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'
}
}
}
Expand All @@ -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)
}
Expand Down
7 changes: 5 additions & 2 deletions android/jni/app-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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/"));
Expand Down
13 changes: 11 additions & 2 deletions android/src/org/ppsspp/ppsspp/NativeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public void onCreate(Bundle savedInstanceState) {
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
Expand Down Expand Up @@ -1670,6 +1670,15 @@ public void recreate() {
}

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;
}
}
}

0 comments on commit cd6101b

Please sign in to comment.