diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index c5f46b0b3d..8513500b86 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -201,18 +201,6 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con int status = IN_VRGetButtonState(j); for (ButtonMapping& m : controllerMapping[j]) { - //check if camera key was pressed - bool cameraKey = false; - std::vector nativeKeys; - if (KeyMap::KeyToPspButton(controllerIds[j], m.keycode, &nativeKeys)) { - for (int& nativeKey : nativeKeys) { - if (nativeKey == VIRTKEY_VR_CAMERA_ADJUST) { - cameraKey = true; - break; - } - } - } - //fill KeyInput structure bool pressed = status & m.ovr; keyInput.flags = pressed ? KEY_DOWN : KEY_UP; @@ -224,16 +212,12 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con if (pressed && haptics) { INVR_Vibrate(100, j, 1000); } - if (!pspKeys[VIRTKEY_VR_CAMERA_ADJUST] || cameraKey) { - NativeKey(keyInput); - } + NativeKey(keyInput); m.pressed = pressed; m.repeat = 0; } else if (pressed && (m.repeat > 30)) { keyInput.flags |= KEY_IS_REPEAT; - if (!pspKeys[VIRTKEY_VR_CAMERA_ADJUST] || cameraKey) { - NativeKey(keyInput); - } + NativeKey(keyInput); m.repeat = 0; } else { m.repeat++; @@ -341,13 +325,14 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con } } -void UpdateVRSpecialKeys(const KeyInput &key) { +bool UpdateVRSpecialKeys(const KeyInput &key) { std::vector nativeKeys; if (KeyMap::KeyToPspButton(key.deviceId, key.keyCode, &nativeKeys)) { for (int& nativeKey : nativeKeys) { pspKeys[nativeKey] = key.flags & KEY_DOWN; } } + return !pspKeys[VIRTKEY_VR_CAMERA_ADJUST]; } /* @@ -579,34 +564,30 @@ bool StartVRRender() { // Camera control if (pspKeys[VIRTKEY_VR_CAMERA_ADJUST]) { //left joystick controls height and side - float height = g_Config.fCameraHeight; - float side = g_Config.fCameraSide; - int status = IN_VRGetButtonState(0); - if (status & ovrButton_Left) side -= 0.05f; - if (status & ovrButton_Right) side += 0.05f; - if (status & ovrButton_Down) height -= 0.05f; - if (status & ovrButton_Up) height += 0.05f; - if (status & ovrButton_LThumb) { - height = 0; - side = 0; - } - g_Config.fCameraHeight = clampFloat(height, -10.0f, 10.0f); - g_Config.fCameraSide = clampFloat(side, -10.0f, 10.0f); + if (pspKeys[CTRL_LEFT]) g_Config.fCameraSide -= 0.05f; + if (pspKeys[CTRL_RIGHT]) g_Config.fCameraSide += 0.05f; + if (pspKeys[CTRL_DOWN]) g_Config.fCameraHeight -= 0.05f; + if (pspKeys[CTRL_UP]) g_Config.fCameraHeight += 0.05f; //right joystick controls distance and fov - float dst = g_Config.fCameraDistance; - float fov = g_Config.fFieldOfViewPercentage; - status = IN_VRGetButtonState(1); - if (status & ovrButton_Left) fov -= 1.0f; - if (status & ovrButton_Right) fov += 1.0f; - if (status & ovrButton_Down) dst -= 0.1f; - if (status & ovrButton_Up) dst += 0.1f; - if (status & ovrButton_RThumb) { - fov = 100; - dst = 0; + if (pspKeys[VIRTKEY_AXIS_X_MIN]) g_Config.fFieldOfViewPercentage -= 1.0f; + if (pspKeys[VIRTKEY_AXIS_X_MAX]) g_Config.fFieldOfViewPercentage += 1.0f; + if (pspKeys[VIRTKEY_AXIS_Y_MIN]) g_Config.fCameraDistance -= 0.1f; + if (pspKeys[VIRTKEY_AXIS_Y_MAX]) g_Config.fCameraDistance += 0.1f; + + // Reset values + if (pspKeys[VIRTKEY_VR_CAMERA_RESET]) { + g_Config.fCameraHeight = 0; + g_Config.fCameraSide = 0; + g_Config.fCameraDistance = 0; + g_Config.fFieldOfViewPercentage = 100; } - g_Config.fCameraDistance = clampFloat(dst, -10.0f, 10.0f); - g_Config.fFieldOfViewPercentage = clampFloat(fov, 100.0f, 200.0f); + + // Clamp values + g_Config.fCameraHeight = clampFloat(g_Config.fCameraHeight, -50.0f, 50.0f); + g_Config.fCameraSide = clampFloat(g_Config.fCameraSide, -50.0f, 50.0f); + g_Config.fCameraDistance = clampFloat(g_Config.fCameraDistance, -50.0f, 50.0f); + g_Config.fFieldOfViewPercentage = clampFloat(g_Config.fFieldOfViewPercentage, 100.0f, 200.0f); } // Set customizations diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 2dd2d1c11f..8dd127a2cb 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -23,7 +23,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 UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale); -void UpdateVRSpecialKeys(const KeyInput &key); +bool UpdateVRSpecialKeys(const KeyInput &key); // VR games compatibility void PreprocessStepVR(void* step); diff --git a/Core/KeyMap.cpp b/Core/KeyMap.cpp index 8c84be11e1..a853b69dfa 100644 --- a/Core/KeyMap.cpp +++ b/Core/KeyMap.cpp @@ -408,6 +408,7 @@ const KeyMap_IntStrPair psp_button_names[] = { #ifdef OPENXR {VIRTKEY_VR_CAMERA_ADJUST, "VR camera adjust"}, + {VIRTKEY_VR_CAMERA_RESET, "VR camera reset"}, #else {VIRTKEY_SCREEN_ROTATION_VERTICAL, "Display Portrait"}, {VIRTKEY_SCREEN_ROTATION_VERTICAL180, "Display Portrait Reversed"}, diff --git a/Core/KeyMap.h b/Core/KeyMap.h index 74859d3628..c81958ab26 100644 --- a/Core/KeyMap.h +++ b/Core/KeyMap.h @@ -69,6 +69,7 @@ enum { VIRTKEY_SCREEN_ROTATION_HORIZONTAL180 = 0x40000023, VIRTKEY_SPEED_ANALOG = 0x40000024, VIRTKEY_VR_CAMERA_ADJUST = 0x40000025, + VIRTKEY_VR_CAMERA_RESET = 0x40000026, VIRTKEY_LAST, VIRTKEY_COUNT = VIRTKEY_LAST - VIRTKEY_FIRST }; diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 5354e82b96..8b8c90a953 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -1304,7 +1304,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " }\n"); } - if (vertexRangeCulling && !gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { + if (vertexRangeCulling) { WRITE(p, " vec3 projPos = outPos.xyz / outPos.w;\n"); WRITE(p, " float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index ddaf02bab8..ef0cd2d246 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -3338,7 +3338,7 @@ u32 GPUCommon::CheckGPUFeatures() const { bool canClipOrCull = draw_->GetDeviceCaps().clipDistanceSupported || draw_->GetDeviceCaps().cullDistanceSupported; bool canDiscardVertex = draw_->GetBugs().Has(Draw::Bugs::BROKEN_NAN_IN_CONDITIONAL); - if (canClipOrCull || canDiscardVertex) { + if (!gstate_c.Use(GPU_USE_VIRTUAL_REALITY) && (canClipOrCull || canDiscardVertex)) { // We'll dynamically use the parts that are supported, to reduce artifacts as much as possible. features |= GPU_USE_VS_RANGE_CULLING; } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index c551d87721..080d19e686 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1144,9 +1144,6 @@ void GameSettingsScreen::CreateViews() { vrSettings->Add(new CheckBox(&g_Config.bForce72Hz, vr->T("Force 72Hz update"))); vrSettings->Add(new ItemHeader(vr->T("VR camera"))); - vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust"), 1.0f, screenManager(), "")); - vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraHeight, -10.0f, 10.0f, vr->T("Camera height adjust"), 1.0f, screenManager(), "")); - vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraSide, -10.0f, 10.0f, vr->T("Camera side adjust"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 10.0f, vr->T("Distance to 2D menus and scenes"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, vr->T("Field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV"))); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index d387e7064b..92bb129f30 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1297,8 +1297,8 @@ bool NativeTouch(const TouchInput &touch) { bool NativeKey(const KeyInput &key) { // Special key VR actions - if (IsVREnabled()) { - UpdateVRSpecialKeys(key); + if (IsVREnabled() && !UpdateVRSpecialKeys(key)) { + return false; } // INFO_LOG(SYSTEM, "Key code: %i flags: %i", key.keyCode, key.flags); diff --git a/assets/compatvr.ini b/assets/compatvr.ini index bc4e1a6dd1..b54081f4f5 100644 --- a/assets/compatvr.ini +++ b/assets/compatvr.ini @@ -758,15 +758,15 @@ ULJM05604 = 1.0 ULUS10490 = 1.0 # Grand Theft Auto: Liberty City Stories -NPJH50825 = 1.0 -ULES00051 = 1.0 -ULES00151 = 1.0 -ULES00181 = 1.0 -ULES00182 = 1.0 -ULJM05255 = 1.0 -ULJM05359 = 1.0 -ULJM05885 = 1.0 -ULUS10041 = 1.0 +NPJH50825 = 0.5 +ULES00051 = 0.5 +ULES00151 = 0.5 +ULES00181 = 0.5 +ULES00182 = 0.5 +ULJM05255 = 0.5 +ULJM05359 = 0.5 +ULJM05885 = 0.5 +ULUS10041 = 0.5 # Grand Theft Auto: Vice City Stories NPJH50827 = 1.0