Skip to content

Commit

Permalink
Merge pull request #72 from mengmeet/dev
Browse files Browse the repository at this point in the history
检查 Steam 版本,显示插件内 TDP 控制组件 / Check the Steam version, to show the TDP control component within the plugin.
  • Loading branch information
honjow authored May 9, 2024
2 parents 0924caa + acd72c3 commit 180c973
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 6 deletions.
2 changes: 2 additions & 0 deletions backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
"7840U": 40,
"7640U": 30,
"7840": 45,
"7320U": 18,
"7520U": 18,
"8840U": 40,
"8840": 45,
"8850U": 40,
Expand Down
27 changes: 23 additions & 4 deletions src/components/cpu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ToggleField,
} from "decky-frontend-lib";
import { useEffect, useState, VFC } from "react";
import { Settings, Backend, PluginManager, ComponentName, UpdateType, GPUMODE, Patch } from "../util";
import { Settings, Backend, PluginManager, ComponentName, UpdateType, GPUMODE, Patch, SteamUtils } from "../util";
import { localizeStrEnum, localizationManager } from "../i18n";
import { SlowSliderField } from "./SlowSliderField"
import { CustomTDPComponent } from ".";
Expand Down Expand Up @@ -122,6 +122,11 @@ const CPUTDPComponent: VFC = () => {
const [customTDPRangeMax, setCustomTDPRangeMax] = useState<number>(Settings.appCustomTDPRangeMax());
const [customTDPRangeMin, setCustomTDPRangeMin] = useState<number>(Settings.appCustomTDPRangeMin());

// 隐藏强制显示TDP开关, 并默认显示 TDP 控制组件。新版 Steam 客户端临时方案
const [hideForceShowSwitch, setHideForceShowSwitch] = useState<boolean>(false);

const minSteamVersion = 1714854927;

const refresh = () => {
setTDPEnable(Settings.appTDPEnable());
setDisable(Settings.appGPUMode() == GPUMODE.AUTO);
Expand Down Expand Up @@ -150,10 +155,24 @@ const CPUTDPComponent: VFC = () => {
}
}
})

// 检查 Steam 客户端版本,如果版本大于等于 minSteamVersion。不显示强制 TDP 开关。并默认显示 TDP 控制组件
// 在解决 QAM 中 TDP 控制组件显示问题后,可以移除该逻辑
SteamUtils.getSystemInfo().then((systemInfo) => {
// json output
console.log(`>>>>>>>> System Info: ${JSON.stringify(systemInfo, null, 2)}`);
if (systemInfo.nSteamVersion >= minSteamVersion) {
setHideForceShowSwitch(true);
}
});
}, []);

const _showTdp = !PluginManager.isPatchSuccess(Patch.TDPPatch) || forceShow || hideForceShowSwitch;
console.log(`>>>>>>>> Hide Force Show Switch: ${hideForceShowSwitch}, Show TDP: ${_showTdp}`);

return (
<>
<PanelSectionRow>
{!hideForceShowSwitch && <PanelSectionRow>
<ToggleField
label={localizationManager.getString(localizeStrEnum.FORCE_SHOW_TDP)}
description={localizationManager.getString(localizeStrEnum.FORCE_SHOW_TDP_DESC)}
Expand All @@ -162,8 +181,8 @@ const CPUTDPComponent: VFC = () => {
Settings.setForceShowTDP(value);
}}
/>
</PanelSectionRow>
{!PluginManager.isPatchSuccess(Patch.TDPPatch) || forceShow &&
</PanelSectionRow>}
{_showTdp &&
<>
<PanelSectionRow>
<ToggleField
Expand Down
24 changes: 24 additions & 0 deletions src/util/steamClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,27 @@ declare global {
// @ts-ignore
let SteamClient: SteamClient;
}

export interface SystemInfo {
sOSName: string;
sKernelVersion: string;
sBIOSVersion: string;
sHostname: string;
sOSCodename: string;
sOSVariantId: string;
sOSVersionId: string;
sOSBuildId: string;
nSteamVersion: number;
sSteamBuildDate: string;
sSteamAPI: string;
sCPUVendor: string;
sCPUName: string;
nCPUHz: number;
nCPUPhysicalCores: number;
nCPULogicalCores: number;
nSystemRAMSizeMB: number;
sVideoCardName: string;
sVideoDriverVersion: string;
nVideoRAMSizeMB: number;
bIsUnsupportedPrototypeHardware: boolean;
}
9 changes: 7 additions & 2 deletions src/util/steamUtils.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Module, findModuleChild } from "decky-frontend-lib";
import { Backend } from ".";
import { Backend, SystemInfo } from ".";
import { ReactNode } from "react";
import { FaSuperpowers } from "react-icons/fa";

Expand Down Expand Up @@ -59,4 +59,9 @@ export class SteamUtils {
static async simpleToast(message: string, duration?: number) {
this.notify({ message, showToast: true, duration });
}
}
;
static async getSystemInfo() : Promise<SystemInfo> {
const systemInfo = await SteamClient.System.GetSystemInfo();
return systemInfo;
}
}

0 comments on commit 180c973

Please sign in to comment.