diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index b2daa2fb8a..704eba7422 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -221,11 +221,16 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con } } -void UpdateVRScreenKey(const KeyInput &key) { +void UpdateVRSpecialKeys(const KeyInput &key) { std::vector nativeKeys; if (KeyMap::KeyToPspButton(key.deviceId, key.keyCode, &nativeKeys)) { for (int& nativeKey : nativeKeys) { - if (nativeKey == CTRL_SCREEN) { + // adjust camera parameters + if (nativeKey == CTRL_HOLD) { + VR_SetConfig(VR_CONFIG_CAMERA_CONTROL, key.flags & KEY_DOWN); + } + // force 2D rendering + else if (nativeKey == CTRL_SCREEN) { VR_SetConfig(VR_CONFIG_FORCE_2D, key.flags & KEY_DOWN); } } @@ -317,6 +322,19 @@ bool StartVRRender() { // Set compatibility vrCompat[VR_COMPAT_SKYPLANE] = PSP_CoreParameter().compat.vrCompat().Skyplane; + // Camera control + if (VR_GetConfig(VR_CONFIG_CAMERA_CONTROL)) { + float dst = g_Config.fCameraDistance; + float fov = g_Config.fFieldOfViewPercentage; + int 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; + g_Config.fCameraDistance = std::clamp(dst, -10.0f, 10.0f); + g_Config.fFieldOfViewPercentage = std::clamp(fov, 100.0f, 200.0f); + } + // Set customizations VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.fCameraDistance * 1000); diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 91f5862ff0..440f27859d 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -25,7 +25,7 @@ void InitVROnAndroid(void* vm, void* activity, int version, const char* name); 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 UpdateVRScreenKey(const KeyInput &key); +void UpdateVRSpecialKeys(const KeyInput &key); // VR games compatibility void PreprocessStepVR(void* step); @@ -53,7 +53,7 @@ inline void InitVROnAndroid(void* vm, void* activity, int version, const char* n inline void EnterVR(bool firstTime, void* vulkanContext) {} inline void GetVRResolutionPerEye(int* width, int* height) {} inline void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale) {} -inline void UpdateVRScreenKey(const KeyInput &key) {} +inline void UpdateVRSpecialKeys(const KeyInput &key) {} // VR games compatibility inline void PreprocessStepVR(void* step) {} diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index 1c93f98752..7ba37ae407 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -7,7 +7,7 @@ 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_DISTANCE, VR_CONFIG_CANVAS_DISTANCE, + VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_CONTROL, VR_CONFIG_CAMERA_DISTANCE, 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/UI/NativeApp.cpp b/UI/NativeApp.cpp index 36ce962ea4..0f4cac7f37 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1296,9 +1296,9 @@ bool NativeTouch(const TouchInput &touch) { } bool NativeKey(const KeyInput &key) { - // Hack to quickly enable 2D mode in VR game mode. + // Special key VR actions if (IsVRBuild()) { - UpdateVRScreenKey(key); + UpdateVRSpecialKeys(key); } // INFO_LOG(SYSTEM, "Key code: %i flags: %i", key.keyCode, key.flags);