Skip to content

Commit 4f9f362

Browse files
committed
Keybinds: Add "Disable VR Key" (Fixes #15)
1 parent fea6c7e commit 4f9f362

2 files changed

Lines changed: 26 additions & 9 deletions

File tree

src/mods/VR.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,15 +1630,9 @@ void VR::on_pre_imgui_frame() {
16301630
}
16311631
}
16321632

1633-
void VR::on_frame() {
1633+
void VR::handle_keybinds() {
16341634
ZoneScopedN(__FUNCTION__);
16351635

1636-
m_cvar_manager->on_frame();
1637-
1638-
if (!get_runtime()->ready()) {
1639-
return;
1640-
}
1641-
16421636
if (m_keybind_recenter->is_key_down_once()) {
16431637
recenter_view();
16441638
}
@@ -1663,6 +1657,21 @@ void VR::on_frame() {
16631657
m_2d_screen_mode->toggle();
16641658
}
16651659

1660+
if (m_keybind_disable_vr->is_key_down_once()) {
1661+
m_disable_vr = !m_disable_vr; // definitely should not be persistent
1662+
}
1663+
}
1664+
1665+
void VR::on_frame() {
1666+
ZoneScopedN(__FUNCTION__);
1667+
1668+
m_cvar_manager->on_frame();
1669+
handle_keybinds();
1670+
1671+
if (!get_runtime()->ready()) {
1672+
return;
1673+
}
1674+
16661675
const auto now = std::chrono::steady_clock::now();
16671676
const auto is_allowed_draw_window = now - m_last_xinput_update < std::chrono::seconds(2);
16681677

@@ -2236,8 +2245,9 @@ void VR::on_draw_sidebar_entry(std::string_view name) {
22362245
}
22372246

22382247
ImGui::SetNextItemOpen(true, ImGuiCond_::ImGuiCond_Once);
2239-
if (ImGui::TreeNode("Overlay Keys")) {
2248+
if (ImGui::TreeNode("Overlay/Runtime Keys")) {
22402249
m_keybind_toggle_2d_screen->draw("Toggle 2D Screen Mode Key");
2250+
m_keybind_disable_vr->draw("Disable VR Key");
22412251

22422252
ImGui::TreePop();
22432253
}
@@ -2277,6 +2287,7 @@ void VR::on_draw_sidebar_entry(std::string_view name) {
22772287
ImGui::Checkbox("Disable View Matrix Override", &m_disable_view_matrix_override);
22782288
ImGui::Checkbox("Disable Backbuffer Size Override", &m_disable_backbuffer_size_override);
22792289
ImGui::Checkbox("Disable VR Overlay", &m_disable_overlay);
2290+
ImGui::Checkbox("Disable VR Entirely", &m_disable_vr);
22802291
ImGui::Checkbox("Stereo Emulation Mode", &m_stereo_emulation_mode);
22812292
ImGui::Checkbox("Wait for Present", &m_wait_for_present);
22822293
ImGui::Checkbox("Controllers allowed", &m_controllers_allowed);

src/mods/VR.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ class VR : public Mod {
106106
void on_draw_ui() override;
107107
void on_draw_sidebar_entry(std::string_view name) override;
108108
void on_pre_imgui_frame() override;
109+
110+
void handle_keybinds();
109111
void on_frame() override;
112+
110113
void on_present() override;
111114
void on_post_present() override;
112115

@@ -231,7 +234,7 @@ class VR : public Mod {
231234
}
232235

233236
bool is_hmd_active() const {
234-
return get_runtime()->ready() || (m_stereo_emulation_mode && get_runtime()->loaded);
237+
return !m_disable_vr && (get_runtime()->ready() || (m_stereo_emulation_mode && get_runtime()->loaded));
235238
}
236239

237240
auto get_hmd() const {
@@ -806,6 +809,8 @@ class VR : public Mod {
806809
const ModKey::Ptr m_keybind_load_camera_2{ ModKey::create(generate_name("LoadCamera2Key")) };
807810

808811
const ModKey::Ptr m_keybind_toggle_2d_screen{ ModKey::create(generate_name("Toggle2DScreenKey")) };
812+
const ModKey::Ptr m_keybind_disable_vr{ ModKey::create(generate_name("DisableVRKey")) };
813+
bool m_disable_vr{false}; // definitely should not be persistent
809814

810815
struct DecoupledPitchData {
811816
mutable std::shared_mutex mtx{};
@@ -878,6 +883,7 @@ class VR : public Mod {
878883
*m_keybind_load_camera_1,
879884
*m_keybind_load_camera_2,
880885
*m_keybind_toggle_2d_screen,
886+
*m_keybind_disable_vr,
881887
};
882888

883889

0 commit comments

Comments
 (0)