Compare commits

...

3 Commits

@ -169,7 +169,7 @@ namespace CEFInject
if (res->status == 200) { if (res->status == 200) {
const auto json = nlohmann::json::parse(res->body); const auto json = nlohmann::json::parse(res->body);
for (const auto& tab : json) { for (const auto& tab : json) {
if (tab["title"].get<std::wstring>().starts_with(tabname)) { if (tab["title"].get<std::wstring>().find(tabname) != std::string::npos) {
return InjectJs(tab["title"].get<std::string>(), tab["webSocketDebuggerUrl"].get<std::string>(), js, port); return InjectJs(tab["title"].get<std::string>(), tab["webSocketDebuggerUrl"].get<std::string>(), js, port);
} }
} }
@ -213,7 +213,7 @@ namespace CEFInject
return [&info](const nlohmann::json::array_t& tabList) return [&info](const nlohmann::json::array_t& tabList)
{ {
for (const auto& tab : tabList) { for (const auto& tab : tabList) {
if (tab["title"].get<std::string>().starts_with(info.name.data())) { if (tab["title"].get<std::string>().find(info.name.data()) != std::string::npos) {
return tab; return tab;
} }
} }
@ -347,7 +347,7 @@ namespace CEFInject
const auto dir_name = path.parent_path().filename(); const auto dir_name = path.parent_path().filename();
if (path_tab_map_.contains(dir_name.wstring())) { if (path_tab_map_.contains(dir_name.wstring())) {
if (tab["title"].get<std::string>().starts_with(path_tab_map_.at(dir_name.wstring()))) { if (tab["title"].get<std::string>().find(path_tab_map_.at(dir_name.wstring())) != std::string::npos) {
InjectJs(tab["title"].get<std::string>(), tab["webSocketDebuggerUrl"].get<std::string>(), js); InjectJs(tab["title"].get<std::string>(), tab["webSocketDebuggerUrl"].get<std::string>(), js);
} }
} }

@ -76,6 +76,7 @@ namespace CEFInject
static inline const std::map<path_name, tab_name> path_tab_map_ = { static inline const std::map<path_name, tab_name> path_tab_map_ = {
{L"SharedContext", "Steam Shared Context"}, {L"SharedContext", "Steam Shared Context"},
{L"Overlay", "HOW TF GET OVERLAY TAB NAME?"}, // TODO: Figure out how to get the overlay tab name {L"Overlay", "HOW TF GET OVERLAY TAB NAME?"}, // TODO: Figure out how to get the overlay tab name
{L"GamepadUI", "Steam Big Picture Mode"},
}; };
static constexpr std::string_view steam_shared_ctx_tab_name_ = "Steam Shared Context"; static constexpr std::string_view steam_shared_ctx_tab_name_ = "Steam Shared Context";

@ -403,7 +403,8 @@ QVariantMap UIModel::getDefaultConf() const
{"steamUserId", {"steamUserId",
QJsonValue::fromVariant(QString::fromStdWString(getSteamUserId(false)))}, QJsonValue::fromVariant(QString::fromStdWString(getSteamUserId(false)))},
{"globalModeGameId", ""}, {"globalModeGameId", ""},
{"globalModeUseGamepadUI", false}, {"globalModeUseGamepadUI", true},
{"minimizeSteamGamepadUI", true},
{"controller", QJsonObject{{"maxControllers", -1}, {"emulateDS4", false}, {"allowDesktopConfig", false}}}, {"controller", QJsonObject{{"maxControllers", -1}, {"emulateDS4", false}, {"allowDesktopConfig", false}}},
{"devices", {"devices",
QJsonObject{ QJsonObject{

@ -0,0 +1,44 @@
export interface GlosSISettings {
controller: {
allowDesktopConfig: boolean;
emulateDS4: boolean;
maxControllers: number;
};
devices: {
hideDevices: boolean;
realDeviceIds: boolean;
};
extendedLogging: boolean;
globalModeGameId: string;
globalModeUseGamepadUI: boolean;
icon?: string;
ignoreEGS: boolean;
killEGS: boolean;
launch: {
closeOnExit: boolean;
ignoreLauncher: boolean;
killLauncher: boolean;
launch: boolean;
launchAppArgs?: string;
launchPath?: string;
launcherProcesses: string[];
waitForChildProcs: boolean;
};
name?: string;
snapshotNotify: boolean;
standaloneModeGameId: string;
standaloneUseGamepadUI: boolean;
minimizeSteamGamepadUI: boolean;
steamPath: string;
steamUserId: string;
steamgridApiKey: string;
version: number;
window: {
disableGlosSIOverlay: boolean;
disableOverlay: boolean;
hideAltTab: boolean;
maxFps?: number;
scale?: number;
windowMode: boolean;
};
}

@ -3,8 +3,18 @@ export interface SteamClient {
SetInGameOverlayShowFPSCorner: (value: 0|1|2|3|4) => void; SetInGameOverlayShowFPSCorner: (value: 0|1|2|3|4) => void;
SetInGameOverlayShowFPSContrast: (value: boolean) => void; SetInGameOverlayShowFPSContrast: (value: boolean) => void;
}; };
UI: {
GetUiMode: () => Promise<SteamUiMode>;
SetUiMode: (mode: SteamUiMode) => void;
};
Window: {
Minimize();
HideWindow();
};
} }
export type FullSteamClient = Required<SteamClient>;
declare global { declare global {
interface Window { interface Window {
SteamClient: SteamClient; SteamClient: SteamClient;

@ -1,9 +1,15 @@
import type { SteamConfig } from './common/util/types'; import type { SteamConfig } from './common/util/types';
import { fetchWithTimeout } from './common/util/util'; import { fetchWithTimeout } from './common/util/util';
import type { GlosSISettings } from './@types/GlosSISettings';
class SteamTargetApi { class SteamTargetApi {
public getGlosSIActive() {
return fetchWithTimeout('http://localhost:8756/', { timeout: 500 })
.then(
() => true
).catch(() => false);
}
public getSteamSettings(): Promise<SteamConfig> { public getSteamSettings(): Promise<SteamConfig> {
return fetch('http://localhost:8756/steam_settings') return fetch('http://localhost:8756/steam_settings')
.then( .then(
@ -13,12 +19,15 @@ class SteamTargetApi {
); );
} }
public getGlosSIActive() { public getGlosSISettings() {
return fetchWithTimeout('http://localhost:8756/', { timeout: 10000 }) return fetch('http://localhost:8756/settings')
.then( .then(
() => true (res) => res.json().then(
).catch((e) => false); (json) => json as GlosSISettings
)
);
} }
} }
@ -27,18 +36,19 @@ class GlosSIApiCtor {
} }
interface GlosSITweaks { interface GlosSITweaks {
[tweakName: string]: { readonly install: () => unknown; readonly uninstall?: () => void } [tweakName: string]: { readonly install: () => unknown; readonly uninstall?: () => void };
} }
declare global { declare global {
interface Window { interface Window {
GlosSITweaks: GlosSITweaks GlosSITweaks: GlosSITweaks;
GlosSIApi: InstanceType<typeof GlosSIApiCtor>; GlosSIApi: InstanceType<typeof GlosSIApiCtor>;
} }
// eslint-disable-next-line // eslint-disable-next-line
const GlosSIApi: InstanceType<typeof GlosSIApiCtor>; const GlosSIApi: InstanceType<typeof GlosSIApiCtor>;
const GlosSITweaks: GlosSITweaks // eslint-disable-next-line
const GlosSITweaks: GlosSITweaks;
} }
@ -51,7 +61,7 @@ const installGlosSIApi = () => {
}, },
uninstall: () => { uninstall: () => {
Object.entries(window.GlosSITweaks) Object.entries(window.GlosSITweaks)
.filter(([tweakName, obj]) => (tweakName !== 'GlosSI')) .filter(([tweakName]) => (tweakName !== 'GlosSI'))
.forEach(([, obj]) => obj.uninstall?.()); .forEach(([, obj]) => obj.uninstall?.());
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // @ts-ignore
@ -66,15 +76,15 @@ const installGlosSIApi = () => {
const glossiCheckInterval = setInterval(() => { const glossiCheckInterval = setInterval(() => {
if (window.GlosSIApi) { if (window.GlosSIApi) {
window.GlosSIApi.SteamTarget.getGlosSIActive().then((active) => { void window.GlosSIApi.SteamTarget.getGlosSIActive().then((active) => {
if (!active) { if (!active) {
window?.GlosSITweaks?.GlosSI?.uninstall?.(); window?.GlosSITweaks?.GlosSI?.uninstall?.();
} }
}); });
return; return;
} }
clearTimeout(glossiCheckInterval) clearTimeout(glossiCheckInterval);
}, 5000) }, 5000);
}; };

@ -0,0 +1,21 @@
import { SteamUiMode } from '../../common/Steam';
import { initTweak } from '../../common/tweakApi';
initTweak('MinimizeSteamGamepadUI', async () => {
const [isGamepadUI, minimizeGPUI] = await Promise.all([
(async () => (await SteamClient.UI.GetUiMode()) === SteamUiMode.GamepadUI)(),
(async () => (await GlosSIApi.SteamTarget.getGlosSISettings()).minimizeSteamGamepadUI)()
]);
if (isGamepadUI && minimizeGPUI) {
SteamClient.Window.Minimize();
return true;
}
if (!isGamepadUI && minimizeGPUI) {
console.warn('MinimizeSteamGamepadUI is enabled but Steam is not in GamepadUI mode');
}
return false;
}).then((minimized: boolean) => {
console.log('MinimizeSteamGamepadUI installed; Minimized GamepadUI:', minimized);
}).catch((e) => console.error('MinimizeSteamGamepadUI failed to install', e));

@ -1,6 +1,5 @@
import type { SteamConfig } from '../../../common/util/types';
import type { SteamConfig } from "../../../common/util/types"; import { initTweak } from '../../../common/tweakApi';
import { initTweak } from "../../../common/tweakApi";
const backup: { originalFpsCorner?: number } = {}; const backup: { originalFpsCorner?: number } = {};
@ -20,4 +19,6 @@ initTweak('HideFPSCounter', {
SteamClient.Settings.SetInGameOverlayShowFPSCorner((backup.originalFpsCorner ?? 0) as 0 | 1 | 2 | 3 | 4); SteamClient.Settings.SetInGameOverlayShowFPSCorner((backup.originalFpsCorner ?? 0) as 0 | 1 | 2 | 3 | 4);
}, 10 * 1000); }, 10 * 1000);
} }
}); }).then(() => {
console.log('HideFPSCounter installed');
}).catch((e) => console.error('HideFPSCounter failed to install', e));

@ -0,0 +1,8 @@
// eslint-disable-next-line no-shadow
export enum SteamUiMode {
Desktop = 0,
Unknown1 = 1,
Unknown2 = 2,
Unknown3 = 3,
GamepadUI = 4,
}

@ -2,9 +2,9 @@
export const initTweak = <T>(name: string, tweakMain: (() => T)|{ export const initTweak = <T>(name: string, tweakMain: (() => T)|{
install: () => T; install: () => T;
uninstall: () => void; uninstall: () => void;
}, force = false): T|Error => { }, force = false): T => {
if (!force && window.GlosSITweaks[name]) { if (!force && window.GlosSITweaks[name]) {
return new Error(`Tweak ${name} is already installed!`); throw new Error(`Tweak ${name} is already installed!`);
} }
if (typeof tweakMain === 'object') { if (typeof tweakMain === 'object') {

@ -1,12 +1,12 @@
export const fetchWithTimeout = async (input: RequestInfo | URL, init?: RequestInit & { timeout: number }) => { export const fetchWithTimeout = async (input: RequestInfo | URL, init?: RequestInit & { timeout: number }) => {
const { timeout = 8000 } = init || {}; const { timeout = 8000 } = init || {};
const controller = new AbortController(); const controller = new AbortController();
const id = setTimeout(() => controller.abort(), timeout); const id = setTimeout(() => controller.abort(), timeout);
const response = await fetch(input, { const response = await fetch(input, {
...(init ||{}), ...(init ||{}),
signal: controller.signal signal: controller.signal
}); });
clearTimeout(id); clearTimeout(id);
return response; return response;
} };

@ -83,6 +83,7 @@ namespace Settings
std::wstring globalModeGameId; /* = L"12605636929694728192"; */ std::wstring globalModeGameId; /* = L"12605636929694728192"; */
bool globalModeUseGamepadUI = false; bool globalModeUseGamepadUI = false;
bool allowGlobalMode = true; bool allowGlobalMode = true;
bool minimizeSteam = true;
} common; } common;
inline const std::map<std::wstring, std::function<void()>> cmd_args = { inline const std::map<std::wstring, std::function<void()>> cmd_args = {
@ -235,6 +236,7 @@ namespace Settings
safeParseValue(json, "globalModeGameId", common.globalModeGameId); safeParseValue(json, "globalModeGameId", common.globalModeGameId);
safeParseValue(json, "globalModeUseGamepadUI", common.globalModeUseGamepadUI); safeParseValue(json, "globalModeUseGamepadUI", common.globalModeUseGamepadUI);
safeParseValue(json, "minimizeSteam", common.minimizeSteam);
} }
catch (const nlohmann::json::exception &e) catch (const nlohmann::json::exception &e)
{ {

Loading…
Cancel
Save