OpenXR - 2D mode hack mappable (using screen keycode)

This commit is contained in:
Lubos 2022-08-15 16:53:00 +02:00
parent 31524df0a8
commit 428145c4b9
4 changed files with 20 additions and 7 deletions

View File

@ -11,7 +11,6 @@
#ifdef OPENXR #ifdef OPENXR
#include "Core/Config.h" #include "Core/Config.h"
#include "VR/VRBase.h" #include "VR/VRBase.h"
#include "VR/VRInput.h"
#include "VR/VRRenderer.h" #include "VR/VRRenderer.h"
#endif #endif
@ -208,7 +207,7 @@ bool GLRenderManager::ThreadFrame() {
VR_BeginFrame(VR_GetEngine()); VR_BeginFrame(VR_GetEngine());
// Decide if the scene is 3D or not // Decide if the scene is 3D or not
if (g_Config.bEnableVR && (VR_GetConfig(VR_CONFIG_3D_GEOMETRY_COUNT) > 15)) { if (g_Config.bEnableVR && !VR_GetConfig(VR_CONFIG_FORCE_2D) && (VR_GetConfig(VR_CONFIG_3D_GEOMETRY_COUNT) > 15)) {
VR_SetConfig(VR_CONFIG_MODE, VR_MODE_MONO_6DOF); VR_SetConfig(VR_CONFIG_MODE, VR_MODE_MONO_6DOF);
} else { } else {
VR_SetConfig(VR_CONFIG_MODE, VR_MODE_FLAT_SCREEN); VR_SetConfig(VR_CONFIG_MODE, VR_MODE_FLAT_SCREEN);
@ -218,11 +217,6 @@ bool GLRenderManager::ThreadFrame() {
// Set customizations // Set customizations
VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF);
VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.iFieldOfViewPercentage); VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.iFieldOfViewPercentage);
// hack to quick enable 2D mode in game
if (IN_VRGetButtonState(0) & ovrButton_GripTrigger) {
VR_SetConfig(VR_CONFIG_MODE, VR_MODE_FLAT_SCREEN);
}
#endif #endif
// In case of syncs or other partial completion, we keep going until we complete a frame. // In case of syncs or other partial completion, we keep going until we complete a frame.

View File

@ -15,6 +15,7 @@ enum VRConfig {
VR_CONFIG_MIRROR_ROLL, VR_CONFIG_MIRROR_ROLL,
VR_CONFIG_3D_GEOMETRY_COUNT, VR_CONFIG_3D_GEOMETRY_COUNT,
VR_CONFIG_FOV_SCALE, VR_CONFIG_FOV_SCALE,
VR_CONFIG_FORCE_2D,
VR_CONFIG_MAX VR_CONFIG_MAX
}; };

View File

@ -317,6 +317,7 @@ static const DefMappingStruct defaultVRLeftController[] = {
{CTRL_SELECT , NKCODE_BUTTON_THUMBL}, {CTRL_SELECT , NKCODE_BUTTON_THUMBL},
{CTRL_LTRIGGER , NKCODE_BUTTON_X}, {CTRL_LTRIGGER , NKCODE_BUTTON_X},
{CTRL_RTRIGGER , NKCODE_BUTTON_Y}, {CTRL_RTRIGGER , NKCODE_BUTTON_Y},
{CTRL_SCREEN , NKCODE_ALT_LEFT},
}; };
static const DefMappingStruct defaultVRRightController[] = { static const DefMappingStruct defaultVRRightController[] = {

View File

@ -142,6 +142,10 @@
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
#endif #endif
#ifdef OPENXR
#include "VR/VRRenderer.h"
#endif
ScreenManager *screenManager; ScreenManager *screenManager;
std::string config_filename; std::string config_filename;
@ -1297,6 +1301,19 @@ bool NativeTouch(const TouchInput &touch) {
} }
bool NativeKey(const KeyInput &key) { bool NativeKey(const KeyInput &key) {
// Hack to quick enable 2D mode in VR game mode.
#ifdef OPENXR
std::vector<int> nativeKeys;
if (KeyMap::KeyToPspButton(key.deviceId, key.keyCode, &nativeKeys)) {
for (int& nativeKey : nativeKeys) {
if (nativeKey == CTRL_SCREEN) {
VR_SetConfig(VR_CONFIG_FORCE_2D, key.flags & KEY_DOWN);
}
}
}
#endif
// INFO_LOG(SYSTEM, "Key code: %i flags: %i", key.keyCode, key.flags); // INFO_LOG(SYSTEM, "Key code: %i flags: %i", key.keyCode, key.flags);
#if !defined(MOBILE_DEVICE) #if !defined(MOBILE_DEVICE)
if (g_Config.bPauseExitsEmulator) { if (g_Config.bPauseExitsEmulator) {