2021-10-15 15:10:57 +00:00
|
|
|
/*
|
2022-01-06 23:38:21 +00:00
|
|
|
Copyright 2021-2022 Peter Repukat - FlatspotSoftware
|
2021-10-15 15:10:57 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
2021-10-14 18:54:29 +00:00
|
|
|
#pragma once
|
2021-10-15 13:02:36 +00:00
|
|
|
|
2021-10-21 17:58:58 +00:00
|
|
|
#include "SteamOverlayDetector.h"
|
2021-10-15 13:02:36 +00:00
|
|
|
|
2021-10-17 19:04:41 +00:00
|
|
|
#include "TargetWindow.h"
|
2021-10-16 20:36:30 +00:00
|
|
|
|
2021-10-20 19:47:24 +00:00
|
|
|
#ifdef _WIN32
|
2021-10-20 19:48:19 +00:00
|
|
|
#include "HidHide.h"
|
2021-10-20 19:47:24 +00:00
|
|
|
#include "InputRedirector.h"
|
2021-10-21 17:54:41 +00:00
|
|
|
#include <subhook.h>
|
2021-10-20 19:47:24 +00:00
|
|
|
#endif
|
|
|
|
|
2021-10-23 11:33:01 +00:00
|
|
|
#include "AppLauncher.h"
|
2021-10-22 10:17:46 +00:00
|
|
|
#include "Overlay.h"
|
|
|
|
|
2021-10-20 19:48:19 +00:00
|
|
|
#include <filesystem>
|
|
|
|
|
2021-10-15 15:10:57 +00:00
|
|
|
class SteamTarget {
|
|
|
|
public:
|
2022-07-13 20:53:57 +00:00
|
|
|
explicit SteamTarget();
|
2021-10-14 18:54:29 +00:00
|
|
|
int run();
|
2021-10-15 13:02:36 +00:00
|
|
|
|
2021-10-15 15:10:57 +00:00
|
|
|
private:
|
2021-10-17 01:47:20 +00:00
|
|
|
void onOverlayChanged(bool overlay_open);
|
2022-01-07 00:36:21 +00:00
|
|
|
void toggleGlossiOverlay();
|
2021-10-17 01:47:20 +00:00
|
|
|
void focusWindow(WindowHandle hndl);
|
2021-10-20 19:48:19 +00:00
|
|
|
std::filesystem::path getSteamPath() const;
|
|
|
|
std::wstring getSteamUserId() const;
|
2021-10-17 19:04:41 +00:00
|
|
|
|
2021-10-20 19:48:19 +00:00
|
|
|
std::filesystem::path steam_path_ = getSteamPath();
|
2021-10-17 19:04:41 +00:00
|
|
|
std::wstring steam_user_id_ = getSteamUserId();
|
|
|
|
|
2021-10-17 01:47:20 +00:00
|
|
|
std::vector<std::string> getOverlayHotkey();
|
2021-10-17 19:04:41 +00:00
|
|
|
std::vector<std::string> getScreenshotHotkey();
|
2021-10-23 00:27:31 +00:00
|
|
|
bool getXBCRebindingEnabled();
|
2021-10-17 01:47:20 +00:00
|
|
|
|
2021-10-22 16:07:08 +00:00
|
|
|
bool steam_overlay_present_ = false;
|
|
|
|
|
2021-10-17 19:04:41 +00:00
|
|
|
// Keep controllerConfig even is window is switched.
|
|
|
|
// On Windoze hooking "GetForeGroundWindow" is enough;
|
|
|
|
void keepControllerConfig(bool keep);
|
2021-10-21 17:54:41 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
static HWND keepFgWindowHookFn();
|
|
|
|
static inline subhook::Hook getFgWinHook;
|
2022-03-14 19:13:43 +00:00
|
|
|
static inline std::vector<HWND> force_config_hwnds_ = {};
|
|
|
|
static inline HWND last_real_hwnd_ = nullptr;
|
2021-10-21 17:54:41 +00:00
|
|
|
#endif
|
|
|
|
|
2021-10-17 16:20:16 +00:00
|
|
|
/*
|
|
|
|
* Run once per frame
|
|
|
|
* detects steam configured overlay hotkey, and simulates key presses to window
|
|
|
|
*
|
|
|
|
* actually opens the overlay, even if window is not currently focused.
|
|
|
|
*/
|
|
|
|
void overlayHotkeyWorkaround();
|
|
|
|
|
2021-10-15 13:02:36 +00:00
|
|
|
bool run_ = false;
|
2021-10-17 01:47:20 +00:00
|
|
|
std::vector<std::string> overlay_hotkey_ = getOverlayHotkey();
|
|
|
|
|
2021-10-20 19:48:19 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
HidHide hidhide_;
|
2021-10-17 21:41:15 +00:00
|
|
|
InputRedirector input_redirector_;
|
2021-10-20 19:48:19 +00:00
|
|
|
#endif
|
2021-10-15 13:02:36 +00:00
|
|
|
TargetWindow window_;
|
2021-10-28 11:38:16 +00:00
|
|
|
std::weak_ptr<Overlay> overlay_;
|
2021-10-21 17:58:58 +00:00
|
|
|
SteamOverlayDetector detector_;
|
2021-10-23 11:33:01 +00:00
|
|
|
AppLauncher launcher_;
|
2021-10-17 01:47:20 +00:00
|
|
|
WindowHandle last_foreground_window_ = nullptr;
|
2021-10-21 17:54:41 +00:00
|
|
|
static inline WindowHandle target_window_handle_ = nullptr;
|
2021-10-17 01:47:20 +00:00
|
|
|
|
2021-10-22 10:17:46 +00:00
|
|
|
sf::Clock overlay_trigger_clock_;
|
2022-01-07 00:01:29 +00:00
|
|
|
uint32_t overlay_trigger_max_seconds_ = 1;
|
2021-10-22 10:17:46 +00:00
|
|
|
bool overlay_trigger_flag_ = false;
|
|
|
|
|
2021-10-23 14:03:18 +00:00
|
|
|
bool delayed_shutdown_ = false;
|
|
|
|
sf::Clock delay_shutdown_clock_;
|
|
|
|
|
2021-10-17 01:47:20 +00:00
|
|
|
static constexpr std::wstring_view user_data_path_ = L"/userdata/";
|
|
|
|
static constexpr std::wstring_view config_file_name_ = L"/config/localconfig.vdf";
|
2021-10-17 19:04:41 +00:00
|
|
|
static constexpr std::string_view overlay_hotkey_name_ = "InGameOverlayShortcutKey ";
|
|
|
|
static constexpr std::string_view screenshot_hotkey_name_ = "InGameOverlayScreenshotHotKey ";
|
2021-10-14 18:54:29 +00:00
|
|
|
};
|