diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index d53dfe99..2f51611d 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -1630,15 +1630,9 @@ void VR::on_pre_imgui_frame() { } } -void VR::on_frame() { +void VR::handle_keybinds() { ZoneScopedN(__FUNCTION__); - m_cvar_manager->on_frame(); - - if (!get_runtime()->ready()) { - return; - } - if (m_keybind_recenter->is_key_down_once()) { recenter_view(); } @@ -1663,6 +1657,21 @@ void VR::on_frame() { m_2d_screen_mode->toggle(); } + if (m_keybind_disable_vr->is_key_down_once()) { + m_disable_vr = !m_disable_vr; // definitely should not be persistent + } +} + +void VR::on_frame() { + ZoneScopedN(__FUNCTION__); + + m_cvar_manager->on_frame(); + handle_keybinds(); + + if (!get_runtime()->ready()) { + return; + } + const auto now = std::chrono::steady_clock::now(); const auto is_allowed_draw_window = now - m_last_xinput_update < std::chrono::seconds(2); @@ -2236,8 +2245,9 @@ void VR::on_draw_sidebar_entry(std::string_view name) { } ImGui::SetNextItemOpen(true, ImGuiCond_::ImGuiCond_Once); - if (ImGui::TreeNode("Overlay Keys")) { + if (ImGui::TreeNode("Overlay/Runtime Keys")) { m_keybind_toggle_2d_screen->draw("Toggle 2D Screen Mode Key"); + m_keybind_disable_vr->draw("Disable VR Key"); ImGui::TreePop(); } @@ -2277,6 +2287,7 @@ void VR::on_draw_sidebar_entry(std::string_view name) { ImGui::Checkbox("Disable View Matrix Override", &m_disable_view_matrix_override); ImGui::Checkbox("Disable Backbuffer Size Override", &m_disable_backbuffer_size_override); ImGui::Checkbox("Disable VR Overlay", &m_disable_overlay); + ImGui::Checkbox("Disable VR Entirely", &m_disable_vr); ImGui::Checkbox("Stereo Emulation Mode", &m_stereo_emulation_mode); ImGui::Checkbox("Wait for Present", &m_wait_for_present); ImGui::Checkbox("Controllers allowed", &m_controllers_allowed); diff --git a/src/mods/VR.hpp b/src/mods/VR.hpp index 6ef9d68c..bc147272 100644 --- a/src/mods/VR.hpp +++ b/src/mods/VR.hpp @@ -106,7 +106,10 @@ class VR : public Mod { void on_draw_ui() override; void on_draw_sidebar_entry(std::string_view name) override; void on_pre_imgui_frame() override; + + void handle_keybinds(); void on_frame() override; + void on_present() override; void on_post_present() override; @@ -231,7 +234,7 @@ class VR : public Mod { } bool is_hmd_active() const { - return get_runtime()->ready() || (m_stereo_emulation_mode && get_runtime()->loaded); + return !m_disable_vr && (get_runtime()->ready() || (m_stereo_emulation_mode && get_runtime()->loaded)); } auto get_hmd() const { @@ -806,6 +809,8 @@ class VR : public Mod { const ModKey::Ptr m_keybind_load_camera_2{ ModKey::create(generate_name("LoadCamera2Key")) }; const ModKey::Ptr m_keybind_toggle_2d_screen{ ModKey::create(generate_name("Toggle2DScreenKey")) }; + const ModKey::Ptr m_keybind_disable_vr{ ModKey::create(generate_name("DisableVRKey")) }; + bool m_disable_vr{false}; // definitely should not be persistent struct DecoupledPitchData { mutable std::shared_mutex mtx{}; @@ -878,6 +883,7 @@ class VR : public Mod { *m_keybind_load_camera_1, *m_keybind_load_camera_2, *m_keybind_toggle_2d_screen, + *m_keybind_disable_vr, };