Support changing hideDevices from GlosSITarget

As well as initially enabling it
pull/183/head
Peter Repukat 2 years ago
parent 5ff02433db
commit a5f6d2d975

@ -68,12 +68,14 @@ void HidHide::closeCtrlDevice()
void HidHide::hideDevices(const std::filesystem::path& steam_path) void HidHide::hideDevices(const std::filesystem::path& steam_path)
{ {
steam_path_ = steam_path;
enableOverlayElement();
if (!Settings::devices.hideDevices) { if (!Settings::devices.hideDevices) {
spdlog::info("Hiding devices is disabled; Not un-patching valve hooks, not looking for HidHide"); spdlog::info("Hiding devices is disabled; Not un-patching valve hooks, not looking for HidHide");
return; return;
} }
spdlog::debug("Device hiding enabled;"); spdlog::debug("Setting up device hiding...");
UnPatchValveHooks(); UnPatchValveHooks();
@ -149,9 +151,9 @@ void HidHide::hideDevices(const std::filesystem::path& steam_path)
spdlog::trace(L"Blacklisted device: {}", dev); spdlog::trace(L"Blacklisted device: {}", dev);
}); });
} }
enableOverlayElement();
} }
closeCtrlDevice(); closeCtrlDevice();
device_hiding_setup_ = true;
} }
void HidHide::disableHidHide() void HidHide::disableHidHide()
@ -217,6 +219,7 @@ void HidHide::enableOverlayElement()
Overlay::AddOverlayElem([this](bool window_has_focus, ImGuiID dockspace_id) { Overlay::AddOverlayElem([this](bool window_has_focus, ImGuiID dockspace_id) {
ImGui::SetNextWindowDockID(dockspace_id, ImGuiCond_FirstUseEver); ImGui::SetNextWindowDockID(dockspace_id, ImGuiCond_FirstUseEver);
if (ImGui::Begin("Hidden Devices")) { if (ImGui::Begin("Hidden Devices")) {
if (device_hiding_setup_) {
if (window_has_focus && (overlay_elem_clock_.getElapsedTime().asSeconds() > OVERLAY_ELEM_REFRESH_INTERVAL_S_)) { if (window_has_focus && (overlay_elem_clock_.getElapsedTime().asSeconds() > OVERLAY_ELEM_REFRESH_INTERVAL_S_)) {
// UnPatchValveHooks(); // UnPatchValveHooks();
openCtrlDevice(); openCtrlDevice();
@ -234,7 +237,7 @@ void HidHide::enableOverlayElement()
}); });
} }
blacklisted_devices_ = getBlackListDevices(); blacklisted_devices_ = getBlackListDevices();
if (hidehide_state_store) { if (hidehide_state_store && Settings::devices.hideDevices) {
setActive(true); setActive(true);
} }
closeCtrlDevice(); closeCtrlDevice();
@ -273,12 +276,20 @@ void HidHide::enableOverlayElement()
} }
}); });
ImGui::EndChild(); ImGui::EndChild();
if (ImGui::Checkbox("Devices Hidden", &hidhide_active_)) { } else {
ImGui::Text("Enable \"Hide Devices\" to see a list of gaming-devices");
}
if (ImGui::Checkbox("Hide devices", &Settings::devices.hideDevices)) {
if (!device_hiding_setup_) {
hideDevices(steam_path_);
}
if (hidhide_active_ != Settings::devices.hideDevices) {
openCtrlDevice(); openCtrlDevice();
setActive(hidhide_active_); setActive(Settings::devices.hideDevices);
closeCtrlDevice(); closeCtrlDevice();
} }
} }
}
ImGui::End(); ImGui::End();
}); });
} }

@ -69,6 +69,10 @@ class HidHide {
private: private:
HANDLE hidhide_handle = nullptr; HANDLE hidhide_handle = nullptr;
std::filesystem::path steam_path_;
bool device_hiding_setup_ = false;
// Valve Hooks various functions and hides Gaming devices like this. // Valve Hooks various functions and hides Gaming devices like this.
// To be able to query them, unpatch the hook with the original bytes... // To be able to query them, unpatch the hook with the original bytes...
static inline const std::map<std::string, std::string> ORIGINAL_BYTES = { static inline const std::map<std::string, std::string> ORIGINAL_BYTES = {

Loading…
Cancel
Save