From 1e16338d2c3d8f30d7ac0e1eed58433b2c319196 Mon Sep 17 00:00:00 2001 From: keton Date: Thu, 29 Feb 2024 22:53:35 +0100 Subject: [PATCH] Persist 'Controllers Allowed' setting (#86) When using Virtual Desktop toggling performance overlay (both thumbsticks down on VR controllers) disconnects gamepad in some games. This patch allows to write state of 'Debug->Controllers Allowed' setting to config.txt making a workaround in game profile possible. VR.is_using_controllers_within() was not respecting the setting making gamepad disconnect on game exit. This is also fixed. --- src/mods/VR.cpp | 2 +- src/mods/VR.hpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index 5685a2d1..24f1e696 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -2557,7 +2557,7 @@ void VR::on_draw_sidebar_entry(std::string_view name) { 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); + m_controllers_allowed->draw("Controllers allowed"); ImGui::Checkbox("Controller test mode", &m_controller_test_mode); const double min_ = 0.0; diff --git a/src/mods/VR.hpp b/src/mods/VR.hpp index 63998a53..d15c1494 100644 --- a/src/mods/VR.hpp +++ b/src/mods/VR.hpp @@ -281,12 +281,12 @@ class VR : public Mod { } bool is_using_controllers() const { - return m_controller_test_mode || (m_controllers_allowed && + return m_controller_test_mode || (m_controllers_allowed->value() && is_hmd_active() && !m_controllers.empty() && (std::chrono::steady_clock::now() - m_last_controller_update) <= std::chrono::seconds((int32_t)m_motion_controls_inactivity_timer->value())); } bool is_using_controllers_within(std::chrono::seconds seconds) const { - return is_hmd_active() && !m_controllers.empty() && (std::chrono::steady_clock::now() - m_last_controller_update) <= seconds; + return m_controllers_allowed->value() && is_hmd_active() && !m_controllers.empty() && (std::chrono::steady_clock::now() - m_last_controller_update) <= seconds; } int get_hmd_index() const { @@ -924,7 +924,7 @@ class VR : public Mod { bool m_stereo_emulation_mode{false}; // not a good config option, just for debugging bool m_wait_for_present{true}; - bool m_controllers_allowed{true}; + const ModToggle::Ptr m_controllers_allowed{ ModToggle::create(generate_name("ControllersAllowed"), true) }; bool m_controller_test_mode{false}; ValueList m_options{ @@ -983,6 +983,7 @@ class VR : public Mod { *m_keybind_disable_vr, *m_keybind_toggle_gui, *m_requested_runtime_name, + *m_controllers_allowed, };