Skip to content

Commit 1dd3089

Browse files
committed
新增最大帧率菜单。
1 parent c7aaa15 commit 1dd3089

6 files changed

Lines changed: 150 additions & 29 deletions

File tree

HelpForm.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,11 @@ private static string GetHelpHtml_ZH(Version version) {
151151
<h2>📦 OmenSuperHub v{Assembly.GetExecutingAssembly().GetName().Version} 更新说明</h2>
152152
<div class='update-list'>
153153
<p><strong>新增:</strong></p>
154-
<li>✨ 浮窗显示功能支持多显示器,新增显示器选择菜单</li>
155-
<li>✨ 风扇配置菜单添加高温自动保护选项,控制是否在温度过高时取消固定转速</li>
156-
<li>✨ 将硬件监控设置纳入自定义预设控制范围</li>
154+
<li>✨ 新增最大帧率菜单,0~1000 FPS可调</li>
157155
<p><strong>优化:</strong></p>
158-
<li>⚡ 将浮窗显示的字号设置改为滑块操作并扩展上限至72号</li>
159-
<li>⚡ 使用WebBrowser美化帮助页面</li>
156+
<li>⚡ 关闭帮助页面后释放内存占用</li>
160157
<p><strong>修复:</strong></p>
161-
<li>🐛 切换语言后菜单状态重置为默认值的问题</li>
162-
<li>🐛 本机信息中显卡列表可能识别到虚拟显示器的问题</li>
158+
<li>🐛 帮助页面打开时触发弹窗将导致卡死的问题</li>
163159
</div>
164160
165161
<p>本项目已开源至 Github:<a href='https://github.com/breadeding/OmenSuperHub'>https://github.com/breadeding/OmenSuperHub</a></p>

Program.Config.cs

Lines changed: 78 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,55 @@
44
using System.IO;
55
using System.Linq;
66
using System.Threading;
7+
using HP.Omen.Core.Common.NVidiaApi;
78
using Microsoft.Win32;
89
using Microsoft.Win32.TaskScheduler;
9-
using Newtonsoft.Json.Linq;
1010
using static OmenSuperHub.GpuAppManager;
1111
using static OmenSuperHub.OmenHardware;
1212

1313
namespace OmenSuperHub {
1414
static partial class Program {
15+
private static List<int> frameRateMap = new List<int>();
16+
17+
private static void InitFrameRateMap() {
18+
frameRateMap.Clear();
19+
20+
frameRateMap.Add(0); // index 0 = 0
21+
22+
for (int v = 1; v <= 5; v += 1)
23+
frameRateMap.Add(v);
24+
25+
for (int v = 5; v <= 60; v += 5)
26+
frameRateMap.Add(v);
27+
28+
for (int v = 60; v <= 240; v += 10)
29+
frameRateMap.Add(v);
30+
31+
for (int v = 240; v <= 1000; v += 20)
32+
frameRateMap.Add(v);
33+
}
34+
35+
private static int IndexToFrameRate(int index) {
36+
if (index < 0) return 0;
37+
if (index >= frameRateMap.Count) return frameRateMap[frameRateMap.Count - 1];
38+
return frameRateMap[index];
39+
}
40+
41+
private static int FrameRateToIndex(int value) {
42+
int bestIndex = 0;
43+
int bestDiff = int.MaxValue;
44+
45+
for (int i = 0; i < frameRateMap.Count; i++) {
46+
int diff = Math.Abs(frameRateMap[i] - value);
47+
if (diff < bestDiff) {
48+
bestDiff = diff;
49+
bestIndex = i;
50+
}
51+
}
52+
53+
return bestIndex;
54+
}
55+
1556
/// <summary>
1657
/// 获取当前系统 UI 语言对应的语言代码(zh-CN / zh-TW / en)
1758
/// 若无法匹配,返回 "en"
@@ -520,6 +561,7 @@ static void SaveConfig(string configName = null) {
520561
key.SetValue("DState", dState);
521562
if (hasNVIDIAGpu) {
522563
key.SetValue("GpuClock", gpuClock);
564+
key.SetValue("MaxFrameRate", maxFrameRate);
523565
key.SetValue("DBVersion", DBVersion);
524566
}
525567
key.SetValue("AutoStart", autoStart);
@@ -581,6 +623,9 @@ static void SaveConfig(string configName = null) {
581623
case "GpuClock":
582624
key.SetValue("GpuClock", gpuClock);
583625
break;
626+
case "MaxFrameRate":
627+
key.SetValue("MaxFrameRate", maxFrameRate);
628+
break;
584629
case "DBVersion":
585630
key.SetValue("DBVersion", DBVersion);
586631
break;
@@ -645,7 +690,7 @@ static void SaveConfig(string configName = null) {
645690
key.SetValue("AutoFanProtect", autoFanProtect);
646691
break;
647692
}
648-
if (configName == "FanTable" || configName == "FanControl" || configName == "TempSensitivity" || configName == "CpuPower" || configName == "TgpPower" || configName == "PpabPower" || configName == "DState" || configName == "GpuClock" || configName == "TppPower" || configName == "IccMax" || configName == "AcLoadLine" ||
693+
if (configName == "FanTable" || configName == "FanControl" || configName == "TempSensitivity" || configName == "CpuPower" || configName == "TgpPower" || configName == "PpabPower" || configName == "DState" || configName == "GpuClock" || configName == "MaxFrameRate" || configName == "TppPower" || configName == "IccMax" || configName == "AcLoadLine" ||
649694
configName == "MonitorCPU" || configName == "MonitorGPU" || configName == "MonitorFan" || configName == "MonitorRefreshRate" || configName == "TempDisplayMode") {
650695
SavePresetToRegistry(currentPreset);
651696
}
@@ -670,6 +715,7 @@ static void SavePresetToRegistry(string presetKey) {
670715
key.SetValue("PpabPower", ppabPower);
671716
key.SetValue("DState", dState);
672717
key.SetValue("GpuClock", gpuClock);
718+
key.SetValue("MaxFrameRate", maxFrameRate);
673719
key.SetValue("TppPower", tppPower);
674720
key.SetValue("IccMax", iccMax);
675721
key.SetValue("AcLoadLine", acLoadline);
@@ -697,6 +743,7 @@ static void LoadPresetFromRegistry(string presetKey) {
697743
ppabPower = (string)key.GetValue("PpabPower", ppabPower);
698744
dState = (string)key.GetValue("DState", dState);
699745
gpuClock = (int)key.GetValue("GpuClock", gpuClock);
746+
maxFrameRate = (int)key.GetValue("MaxFrameRate", maxFrameRate);
700747
tppPower = (string)key.GetValue("TppPower", tppPower);
701748
iccMax = (string)key.GetValue("IccMax", iccMax);
702749
acLoadline = (string)key.GetValue("AcLoadLine", acLoadline);
@@ -751,6 +798,7 @@ static void RestoreConfig(bool isPreset = false) {
751798
ppabPower = (string)key.GetValue("PpabPower", "on");
752799
dState = (string)key.GetValue("DState", "normal");
753800
gpuClock = (int)key.GetValue("GpuClock", 0);
801+
maxFrameRate = (int)key.GetValue("MaxFrameRate", -1);
754802
tppPower = (string)key.GetValue("TppPower", "null");
755803
iccMax = (string)key.GetValue("IccMax", "null");
756804
acLoadline = (string)key.GetValue("AcLoadLine", "null");
@@ -893,15 +941,32 @@ static void RestoreConfig(bool isPreset = false) {
893941
UpdateCheckedState("dStateGroup", dState == "normal" ? Strings.Normal : Strings.LowPower);
894942

895943
if (hasNVIDIAGpu) {
896-
if (SetGPUClockLimit(gpuClock)) {
897-
if (gpuClock > 0 && gpuClockTrackBar != null) {
898-
gpuClockTrackBar.Value = gpuClock / 10;
899-
UpdateCheckedState("gpuClockGroup", Strings.SetGpuClockSlider);
900-
} else if (gpuClock == 0) {
901-
UpdateCheckedState("gpuClockGroup", Strings.Restore);
944+
if (gpuClockTrackBar != null) {
945+
if (SetGPUClockLimit(gpuClock)) {
946+
if (gpuClock > 0) {
947+
gpuClockTrackBar.Value = gpuClock / 10;
948+
UpdateCheckedState("gpuClockGroup", Strings.SetGpuClockSlider);
949+
} else if (gpuClock == 0) {
950+
UpdateCheckedState("gpuClockGroup", Strings.Unlimited);
951+
}
952+
} else {
953+
UpdateCheckedState("gpuClockGroup", Strings.Unlimited);
954+
}
955+
}
956+
957+
if (maxFrameRateTrackBar != null) {
958+
if (maxFrameRate > 0) {
959+
NvApiWrapper.NVAPI_SetMaxFrameRate(maxFrameRate);
960+
maxFrameRateTrackBar.Value = FrameRateToIndex(maxFrameRate);
961+
UpdateCheckedState("maxFrameRateGroup", Strings.SetMaxFrameRateSlider);
962+
} else if (maxFrameRate == 0) {
963+
NvApiWrapper.NVAPI_SetMaxFrameRate(0);
964+
maxFrameRateTrackBar.Value = FrameRateToIndex(NvApiWrapper.NVAPI_GetMaxFrameRate());
965+
UpdateCheckedState("maxFrameRateGroup", Strings.Unlimited);
966+
} else {
967+
maxFrameRateTrackBar.Value = FrameRateToIndex(NvApiWrapper.NVAPI_GetMaxFrameRate());
968+
UpdateCheckedState("maxFrameRateGroup", Strings.NotSet);
902969
}
903-
} else {
904-
UpdateCheckedState("gpuClockGroup", Strings.Restore);
905970
}
906971

907972
if (DBMenu.Enabled && !isPreset) {
@@ -1137,16 +1202,19 @@ static void applyPresetLogic(string targetPreset) {
11371202
if (targetPreset == "PresetExtreme") {
11381203
cpuPower = $"{targetPL1Perf} W";
11391204
tppPower = $"{targetPL1Perf} W";
1205+
maxFrameRate = 0;
11401206
} else if (targetPreset == "PresetGpuPriority") {
11411207
cpuPower = $"{targetPL1Default} W";
11421208
tppPower = $"{targetPL1Perf} W";
1209+
maxFrameRate = 0;
11431210
} else if (targetPreset == "PresetLightUse") {
11441211
fanTable = "silent";
11451212
cpuPower = $"{(int)(targetPL1Default * 0.6)} W";
11461213
if (currentPreset == "PresetLightUse" && platformSettings?.NbPL1UpperBoundDefault == null) cpuPower = "30 W";
11471214
tppPower = "null";
11481215
tgpPower = "off";
11491216
ppabPower = "off";
1217+
maxFrameRate = 60;
11501218
}
11511219
} else {
11521220
LoadPresetFromRegistry(targetPreset);

Program.Menu.cs

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ void attachRename(ToolStripMenuItem item, string presetKey) {
670670
performanceControlMenu.DropDownItems.Add(gpuPowerMenu);
671671
if (hasNVIDIAGpu) {
672672
ToolStripMenuItem gpuClockMenu = new ToolStripMenuItem(Strings.GpuClockMenu);
673-
gpuClockMenu.DropDownItems.Add(CreateMenuItem(Strings.Restore, "gpuClockGroup", (s, e) => {
673+
gpuClockMenu.DropDownItems.Add(CreateMenuItem(Strings.Unlimited, "gpuClockGroup", (s, e) => {
674674
gpuClock = 0;
675675
SetGPUClockLimit(gpuClock);
676676
SaveConfig("GpuClock");
@@ -685,9 +685,17 @@ void attachRename(ToolStripMenuItem item, string presetKey) {
685685

686686
gpuClockValueLabel = new ToolStripMenuItem(string.Format(Strings.CurrentSliderValueTemp, $"{gpuClockTrackBar.Value * 10} MHz")) { Enabled = false };
687687

688+
gpuClockTrackBar.MouseDown += (sender, e) => {
689+
gpuClock = gpuClockTrackBar.Value * 10;
690+
SetGPUClockLimit(gpuClock);
691+
SaveConfig("GpuClock");
692+
UpdateCheckedState("gpuClockGroup", Strings.SetGpuClockSlider);
693+
};
694+
688695
gpuClockTrackBar.ValueChanged += (sender, e) => {
696+
gpuClock = gpuClockTrackBar.Value * 10;
689697
gpuClockValueLabel.Text = string.Format(Strings.CurrentSliderValueTemp, $"{gpuClockTrackBar.Value * 10} MHz");
690-
UpdateCheckedState("gpuClockGroup", Strings.SetGpuClockSlider);
698+
SaveConfig("GpuClock");
691699
};
692700

693701
gpuClockTrackBar.MouseUp += (sender, e) => {
@@ -700,6 +708,53 @@ void attachRename(ToolStripMenuItem item, string presetKey) {
700708
gpuClockMenu.DropDownItems.Add(gpuClockTrackBar);
701709
gpuClockMenu.DropDownItems.Add(gpuClockValueLabel);
702710
performanceControlMenu.DropDownItems.Add(gpuClockMenu);
711+
712+
InitFrameRateMap();
713+
ToolStripMenuItem maxFrameRateMenu = new ToolStripMenuItem(Strings.MaxFrameRateMenu);
714+
maxFrameRateMenu.DropDownItems.Add(CreateMenuItem(Strings.NotSet, "maxFrameRateGroup", (s, e) => {
715+
maxFrameRate = -1;
716+
NvApiWrapper.NVAPI_SetMaxFrameRate(0);
717+
SaveConfig("MaxFrameRate");
718+
}, true));
719+
maxFrameRateMenu.DropDownItems.Add(CreateMenuItem(Strings.Unlimited, "maxFrameRateGroup", (s, e) => {
720+
maxFrameRate = 0;
721+
NvApiWrapper.NVAPI_SetMaxFrameRate(maxFrameRate);
722+
SaveConfig("MaxFrameRate");
723+
}, false));
724+
maxFrameRateMenu.DropDownItems.Add(CreateMenuItem(Strings.SetMaxFrameRateSlider, "maxFrameRateGroup", (s, e) => { }, false));
725+
maxFrameRateTrackBar = new ToolStripTrackBar();
726+
maxFrameRateTrackBar.Minimum = 0;
727+
maxFrameRateTrackBar.Maximum = frameRateMap.Count - 1;
728+
maxFrameRateTrackBar.Value = maxFrameRateTrackBar.Maximum;
729+
maxFrameRateTrackBar.TickFrequency = maxFrameRateTrackBar.Maximum - maxFrameRateTrackBar.Minimum;
730+
maxFrameRateTrackBar.Width = 800;
731+
732+
maxFrameRateValueLabel = new ToolStripMenuItem(string.Format(Strings.CurrentSliderValueTemp, $"{IndexToFrameRate(maxFrameRateTrackBar.Value)} FPS")) { Enabled = false };
733+
734+
maxFrameRateTrackBar.MouseDown += (sender, e) => {
735+
maxFrameRate = IndexToFrameRate(maxFrameRateTrackBar.Value);
736+
NvApiWrapper.NVAPI_SetMaxFrameRate(maxFrameRate);
737+
SaveConfig("MaxFrameRate");
738+
UpdateCheckedState("maxFrameRateGroup", Strings.SetMaxFrameRateSlider);
739+
};
740+
741+
maxFrameRateTrackBar.ValueChanged += (sender, e) => {
742+
maxFrameRate = IndexToFrameRate(maxFrameRateTrackBar.Value);
743+
maxFrameRateValueLabel.Text = string.Format(Strings.CurrentSliderValueTemp, $"{IndexToFrameRate(maxFrameRateTrackBar.Value)} FPS");
744+
SaveConfig("MaxFrameRate");
745+
};
746+
747+
maxFrameRateTrackBar.MouseUp += (sender, e) => {
748+
maxFrameRate = IndexToFrameRate(maxFrameRateTrackBar.Value);
749+
NvApiWrapper.NVAPI_SetMaxFrameRate(maxFrameRate);
750+
SaveConfig("MaxFrameRate");
751+
UpdateCheckedState("maxFrameRateGroup", Strings.SetMaxFrameRateSlider);
752+
};
753+
754+
maxFrameRateMenu.DropDownItems.Add(maxFrameRateTrackBar);
755+
maxFrameRateMenu.DropDownItems.Add(maxFrameRateValueLabel);
756+
performanceControlMenu.DropDownItems.Add(maxFrameRateMenu);
757+
703758
DBMenu = new ToolStripMenuItem(Strings.DbVersionMenu);
704759
if (platformSettings != null && platformSettings.TppSupport) {
705760
DBMenu.DropDownItems.Add(new ToolStripMenuItem(Strings.PerfDbTip) { Enabled = false });

Program.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Threading;
1414
using System.Windows.Forms;
1515
using Hp.Bridge.Client.SDKs.PerformanceControl.DataStructure;
16+
using HP.Omen.Core.Common.NVidiaApi;
1617
using HP.Omen.Core.Model.Device.Enums;
1718
using HP.Omen.Core.Model.Device.Models;
1819
using Microsoft.Win32;
@@ -47,7 +48,7 @@ static partial class Program {
4748
static int DBVersion = 2, countDB = 0, countDBInit = 5, tryTimes = 0, CPULimitDB = 25;
4849
static ToolStripMenuItem DBMenu;
4950
static int textSize = 40;
50-
static int countRestore = 0, gpuClock = 0;
51+
static int countRestore = 0, gpuClock = 0, maxFrameRate = -1;
5152
static int alreadyRead = 0, alreadyReadCode = 1000;
5253
static string currentPreset = "PresetCustom1", presetCustom1Name = Strings.PresetCustom1, presetCustom2Name = Strings.PresetCustom2, presetCustom3Name = Strings.PresetCustom3;
5354
static string fanTable = "cool", fanControl = "auto", tempSensitivity = "high", tppPower = "null", iccMax = "null", acLoadline = "null", cpuPower = "null", tgpPower = "on", ppabPower = "on", dState = "normal", autoStart = "off", customIcon = "original", floatingBar = "off", floatingBarLoc = "left", floatingBarScreen = "", omenKey = "default", dataLocalize = "off", appLanguage = "zh-CN", autoFanProtect = "on";
@@ -87,8 +88,8 @@ static partial class Program {
8788
static ToolStripMenuItem ambientSensorMenu;
8889
static ToolStripMenuItem pchSensorMenu;
8990
static ToolStripMenuItem vrSensorMenu;
90-
static ToolStripTrackBar fanTrackBar, cpuPowerTrackBar, tppTrackBar, gpuClockTrackBar, textSizeTrackBar;
91-
static ToolStripMenuItem fanValueLabel, cpuPowerValueLabel, tppValueLabel, gpuClockValueLabel, textSizeLabel;
91+
static ToolStripTrackBar fanTrackBar, cpuPowerTrackBar, tppTrackBar, gpuClockTrackBar, maxFrameRateTrackBar, textSizeTrackBar;
92+
static ToolStripMenuItem fanValueLabel, cpuPowerValueLabel, tppValueLabel, gpuClockValueLabel, maxFrameRateValueLabel, textSizeLabel;
9293

9394
static bool Is3FanNb = false, isFanCleanSupported = false, isFanLegacyCleanSupported = false;
9495
static bool isSysInfoMenuOpen = false;
@@ -193,8 +194,10 @@ static void Main(string[] args) {
193194
NvGraphicsMode = GetGfxMode();
194195
hasAMDDiscreteGpu = HasAmdDiscreteGpu();
195196
hasNVIDIAGpu = HasNvidiaGpu();
196-
if (hasNVIDIAGpu && (NvGraphicsMode == GraphicsSwitcherMode.Hybrid || NvGraphicsMode == GraphicsSwitcherMode.Optimus))
197+
if (hasNVIDIAGpu) {
197198
ExtractAndPreloadNativeDll("NvidiaApi.dll");
199+
maxFrameRate = NvApiWrapper.NVAPI_GetMaxFrameRate();
200+
}
198201
// 固定为释放全部性能模式
199202
SetUnleashMode();
200203
Is3FanNb = IsThreeFanSupported();
@@ -260,9 +263,6 @@ static void Main(string[] args) {
260263
//trayIcon.BalloonTipIcon = ToolTipIcon.Warning;
261264
//trayIcon.ShowBalloonTip(3000);
262265

263-
//int setRet = NvApiWrapper.NVAPI_SetMaxFrameRate(0); // 0 success
264-
//Console.WriteLine($"GetMaxFrameRate: {NvApiWrapper.NVAPI_GetMaxFrameRate()}");
265-
266266
//Console.WriteLine($"DeviceType: {deviceType}");
267267
//Console.WriteLine($"PlatformSku: {sku}");
268268
//Console.WriteLine($"TppMaxValue: {platformSettings.TppMaxValue}");

Properties/AssemblyVersion.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
using System.Reflection;
22

3-
[assembly: AssemblyVersion("2026.6.8.1")]
4-
[assembly: AssemblyInformationalVersion("2026.6.8")]
3+
[assembly: AssemblyVersion("2026.6.9.0")]
4+
[assembly: AssemblyInformationalVersion("2026.6.9")]

Strings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public static string GpuCloseError(string msg) => T(
201201
public static string Disable => T("关闭", "關閉", "Disable");
202202
public static string Normal => T("正常", "正常", "Normal");
203203
public static string LowPower => T("低功耗", "低功耗", "Low Power");
204-
public static string Restore => T("无限制", "無限制", "Unlimited");
204+
public static string Unlimited => T("无限制", "無限制", "Unlimited");
205205

206206
public static string IccMaxMenu => T("IccMax", "IccMax", "IccMax");
207207
public static string AcLoadLineMenu => T("AC Load Line", "AC Load Line", "AC Load Line");
@@ -211,12 +211,14 @@ public static string GpuCloseError(string msg) => T(
211211
public static string SetFanSpeedSlider => T("拖动滑块设置转速 (RPM)", "拖動滑桿設定轉速 (RPM)", "Drag slider to set speed (RPM)");
212212
public static string SetTppSlider => T("拖动滑块设置功率 (W)", "拖動滑桿設定功率 (W)", "Drag slider to set power (W)");
213213
public static string SetGpuClockSlider => T("拖动滑块设置频率 (MHz)", "拖動滑桿設定頻率 (MHz)", "Drag slider to set clock (MHz)");
214+
public static string SetMaxFrameRateSlider => T("拖动滑块设置最大帧率", "拖動滑桿設定最大幀率", "Drag slider to set max frame rate");
214215
public static string PpabPowerMenu => T("PPab条件(Tpp)", "PPab條件(Tpp)", "PPab (Tpp)");
215216
public static string DStateSubMenu => T("dState", "dState", "dState");
216217
public static string DbVersionMenu => T("DB版本", "DB版本", "DB Version");
217218
public static string DbNormal => T("普通版本", "普通版本", "Normal");
218219
public static string DbUnlocked => T("解锁版本", "解鎖版本", "Unlocked");
219220
public static string GpuClockMenu => T("GPU频率限制", "GPU頻率限制", "GPU Clock Limit");
221+
public static string MaxFrameRateMenu => T("最大帧率", "最大幀率", "Max Frame Rate");
220222

221223
// DB 解锁相关
222224
public static string DbUnlockCpuHighWarning => T("请在CPU低负载下解锁",

0 commit comments

Comments
 (0)