From 6e91ca9e54a0294b7112b975d25833d0cf322833 Mon Sep 17 00:00:00 2001 From: Lubos Date: Tue, 7 Feb 2023 19:48:16 +0100 Subject: [PATCH] OpenXR - Option to disable automatic switch between 2D and VR --- Common/VR/PPSSPPVR.cpp | 18 +++++++++++++++--- Core/Config.cpp | 3 ++- Core/Config.h | 1 + UI/GameSettingsScreen.cpp | 1 + 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index f3ede39317..d30511ad20 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -42,6 +42,7 @@ static std::map pspKeys; static int vr3DGeometryCount = 0; static long vrCompat[VR_COMPAT_MAX]; +static bool vrFlatForced = false; static bool vrFlatGame = false; static float vrMatrix[VR_MATRIX_COUNT][16]; static bool vrMirroring[VR_MIRRORING_COUNT]; @@ -317,7 +318,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { if (g_Config.iHeadRotation) { float pitch = -VR_GetHMDAngles().x; float yaw = -VR_GetHMDAngles().y; - bool disable = pspKeys[CTRL_SCREEN] || appMode == VR_MENU_MODE; + bool disable = vrFlatForced || appMode == VR_MENU_MODE; bool isVR = !IsFlatVRScene(); // calculate delta angles of the rotation @@ -482,6 +483,7 @@ bool UpdateVRAxis(const AxisInput &axis) { bool UpdateVRKeys(const KeyInput &key) { //store key value std::vector nativeKeys; + bool wasScreenKeyOn = pspKeys[CTRL_SCREEN]; bool wasCameraAdjustOn = pspKeys[VIRTKEY_VR_CAMERA_ADJUST]; if (KeyMap::KeyToPspButton(key.deviceId, key.keyCode, &nativeKeys)) { for (int& nativeKey : nativeKeys) { @@ -503,6 +505,15 @@ bool UpdateVRKeys(const KeyInput &key) { } } + // Update force flat 2D mode + if (g_Config.bManualForceVR) { + if (!wasScreenKeyOn && pspKeys[CTRL_SCREEN]) { + vrFlatForced = !vrFlatForced; + } + } else { + vrFlatForced = pspKeys[CTRL_SCREEN]; + } + // Release keys on enabling camera adjust if (!wasCameraAdjustOn && pspKeys[VIRTKEY_VR_CAMERA_ADJUST]) { KeyInput keyUp; @@ -748,9 +759,10 @@ bool StartVRRender() { // Decide if the scene is 3D or not bool stereo = hasUnitScale && g_Config.bEnableStereo; - bool forceFlat = PSP_CoreParameter().compat.vrCompat().ForceFlatScreen; + bool vrIncompatibleGame = PSP_CoreParameter().compat.vrCompat().ForceFlatScreen; + bool vrScene = !vrFlatForced && (g_Config.bManualForceVR || (vr3DGeometryCount > 15)); VR_SetConfigFloat(VR_CONFIG_CANVAS_ASPECT, 480.0f / 272.0f); - if (g_Config.bEnableVR && !pspKeys[CTRL_SCREEN] && !forceFlat && (appMode == VR_GAME_MODE) && (vr3DGeometryCount > 15)) { + if (g_Config.bEnableVR && !vrIncompatibleGame && (appMode == VR_GAME_MODE) && vrScene) { VR_SetConfig(VR_CONFIG_MODE, stereo ? VR_MODE_STEREO_6DOF : VR_MODE_MONO_6DOF); vrFlatGame = false; } else { diff --git a/Core/Config.cpp b/Core/Config.cpp index 86cd15c61e..8cc8eeaea1 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1140,7 +1140,8 @@ static const ConfigSetting vrSettings[] = { ConfigSetting("VREnable6DoF", &g_Config.bEnable6DoF, true), ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false), ConfigSetting("VREnableMotions", &g_Config.bEnableMotions, true), - ConfigSetting("VRbForce72Hz", &g_Config.bForce72Hz, true), + ConfigSetting("VRForce72Hz", &g_Config.bForce72Hz, true), + ConfigSetting("VRManualForceVR", &g_Config.bManualForceVR, false), ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f), ConfigSetting("VRCameraHeight", &g_Config.fCameraHeight, 0.0f), ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), diff --git a/Core/Config.h b/Core/Config.h index dc2f1a8ca7..f3a93d4dc7 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -465,6 +465,7 @@ public: bool bEnableStereo; bool bEnableMotions; bool bForce72Hz; + bool bManualForceVR; float fCameraDistance; float fCameraHeight; float fCameraSide; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index ab756a0d2a..2f71c2ec55 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1137,6 +1137,7 @@ void GameSettingsScreen::CreateVRSettings(UI::ViewGroup *vrSettings) { vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fHeadUpDisplayScale, 0.0f, 1.5f, vr->T("Heads-up display scale"), 0.1f, screenManager(), "")); vrSettings->Add(new ItemHeader(vr->T("Experts only"))); + vrSettings->Add(new CheckBox(&g_Config.bManualForceVR, vr->T("Manual switching between flat screen and VR using SCREEN key"))); static const char *vrHeadRotations[] = { vr->T("Disabled"), vr->T("Horizontal only"), vr->T("Horizontal and vertical") }; vrSettings->Add(new PopupMultiChoice(&g_Config.iHeadRotation, vr->T("Map HMD rotations on keys instead of VR camera"), vrHeadRotations, 0, ARRAY_SIZE(vrHeadRotations), vr->GetName(), screenManager())); PopupSliderChoiceFloat *vrHeadRotationScale = vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fHeadRotationScale, 0.1f, 10.0f, vr->T("Game camera rotation step per frame"), 0.1f, screenManager(), "°"));