diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 2c3e730bfc..84ce7274fd 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -344,9 +344,20 @@ bool StartVRRender() { // Camera control if (VR_GetConfig(VR_CONFIG_CAMERA_CONTROL)) { + //light joystick controls height + float height = g_Config.fCameraHeight; + int status = IN_VRGetButtonState(0); + if (status & ovrButton_Down) height -= 0.05f; + if (status & ovrButton_Up) height += 0.05f; + if (status & ovrButton_LThumb) { + height = 0; + } + g_Config.fCameraHeight = std::clamp(height, -10.0f, 10.0f); + + //right joystick controls distance and fov float dst = g_Config.fCameraDistance; float fov = g_Config.fFieldOfViewPercentage; - int status = IN_VRGetButtonState(1); + 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; @@ -362,6 +373,7 @@ bool StartVRRender() { // Set customizations VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.fCameraDistance * 1000); + VR_SetConfig(VR_CONFIG_CAMERA_HEIGHT, g_Config.fCameraHeight * 1000); VR_SetConfig(VR_CONFIG_CANVAS_DISTANCE, g_Config.fCanvasDistance); VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.fFieldOfViewPercentage); VR_SetConfig(VR_CONFIG_MIRROR_UPDATED, false); diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index a43b169f8e..aba7c4def0 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -346,6 +346,14 @@ bool VR_InitFrame( engine_t* engine ) { vrMatrix[matrix].M[1][3] += forward.y; vrMatrix[matrix].M[2][3] += forward.z; } + if (abs(vrConfig[VR_CONFIG_CAMERA_HEIGHT]) > 0) { + XrVector3f up = {0.0f, -(float)vrConfig[VR_CONFIG_CAMERA_HEIGHT] * 0.001f * scale, 0.0f}; + up = XrQuaternionf_Rotate(invView.orientation, up); + up = XrVector3f_ScalarMultiply(up, vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f); + vrMatrix[matrix].M[0][3] += up.x; + vrMatrix[matrix].M[1][3] += up.y; + vrMatrix[matrix].M[2][3] += up.z; + } if (vrConfig[VR_CONFIG_6DOF_PRECISE] && (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index 7ba37ae407..95671fc0c2 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -7,7 +7,8 @@ enum VRConfig { //switching between 2D and 3D VR_CONFIG_MODE, VR_CONFIG_3D_GEOMETRY_COUNT, VR_CONFIG_FORCE_2D, //camera setup - VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_CONTROL, VR_CONFIG_CAMERA_DISTANCE, VR_CONFIG_CANVAS_DISTANCE, + VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_CONTROL, VR_CONFIG_CAMERA_DISTANCE, + VR_CONFIG_CAMERA_HEIGHT, VR_CONFIG_CANVAS_DISTANCE, //6DoF VR_CONFIG_6DOF_ENABLED, VR_CONFIG_6DOF_SCALE, VR_CONFIG_6DOF_PRECISE, VR_CONFIG_MIRROR_UPDATED, VR_CONFIG_MIRROR_AXIS_X, VR_CONFIG_MIRROR_AXIS_Y, VR_CONFIG_MIRROR_AXIS_Z, diff --git a/Core/Config.cpp b/Core/Config.cpp index da71b8bfff..f52738b8bd 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1209,6 +1209,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VREnable6DoF", &g_Config.bEnable6DoF, true), ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false), ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f), + ConfigSetting("VRCameraHeight", &g_Config.fCameraHeight, 0.0f), ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 6.0f), ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f), diff --git a/Core/Config.h b/Core/Config.h index f42fd77720..2a66f73fa2 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -464,6 +464,7 @@ public: bool bEnable6DoF; bool bEnableStereo; float fCameraDistance; + float fCameraHeight; float fCanvasDistance; float fFieldOfViewPercentage; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 5dce2e89cd..a6311ab4ef 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1166,6 +1166,7 @@ void GameSettingsScreen::CreateViews() { vrSettings->Add(new ItemHeader(vr->T("VR camera"))); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust", "Camera distance adjust"), 1.0f, screenManager(), "")); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraHeight, -10.0f, 10.0f, vr->T("Camera height adjust", "Camera height adjust"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 10.0f, vr->T("Distance to 2D menus and scenes", "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", "Headset's field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV"))); }