diff --git a/GlosSITarget/HidHide.cpp b/GlosSITarget/HidHide.cpp index 481640d..9ac4c31 100644 --- a/GlosSITarget/HidHide.cpp +++ b/GlosSITarget/HidHide.cpp @@ -135,12 +135,12 @@ void HidHide::hideDevices(const std::filesystem::path& steam_path) void HidHide::disableHidHide() { - openCtrlDevice(); - if (getActive()) { - setActive(false); - spdlog::info("Un-hid Gaming Devices"); - } - closeCtrlDevice(); + openCtrlDevice(); + if (getActive()) { + setActive(false); + spdlog::info("Un-hid Gaming Devices"); + } + closeCtrlDevice(); } void HidHide::UnPatchValveHooks() @@ -257,8 +257,7 @@ void HidHide::UnPatchHook(BYTE* address, const std::string& bytes) void HidHide::enableOverlayElement() { - Overlay::AddOverlayElem([this]() { - if (overlay_elem_clock_.getElapsedTime().asSeconds() > OVERLAY_ELEM_REFRESH_INTERVAL_S_) { + Overlay::AddOverlayElem([this](bool window_has_focus) { openCtrlDevice(); bool hidehide_state_store = hidhide_active_; if (hidhide_active_) { diff --git a/GlosSITarget/InputRedirector.cpp b/GlosSITarget/InputRedirector.cpp index d9b0382..f778005 100644 --- a/GlosSITarget/InputRedirector.cpp +++ b/GlosSITarget/InputRedirector.cpp @@ -53,7 +53,7 @@ void InputRedirector::run() max_controller_count_ = Settings::controller.maxControllers; use_real_vid_pid_ = Settings::devices.realDeviceIds; #ifdef _WIN32 - Overlay::AddOverlayElem([this]() { + Overlay::AddOverlayElem([this](bool window_has_focus) { ImGui::SetNextWindowPos({650, 450}, ImGuiCond_FirstUseEver); ImGui::SetNextWindowSizeConstraints({400, 270}, {1000, 1000}); ImGui::Begin("Controller Emulation"); diff --git a/GlosSITarget/Overlay.cpp b/GlosSITarget/Overlay.cpp index dc26fc6..d84a938 100644 --- a/GlosSITarget/Overlay.cpp +++ b/GlosSITarget/Overlay.cpp @@ -153,7 +153,7 @@ void Overlay::update() if (enabled_ || force_enable_) { window_.clear(sf::Color(0, 0, 0, 128)); // make window slightly dim screen with overlay std::ranges::for_each(OVERLAY_ELEMS_, [this](const auto& elem) { - elem.second(); + elem.second(window_.hasFocus()); }); // ImGui::ShowDemoWindow(); @@ -183,7 +183,7 @@ void Overlay::AddLog(const spdlog::details::log_msg& msg) LOG_MSGS_.push_back({.time = msg.time, .level = msg.level, .payload = msg.payload.data()}); } -int Overlay::AddOverlayElem(const std::function& elem_fn) +int Overlay::AddOverlayElem(const std::function& elem_fn) { OVERLAY_ELEMS_.insert({overlay_element_id_, elem_fn}); // keep this non confusing, but longer... diff --git a/GlosSITarget/Overlay.h b/GlosSITarget/Overlay.h index 5acf3bc..46cda4f 100644 --- a/GlosSITarget/Overlay.h +++ b/GlosSITarget/Overlay.h @@ -38,7 +38,7 @@ class Overlay { static void Shutdown(); static void AddLog(const spdlog::details::log_msg& msg); - static int AddOverlayElem(const std::function& elem_fn); + static int AddOverlayElem(const std::function& elem_fn); static void RemoveOverlayElem(int id); private: @@ -62,10 +62,9 @@ class Overlay { static constexpr int LOG_RETENTION_TIME_ = 5; static inline int overlay_element_id_ = 0; - static inline std::map> OVERLAY_ELEMS_; + static inline std::map> OVERLAY_ELEMS_; #ifdef _WIN32 std::string config_file_name_; #endif - }; diff --git a/GlosSITarget/ProcessPriority.h b/GlosSITarget/ProcessPriority.h index 972d60a..5357a77 100644 --- a/GlosSITarget/ProcessPriority.h +++ b/GlosSITarget/ProcessPriority.h @@ -7,14 +7,13 @@ namespace ProcessPriority { - static int current_priority = HIGH_PRIORITY_CLASS; inline void init() { - SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); + SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); - Overlay::AddOverlayElem([]() { + Overlay::AddOverlayElem([](bool window_has_focus) { ImGui::SetNextWindowPos({913, 418}, ImGuiCond_FirstUseEver); ImGui::SetNextWindowSizeConstraints({170, 325}, {1000, 1000}); ImGui::Begin("Process Priority"); @@ -45,7 +44,6 @@ inline void init() } ImGui::End(); }); - } -} +} // namespace ProcessPriority diff --git a/GlosSITarget/TargetWindow.cpp b/GlosSITarget/TargetWindow.cpp index 925bb6d..f2eb178 100644 --- a/GlosSITarget/TargetWindow.cpp +++ b/GlosSITarget/TargetWindow.cpp @@ -50,7 +50,7 @@ TargetWindow::TargetWindow( { createWindow(Settings::window.windowMode); - Overlay::AddOverlayElem([this]() { + Overlay::AddOverlayElem([this](bool window_has_focus) { bool windowed_copy = windowed_; ImGui::SetNextWindowPos({window_.getSize().x - 370.f, 100}, ImGuiCond_FirstUseEver); ImGui::Begin("Window mode"); diff --git a/GlosSITarget/UWPOverlayEnabler.h b/GlosSITarget/UWPOverlayEnabler.h index a53bd35..110b329 100644 --- a/GlosSITarget/UWPOverlayEnabler.h +++ b/GlosSITarget/UWPOverlayEnabler.h @@ -34,7 +34,7 @@ inline DWORD ExplorerPid() return 0; } -} +} // namespace internal inline void EnableUwpOverlay() { @@ -60,7 +60,7 @@ inline void EnableUwpOverlay() inline void AddUwpOverlayOvWidget() { - Overlay::AddOverlayElem([]() { + Overlay::AddOverlayElem([](bool window_has_focus) { ImGui::SetNextWindowPos({1200, 250}, ImGuiCond_FirstUseEver); ImGui::SetNextWindowSizeConstraints({170, 325}, {1000, 1000}); ImGui::SetNextWindowCollapsed(true, ImGuiCond_FirstUseEver); @@ -80,4 +80,4 @@ inline void AddUwpOverlayOvWidget() }); } -} \ No newline at end of file +} // namespace UWPOverlayEnabler \ No newline at end of file