Skip to content

Commit

Permalink
Persist 'Controllers Allowed' setting (#86)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
keton committed Feb 29, 2024
1 parent 1ea27b6 commit 1e16338
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/mods/VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/mods/VR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -983,6 +983,7 @@ class VR : public Mod {
*m_keybind_disable_vr,
*m_keybind_toggle_gui,
*m_requested_runtime_name,
*m_controllers_allowed,
};


Expand Down

0 comments on commit 1e16338

Please sign in to comment.