From 4e0d174fc96255507f5e5ed399695aeae868b981 Mon Sep 17 00:00:00 2001 From: davispuh Date: Mon, 27 Jun 2022 22:08:43 +0100 Subject: [PATCH] Fix Steam overlay for Linux --- CMakeLists.txt | 6 +++++- overlay_experimental/Renderer_Detector.cpp | 5 ++++- overlay_experimental/steam_overlay.cpp | 9 +++++++-- overlay_experimental/steam_overlay.h | 8 ++++---- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index abaace2..31b8767 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ endif() # Add option to enable experimental build option(EMU_EXPERIMENTAL_BUILD "Enable experimental build" OFF) +option(EMU_OVERLAY "Enable overlay support" OFF) # Set CXX standard set(CMAKE_CXX_STANDARD 14) @@ -86,6 +87,9 @@ if(WIN32) ImGui/impls/windows/*.cpp glew/glew.c ) + if(EMU_OVERLAY AND NOT EMU_EXPERIMENTAL_BUILD) + message(FATAL_ERROR "You need to enable experimental build to use overlay on Windows") + endif() elseif(UNIX) file(GLOB OVERLAY_EXPERIMENTAL_SRC_SHARED overlay_experimental/*.cpp @@ -105,7 +109,7 @@ endif() add_library(${LIB_STEAM_API} SHARED $<$:${DETOURS_SRC_SHARED}> - $<$,$>:${OVERLAY_EXPERIMENTAL_SRC_SHARED}> + $<$:${OVERLAY_EXPERIMENTAL_SRC_SHARED}> ${DLL_SRC_SHARED} ${PROTO_SRCS} ${PROTO_HDRS} diff --git a/overlay_experimental/Renderer_Detector.cpp b/overlay_experimental/Renderer_Detector.cpp index 41fd7cd..5824b15 100644 --- a/overlay_experimental/Renderer_Detector.cpp +++ b/overlay_experimental/Renderer_Detector.cpp @@ -783,10 +783,13 @@ void Renderer_Detector::renderer_found(Base_Hook* hook) game_renderer = hook; if (hook == nullptr) + { PRINT_DEBUG("We found a renderer but couldn't hook it, aborting overlay hook.\n"); + } else + { PRINT_DEBUG("Hooked renderer in %d/%d tries\n", _hook_retries, max_hook_retries); - + } hm.RemoveHook(rendererdetect_hook); } diff --git a/overlay_experimental/steam_overlay.cpp b/overlay_experimental/steam_overlay.cpp index 4002278..42e3f6c 100644 --- a/overlay_experimental/steam_overlay.cpp +++ b/overlay_experimental/steam_overlay.cpp @@ -17,6 +17,11 @@ static constexpr int base_notif_window_id = 0 * max_window_id; static constexpr int base_friend_window_id = 1 * max_window_id; static constexpr int base_friend_item_id = 2 * max_window_id; +std::chrono::milliseconds Notification::fade_in = std::chrono::milliseconds(2000); +std::chrono::milliseconds Notification::fade_out = std::chrono::milliseconds(2000); +std::chrono::milliseconds Notification::show_time = std::chrono::milliseconds(6000) + fade_in + fade_out; +std::chrono::milliseconds Notification::fade_out_start = show_time - fade_out; + int find_free_id(std::vector & ids, int base) { std::sort(ids.begin(), ids.end()); @@ -355,11 +360,11 @@ bool Steam_Overlay::FriendJoinable(std::pair { Steam_Friends* steamFriends = get_steam_client()->steam_friends; - if( std::string(steamFriends->GetFriendRichPresence(f.first.id(), "connect")).length() > 0 ) + if( std::string(steamFriends->GetFriendRichPresence((uint64)f.first.id(), "connect")).length() > 0 ) return true; FriendGameInfo_t friend_game_info = {}; - steamFriends->GetFriendGamePlayed(f.first.id(), &friend_game_info); + steamFriends->GetFriendGamePlayed((uint64)f.first.id(), &friend_game_info); if (friend_game_info.m_steamIDLobby.IsValid() && (f.second.window_state & window_state_lobby_invite)) return true; diff --git a/overlay_experimental/steam_overlay.h b/overlay_experimental/steam_overlay.h index d3b301e..8514ec9 100644 --- a/overlay_experimental/steam_overlay.h +++ b/overlay_experimental/steam_overlay.h @@ -54,10 +54,10 @@ struct Notification { static constexpr float width = 0.25; static constexpr float height = 5.0; - static constexpr std::chrono::milliseconds fade_in = std::chrono::milliseconds(2000); - static constexpr std::chrono::milliseconds fade_out = std::chrono::milliseconds(2000); - static constexpr std::chrono::milliseconds show_time = std::chrono::milliseconds(6000) + fade_in + fade_out; - static constexpr std::chrono::milliseconds fade_out_start = show_time - fade_out; + static std::chrono::milliseconds fade_in; + static std::chrono::milliseconds fade_out; + static std::chrono::milliseconds show_time; + static std::chrono::milliseconds fade_out_start; static constexpr float r = 0.16; static constexpr float g = 0.29; static constexpr float b = 0.48;