mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
68 Commits
v0.155
...
cpu-auto-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02c2a7ff37 | ||
|
|
65c5b645a8 | ||
|
|
61803dbc39 | ||
|
|
adcec744d4 | ||
|
|
12d7afc532 | ||
|
|
cb685f9158 | ||
|
|
6523d6ac12 | ||
|
|
b8c3c04e4b | ||
|
|
0eb5394af8 | ||
|
|
b765514477 | ||
|
|
da47c094e4 | ||
|
|
c32fa46991 | ||
|
|
f2ef77b866 | ||
|
|
b104d852c7 | ||
|
|
89de581e1f | ||
|
|
40d31c0de2 | ||
|
|
edf05935c0 | ||
|
|
082c7036f5 | ||
|
|
b94e20a3fc | ||
|
|
2d0defd484 | ||
|
|
2e9a34d8f5 | ||
|
|
6f49af19ed | ||
|
|
097d91b5a4 | ||
|
|
181a16bee3 | ||
|
|
599def92b3 | ||
|
|
c31e52bc74 | ||
|
|
5fee6e03d1 | ||
|
|
f36a55f086 | ||
|
|
7f087d36dc | ||
|
|
6850b644a0 | ||
|
|
c1a6019d57 | ||
|
|
0370aa8c94 | ||
|
|
f1198440d4 | ||
|
|
8cd256463a | ||
|
|
2aebf3044d | ||
|
|
5d231ea172 | ||
|
|
b9b98577d0 | ||
|
|
37dfa199b0 | ||
|
|
9b59e7b08c | ||
|
|
63b357a71b | ||
|
|
c337103806 | ||
|
|
268e55d47a | ||
|
|
20a04dd1b2 | ||
|
|
3cc4955dd7 | ||
|
|
06205a1ad3 | ||
|
|
82f90fcab3 | ||
|
|
4af2bf63c7 | ||
|
|
54dcb46527 | ||
|
|
20c9d57299 | ||
|
|
84a6fd4d5f | ||
|
|
db8e4b9c5e | ||
|
|
c517f340dc | ||
|
|
f0da110a83 | ||
|
|
7cc4e87d5f | ||
|
|
88ab4f396e | ||
|
|
4378118951 | ||
|
|
dea90f66b2 | ||
|
|
ac9b67868e | ||
|
|
e08092a754 | ||
|
|
7e3d6eab44 | ||
|
|
cf447174cb | ||
|
|
0d18e5b850 | ||
|
|
df52fbe25d | ||
|
|
0a86b6db3c | ||
|
|
acf52c2edd | ||
|
|
b006a11dcf | ||
|
|
0dc16c5cda | ||
|
|
b0e412f370 |
4
.github/SECURITY.md
vendored
4
.github/SECURITY.md
vendored
@@ -4,8 +4,8 @@
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 0.89+ | :white_check_mark: |
|
||||
| < 0.89 | :x: |
|
||||
| 0.151+ | :white_check_mark: |
|
||||
| < 0.151 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
|
||||
@@ -67,9 +67,17 @@ public static class AppConfig
|
||||
{
|
||||
File.WriteAllText(backup, jsonString);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
Logger.WriteLine(ex.ToString());
|
||||
Thread.Sleep(100);
|
||||
try
|
||||
{
|
||||
File.WriteAllText(backup, jsonString);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.Message);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,9 @@ public class AsusACPI
|
||||
public const uint CORES_CPU = 0x001200D2; // Intel E-core and P-core configuration in a format 0x0[E]0[P]
|
||||
public const uint CORES_MAX = 0x001200D3; // Maximum Intel E-core and P-core availability
|
||||
|
||||
public const uint GPU_BASE = 0x00120099; // Base part GPU TGP
|
||||
public const uint GPU_POWER = 0x00120098; // Additonal part of GPU TGP
|
||||
|
||||
public const int APU_MEM = 0x000600C1;
|
||||
|
||||
public const int TUF_KB_BRIGHTNESS = 0x00050021;
|
||||
@@ -150,6 +153,9 @@ public class AsusACPI
|
||||
public const int MinGPUBoost = 5;
|
||||
public static int MaxGPUBoost = 25;
|
||||
|
||||
public static int MinGPUPower = 0;
|
||||
public static int MaxGPUPower = 50;
|
||||
|
||||
public const int MinGPUTemp = 75;
|
||||
public const int MaxGPUTemp = 87;
|
||||
|
||||
@@ -285,6 +291,12 @@ public class AsusACPI
|
||||
if (AppConfig.IsIntelHX())
|
||||
{
|
||||
MaxTotal = 175;
|
||||
MaxGPUPower = 70;
|
||||
}
|
||||
|
||||
if (AppConfig.IsSlash())
|
||||
{
|
||||
MaxGPUPower = 25;
|
||||
}
|
||||
|
||||
if (AppConfig.DynamicBoost5())
|
||||
@@ -542,7 +554,7 @@ public class AsusACPI
|
||||
break;
|
||||
}
|
||||
|
||||
Logger.WriteLine($"GetFan {device} :" + BitConverter.ToString(result));
|
||||
//Logger.WriteLine($"GetFan {device} :" + BitConverter.ToString(result));
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
336
app/AutoTDP/AutoTDPGameProfileUI.Designer.cs
generated
Normal file
336
app/AutoTDP/AutoTDPGameProfileUI.Designer.cs
generated
Normal file
@@ -0,0 +1,336 @@
|
||||
namespace GHelper.AutoTDP
|
||||
{
|
||||
partial class AutoTDPGameProfileUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
panelPerformanceHeader = new Panel();
|
||||
pictureKeyboard = new PictureBox();
|
||||
labelSettings = new Label();
|
||||
checkBoxEnabled = new CheckBox();
|
||||
panelGameSettings = new Panel();
|
||||
labelMinTDP = new Label();
|
||||
labelMaxTDP = new Label();
|
||||
sliderMaxTDP = new UI.Slider();
|
||||
numericUpDownFPS = new NumericUpDown();
|
||||
sliderMinTDP = new UI.Slider();
|
||||
labelMaxTDPText = new Label();
|
||||
labeMinTDPText = new Label();
|
||||
labelTargetFPS = new Label();
|
||||
textBoxTitle = new TextBox();
|
||||
textBoxProcessName = new TextBox();
|
||||
labelFPSSource = new Label();
|
||||
labelLimiter = new Label();
|
||||
buttonSave = new UI.RButton();
|
||||
buttonDelete = new UI.RButton();
|
||||
panelPerformanceHeader.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureKeyboard).BeginInit();
|
||||
panelGameSettings.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownFPS).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panelPerformanceHeader
|
||||
//
|
||||
panelPerformanceHeader.BackColor = SystemColors.ControlLight;
|
||||
panelPerformanceHeader.Controls.Add(pictureKeyboard);
|
||||
panelPerformanceHeader.Controls.Add(labelSettings);
|
||||
panelPerformanceHeader.Controls.Add(checkBoxEnabled);
|
||||
panelPerformanceHeader.Dock = DockStyle.Top;
|
||||
panelPerformanceHeader.Location = new Point(0, 0);
|
||||
panelPerformanceHeader.Name = "panelPerformanceHeader";
|
||||
panelPerformanceHeader.Size = new Size(551, 50);
|
||||
panelPerformanceHeader.TabIndex = 53;
|
||||
//
|
||||
// pictureKeyboard
|
||||
//
|
||||
pictureKeyboard.BackgroundImage = Properties.Resources.icons8_automation_32;
|
||||
pictureKeyboard.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureKeyboard.Location = new Point(4, 13);
|
||||
pictureKeyboard.Name = "pictureKeyboard";
|
||||
pictureKeyboard.Size = new Size(23, 27);
|
||||
pictureKeyboard.TabIndex = 35;
|
||||
pictureKeyboard.TabStop = false;
|
||||
//
|
||||
// labelSettings
|
||||
//
|
||||
labelSettings.AutoSize = true;
|
||||
labelSettings.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelSettings.Location = new Point(31, 13);
|
||||
labelSettings.Margin = new Padding(6, 0, 6, 0);
|
||||
labelSettings.Name = "labelSettings";
|
||||
labelSettings.Size = new Size(135, 25);
|
||||
labelSettings.TabIndex = 34;
|
||||
labelSettings.Text = "Game Settings";
|
||||
//
|
||||
// checkBoxEnabled
|
||||
//
|
||||
checkBoxEnabled.Location = new Point(344, 3);
|
||||
checkBoxEnabled.Margin = new Padding(6, 0, 6, 0);
|
||||
checkBoxEnabled.Name = "checkBoxEnabled";
|
||||
checkBoxEnabled.Size = new Size(194, 42);
|
||||
checkBoxEnabled.TabIndex = 53;
|
||||
checkBoxEnabled.Text = "Enabled";
|
||||
checkBoxEnabled.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// panelGameSettings
|
||||
//
|
||||
panelGameSettings.AutoSize = true;
|
||||
panelGameSettings.Controls.Add(labelMinTDP);
|
||||
panelGameSettings.Controls.Add(labelMaxTDP);
|
||||
panelGameSettings.Controls.Add(sliderMaxTDP);
|
||||
panelGameSettings.Controls.Add(numericUpDownFPS);
|
||||
panelGameSettings.Controls.Add(sliderMinTDP);
|
||||
panelGameSettings.Controls.Add(labelMaxTDPText);
|
||||
panelGameSettings.Controls.Add(labeMinTDPText);
|
||||
panelGameSettings.Controls.Add(labelTargetFPS);
|
||||
panelGameSettings.Controls.Add(textBoxTitle);
|
||||
panelGameSettings.Controls.Add(textBoxProcessName);
|
||||
panelGameSettings.Controls.Add(labelFPSSource);
|
||||
panelGameSettings.Controls.Add(labelLimiter);
|
||||
panelGameSettings.Dock = DockStyle.Top;
|
||||
panelGameSettings.Location = new Point(0, 50);
|
||||
panelGameSettings.Name = "panelGameSettings";
|
||||
panelGameSettings.Padding = new Padding(0, 0, 0, 12);
|
||||
panelGameSettings.Size = new Size(551, 244);
|
||||
panelGameSettings.TabIndex = 57;
|
||||
//
|
||||
// labelMinTDP
|
||||
//
|
||||
labelMinTDP.Location = new Point(489, 152);
|
||||
labelMinTDP.Margin = new Padding(4, 0, 4, 0);
|
||||
labelMinTDP.Name = "labelMinTDP";
|
||||
labelMinTDP.Size = new Size(56, 37);
|
||||
labelMinTDP.TabIndex = 67;
|
||||
labelMinTDP.Text = "30W";
|
||||
labelMinTDP.TextAlign = ContentAlignment.MiddleRight;
|
||||
//
|
||||
// labelMaxTDP
|
||||
//
|
||||
labelMaxTDP.Location = new Point(487, 195);
|
||||
labelMaxTDP.Margin = new Padding(4, 0, 4, 0);
|
||||
labelMaxTDP.Name = "labelMaxTDP";
|
||||
labelMaxTDP.Size = new Size(57, 37);
|
||||
labelMaxTDP.TabIndex = 66;
|
||||
labelMaxTDP.Text = "150W";
|
||||
labelMaxTDP.TextAlign = ContentAlignment.MiddleRight;
|
||||
//
|
||||
// sliderMaxTDP
|
||||
//
|
||||
sliderMaxTDP.AccessibleName = "DPI Slider";
|
||||
sliderMaxTDP.Location = new Point(200, 195);
|
||||
sliderMaxTDP.Max = 200;
|
||||
sliderMaxTDP.Min = 5;
|
||||
sliderMaxTDP.Name = "sliderMaxTDP";
|
||||
sliderMaxTDP.Size = new Size(291, 33);
|
||||
sliderMaxTDP.Step = 1;
|
||||
sliderMaxTDP.TabIndex = 65;
|
||||
sliderMaxTDP.TabStop = false;
|
||||
sliderMaxTDP.Text = "sliderBattery";
|
||||
sliderMaxTDP.Value = 0;
|
||||
//
|
||||
// numericUpDownFPS
|
||||
//
|
||||
numericUpDownFPS.BorderStyle = BorderStyle.None;
|
||||
numericUpDownFPS.Location = new Point(416, 110);
|
||||
numericUpDownFPS.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownFPS.Minimum = new decimal(new int[] { 20, 0, 0, 0 });
|
||||
numericUpDownFPS.Name = "numericUpDownFPS";
|
||||
numericUpDownFPS.Size = new Size(123, 27);
|
||||
numericUpDownFPS.TabIndex = 64;
|
||||
numericUpDownFPS.TextAlign = HorizontalAlignment.Center;
|
||||
numericUpDownFPS.Value = new decimal(new int[] { 60, 0, 0, 0 });
|
||||
//
|
||||
// sliderMinTDP
|
||||
//
|
||||
sliderMinTDP.AccessibleName = "DPI Slider";
|
||||
sliderMinTDP.Location = new Point(200, 155);
|
||||
sliderMinTDP.Max = 200;
|
||||
sliderMinTDP.Min = 5;
|
||||
sliderMinTDP.Name = "sliderMinTDP";
|
||||
sliderMinTDP.Size = new Size(291, 33);
|
||||
sliderMinTDP.Step = 1;
|
||||
sliderMinTDP.TabIndex = 63;
|
||||
sliderMinTDP.TabStop = false;
|
||||
sliderMinTDP.Text = "sliderBattery";
|
||||
sliderMinTDP.Value = 0;
|
||||
//
|
||||
// labelMaxTDPText
|
||||
//
|
||||
labelMaxTDPText.Location = new Point(7, 195);
|
||||
labelMaxTDPText.Margin = new Padding(6, 0, 6, 0);
|
||||
labelMaxTDPText.Name = "labelMaxTDPText";
|
||||
labelMaxTDPText.Size = new Size(184, 37);
|
||||
labelMaxTDPText.TabIndex = 61;
|
||||
labelMaxTDPText.Text = "Max TDP:";
|
||||
labelMaxTDPText.TextAlign = ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// labeMinTDPText
|
||||
//
|
||||
labeMinTDPText.Location = new Point(7, 152);
|
||||
labeMinTDPText.Margin = new Padding(6, 0, 6, 0);
|
||||
labeMinTDPText.Name = "labeMinTDPText";
|
||||
labeMinTDPText.Size = new Size(184, 37);
|
||||
labeMinTDPText.TabIndex = 62;
|
||||
labeMinTDPText.Text = "Min TDP:";
|
||||
labeMinTDPText.TextAlign = ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// labelTargetFPS
|
||||
//
|
||||
labelTargetFPS.Location = new Point(7, 105);
|
||||
labelTargetFPS.Margin = new Padding(6, 0, 6, 0);
|
||||
labelTargetFPS.Name = "labelTargetFPS";
|
||||
labelTargetFPS.Size = new Size(184, 37);
|
||||
labelTargetFPS.TabIndex = 60;
|
||||
labelTargetFPS.Text = "Target FPS:";
|
||||
labelTargetFPS.TextAlign = ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// textBoxTitle
|
||||
//
|
||||
textBoxTitle.Location = new Point(200, 60);
|
||||
textBoxTitle.Margin = new Padding(4, 5, 4, 5);
|
||||
textBoxTitle.Name = "textBoxTitle";
|
||||
textBoxTitle.Size = new Size(337, 31);
|
||||
textBoxTitle.TabIndex = 59;
|
||||
//
|
||||
// textBoxProcessName
|
||||
//
|
||||
textBoxProcessName.Location = new Point(200, 10);
|
||||
textBoxProcessName.Margin = new Padding(4, 5, 4, 5);
|
||||
textBoxProcessName.Name = "textBoxProcessName";
|
||||
textBoxProcessName.ReadOnly = true;
|
||||
textBoxProcessName.Size = new Size(337, 31);
|
||||
textBoxProcessName.TabIndex = 58;
|
||||
textBoxProcessName.WordWrap = false;
|
||||
//
|
||||
// labelFPSSource
|
||||
//
|
||||
labelFPSSource.Location = new Point(6, 62);
|
||||
labelFPSSource.Margin = new Padding(6, 0, 6, 0);
|
||||
labelFPSSource.Name = "labelFPSSource";
|
||||
labelFPSSource.Size = new Size(184, 37);
|
||||
labelFPSSource.TabIndex = 57;
|
||||
labelFPSSource.Text = "Name:";
|
||||
labelFPSSource.TextAlign = ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// labelLimiter
|
||||
//
|
||||
labelLimiter.Location = new Point(6, 12);
|
||||
labelLimiter.Margin = new Padding(6, 0, 6, 0);
|
||||
labelLimiter.Name = "labelLimiter";
|
||||
labelLimiter.Size = new Size(184, 37);
|
||||
labelLimiter.TabIndex = 47;
|
||||
labelLimiter.Text = "Process";
|
||||
labelLimiter.TextAlign = ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.AccessibleName = "Keyboard Color";
|
||||
buttonSave.Activated = false;
|
||||
buttonSave.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonSave.BackColor = SystemColors.ButtonHighlight;
|
||||
buttonSave.BorderColor = Color.Transparent;
|
||||
buttonSave.BorderRadius = 2;
|
||||
buttonSave.FlatStyle = FlatStyle.Flat;
|
||||
buttonSave.ForeColor = SystemColors.ControlText;
|
||||
buttonSave.Location = new Point(399, 303);
|
||||
buttonSave.Margin = new Padding(3, 7, 3, 7);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Secondary = false;
|
||||
buttonSave.Size = new Size(147, 42);
|
||||
buttonSave.TabIndex = 61;
|
||||
buttonSave.Text = "Save";
|
||||
buttonSave.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.AccessibleName = "Keyboard Color";
|
||||
buttonDelete.Activated = false;
|
||||
buttonDelete.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonDelete.BackColor = SystemColors.ButtonHighlight;
|
||||
buttonDelete.BorderColor = Color.Transparent;
|
||||
buttonDelete.BorderRadius = 2;
|
||||
buttonDelete.FlatStyle = FlatStyle.Flat;
|
||||
buttonDelete.ForeColor = SystemColors.ControlText;
|
||||
buttonDelete.Location = new Point(6, 303);
|
||||
buttonDelete.Margin = new Padding(3, 7, 3, 7);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Secondary = false;
|
||||
buttonDelete.Size = new Size(147, 42);
|
||||
buttonDelete.TabIndex = 62;
|
||||
buttonDelete.Text = "Delete";
|
||||
buttonDelete.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// AutoTDPGameProfileUI
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(551, 362);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(panelGameSettings);
|
||||
Controls.Add(panelPerformanceHeader);
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
Margin = new Padding(4, 5, 4, 5);
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "AutoTDPGameProfileUI";
|
||||
ShowIcon = false;
|
||||
ShowInTaskbar = false;
|
||||
Text = "Game Profile";
|
||||
panelPerformanceHeader.ResumeLayout(false);
|
||||
panelPerformanceHeader.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureKeyboard).EndInit();
|
||||
panelGameSettings.ResumeLayout(false);
|
||||
panelGameSettings.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownFPS).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panelPerformanceHeader;
|
||||
private PictureBox pictureKeyboard;
|
||||
private Label labelSettings;
|
||||
private CheckBox checkBoxEnabled;
|
||||
private Panel panelGameSettings;
|
||||
private Label labelFPSSource;
|
||||
private Label labelLimiter;
|
||||
private TextBox textBoxTitle;
|
||||
private TextBox textBoxProcessName;
|
||||
private UI.RButton buttonSave;
|
||||
private Label labelMaxTDPText;
|
||||
private Label labeMinTDPText;
|
||||
private Label labelTargetFPS;
|
||||
private UI.Slider sliderMinTDP;
|
||||
private UI.Slider sliderMaxTDP;
|
||||
private NumericUpDown numericUpDownFPS;
|
||||
private Label labelMinTDP;
|
||||
private Label labelMaxTDP;
|
||||
private UI.RButton buttonDelete;
|
||||
}
|
||||
}
|
||||
90
app/AutoTDP/AutoTDPGameProfileUI.cs
Normal file
90
app/AutoTDP/AutoTDPGameProfileUI.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using GHelper.UI;
|
||||
|
||||
namespace GHelper.AutoTDP
|
||||
{
|
||||
public partial class AutoTDPGameProfileUI : RForm
|
||||
{
|
||||
public GameProfile GameProfile;
|
||||
private AutoTDPUI AutoTDPUI;
|
||||
|
||||
public AutoTDPGameProfileUI(GameProfile profile, AutoTDPUI parent)
|
||||
{
|
||||
AutoTDPUI = parent;
|
||||
GameProfile = profile;
|
||||
InitializeComponent();
|
||||
|
||||
sliderMinTDP.ValueChanged += SliderMinTDP_ValueChanged;
|
||||
sliderMaxTDP.ValueChanged += SliderMaxTDP_ValueChanged;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
|
||||
InitTheme();
|
||||
|
||||
|
||||
Shown += AutoTDPGameProfileUI_Shown;
|
||||
|
||||
VisualizeGameProfile();
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object? sender, EventArgs e)
|
||||
{
|
||||
AutoTDPUI.DeleteGameProfile(GameProfile);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object? sender, EventArgs e)
|
||||
{
|
||||
GameProfile.Enabled = checkBoxEnabled.Checked;
|
||||
GameProfile.GameTitle = textBoxTitle.Text;
|
||||
GameProfile.TargetFPS = ((int)numericUpDownFPS.Value);
|
||||
GameProfile.MinTdp = sliderMinTDP.Value;
|
||||
GameProfile.MaxTdp = sliderMaxTDP.Value;
|
||||
|
||||
AutoTDPUI.UpdateGameProfile(GameProfile);
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SliderMaxTDP_ValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
labelMaxTDP.Text = sliderMaxTDP.Value + "W";
|
||||
if (sliderMaxTDP.Value < sliderMinTDP.Value)
|
||||
{
|
||||
sliderMinTDP.Value = sliderMaxTDP.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void SliderMinTDP_ValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
labelMinTDP.Text = sliderMinTDP.Value + "W";
|
||||
if (sliderMaxTDP.Value < sliderMinTDP.Value)
|
||||
{
|
||||
sliderMaxTDP.Value = sliderMinTDP.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void AutoTDPGameProfileUI_Shown(object? sender, EventArgs e)
|
||||
{
|
||||
if (Height > Program.settingsForm.Height)
|
||||
{
|
||||
Top = Program.settingsForm.Top + Program.settingsForm.Height - Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Top = Program.settingsForm.Top + 60;
|
||||
}
|
||||
|
||||
Left = Program.settingsForm.Left - Width - ((AutoTDPUI.Width - Width) / 2);
|
||||
}
|
||||
|
||||
private void VisualizeGameProfile()
|
||||
{
|
||||
sliderMinTDP.Value = GameProfile.MinTdp;
|
||||
sliderMaxTDP.Value = GameProfile.MaxTdp;
|
||||
numericUpDownFPS.Value = GameProfile.TargetFPS;
|
||||
textBoxProcessName.Text = GameProfile.ProcessName;
|
||||
textBoxTitle.Text = GameProfile.GameTitle;
|
||||
checkBoxEnabled.Checked = GameProfile.Enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
app/AutoTDP/AutoTDPGameProfileUI.resx
Normal file
120
app/AutoTDP/AutoTDPGameProfileUI.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
620
app/AutoTDP/AutoTDPService.cs
Normal file
620
app/AutoTDP/AutoTDPService.cs
Normal file
@@ -0,0 +1,620 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using GHelper.AutoTDP.FramerateSource;
|
||||
using GHelper.AutoTDP.PowerLimiter;
|
||||
using Ryzen;
|
||||
|
||||
namespace GHelper.AutoTDP
|
||||
{
|
||||
internal class AutoTDPService : IDisposable
|
||||
{
|
||||
|
||||
private static readonly bool LOG_AUTO_TDP = false;
|
||||
private static readonly int INTERVAL_MIN_CHECK = 30 * 1_000;
|
||||
private static readonly int INTERVAL_APP_CHECK = 5_000;
|
||||
private static readonly int INTERVAL_FPS_CHECK = 500;
|
||||
|
||||
string GameProfileFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper\\AutoTDP.json";
|
||||
|
||||
IFramerateSource? framerateSouce;
|
||||
IPowerLimiter? powerLimiter;
|
||||
|
||||
public List<GameProfile> GameProfiles = new List<GameProfile>();
|
||||
|
||||
private bool Running = false;
|
||||
private Thread? checkerThread;
|
||||
private Thread? tdpThread;
|
||||
|
||||
private double GameFPSPrevious = double.NaN;
|
||||
private double GameFPS;
|
||||
|
||||
private int FramerateTargetReachedCounter;
|
||||
private int FramerateDipCounter;
|
||||
|
||||
private static readonly int FPSDipHistorySize = 6;
|
||||
|
||||
private List<double> FramerateLog = new List<double>();
|
||||
|
||||
private double LowestTDP;
|
||||
private double LowestStableTDP;
|
||||
private long LowestStableStability = 0;
|
||||
private int LowestStableChecks = 0;
|
||||
private double CurrentTDP;
|
||||
private double LastAdjustment;
|
||||
private double LastAdjustmentTotal = 0;
|
||||
private int LastAdjustmentsWithoutImprovement = 0;
|
||||
|
||||
private GameInstance? currentGame;
|
||||
|
||||
public AutoTDPService()
|
||||
{
|
||||
LoadGameProfiles();
|
||||
|
||||
Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the system is enabled and currently running.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsRunning()
|
||||
{
|
||||
return Running;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether a supported game is actively monitored and TDP is adjusted
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsActive()
|
||||
{
|
||||
return currentGame is not null;
|
||||
}
|
||||
|
||||
public static bool IsAvailable()
|
||||
{
|
||||
|
||||
if (AppConfig.IsAlly())
|
||||
{
|
||||
//Not yet supported
|
||||
return false;
|
||||
}
|
||||
|
||||
return AvailablePowerLimiters().Count > 0 && AvailableFramerateSources().Count > 0;
|
||||
}
|
||||
|
||||
public static List<string> AvailableFramerateSources()
|
||||
{
|
||||
List<string> l = new List<string>();
|
||||
|
||||
if (RTSSFramerateSource.IsAvailable()) l.Add("rtss");
|
||||
|
||||
Logger.WriteLine("[AutoTDPService] Available Framerate Sources: " + string.Join(", ", l.ToArray()));
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
public static List<string> AvailablePowerLimiters()
|
||||
{
|
||||
List<string> l = new List<string>();
|
||||
|
||||
if (IntelMSRPowerLimiter.IsAvailable()) l.Add("intel_msr");
|
||||
|
||||
if (ASUSACPIPowerLimiter.IsAvailable()) l.Add("asus_acpi");
|
||||
|
||||
|
||||
Logger.WriteLine("[AutoTDPService] Available Power Limiters: " + string.Join(", ", l.ToArray()));
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (!IsEnabled() || IsRunning() || !IsAvailable())
|
||||
{
|
||||
Logger.WriteLine("[AutoTDPService] Refusing startup. Stats: Enabled: " + IsEnabled() + ", Running: " + IsRunning() + " ,Available: " + IsAvailable());
|
||||
return;
|
||||
}
|
||||
|
||||
Running = true;
|
||||
|
||||
InitFramerateSource();
|
||||
|
||||
InitLimiter();
|
||||
|
||||
|
||||
checkerThread = new Thread(() =>
|
||||
{
|
||||
while (Running)
|
||||
{
|
||||
CheckForGame();
|
||||
try
|
||||
{
|
||||
Thread.Sleep(INTERVAL_APP_CHECK);
|
||||
}
|
||||
catch (ThreadInterruptedException)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
});
|
||||
checkerThread.Start();
|
||||
}
|
||||
|
||||
public bool IsEnabled()
|
||||
{
|
||||
return AppConfig.Get("auto_tdp_enabled", 0) == 1;
|
||||
}
|
||||
|
||||
public void InitFramerateSource()
|
||||
{
|
||||
string? source = AppConfig.GetString("auto_tdp_fps_source");
|
||||
|
||||
if ((source is null || source.Equals("rtss")) && RTSSFramerateSource.IsAvailable())
|
||||
{
|
||||
Logger.WriteLine("[AutoTDPService] Initializing RTSSFramerateSource...");
|
||||
RTSSFramerateSource rtss = new RTSSFramerateSource();
|
||||
RTSSFramerateSource.Start();
|
||||
framerateSouce = rtss;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitLimiter()
|
||||
{
|
||||
string? limiter = AppConfig.GetString("auto_tdp_limiter");
|
||||
|
||||
if (limiter is null || limiter.Equals("asus_acpi") && ASUSACPIPowerLimiter.IsAvailable())
|
||||
{
|
||||
Logger.WriteLine("[AutoTDPService] Initializing ASUSACPIPowerLimiter...");
|
||||
powerLimiter = new ASUSACPIPowerLimiter();
|
||||
return;
|
||||
}
|
||||
|
||||
if (limiter is not null && limiter.Equals("intel_msr") && IntelMSRPowerLimiter.IsAvailable())
|
||||
{
|
||||
Logger.WriteLine("[AutoTDPService] Initializing IntelMSRPowerLimiter...");
|
||||
powerLimiter = new IntelMSRPowerLimiter();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveGameProfiles()
|
||||
{
|
||||
string json = JsonSerializer.Serialize(GameProfiles);
|
||||
|
||||
File.WriteAllText(GameProfileFile, json);
|
||||
}
|
||||
|
||||
|
||||
public void LoadGameProfiles()
|
||||
{
|
||||
if (!File.Exists(GameProfileFile))
|
||||
{
|
||||
if (GameProfiles is null) GameProfiles = new List<GameProfile>();
|
||||
return;
|
||||
}
|
||||
|
||||
string? json = File.ReadAllText(GameProfileFile);
|
||||
|
||||
if (json == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
GameProfiles = JsonSerializer.Deserialize<List<GameProfile>>(json);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.WriteLine("[AutoTDPService] Deserialization failed. Creating empty list. Message: " + e.Message);
|
||||
GameProfiles = new List<GameProfile>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void CheckForGame()
|
||||
{
|
||||
if (currentGame is not null)
|
||||
{
|
||||
//Already handling a running game. No need to check for other games
|
||||
return;
|
||||
}
|
||||
List<GameInstance> runningGames = framerateSouce.GetRunningGames();
|
||||
|
||||
if (runningGames.Count == 0)
|
||||
{
|
||||
if (LOG_AUTO_TDP)
|
||||
Logger.WriteLine("[AutoTDPService] No games detected");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (GameInstance gi in runningGames)
|
||||
{
|
||||
if (LOG_AUTO_TDP)
|
||||
Logger.WriteLine("[AutoTDPService] Detected App: " + gi.ProcessName + " PID: " + gi.ProcessID);
|
||||
|
||||
if (IsGameInList(gi.ProcessName))
|
||||
{
|
||||
Logger.WriteLine("[AutoTDPService] Detected Supported Game: " + gi.ProcessName + " PID: " + gi.ProcessID);
|
||||
HandleGame(gi);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GameProfile? ProfileForGame(String? processName)
|
||||
{
|
||||
if (processName is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (GameProfile gp in GameProfiles)
|
||||
{
|
||||
if (gp.ProcessName is not null && processName.EndsWith(gp.ProcessName, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
return gp;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsGameInList(String? processName)
|
||||
{
|
||||
return ProfileForGame(processName) is not null;
|
||||
}
|
||||
|
||||
|
||||
public void HandleGame(GameInstance instance)
|
||||
{
|
||||
if (currentGame is not null)
|
||||
{
|
||||
if (LOG_AUTO_TDP)
|
||||
Logger.WriteLine("[AutoTDPService] Already handling a game");
|
||||
return;
|
||||
}
|
||||
|
||||
if (tdpThread is not null)
|
||||
{
|
||||
tdpThread.Join();
|
||||
tdpThread = null;
|
||||
}
|
||||
currentGame = instance;
|
||||
|
||||
StartGameHandler(instance);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
currentGame = null;
|
||||
GameFPSPrevious = double.NaN;
|
||||
GameFPS = 0;
|
||||
LastAdjustmentsWithoutImprovement = 0;
|
||||
LastAdjustment = 0.0;
|
||||
FramerateLog = new List<double>();
|
||||
FramerateTargetReachedCounter = 0;
|
||||
FramerateDipCounter = 0;
|
||||
LowestStableStability = 0;
|
||||
LowestStableChecks = 0;
|
||||
|
||||
if (powerLimiter is not null)
|
||||
{
|
||||
powerLimiter.ResetPowerLimits();
|
||||
CurrentTDP = powerLimiter.GetCPUPowerLimit();
|
||||
}
|
||||
}
|
||||
|
||||
public void StartGameHandler(GameInstance instance)
|
||||
{
|
||||
GameProfile? profile = ProfileForGame(instance.ProcessName);
|
||||
if (profile is null || powerLimiter is null || framerateSouce is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.WriteLine("[AutoTDPService] Start handling game: " + instance.ProcessName + " PID: " + instance.ProcessID);
|
||||
|
||||
tdpThread = new Thread(() =>
|
||||
{
|
||||
CurrentTDP = powerLimiter.GetCPUPowerLimit();
|
||||
powerLimiter.SavePowerLimits(); // save current power limits to restore them afterwards
|
||||
|
||||
LowestStableTDP = profile.MaxTdp;
|
||||
LowestTDP = profile.MaxTdp;
|
||||
|
||||
while (currentGame is not null && Running)
|
||||
{
|
||||
|
||||
double fps = framerateSouce.GetFramerate(instance);
|
||||
|
||||
if (LOG_AUTO_TDP)
|
||||
Logger.WriteLine("[AutoTDPService] (" + instance.ProcessName + ") Framerate " + GameFPS);
|
||||
|
||||
if (fps < 0.0d)
|
||||
{
|
||||
//Game is not running anymore or RTSS lost its hook
|
||||
Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
//prevent FPS from going to 0 which causes issues with the math
|
||||
GameFPS = Math.Max(5, fps);
|
||||
AdjustPowerLimit(profile);
|
||||
|
||||
try
|
||||
{
|
||||
Thread.Sleep(INTERVAL_FPS_CHECK);
|
||||
}
|
||||
catch (ThreadInterruptedException)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
tdpThread.Start();
|
||||
}
|
||||
|
||||
private double FPSDipCorrection(double currentFramerate, double targetFPS)
|
||||
{
|
||||
double correction = 0.0d;
|
||||
|
||||
|
||||
FramerateLog.Insert(0, currentFramerate);
|
||||
|
||||
//Remove last entry when exceeding the desired size.
|
||||
if (FramerateLog.Count > FPSDipHistorySize)
|
||||
{
|
||||
FramerateLog.RemoveAt(FramerateLog.Count - 1);
|
||||
}
|
||||
|
||||
if (targetFPS - 1 <= currentFramerate && currentFramerate <= targetFPS + 1)
|
||||
{
|
||||
//Framerate is inside ideal range
|
||||
FramerateTargetReachedCounter++;
|
||||
|
||||
if (FramerateTargetReachedCounter >= 3
|
||||
&& FramerateTargetReachedCounter < FPSDipHistorySize
|
||||
&& targetFPS - 0.5 <= FramerateLog.Take(3).Average()
|
||||
&& FramerateLog.Take(3).Average() - 0.05 <= targetFPS)
|
||||
{
|
||||
//short dip
|
||||
FramerateDipCounter++;
|
||||
FramerateUnstable();
|
||||
|
||||
correction = targetFPS + 0.15 - currentFramerate;
|
||||
}
|
||||
else if (FramerateDipCounter >= 4
|
||||
&& targetFPS - 0.5 <= FramerateLog.Average()
|
||||
&& FramerateLog.Average() - 0.1 <= targetFPS)
|
||||
{
|
||||
//long dip
|
||||
correction = targetFPS + 0.35 - currentFramerate;
|
||||
FramerateTargetReachedCounter = FPSDipHistorySize;
|
||||
FramerateVeryUnstable();
|
||||
}
|
||||
else
|
||||
{
|
||||
FramerateStable();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Framerate not in target range
|
||||
correction = 0.0;
|
||||
FramerateTargetReachedCounter = 0;
|
||||
FramerateDipCounter = 0;
|
||||
FramerateStable();
|
||||
}
|
||||
|
||||
ProcessStability();
|
||||
return correction;
|
||||
}
|
||||
|
||||
private void FramerateStable()
|
||||
{
|
||||
LowestStableStability++;
|
||||
}
|
||||
|
||||
private void FramerateUnstable()
|
||||
{
|
||||
LowestStableStability -= 15;
|
||||
}
|
||||
private void FramerateVeryUnstable()
|
||||
{
|
||||
LowestStableStability -= 60;
|
||||
}
|
||||
|
||||
private bool Stabilize()
|
||||
{
|
||||
return LowestStableChecks * INTERVAL_FPS_CHECK > INTERVAL_MIN_CHECK;
|
||||
}
|
||||
|
||||
private void ProcessStability()
|
||||
{
|
||||
if (!Stabilize()) LowestStableChecks++;
|
||||
|
||||
if (LowestStableStability < 0 && Stabilize())
|
||||
{
|
||||
//If unstable for too often increase lowest stable TDP
|
||||
LowestStableTDP += 1;
|
||||
LowestTDP += 1;
|
||||
LowestStableStability = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (CurrentTDP > LowestStableTDP - 0.1 && CurrentTDP < LowestStableTDP + 0.1 && Stabilize())
|
||||
{
|
||||
LowestStableStability++;
|
||||
|
||||
if (LowestStableStability > 120)
|
||||
{
|
||||
//if stable for long time try to reduce it again
|
||||
LowestStableTDP = ProfileForGame(currentGame.ProcessName).MaxTdp;
|
||||
LowestStableStability = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (LowestTDP - 0.25 <= CurrentTDP && CurrentTDP <= LowestTDP + 0.25)
|
||||
{
|
||||
LowestStableStability++;
|
||||
|
||||
if (LowestStableStability > 10 && Stabilize())
|
||||
{
|
||||
LowestStableTDP = LowestTDP + (LowestTDP * 0.10); // Add 10% additional wattage to get a smoother framerate
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (CurrentTDP < LowestTDP - 0.1 && LowestStableStability > 0)
|
||||
{
|
||||
LowestStableStability = 0;
|
||||
LowestTDP = CurrentTDP;
|
||||
}
|
||||
|
||||
LowestStableStability = Math.Min(LowestStableStability, 150);
|
||||
}
|
||||
|
||||
|
||||
private double TDPDamper(double currentFramerate)
|
||||
{
|
||||
if (double.IsNaN(GameFPSPrevious)) GameFPSPrevious = currentFramerate;
|
||||
double dF = -0.12d;
|
||||
|
||||
// PID Compute
|
||||
double deltaError = currentFramerate - GameFPSPrevious;
|
||||
double dT = deltaError / (1020.0 / 1000.0);
|
||||
double damping = CurrentTDP / currentFramerate * dF * dT;
|
||||
|
||||
GameFPSPrevious = currentFramerate;
|
||||
|
||||
return damping;
|
||||
}
|
||||
|
||||
public void AdjustPowerLimit(GameProfile profile)
|
||||
{
|
||||
|
||||
if (powerLimiter is null)
|
||||
{
|
||||
//Should not happen... but we also don't want it to crash
|
||||
return;
|
||||
}
|
||||
|
||||
double newPL = CurrentTDP;
|
||||
double fpsCorrection = FPSDipCorrection(GameFPS, profile.GetTDPFPS());
|
||||
double delta = profile.GetTDPFPS() - GameFPS - fpsCorrection - 1;
|
||||
delta = Math.Clamp(delta, -15, 15);
|
||||
|
||||
|
||||
double adjustment = (delta * CurrentTDP / GameFPS) * 0.65;
|
||||
//Dampen the changes to not change TDP too aggressively which would cause performance issues
|
||||
adjustment += TDPDamper(GameFPS);
|
||||
|
||||
adjustment = Math.Min(adjustment, (CurrentTDP * 0.1));
|
||||
|
||||
if (GameFPSPrevious > profile.GetTDPFPS() && GameFPS < profile.GetTDPFPS())
|
||||
{
|
||||
if (LOG_AUTO_TDP)
|
||||
Logger.WriteLine("[AutoTDPService] Single Dip, Ignore");
|
||||
//single dip. Ignore
|
||||
return;
|
||||
}
|
||||
|
||||
if (LastAdjustment > 0 && GameFPS <= GameFPSPrevious && adjustment > 0)
|
||||
{
|
||||
LastAdjustmentsWithoutImprovement++;
|
||||
LastAdjustmentTotal += adjustment;
|
||||
|
||||
//Wait for 3 consecutive power increases and at least 3W increased TDP before judging that increasing power does nothing.
|
||||
if (LastAdjustmentsWithoutImprovement >= 3 && LastAdjustmentTotal > 3)
|
||||
{
|
||||
//Do not adjust if increasing power does not improve framerate.
|
||||
if (LOG_AUTO_TDP)
|
||||
Logger.WriteLine("[AutoTDPService] Not adjusting because no improvement from last increase");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LastAdjustmentsWithoutImprovement = 0;
|
||||
LastAdjustmentTotal = 0;
|
||||
}
|
||||
|
||||
newPL += adjustment;
|
||||
LastAdjustment = adjustment;
|
||||
|
||||
//Respect the limits that the user chose
|
||||
newPL = Math.Clamp(newPL, profile.MinTdp, profile.MaxTdp);
|
||||
|
||||
if (newPL < LowestStableTDP && LowestStableTDP < profile.MaxTdp - 1)
|
||||
{
|
||||
newPL = LowestStableTDP;
|
||||
}
|
||||
|
||||
if (LOG_AUTO_TDP)
|
||||
Logger.WriteLine("[AutoTDPService] Power Limit from " + CurrentTDP + "W to " + newPL + "W, Delta:" + adjustment
|
||||
+ " Lowest: " + LowestTDP + "W, Lowest Stable(" + LowestStableStability + "): " + LowestStableTDP + "W");
|
||||
|
||||
//Apply power limits
|
||||
powerLimiter.SetCPUPowerLimit(newPL);
|
||||
CurrentTDP = newPL;
|
||||
}
|
||||
|
||||
public void StopGameHandler()
|
||||
{
|
||||
if (tdpThread is not null)
|
||||
{
|
||||
currentGame = null;
|
||||
tdpThread.Join();
|
||||
tdpThread = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
Running = false;
|
||||
|
||||
if (checkerThread is not null)
|
||||
{
|
||||
checkerThread.Interrupt();
|
||||
checkerThread.Join();
|
||||
}
|
||||
|
||||
|
||||
if (tdpThread is not null)
|
||||
{
|
||||
tdpThread.Interrupt();
|
||||
tdpThread.Join();
|
||||
}
|
||||
|
||||
if (powerLimiter is not null)
|
||||
{
|
||||
powerLimiter.ResetPowerLimits();
|
||||
powerLimiter.Dispose();
|
||||
powerLimiter = null;
|
||||
}
|
||||
|
||||
if (framerateSouce is not null)
|
||||
{
|
||||
framerateSouce = null;
|
||||
}
|
||||
|
||||
currentGame = null;
|
||||
Reset();
|
||||
|
||||
//Kill RTSS instance if we started one
|
||||
RTSSFramerateSource.Stop();
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
311
app/AutoTDP/AutoTDPUI.Designer.cs
generated
Normal file
311
app/AutoTDP/AutoTDPUI.Designer.cs
generated
Normal file
@@ -0,0 +1,311 @@
|
||||
using GHelper.UI;
|
||||
|
||||
namespace GHelper.AutoTDP
|
||||
{
|
||||
partial class AutoTDPUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
panelPerformanceHeader = new Panel();
|
||||
pictureKeyboard = new PictureBox();
|
||||
labelGlobalSettings = new Label();
|
||||
checkBoxEnabled = new CheckBox();
|
||||
panelLightingContent = new Panel();
|
||||
comboBoxFPSSource = new RComboBox();
|
||||
labelFPSSource = new Label();
|
||||
comboBoxLimiter = new RComboBox();
|
||||
labelLimiter = new Label();
|
||||
buttonAddGame = new RButton();
|
||||
panelGamesHeader = new Panel();
|
||||
pictureBox1 = new PictureBox();
|
||||
labelGames = new Label();
|
||||
tableLayoutGames = new TableLayoutPanel();
|
||||
buttonGameDummy = new RButton();
|
||||
panelPerformanceHeader.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureKeyboard).BeginInit();
|
||||
panelLightingContent.SuspendLayout();
|
||||
panelGamesHeader.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
tableLayoutGames.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panelPerformanceHeader
|
||||
//
|
||||
panelPerformanceHeader.BackColor = SystemColors.ControlLight;
|
||||
panelPerformanceHeader.Controls.Add(pictureKeyboard);
|
||||
panelPerformanceHeader.Controls.Add(labelGlobalSettings);
|
||||
panelPerformanceHeader.Controls.Add(checkBoxEnabled);
|
||||
panelPerformanceHeader.Dock = DockStyle.Top;
|
||||
panelPerformanceHeader.Location = new Point(0, 0);
|
||||
panelPerformanceHeader.Margin = new Padding(2);
|
||||
panelPerformanceHeader.Name = "panelPerformanceHeader";
|
||||
panelPerformanceHeader.Size = new Size(446, 30);
|
||||
panelPerformanceHeader.TabIndex = 52;
|
||||
//
|
||||
// pictureKeyboard
|
||||
//
|
||||
pictureKeyboard.BackgroundImage = Properties.Resources.icons8_automation_32;
|
||||
pictureKeyboard.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureKeyboard.Location = new Point(3, 8);
|
||||
pictureKeyboard.Margin = new Padding(2);
|
||||
pictureKeyboard.Name = "pictureKeyboard";
|
||||
pictureKeyboard.Size = new Size(16, 16);
|
||||
pictureKeyboard.TabIndex = 35;
|
||||
pictureKeyboard.TabStop = false;
|
||||
//
|
||||
// labelGlobalSettings
|
||||
//
|
||||
labelGlobalSettings.AutoSize = true;
|
||||
labelGlobalSettings.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelGlobalSettings.Location = new Point(22, 8);
|
||||
labelGlobalSettings.Margin = new Padding(4, 0, 4, 0);
|
||||
labelGlobalSettings.Name = "labelGlobalSettings";
|
||||
labelGlobalSettings.Size = new Size(100, 15);
|
||||
labelGlobalSettings.TabIndex = 34;
|
||||
labelGlobalSettings.Text = "General Settings";
|
||||
//
|
||||
// checkBoxEnabled
|
||||
//
|
||||
checkBoxEnabled.Location = new Point(244, 4);
|
||||
checkBoxEnabled.Margin = new Padding(4, 0, 4, 0);
|
||||
checkBoxEnabled.Name = "checkBoxEnabled";
|
||||
checkBoxEnabled.Size = new Size(198, 25);
|
||||
checkBoxEnabled.TabIndex = 53;
|
||||
checkBoxEnabled.Text = "Enabled";
|
||||
checkBoxEnabled.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// panelLightingContent
|
||||
//
|
||||
panelLightingContent.AutoSize = true;
|
||||
panelLightingContent.Controls.Add(comboBoxFPSSource);
|
||||
panelLightingContent.Controls.Add(labelFPSSource);
|
||||
panelLightingContent.Controls.Add(comboBoxLimiter);
|
||||
panelLightingContent.Controls.Add(labelLimiter);
|
||||
panelLightingContent.Dock = DockStyle.Top;
|
||||
panelLightingContent.Location = new Point(0, 30);
|
||||
panelLightingContent.Margin = new Padding(2);
|
||||
panelLightingContent.Name = "panelLightingContent";
|
||||
panelLightingContent.Padding = new Padding(0, 0, 0, 7);
|
||||
panelLightingContent.Size = new Size(446, 67);
|
||||
panelLightingContent.TabIndex = 56;
|
||||
//
|
||||
// comboBoxFPSSource
|
||||
//
|
||||
comboBoxFPSSource.BorderColor = Color.White;
|
||||
comboBoxFPSSource.ButtonColor = Color.FromArgb(255, 255, 255);
|
||||
comboBoxFPSSource.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxFPSSource.FlatStyle = FlatStyle.Flat;
|
||||
comboBoxFPSSource.FormattingEnabled = true;
|
||||
comboBoxFPSSource.Location = new Point(244, 37);
|
||||
comboBoxFPSSource.Margin = new Padding(11, 0, 11, 0);
|
||||
comboBoxFPSSource.Name = "comboBoxFPSSource";
|
||||
comboBoxFPSSource.Size = new Size(191, 23);
|
||||
comboBoxFPSSource.TabIndex = 56;
|
||||
//
|
||||
// labelFPSSource
|
||||
//
|
||||
labelFPSSource.Location = new Point(4, 37);
|
||||
labelFPSSource.Margin = new Padding(4, 0, 4, 0);
|
||||
labelFPSSource.Name = "labelFPSSource";
|
||||
labelFPSSource.Size = new Size(211, 22);
|
||||
labelFPSSource.TabIndex = 57;
|
||||
labelFPSSource.Text = "FPS Source";
|
||||
//
|
||||
// comboBoxLimiter
|
||||
//
|
||||
comboBoxLimiter.BorderColor = Color.White;
|
||||
comboBoxLimiter.ButtonColor = Color.FromArgb(255, 255, 255);
|
||||
comboBoxLimiter.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxLimiter.FlatStyle = FlatStyle.Flat;
|
||||
comboBoxLimiter.FormattingEnabled = true;
|
||||
comboBoxLimiter.Location = new Point(244, 7);
|
||||
comboBoxLimiter.Margin = new Padding(11, 0, 11, 0);
|
||||
comboBoxLimiter.Name = "comboBoxLimiter";
|
||||
comboBoxLimiter.Size = new Size(191, 23);
|
||||
comboBoxLimiter.TabIndex = 46;
|
||||
//
|
||||
// labelLimiter
|
||||
//
|
||||
labelLimiter.Location = new Point(4, 7);
|
||||
labelLimiter.Margin = new Padding(4, 0, 4, 0);
|
||||
labelLimiter.Name = "labelLimiter";
|
||||
labelLimiter.Size = new Size(211, 22);
|
||||
labelLimiter.TabIndex = 47;
|
||||
labelLimiter.Text = "Power Limiter";
|
||||
//
|
||||
// buttonAddGame
|
||||
//
|
||||
buttonAddGame.AccessibleName = "Keyboard Color";
|
||||
buttonAddGame.Activated = false;
|
||||
buttonAddGame.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonAddGame.BackColor = SystemColors.ButtonHighlight;
|
||||
buttonAddGame.BorderColor = Color.Transparent;
|
||||
buttonAddGame.BorderRadius = 2;
|
||||
buttonAddGame.FlatStyle = FlatStyle.Flat;
|
||||
buttonAddGame.ForeColor = SystemColors.ControlText;
|
||||
buttonAddGame.Location = new Point(339, 3);
|
||||
buttonAddGame.Margin = new Padding(2, 4, 2, 4);
|
||||
buttonAddGame.Name = "buttonAddGame";
|
||||
buttonAddGame.Secondary = false;
|
||||
buttonAddGame.Size = new Size(103, 25);
|
||||
buttonAddGame.TabIndex = 60;
|
||||
buttonAddGame.Text = "Add Game";
|
||||
buttonAddGame.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// panelGamesHeader
|
||||
//
|
||||
panelGamesHeader.BackColor = SystemColors.ControlLight;
|
||||
panelGamesHeader.Controls.Add(pictureBox1);
|
||||
panelGamesHeader.Controls.Add(buttonAddGame);
|
||||
panelGamesHeader.Controls.Add(labelGames);
|
||||
panelGamesHeader.Dock = DockStyle.Top;
|
||||
panelGamesHeader.Location = new Point(0, 97);
|
||||
panelGamesHeader.Margin = new Padding(2);
|
||||
panelGamesHeader.Name = "panelGamesHeader";
|
||||
panelGamesHeader.Size = new Size(446, 30);
|
||||
panelGamesHeader.TabIndex = 61;
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
pictureBox1.BackgroundImage = Properties.Resources.icons8_software_32_white;
|
||||
pictureBox1.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureBox1.Location = new Point(3, 8);
|
||||
pictureBox1.Margin = new Padding(2);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(16, 16);
|
||||
pictureBox1.TabIndex = 35;
|
||||
pictureBox1.TabStop = false;
|
||||
//
|
||||
// labelGames
|
||||
//
|
||||
labelGames.AutoSize = true;
|
||||
labelGames.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelGames.Location = new Point(22, 8);
|
||||
labelGames.Margin = new Padding(4, 0, 4, 0);
|
||||
labelGames.Name = "labelGames";
|
||||
labelGames.Size = new Size(45, 15);
|
||||
labelGames.TabIndex = 34;
|
||||
labelGames.Text = "Games";
|
||||
//
|
||||
// tableLayoutGames
|
||||
//
|
||||
tableLayoutGames.AutoSize = true;
|
||||
tableLayoutGames.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
tableLayoutGames.ColumnCount = 4;
|
||||
tableLayoutGames.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
|
||||
tableLayoutGames.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
|
||||
tableLayoutGames.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
|
||||
tableLayoutGames.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
|
||||
tableLayoutGames.Controls.Add(buttonGameDummy, 0, 0);
|
||||
tableLayoutGames.Dock = DockStyle.Top;
|
||||
tableLayoutGames.Location = new Point(0, 127);
|
||||
tableLayoutGames.Margin = new Padding(4, 2, 4, 2);
|
||||
tableLayoutGames.Name = "tableLayoutGames";
|
||||
tableLayoutGames.RowCount = 7;
|
||||
tableLayoutGames.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F));
|
||||
tableLayoutGames.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F));
|
||||
tableLayoutGames.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F));
|
||||
tableLayoutGames.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F));
|
||||
tableLayoutGames.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F));
|
||||
tableLayoutGames.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F));
|
||||
tableLayoutGames.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F));
|
||||
tableLayoutGames.Size = new Size(446, 420);
|
||||
tableLayoutGames.TabIndex = 62;
|
||||
//
|
||||
// buttonGameDummy
|
||||
//
|
||||
buttonGameDummy.AccessibleName = "DPI Setting 4";
|
||||
buttonGameDummy.Activated = false;
|
||||
buttonGameDummy.AutoSize = true;
|
||||
buttonGameDummy.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
buttonGameDummy.BackColor = SystemColors.ControlLightLight;
|
||||
buttonGameDummy.BorderColor = Color.LightGreen;
|
||||
buttonGameDummy.BorderRadius = 5;
|
||||
buttonGameDummy.Dock = DockStyle.Fill;
|
||||
buttonGameDummy.FlatAppearance.BorderSize = 0;
|
||||
buttonGameDummy.FlatStyle = FlatStyle.Flat;
|
||||
buttonGameDummy.ForeColor = SystemColors.ControlText;
|
||||
buttonGameDummy.ImageAlign = ContentAlignment.BottomCenter;
|
||||
buttonGameDummy.Location = new Point(2, 2);
|
||||
buttonGameDummy.Margin = new Padding(2);
|
||||
buttonGameDummy.Name = "buttonGameDummy";
|
||||
buttonGameDummy.Secondary = false;
|
||||
buttonGameDummy.Size = new Size(107, 56);
|
||||
buttonGameDummy.TabIndex = 7;
|
||||
buttonGameDummy.Text = "Genshin Impact\r\n60FPS\r\n";
|
||||
buttonGameDummy.TextImageRelation = TextImageRelation.ImageAboveText;
|
||||
buttonGameDummy.UseVisualStyleBackColor = false;
|
||||
buttonGameDummy.Visible = false;
|
||||
//
|
||||
// AutoTDPUI
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(446, 547);
|
||||
Controls.Add(tableLayoutGames);
|
||||
Controls.Add(panelGamesHeader);
|
||||
Controls.Add(panelLightingContent);
|
||||
Controls.Add(panelPerformanceHeader);
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "AutoTDPUI";
|
||||
ShowIcon = false;
|
||||
Text = "Auto TDP Settings";
|
||||
panelPerformanceHeader.ResumeLayout(false);
|
||||
panelPerformanceHeader.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureKeyboard).EndInit();
|
||||
panelLightingContent.ResumeLayout(false);
|
||||
panelGamesHeader.ResumeLayout(false);
|
||||
panelGamesHeader.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
tableLayoutGames.ResumeLayout(false);
|
||||
tableLayoutGames.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private Panel panelPerformanceHeader;
|
||||
private PictureBox pictureKeyboard;
|
||||
private Label labelGlobalSettings;
|
||||
private Panel panelLightingContent;
|
||||
private TableLayoutPanel tableLayoutGames;
|
||||
private UI.RButton rButton1;
|
||||
private CheckBox checkBoxEnabled;
|
||||
private UI.RComboBox comboBoxLightingMode;
|
||||
private Label labelLimiter;
|
||||
private UI.RComboBox comboBoxFPSSource;
|
||||
private Label labelFPSSource;
|
||||
private RComboBox comboBoxLimiter;
|
||||
private RButton buttonAddGame;
|
||||
private Panel panelGamesHeader;
|
||||
private PictureBox pictureBox1;
|
||||
private Label labelGames;
|
||||
private RButton buttonGameDummy;
|
||||
}
|
||||
}
|
||||
220
app/AutoTDP/AutoTDPUI.cs
Normal file
220
app/AutoTDP/AutoTDPUI.cs
Normal file
@@ -0,0 +1,220 @@
|
||||
using GHelper.AutoTDP.FramerateSource;
|
||||
using GHelper.AutoTDP.PowerLimiter;
|
||||
using GHelper.UI;
|
||||
using Ryzen;
|
||||
using System.Linq;
|
||||
|
||||
namespace GHelper.AutoTDP
|
||||
{
|
||||
public partial class AutoTDPUI : RForm
|
||||
{
|
||||
|
||||
private Dictionary<string, string> ModeTexts = new Dictionary<string, string>();
|
||||
|
||||
|
||||
private AutoTDPGameProfileUI? profileUI;
|
||||
public AutoTDPUI()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
InitTheme();
|
||||
|
||||
|
||||
ModeTexts.Add("intel_msr", "Intel MSR Power Limiter");
|
||||
ModeTexts.Add("asus_acpi", "ASUS ACPI Power Limiter");
|
||||
ModeTexts.Add("rtss", "Riva Tuner Statistics Server");
|
||||
|
||||
checkBoxEnabled.CheckedChanged += CheckBoxEnabled_CheckedChanged;
|
||||
buttonAddGame.Click += ButtonAddGame_Click;
|
||||
|
||||
comboBoxLimiter.DropDownClosed += ComboBoxLimiter_DropDownClosed;
|
||||
|
||||
comboBoxFPSSource.DropDownClosed += ComboBoxFPSSource_DropDownClosed;
|
||||
|
||||
Shown += AutoTDPUI_Shown;
|
||||
|
||||
VisualizeGeneralSettings();
|
||||
VizualizeGameList();
|
||||
}
|
||||
|
||||
private void ComboBoxFPSSource_DropDownClosed(object? sender, EventArgs e)
|
||||
{
|
||||
AppConfig.Set("auto_tdp_fps_source", AutoTDPService.AvailableFramerateSources().ElementAt(comboBoxFPSSource.SelectedIndex));
|
||||
|
||||
}
|
||||
|
||||
private void ComboBoxLimiter_DropDownClosed(object? sender, EventArgs e)
|
||||
{
|
||||
AppConfig.Set("auto_tdp_limiter", AutoTDPService.AvailablePowerLimiters().ElementAt(comboBoxLimiter.SelectedIndex));
|
||||
}
|
||||
|
||||
private void CheckBoxEnabled_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
AppConfig.Set("auto_tdp_enabled", checkBoxEnabled.Checked ? 1 : 0);
|
||||
|
||||
if (Program.autoTDPService.IsEnabled())
|
||||
{
|
||||
Program.autoTDPService.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.autoTDPService.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddGame_Click(object? sender, EventArgs e)
|
||||
{
|
||||
string? path = null;
|
||||
Thread t = new Thread(() =>
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Executables (*.exe)|*.exe";
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
path = ofd.FileName;
|
||||
}
|
||||
});
|
||||
|
||||
t.SetApartmentState(ApartmentState.STA);
|
||||
t.Start();
|
||||
t.Join();
|
||||
|
||||
if (path is null)
|
||||
{
|
||||
//User did not select a file
|
||||
return;
|
||||
}
|
||||
|
||||
GameProfile p = new GameProfile();
|
||||
p.ProcessName = Path.GetFileName(path);
|
||||
p.GameTitle = Path.GetFileName(path).Replace(".exe", "");
|
||||
p.Enabled = true;
|
||||
p.TargetFPS = 60;
|
||||
p.MaxTdp = 40;
|
||||
p.MinTdp = 15;
|
||||
|
||||
profileUI = new AutoTDPGameProfileUI(p, this);
|
||||
profileUI.FormClosed += ProfileUI_FormClosed;
|
||||
profileUI.ShowDialog(this);
|
||||
}
|
||||
|
||||
private void ProfileUI_FormClosed(object? sender, FormClosedEventArgs e)
|
||||
{
|
||||
profileUI = null;
|
||||
}
|
||||
|
||||
private void AutoTDPUI_Shown(object? sender, EventArgs e)
|
||||
{
|
||||
if (Height > Program.settingsForm.Height)
|
||||
{
|
||||
Top = Program.settingsForm.Top + Program.settingsForm.Height - Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Top = Program.settingsForm.Top;
|
||||
}
|
||||
|
||||
Left = Program.settingsForm.Left - Width - 5;
|
||||
}
|
||||
|
||||
private void VisualizeGeneralSettings()
|
||||
{
|
||||
checkBoxEnabled.Checked = AppConfig.Get("auto_tdp_enabled", 0) == 1;
|
||||
|
||||
comboBoxLimiter.Items.Clear();
|
||||
comboBoxFPSSource.Items.Clear();
|
||||
|
||||
foreach (string s in AutoTDPService.AvailablePowerLimiters())
|
||||
{
|
||||
comboBoxLimiter.Items.Add(ModeTexts[s]);
|
||||
}
|
||||
|
||||
foreach (string s in AutoTDPService.AvailableFramerateSources())
|
||||
{
|
||||
comboBoxFPSSource.Items.Add(ModeTexts[s]);
|
||||
}
|
||||
|
||||
|
||||
string? limiter = AppConfig.GetString("auto_tdp_limiter", null);
|
||||
string? source = AppConfig.GetString("auto_tdp_fps_source", null);
|
||||
|
||||
|
||||
if (limiter is not null && AutoTDPService.AvailablePowerLimiters().Contains(limiter))
|
||||
{
|
||||
comboBoxLimiter.SelectedIndex = AutoTDPService.AvailablePowerLimiters().IndexOf(limiter);
|
||||
}
|
||||
else
|
||||
{
|
||||
comboBoxLimiter.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
if (source is not null && AutoTDPService.AvailableFramerateSources().Contains(source))
|
||||
{
|
||||
comboBoxFPSSource.SelectedIndex = AutoTDPService.AvailableFramerateSources().IndexOf(source);
|
||||
}
|
||||
else
|
||||
{
|
||||
comboBoxFPSSource.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void VizualizeGameList()
|
||||
{
|
||||
//Due to my lousy skills in UI design, the game table is limited to 7x4 games.
|
||||
buttonAddGame.Enabled = Program.autoTDPService.GameProfiles.Count < 7 * 4;
|
||||
|
||||
tableLayoutGames.Controls.Clear();
|
||||
|
||||
foreach (GameProfile gp in Program.autoTDPService.GameProfiles)
|
||||
{
|
||||
RButton bt = new RButton();
|
||||
bt.Text = gp.GameTitle + "\n" + gp.TargetFPS + " FPS";
|
||||
|
||||
bt.Dock = DockStyle.Fill;
|
||||
bt.FlatStyle = FlatStyle.Flat;
|
||||
bt.FlatAppearance.BorderColor = RForm.borderMain;
|
||||
bt.UseVisualStyleBackColor = false;
|
||||
bt.AutoSize = true;
|
||||
bt.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
bt.BackColor = RForm.buttonMain;
|
||||
bt.ForeColor = RForm.foreMain;
|
||||
bt.Click += Bt_Click;
|
||||
bt.Tag = gp;
|
||||
|
||||
tableLayoutGames.Controls.Add(bt);
|
||||
}
|
||||
}
|
||||
|
||||
private void Bt_Click(object? sender, EventArgs e)
|
||||
{
|
||||
GameProfile gp = (GameProfile)((RButton)sender).Tag;
|
||||
profileUI = new AutoTDPGameProfileUI(gp, this);
|
||||
profileUI.FormClosed += ProfileUI_FormClosed;
|
||||
profileUI.ShowDialog(this);
|
||||
}
|
||||
|
||||
public void DeleteGameProfile(GameProfile gp)
|
||||
{
|
||||
if (Program.autoTDPService.IsGameInList(gp.ProcessName))
|
||||
{
|
||||
Program.autoTDPService.GameProfiles.Remove(gp);
|
||||
}
|
||||
|
||||
Program.autoTDPService.SaveGameProfiles();
|
||||
VizualizeGameList();
|
||||
}
|
||||
|
||||
public void UpdateGameProfile(GameProfile gp)
|
||||
{
|
||||
if (!Program.autoTDPService.IsGameInList(gp.ProcessName))
|
||||
{
|
||||
Program.autoTDPService.GameProfiles.Add(gp);
|
||||
}
|
||||
Program.autoTDPService.SaveGameProfiles();
|
||||
VizualizeGameList();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
app/AutoTDP/AutoTDPUI.resx
Normal file
120
app/AutoTDP/AutoTDPUI.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
17
app/AutoTDP/FramerateSource/IFramerateSource.cs
Normal file
17
app/AutoTDP/FramerateSource/IFramerateSource.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace GHelper.AutoTDP.FramerateSource
|
||||
{
|
||||
|
||||
internal class GameInstance
|
||||
{
|
||||
public string? ProcessName { get; set; }
|
||||
|
||||
public int ProcessID { get; set; }
|
||||
}
|
||||
|
||||
internal interface IFramerateSource
|
||||
{
|
||||
public double GetFramerate(GameInstance instance);
|
||||
|
||||
public List<GameInstance> GetRunningGames();
|
||||
}
|
||||
}
|
||||
130
app/AutoTDP/FramerateSource/RTSSFramerateSource.cs
Normal file
130
app/AutoTDP/FramerateSource/RTSSFramerateSource.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using System.Diagnostics;
|
||||
using RTSSSharedMemoryNET;
|
||||
|
||||
namespace GHelper.AutoTDP.FramerateSource
|
||||
{
|
||||
internal class RTSSFramerateSource : IFramerateSource
|
||||
{
|
||||
private static Process? rtssInstance;
|
||||
|
||||
private static OSD? osd;
|
||||
|
||||
public static string RTSSPath { get; set; }
|
||||
|
||||
|
||||
public static bool IsRunning => Process.GetProcessesByName("RTSS").Length != 0;
|
||||
|
||||
|
||||
static RTSSFramerateSource()
|
||||
{
|
||||
RTSSPath = @"C:\Program Files (x86)\RivaTuner Statistics Server\RTSS.exe";
|
||||
}
|
||||
|
||||
public static bool IsAvailable()
|
||||
{
|
||||
return File.Exists(RTSSPath);
|
||||
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
if ((rtssInstance == null || rtssInstance.HasExited) && !IsRunning && File.Exists(RTSSPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
rtssInstance = Process.Start(RTSSPath);
|
||||
Thread.Sleep(2000); // If it works, don't touch it
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Logger.WriteLine("Could not start RTSS Service" + exc.Message);
|
||||
}
|
||||
|
||||
RunOSD();
|
||||
}
|
||||
else
|
||||
{
|
||||
RunOSD();
|
||||
}
|
||||
}
|
||||
|
||||
public List<GameInstance> GetRunningGames()
|
||||
{
|
||||
if (!IsRunning)
|
||||
{
|
||||
return new List<GameInstance>();
|
||||
}
|
||||
|
||||
List<GameInstance> giL = new List<GameInstance>();
|
||||
|
||||
foreach (AppEntry appEntry in OSD.GetAppEntries())
|
||||
{
|
||||
GameInstance i = new GameInstance();
|
||||
i.ProcessID = appEntry.ProcessId;
|
||||
i.ProcessName = appEntry.Name;
|
||||
|
||||
giL.Add(i);
|
||||
}
|
||||
|
||||
return giL;
|
||||
}
|
||||
|
||||
public double GetFramerate(GameInstance instance)
|
||||
{
|
||||
if (!IsRunning)
|
||||
{
|
||||
return -1.0d;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var appE = OSD.GetAppEntries().FirstOrDefault(a => a.ProcessId == instance.ProcessID);
|
||||
if (appE is null)
|
||||
return -1.0d;
|
||||
|
||||
return (double)appE.StatFrameTimeBufFramerate / 10;
|
||||
}
|
||||
catch (InvalidDataException)
|
||||
{
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
}
|
||||
|
||||
return -1.0d;
|
||||
}
|
||||
|
||||
public static void RunOSD()
|
||||
{
|
||||
if (osd == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
osd = new OSD("GHELPER");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Logger.WriteLine("Could not start OSD" + exc.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Stop()
|
||||
{
|
||||
if (rtssInstance != null && !rtssInstance.HasExited)
|
||||
{
|
||||
try
|
||||
{
|
||||
rtssInstance.Kill();
|
||||
rtssInstance = null;
|
||||
var proc = Process.GetProcessesByName("RTSSHooksLoader64");
|
||||
proc[0].Kill();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
app/AutoTDP/GameProfile.cs
Normal file
18
app/AutoTDP/GameProfile.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
namespace GHelper.AutoTDP
|
||||
{
|
||||
public class GameProfile
|
||||
{
|
||||
public string GameTitle { get; set; }
|
||||
public string ProcessName { get; set; }
|
||||
public int TargetFPS { get; set; }
|
||||
public int MinTdp { get; set; }
|
||||
public int MaxTdp { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int GetTDPFPS()
|
||||
{
|
||||
return TargetFPS - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
57
app/AutoTDP/PowerLimiter/ASUSACPIPowerLimiter.cs
Normal file
57
app/AutoTDP/PowerLimiter/ASUSACPIPowerLimiter.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using GHelper.Mode;
|
||||
|
||||
namespace GHelper.AutoTDP.PowerLimiter
|
||||
{
|
||||
internal class ASUSACPIPowerLimiter : IPowerLimiter
|
||||
{
|
||||
|
||||
private bool allAmd;
|
||||
private bool fPPT;
|
||||
|
||||
public ASUSACPIPowerLimiter()
|
||||
{
|
||||
allAmd = Program.acpi.IsAllAmdPPT();
|
||||
fPPT = Program.acpi.DeviceGet(AsusACPI.PPT_APUC1) >= 0;
|
||||
}
|
||||
|
||||
public static bool IsAvailable()
|
||||
{
|
||||
return AppConfig.IsASUS();
|
||||
}
|
||||
|
||||
public void SavePowerLimits()
|
||||
{
|
||||
}
|
||||
|
||||
public void SetCPUPowerLimit(double watts)
|
||||
{
|
||||
|
||||
if (allAmd) // CPU limit all amd models
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.PPT_CPUB0, (int)watts, "PowerLimit B0");
|
||||
} else {
|
||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUA3, (int)watts, "PowerLimit A3");
|
||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUA0, (int)watts, "PowerLimit A0");
|
||||
if (fPPT) Program.acpi.DeviceSet(AsusACPI.PPT_APUC1, (int)watts, "PowerLimit C1");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// You can't read PPTs on ASUS :) endpoints just return 0 if they are available
|
||||
public int GetCPUPowerLimit()
|
||||
{
|
||||
return Program.acpi.DeviceGet(AsusACPI.PPT_APUA0);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
//Nothing to dispose here
|
||||
}
|
||||
|
||||
// Correct Asus way to reset everything, is just to set mode again
|
||||
public void ResetPowerLimits()
|
||||
{
|
||||
Program.modeControl.SetPerformanceMode(Modes.GetCurrent());
|
||||
}
|
||||
}
|
||||
}
|
||||
14
app/AutoTDP/PowerLimiter/IPowerLimiter.cs
Normal file
14
app/AutoTDP/PowerLimiter/IPowerLimiter.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace GHelper.AutoTDP.PowerLimiter
|
||||
{
|
||||
internal interface IPowerLimiter : IDisposable
|
||||
{
|
||||
public void SetCPUPowerLimit(double watts);
|
||||
|
||||
public int GetCPUPowerLimit();
|
||||
|
||||
public void ResetPowerLimits();
|
||||
|
||||
public void SavePowerLimits();
|
||||
|
||||
}
|
||||
}
|
||||
110
app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs
Normal file
110
app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using Ryzen;
|
||||
|
||||
namespace GHelper.AutoTDP.PowerLimiter
|
||||
{
|
||||
|
||||
internal class IntelMSRPowerLimiter : IPowerLimiter
|
||||
{
|
||||
public static readonly uint MSR_PKG_POWER_LIMIT = 0x610;
|
||||
public static readonly uint MSR_RAPL_POWER_UNIT = 0x606;
|
||||
|
||||
private Ols ols;
|
||||
|
||||
private uint DefaultEax = 0; // Set on first reading
|
||||
private uint DefaultEdx = 0;
|
||||
|
||||
//Lower 14 bits are the power limits
|
||||
private uint PL1_MASK = 0x3FFF;
|
||||
private uint PL2_MASK = 0x3FFF;
|
||||
|
||||
//The power unit factor (Default is 0.125 for most Intel CPUs).
|
||||
private double PowerUnit = 0x0;
|
||||
|
||||
public IntelMSRPowerLimiter()
|
||||
{
|
||||
ols = new Ols();
|
||||
ols.InitializeOls();
|
||||
ReadPowerUnit();
|
||||
}
|
||||
|
||||
public static bool IsAvailable()
|
||||
{
|
||||
return !RyzenControl.IsAMD();
|
||||
}
|
||||
|
||||
public void SavePowerLimits()
|
||||
{
|
||||
DefaultEax = 0;
|
||||
DefaultEdx = 0;
|
||||
|
||||
ols.Rdmsr(MSR_PKG_POWER_LIMIT, ref DefaultEax, ref DefaultEdx);
|
||||
}
|
||||
|
||||
public void ReadPowerUnit()
|
||||
{
|
||||
uint eax = 0;
|
||||
uint edx = 0;
|
||||
|
||||
ols.Rdmsr(MSR_RAPL_POWER_UNIT, ref eax, ref edx);
|
||||
|
||||
|
||||
uint pwr = eax & 0x03;
|
||||
|
||||
PowerUnit = 1 / Math.Pow(2, pwr);
|
||||
}
|
||||
|
||||
public void SetCPUPowerLimit(double watts)
|
||||
{
|
||||
uint eax = 0;
|
||||
uint edx = 0;
|
||||
|
||||
|
||||
ols.Rdmsr(MSR_PKG_POWER_LIMIT, ref eax, ref edx);
|
||||
|
||||
uint watsRapl = (uint)(watts / PowerUnit);
|
||||
|
||||
//Set limits for both PL1 and PL2
|
||||
uint eaxFilterd = eax & ~PL1_MASK;
|
||||
uint edxFilterd = edx & ~PL2_MASK;
|
||||
|
||||
eaxFilterd |= watsRapl;
|
||||
edxFilterd |= watsRapl;
|
||||
|
||||
//Enable clamping
|
||||
eaxFilterd |= 0x8000;
|
||||
edxFilterd |= 0x8000;
|
||||
|
||||
ols.Wrmsr(0x610, eaxFilterd, edxFilterd);
|
||||
}
|
||||
|
||||
|
||||
public int GetCPUPowerLimit()
|
||||
{
|
||||
uint eax = 0;
|
||||
uint edx = 0;
|
||||
|
||||
ols.Rdmsr(MSR_PKG_POWER_LIMIT, ref eax, ref edx);
|
||||
|
||||
uint pl1 = eax & PL1_MASK;
|
||||
uint pl2 = edx & PL2_MASK;
|
||||
|
||||
return (int)(pl1 * PowerUnit);
|
||||
}
|
||||
|
||||
|
||||
public void ResetPowerLimits()
|
||||
{
|
||||
if (DefaultEax == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ols.Wrmsr(MSR_PKG_POWER_LIMIT, DefaultEax, DefaultEdx);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
ols.DeinitializeOls();
|
||||
ols.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,29 +24,17 @@ namespace GHelper.Display
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveGamma()
|
||||
public void SetBrightness(int brightness = -1)
|
||||
{
|
||||
var screenName = ScreenNative.FindLaptopScreen();
|
||||
if (screenName is null) return;
|
||||
if (!AppConfig.IsOLED()) return;
|
||||
|
||||
try
|
||||
{
|
||||
var handle = ScreenNative.CreateDC(screenName, screenName, null, IntPtr.Zero);
|
||||
var gammaRamp = new GammaRamp();
|
||||
if (ScreenNative.GetDeviceGammaRamp(handle, ref gammaRamp))
|
||||
{
|
||||
var gamma = new DisplayGammaRamp(gammaRamp);
|
||||
Logger.WriteLine("Gamma R: " + string.Join("-", gamma.Red));
|
||||
Logger.WriteLine("Gamma G: " + string.Join("-", gamma.Green));
|
||||
Logger.WriteLine("Gamma B: " + string.Join("-", gamma.Blue));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.ToString());
|
||||
}
|
||||
if (brightness >= 0) AppConfig.Set("brightness", brightness);
|
||||
else brightness = AppConfig.Get("brightness");
|
||||
|
||||
if (brightness >= 0) SetGamma(brightness);
|
||||
}
|
||||
|
||||
|
||||
public void SetGamma(int brightness = 100)
|
||||
{
|
||||
var bright = Math.Round((float)brightness / 200 + 0.5, 2);
|
||||
@@ -63,15 +51,15 @@ namespace GHelper.Display
|
||||
if (ScreenNative.GetDeviceGammaRamp(handle, ref gammaDump))
|
||||
{
|
||||
gammaRamp = new DisplayGammaRamp(gammaDump);
|
||||
Logger.WriteLine("Gamma R: " + string.Join("-", gammaRamp.Red));
|
||||
Logger.WriteLine("Gamma G: " + string.Join("-", gammaRamp.Green));
|
||||
Logger.WriteLine("Gamma B: " + string.Join("-", gammaRamp.Blue));
|
||||
//Logger.WriteLine("Gamma R: " + string.Join("-", gammaRamp.Red));
|
||||
//Logger.WriteLine("Gamma G: " + string.Join("-", gammaRamp.Green));
|
||||
//Logger.WriteLine("Gamma B: " + string.Join("-", gammaRamp.Blue));
|
||||
}
|
||||
}
|
||||
|
||||
if (gammaRamp is null || !gammaRamp.IsOriginal())
|
||||
{
|
||||
Logger.WriteLine("Default Gamma");
|
||||
Logger.WriteLine("Not default Gamma");
|
||||
gammaRamp = new DisplayGammaRamp();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,12 @@ namespace GHelper.Display
|
||||
[DllImport("gdi32")]
|
||||
internal static extern bool GetDeviceGammaRamp(IntPtr dcHandle, ref GammaRamp ramp);
|
||||
|
||||
[DllImport("gdi32", CharSet = CharSet.Unicode)]
|
||||
internal static extern bool SetICMProfileW(IntPtr dcHandle, string lpFileName);
|
||||
|
||||
[DllImport("gdi32", CharSet = CharSet.Unicode)]
|
||||
internal static extern bool SetICMMode(IntPtr dcHandle, int mode);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct DEVMODE
|
||||
{
|
||||
|
||||
@@ -398,17 +398,19 @@ namespace GHelper
|
||||
InitServices();
|
||||
InitHibernate();
|
||||
|
||||
//InitACPITesting();
|
||||
InitACPITesting();
|
||||
|
||||
}
|
||||
|
||||
private void InitACPITesting()
|
||||
{
|
||||
if (!AppConfig.Is("debug")) return;
|
||||
|
||||
pictureScan.Visible = true;
|
||||
panelACPI.Visible = true;
|
||||
|
||||
textACPICommand.Text = "120075";
|
||||
textACPIParam.Text = "1";
|
||||
textACPICommand.Text = "120098";
|
||||
textACPIParam.Text = "25";
|
||||
|
||||
buttonACPISend.Click += ButtonACPISend_Click;
|
||||
pictureScan.Click += PictureScan_Click;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace GHelper.Fan
|
||||
|
||||
public const int XGM_FAN_MAX = 72;
|
||||
|
||||
public const int INADEQUATE_MAX = 92;
|
||||
public const int INADEQUATE_MAX = 104;
|
||||
|
||||
const int FAN_COUNT = 3;
|
||||
|
||||
|
||||
73
app/Fans.Designer.cs
generated
73
app/Fans.Designer.cs
generated
@@ -119,6 +119,10 @@ namespace GHelper
|
||||
picturePowerMode = new PictureBox();
|
||||
labelPowerModeTitle = new Label();
|
||||
panelGPU = new Panel();
|
||||
panelGPUPower = new Panel();
|
||||
labelGPUPower = new Label();
|
||||
labelGPUPowerTitle = new Label();
|
||||
trackGPUPower = new TrackBar();
|
||||
panelGPUTemp = new Panel();
|
||||
labelGPUTemp = new Label();
|
||||
labelGPUTempTitle = new Label();
|
||||
@@ -190,6 +194,8 @@ namespace GHelper
|
||||
panelPowerModeTItle.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)picturePowerMode).BeginInit();
|
||||
panelGPU.SuspendLayout();
|
||||
panelGPUPower.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackGPUPower).BeginInit();
|
||||
panelGPUTemp.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackGPUTemp).BeginInit();
|
||||
panelGPUBoost.SuspendLayout();
|
||||
@@ -533,7 +539,7 @@ namespace GHelper
|
||||
panelAdvanced.Controls.Add(panelTitleTemp);
|
||||
panelAdvanced.Controls.Add(panelDownload);
|
||||
panelAdvanced.Dock = DockStyle.Top;
|
||||
panelAdvanced.Location = new Point(10, 1644);
|
||||
panelAdvanced.Location = new Point(10, 1768);
|
||||
panelAdvanced.Name = "panelAdvanced";
|
||||
panelAdvanced.Size = new Size(520, 992);
|
||||
panelAdvanced.TabIndex = 14;
|
||||
@@ -864,7 +870,7 @@ namespace GHelper
|
||||
panelPower.Controls.Add(panelPowerMode);
|
||||
panelPower.Controls.Add(panelPowerModeTItle);
|
||||
panelPower.Dock = DockStyle.Top;
|
||||
panelPower.Location = new Point(10, 764);
|
||||
panelPower.Location = new Point(10, 888);
|
||||
panelPower.Margin = new Padding(4);
|
||||
panelPower.Name = "panelPower";
|
||||
panelPower.Size = new Size(520, 880);
|
||||
@@ -1237,6 +1243,7 @@ namespace GHelper
|
||||
panelGPU.AutoSize = true;
|
||||
panelGPU.Controls.Add(panelGPUTemp);
|
||||
panelGPU.Controls.Add(panelGPUBoost);
|
||||
panelGPU.Controls.Add(panelGPUPower);
|
||||
panelGPU.Controls.Add(panelGPUMemory);
|
||||
panelGPU.Controls.Add(panelGPUCore);
|
||||
panelGPU.Controls.Add(panelGPUClockLimit);
|
||||
@@ -1246,10 +1253,59 @@ namespace GHelper
|
||||
panelGPU.Margin = new Padding(4);
|
||||
panelGPU.Name = "panelGPU";
|
||||
panelGPU.Padding = new Padding(0, 0, 0, 18);
|
||||
panelGPU.Size = new Size(520, 698);
|
||||
panelGPU.Size = new Size(520, 822);
|
||||
panelGPU.TabIndex = 44;
|
||||
panelGPU.Visible = false;
|
||||
//
|
||||
// panelGPUPower
|
||||
//
|
||||
panelGPUPower.AutoSize = true;
|
||||
panelGPUPower.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
panelGPUPower.Controls.Add(labelGPUPower);
|
||||
panelGPUPower.Controls.Add(labelGPUPowerTitle);
|
||||
panelGPUPower.Controls.Add(trackGPUPower);
|
||||
panelGPUPower.Dock = DockStyle.Top;
|
||||
panelGPUPower.Location = new Point(0, 432);
|
||||
panelGPUPower.Margin = new Padding(4);
|
||||
panelGPUPower.MaximumSize = new Size(0, 124);
|
||||
panelGPUPower.Name = "panelGPUPower";
|
||||
panelGPUPower.Size = new Size(520, 124);
|
||||
panelGPUPower.TabIndex = 49;
|
||||
//
|
||||
// labelGPUPower
|
||||
//
|
||||
labelGPUPower.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelGPUPower.Location = new Point(374, 14);
|
||||
labelGPUPower.Margin = new Padding(4, 0, 4, 0);
|
||||
labelGPUPower.Name = "labelGPUPower";
|
||||
labelGPUPower.Size = new Size(124, 32);
|
||||
labelGPUPower.TabIndex = 44;
|
||||
labelGPUPower.Text = "105W";
|
||||
labelGPUPower.TextAlign = ContentAlignment.TopRight;
|
||||
//
|
||||
// labelGPUPowerTitle
|
||||
//
|
||||
labelGPUPowerTitle.AutoSize = true;
|
||||
labelGPUPowerTitle.Location = new Point(10, 14);
|
||||
labelGPUPowerTitle.Margin = new Padding(4, 0, 4, 0);
|
||||
labelGPUPowerTitle.Name = "labelGPUPowerTitle";
|
||||
labelGPUPowerTitle.Size = new Size(130, 32);
|
||||
labelGPUPowerTitle.TabIndex = 43;
|
||||
labelGPUPowerTitle.Text = "GPU Power";
|
||||
//
|
||||
// trackGPUPower
|
||||
//
|
||||
trackGPUPower.Location = new Point(6, 48);
|
||||
trackGPUPower.Margin = new Padding(4, 2, 4, 2);
|
||||
trackGPUPower.Maximum = 25;
|
||||
trackGPUPower.Minimum = 5;
|
||||
trackGPUPower.Name = "trackGPUPower";
|
||||
trackGPUPower.Size = new Size(496, 90);
|
||||
trackGPUPower.TabIndex = 42;
|
||||
trackGPUPower.TickFrequency = 5;
|
||||
trackGPUPower.TickStyle = TickStyle.TopLeft;
|
||||
trackGPUPower.Value = 25;
|
||||
//
|
||||
// panelGPUTemp
|
||||
//
|
||||
panelGPUTemp.AutoSize = true;
|
||||
@@ -1258,7 +1314,7 @@ namespace GHelper
|
||||
panelGPUTemp.Controls.Add(labelGPUTempTitle);
|
||||
panelGPUTemp.Controls.Add(trackGPUTemp);
|
||||
panelGPUTemp.Dock = DockStyle.Top;
|
||||
panelGPUTemp.Location = new Point(0, 556);
|
||||
panelGPUTemp.Location = new Point(0, 680);
|
||||
panelGPUTemp.Margin = new Padding(4);
|
||||
panelGPUTemp.MaximumSize = new Size(0, 124);
|
||||
panelGPUTemp.Name = "panelGPUTemp";
|
||||
@@ -1307,7 +1363,7 @@ namespace GHelper
|
||||
panelGPUBoost.Controls.Add(labelGPUBoostTitle);
|
||||
panelGPUBoost.Controls.Add(trackGPUBoost);
|
||||
panelGPUBoost.Dock = DockStyle.Top;
|
||||
panelGPUBoost.Location = new Point(0, 432);
|
||||
panelGPUBoost.Location = new Point(0, 556);
|
||||
panelGPUBoost.Margin = new Padding(4);
|
||||
panelGPUBoost.MaximumSize = new Size(0, 124);
|
||||
panelGPUBoost.Name = "panelGPUBoost";
|
||||
@@ -1700,6 +1756,9 @@ namespace GHelper
|
||||
((System.ComponentModel.ISupportInitialize)picturePowerMode).EndInit();
|
||||
panelGPU.ResumeLayout(false);
|
||||
panelGPU.PerformLayout();
|
||||
panelGPUPower.ResumeLayout(false);
|
||||
panelGPUPower.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackGPUPower).EndInit();
|
||||
panelGPUTemp.ResumeLayout(false);
|
||||
panelGPUTemp.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackGPUTemp).EndInit();
|
||||
@@ -1833,5 +1892,9 @@ namespace GHelper
|
||||
private TrackBar trackSlow;
|
||||
private Panel panelDownload;
|
||||
private RButton buttonDownload;
|
||||
private Panel panelGPUPower;
|
||||
private Label labelGPUPower;
|
||||
private Label labelGPUPowerTitle;
|
||||
private TrackBar trackGPUPower;
|
||||
}
|
||||
}
|
||||
76
app/Fans.cs
76
app/Fans.cs
@@ -31,6 +31,8 @@ namespace GHelper
|
||||
|
||||
FanSensorControl fanSensorControl;
|
||||
|
||||
static int gpuPowerBase = 0;
|
||||
|
||||
public Fans()
|
||||
{
|
||||
|
||||
@@ -144,17 +146,22 @@ namespace GHelper
|
||||
trackGPUTemp.Minimum = AsusACPI.MinGPUTemp;
|
||||
trackGPUTemp.Maximum = AsusACPI.MaxGPUTemp;
|
||||
|
||||
trackGPUPower.Minimum = AsusACPI.MinGPUPower;
|
||||
trackGPUPower.Maximum = AsusACPI.MaxGPUPower;
|
||||
|
||||
trackGPUClockLimit.Scroll += trackGPUClockLimit_Scroll;
|
||||
trackGPUCore.Scroll += trackGPU_Scroll;
|
||||
trackGPUMemory.Scroll += trackGPU_Scroll;
|
||||
|
||||
trackGPUBoost.Scroll += trackGPUPower_Scroll;
|
||||
trackGPUTemp.Scroll += trackGPUPower_Scroll;
|
||||
trackGPUPower.Scroll += trackGPUPower_Scroll;
|
||||
|
||||
trackGPUCore.MouseUp += TrackGPU_MouseUp;
|
||||
trackGPUMemory.MouseUp += TrackGPU_MouseUp;
|
||||
trackGPUBoost.MouseUp += TrackGPU_MouseUp;
|
||||
trackGPUTemp.MouseUp += TrackGPU_MouseUp;
|
||||
trackGPUPower.MouseUp += TrackGPU_MouseUp;
|
||||
|
||||
trackGPUClockLimit.MouseUp += TrackGPU_MouseUp;
|
||||
|
||||
@@ -541,8 +548,12 @@ namespace GHelper
|
||||
{
|
||||
gpuVisible = buttonGPU.Visible = true;
|
||||
|
||||
gpuPowerBase = Program.acpi.DeviceGet(AsusACPI.GPU_BASE);
|
||||
int gpuPowerVar = Program.acpi.DeviceGet(AsusACPI.GPU_POWER);
|
||||
|
||||
int gpu_boost = AppConfig.GetMode("gpu_boost");
|
||||
int gpu_temp = AppConfig.GetMode("gpu_temp");
|
||||
int gpu_power = AppConfig.GetMode("gpu_power");
|
||||
|
||||
int core = AppConfig.GetMode("gpu_core");
|
||||
int memory = AppConfig.GetMode("gpu_memory");
|
||||
@@ -550,32 +561,35 @@ namespace GHelper
|
||||
|
||||
if (gpu_boost < 0) gpu_boost = AsusACPI.MaxGPUBoost;
|
||||
if (gpu_temp < 0) gpu_temp = AsusACPI.MaxGPUTemp;
|
||||
if (gpu_power < 0) gpu_power = (gpuPowerVar >= 0) ? gpuPowerVar : AsusACPI.MaxGPUPower;
|
||||
|
||||
if (core == -1) core = 0;
|
||||
if (memory == -1) memory = 0;
|
||||
if (clock_limit == -1) clock_limit = NvidiaGpuControl.MaxClockLimit;
|
||||
|
||||
if (nvControl.GetClocks(out int current_core, out int current_memory))
|
||||
if (nvControl is not null)
|
||||
{
|
||||
core = current_core;
|
||||
memory = current_memory;
|
||||
if (nvControl.GetClocks(out int current_core, out int current_memory))
|
||||
{
|
||||
core = current_core;
|
||||
memory = current_memory;
|
||||
}
|
||||
|
||||
int _clockLimit = nvControl.GetMaxGPUCLock();
|
||||
|
||||
if (_clockLimit == 0) clock_limit = NvidiaGpuControl.MaxClockLimit;
|
||||
else if (_clockLimit > 0) clock_limit = _clockLimit;
|
||||
|
||||
try
|
||||
{
|
||||
labelGPU.Text = nvControl.FullName;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int _clockLimit = nvControl.GetMaxGPUCLock();
|
||||
|
||||
if (_clockLimit == 0) clock_limit = NvidiaGpuControl.MaxClockLimit;
|
||||
else if (_clockLimit > 0) clock_limit = _clockLimit;
|
||||
|
||||
try
|
||||
{
|
||||
labelGPU.Text = nvControl.FullName;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//}
|
||||
trackGPUClockLimit.Value = Math.Max(Math.Min(clock_limit, NvidiaGpuControl.MaxClockLimit), NvidiaGpuControl.MinClockLimit);
|
||||
|
||||
trackGPUCore.Value = Math.Max(Math.Min(core, NvidiaGpuControl.MaxCoreOffset), NvidiaGpuControl.MinCoreOffset);
|
||||
@@ -584,9 +598,13 @@ namespace GHelper
|
||||
trackGPUBoost.Value = Math.Max(Math.Min(gpu_boost, AsusACPI.MaxGPUBoost), AsusACPI.MinGPUBoost);
|
||||
trackGPUTemp.Value = Math.Max(Math.Min(gpu_temp, AsusACPI.MaxGPUTemp), AsusACPI.MinGPUTemp);
|
||||
|
||||
trackGPUPower.Value = Math.Max(Math.Min(gpu_power, AsusACPI.MaxGPUPower), AsusACPI.MinGPUPower);
|
||||
|
||||
panelGPUBoost.Visible = (Program.acpi.DeviceGet(AsusACPI.PPT_GPUC0) >= 0);
|
||||
panelGPUTemp.Visible = (Program.acpi.DeviceGet(AsusACPI.PPT_GPUC2) >= 0);
|
||||
|
||||
panelGPUPower.Visible = gpuPowerBase > 0 && gpuPowerVar >= 0;
|
||||
|
||||
VisualiseGPUSettings();
|
||||
|
||||
}
|
||||
@@ -610,6 +628,9 @@ namespace GHelper
|
||||
labelGPUClockLimit.Text = "Default";
|
||||
else
|
||||
labelGPUClockLimit.Text = $"{trackGPUClockLimit.Value} MHz";
|
||||
|
||||
labelGPUPower.Text = (gpuPowerBase + trackGPUPower.Value) + "W";
|
||||
|
||||
}
|
||||
|
||||
private void trackGPUClockLimit_Scroll(object? sender, EventArgs e)
|
||||
@@ -640,6 +661,7 @@ namespace GHelper
|
||||
{
|
||||
AppConfig.SetMode("gpu_boost", trackGPUBoost.Value);
|
||||
AppConfig.SetMode("gpu_temp", trackGPUTemp.Value);
|
||||
AppConfig.SetMode("gpu_power", trackGPUPower.Value);
|
||||
|
||||
VisualiseGPUSettings();
|
||||
}
|
||||
@@ -740,7 +762,10 @@ namespace GHelper
|
||||
|
||||
private void TrackPower_MouseUp(object? sender, MouseEventArgs e)
|
||||
{
|
||||
modeControl.AutoPower();
|
||||
Task.Run(() =>
|
||||
{
|
||||
modeControl.AutoPower(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1089,19 +1114,24 @@ namespace GHelper
|
||||
|
||||
if (gpuVisible)
|
||||
{
|
||||
int gpuPowerVar = Program.acpi.DeviceGet(AsusACPI.GPU_POWER);
|
||||
|
||||
trackGPUClockLimit.Value = NvidiaGpuControl.MaxClockLimit;
|
||||
trackGPUCore.Value = 0;
|
||||
trackGPUMemory.Value = 0;
|
||||
|
||||
trackGPUBoost.Value = AsusACPI.MaxGPUBoost;
|
||||
trackGPUTemp.Value = AsusACPI.MaxGPUTemp;
|
||||
|
||||
AppConfig.SetMode("gpu_clock_limit", trackGPUClockLimit.Value);
|
||||
trackGPUPower.Value = (gpuPowerVar >= 0) ? gpuPowerVar : AsusACPI.MaxGPUPower;
|
||||
|
||||
AppConfig.SetMode("gpu_boost", trackGPUBoost.Value);
|
||||
AppConfig.SetMode("gpu_temp", trackGPUTemp.Value);
|
||||
|
||||
AppConfig.SetMode("gpu_core", trackGPUCore.Value);
|
||||
AppConfig.SetMode("gpu_memory", trackGPUMemory.Value);
|
||||
AppConfig.RemoveMode("gpu_power");
|
||||
|
||||
AppConfig.RemoveMode("gpu_clock_limit");
|
||||
AppConfig.RemoveMode("gpu_core");
|
||||
AppConfig.RemoveMode("gpu_memory");
|
||||
|
||||
VisualiseGPUSettings();
|
||||
modeControl.SetGPUClocks(true);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<AssemblyVersion>0.155</AssemblyVersion>
|
||||
<AssemblyVersion>0.156</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
@@ -88,6 +88,14 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="RTSSSharedMemoryNET">
|
||||
<HintPath>RTSSSharedMemoryNET.dll</HintPath>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
|
||||
@@ -14,18 +14,24 @@ Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|Any CPU.Build.0 = Release|x64
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|x64.ActiveCfg = Release|x64
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|x64.Build.0 = Release|x64
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -101,6 +101,8 @@ namespace GHelper.Helpers
|
||||
if (Program.settingsForm.Visible)
|
||||
Program.screenControl.InitScreen();
|
||||
|
||||
Program.screenControl.SetBrightness();
|
||||
|
||||
}
|
||||
|
||||
private static int CheckAndSaveLidAction()
|
||||
|
||||
@@ -87,8 +87,15 @@ namespace GHelper.Mode
|
||||
Program.toast.RunToast(Modes.GetCurrentName(), SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online ? ToastIcon.Charger : ToastIcon.Battery);
|
||||
|
||||
SetGPUClocks();
|
||||
AutoFans();
|
||||
AutoPower(1000);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(100));
|
||||
AutoFans();
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(1000));
|
||||
AutoPower();
|
||||
});
|
||||
|
||||
|
||||
// Power plan from config or defaulting to balanced
|
||||
if (AppConfig.GetModeString("scheme") is not null)
|
||||
@@ -145,18 +152,17 @@ namespace GHelper.Mode
|
||||
Program.acpi.SetFanCurve(AsusFan.Mid, AppConfig.GetFanConfig(AsusFan.Mid));
|
||||
|
||||
|
||||
// something went wrong, resetting to default profile
|
||||
// Alternative way to set fan curve
|
||||
if (cpuResult != 1 || gpuResult != 1)
|
||||
{
|
||||
cpuResult = Program.acpi.SetFanRange(AsusFan.CPU, AppConfig.GetFanConfig(AsusFan.CPU));
|
||||
gpuResult = Program.acpi.SetFanRange(AsusFan.GPU, AppConfig.GetFanConfig(AsusFan.GPU));
|
||||
|
||||
// Something went wrong, resetting to default profile
|
||||
if (cpuResult != 1 || gpuResult != 1)
|
||||
{
|
||||
int mode = Modes.GetCurrentBase();
|
||||
Logger.WriteLine("ASUS BIOS rejected fan curve, resetting mode to " + mode);
|
||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, mode, "Reset Mode");
|
||||
settings.LabelFansResult("ASUS BIOS rejected fan curve");
|
||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, Modes.GetCurrentBase(), "Reset Mode");
|
||||
settings.LabelFansResult("Model doesn't support custom fan curves");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -182,52 +188,25 @@ namespace GHelper.Mode
|
||||
|
||||
}
|
||||
|
||||
public void AutoPower(int delay = 0)
|
||||
public void AutoPower(bool launchAsAdmin = false)
|
||||
{
|
||||
|
||||
customPower = 0;
|
||||
|
||||
bool applyPower = AppConfig.IsMode("auto_apply_power");
|
||||
bool applyFans = AppConfig.IsMode("auto_apply");
|
||||
//bool applyGPU = true;
|
||||
|
||||
if (applyPower && !applyFans)
|
||||
if (applyPower && !applyFans && (AppConfig.IsFanRequired() || AppConfig.IsManualModeRequired()))
|
||||
{
|
||||
// force fan curve for misbehaving bios PPTs on some models
|
||||
if (AppConfig.IsFanRequired())
|
||||
{
|
||||
delay = 500;
|
||||
AutoFans(true);
|
||||
}
|
||||
|
||||
// Fix for models that don't support PPT settings in all modes, setting a "manual" mode for them
|
||||
if (AppConfig.IsManualModeRequired())
|
||||
{
|
||||
AutoFans(true);
|
||||
}
|
||||
AutoFans(true);
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
if (delay > 0)
|
||||
{
|
||||
var timer = new System.Timers.Timer(delay);
|
||||
timer.Elapsed += delegate
|
||||
{
|
||||
timer.Stop();
|
||||
timer.Dispose();
|
||||
if (applyPower) SetPower(launchAsAdmin);
|
||||
|
||||
if (applyPower) SetPower();
|
||||
Thread.Sleep(500);
|
||||
SetGPUPower();
|
||||
AutoRyzen();
|
||||
};
|
||||
timer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (applyPower) SetPower(true);
|
||||
SetGPUPower();
|
||||
AutoRyzen();
|
||||
}
|
||||
Thread.Sleep(500);
|
||||
SetGPUPower();
|
||||
AutoRyzen();
|
||||
|
||||
}
|
||||
|
||||
@@ -346,18 +325,20 @@ namespace GHelper.Mode
|
||||
|
||||
int gpu_boost = AppConfig.GetMode("gpu_boost");
|
||||
int gpu_temp = AppConfig.GetMode("gpu_temp");
|
||||
int gpu_power = AppConfig.GetMode("gpu_power");
|
||||
|
||||
int boostResult = -1;
|
||||
|
||||
if (gpu_boost < AsusACPI.MinGPUBoost || gpu_boost > AsusACPI.MaxGPUBoost) return;
|
||||
if (gpu_temp < AsusACPI.MinGPUTemp || gpu_temp > AsusACPI.MaxGPUTemp) return;
|
||||
if (gpu_power >= AsusACPI.MinGPUPower && gpu_power <= AsusACPI.MaxGPUPower && Program.acpi.DeviceGet(AsusACPI.GPU_POWER) >= 0)
|
||||
Program.acpi.DeviceSet(AsusACPI.GPU_POWER, gpu_power, "PowerLimit TGP (GPU VAR)");
|
||||
|
||||
if (Program.acpi.DeviceGet(AsusACPI.PPT_GPUC0) >= 0)
|
||||
boostResult = Program.acpi.DeviceSet(AsusACPI.PPT_GPUC0, gpu_boost, "PowerLimit C0");
|
||||
if (gpu_boost >= AsusACPI.MinGPUBoost && gpu_boost <= AsusACPI.MaxGPUBoost && Program.acpi.DeviceGet(AsusACPI.PPT_GPUC0) >= 0)
|
||||
boostResult = Program.acpi.DeviceSet(AsusACPI.PPT_GPUC0, gpu_boost, "PowerLimit C0 (GPU BOOST)");
|
||||
|
||||
if (Program.acpi.DeviceGet(AsusACPI.PPT_GPUC2) >= 0)
|
||||
Program.acpi.DeviceSet(AsusACPI.PPT_GPUC2, gpu_temp, "PowerLimit C2");
|
||||
if (gpu_temp >= AsusACPI.MinGPUTemp && gpu_temp <= AsusACPI.MaxGPUTemp && Program.acpi.DeviceGet(AsusACPI.PPT_GPUC2) >= 0)
|
||||
Program.acpi.DeviceSet(AsusACPI.PPT_GPUC2, gpu_temp, "PowerLimit C2 (GPU TEMP)");
|
||||
|
||||
// Fallback
|
||||
if (boostResult == 0)
|
||||
Program.acpi.DeviceSet(AsusACPI.PPT_GPUC0, gpu_boost, "PowerLimit C0");
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GHelper.Ally;
|
||||
using GHelper.AutoTDP;
|
||||
using GHelper.Battery;
|
||||
using GHelper.Display;
|
||||
using GHelper.Gpu;
|
||||
@@ -46,6 +47,8 @@ namespace GHelper
|
||||
|
||||
private static PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||
|
||||
public static AutoTDPService autoTDPService = new AutoTDPService();
|
||||
|
||||
// The main entry point for the application
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
@@ -306,6 +309,7 @@ namespace GHelper
|
||||
|
||||
static void OnExit(object sender, EventArgs e)
|
||||
{
|
||||
autoTDPService.Shutdown();
|
||||
trayIcon.Visible = false;
|
||||
PeripheralsProvider.UnregisterForDeviceEvents();
|
||||
clamshellControl.UnregisterDisplayEvents();
|
||||
|
||||
@@ -124,10 +124,10 @@
|
||||
<value>Verbindung zu ASUS ACPI fehlgeschlagen. G-Helper kann nicht ausgeführt werden. Bitte installiere ASUS System Control Interface.</value>
|
||||
</data>
|
||||
<data name="AlertAPUMemoryRestart" xml:space="preserve">
|
||||
<value>Restart your device to apply changes</value>
|
||||
<value>Gerät neu starten, um Änderungen anzuwenden</value>
|
||||
</data>
|
||||
<data name="AlertAPUMemoryRestartTitle" xml:space="preserve">
|
||||
<value>Restart now?</value>
|
||||
<value>Jetzt neu starten?</value>
|
||||
</data>
|
||||
<data name="AlertDGPU" xml:space="preserve">
|
||||
<value>Die GPU wird gerade verwendet. Trotzdem deaktivieren?</value>
|
||||
@@ -250,7 +250,7 @@
|
||||
<value>Im Betrieb</value>
|
||||
</data>
|
||||
<data name="BacklightTimeout" xml:space="preserve">
|
||||
<value>Timeout angeschlossen / bei Akku (0 - AN)</value>
|
||||
<value>Timeout angeschlossen / bei Akku (0 = An)</value>
|
||||
</data>
|
||||
<data name="BacklightTimeoutBattery" xml:space="preserve">
|
||||
<value>Backlight Timeout when on battery</value>
|
||||
@@ -289,7 +289,7 @@
|
||||
<value>Hochfahren</value>
|
||||
</data>
|
||||
<data name="BootSound" xml:space="preserve">
|
||||
<value>Boot Sound</value>
|
||||
<value>Boot-Sound</value>
|
||||
</data>
|
||||
<data name="Brightness" xml:space="preserve">
|
||||
<value>Helligkeit</value>
|
||||
@@ -310,7 +310,7 @@
|
||||
<value>Farbe</value>
|
||||
</data>
|
||||
<data name="Contrast" xml:space="preserve">
|
||||
<value>Contrast</value>
|
||||
<value>Kontrast</value>
|
||||
</data>
|
||||
<data name="Controller" xml:space="preserve">
|
||||
<value>Controller</value>
|
||||
@@ -328,7 +328,7 @@
|
||||
<value>Standard</value>
|
||||
</data>
|
||||
<data name="DisableController" xml:space="preserve">
|
||||
<value>Disable Controller</value>
|
||||
<value>Controller deaktivieren</value>
|
||||
</data>
|
||||
<data name="DisableOnLidClose" xml:space="preserve">
|
||||
<value>Disable on lid close</value>
|
||||
@@ -352,7 +352,7 @@
|
||||
<value>Eco</value>
|
||||
</data>
|
||||
<data name="EnableGPUOnShutdown" xml:space="preserve">
|
||||
<value>Enable GPU on shutdown (prevents issue with Eco mode)</value>
|
||||
<value>Aktiviere GPU beim Herunterfahren (verhindert Problem im Eco-Modus)</value>
|
||||
</data>
|
||||
<data name="EnableOptimusText" xml:space="preserve">
|
||||
<value>Die dGPU zu deaktivieren, indem Sie in den Eco-Modus wechseln während der Anzeigemodus nicht auf Optimus eingestellt ist, kann zu Problemen mit der Helligkeitseinstellung führen.
|
||||
@@ -366,7 +366,7 @@ Trotzdem fortfahren?</value>
|
||||
<value>Energieeinstellungen</value>
|
||||
</data>
|
||||
<data name="Export" xml:space="preserve">
|
||||
<value>Export Profile</value>
|
||||
<value>Profil exportieren</value>
|
||||
</data>
|
||||
<data name="Extra" xml:space="preserve">
|
||||
<value>Extra</value>
|
||||
@@ -441,10 +441,10 @@ Trotzdem fortfahren?</value>
|
||||
<value>Hoch</value>
|
||||
</data>
|
||||
<data name="ImageRotation" xml:space="preserve">
|
||||
<value>Image Rotation</value>
|
||||
<value>Bilddrehung</value>
|
||||
</data>
|
||||
<data name="Import" xml:space="preserve">
|
||||
<value>Import Profile</value>
|
||||
<value>Profil importieren</value>
|
||||
</data>
|
||||
<data name="KeyBindings" xml:space="preserve">
|
||||
<value>Tastenbelegung</value>
|
||||
@@ -534,7 +534,7 @@ Trotzdem fortfahren?</value>
|
||||
<value>Tastenreaktionsgeschwindigkeit</value>
|
||||
</data>
|
||||
<data name="MouseImportFailed" xml:space="preserve">
|
||||
<value>Import failed. Selected file is not a valid mouse profile or corrutpted.</value>
|
||||
<value>Import fehlgeschlagen. Die ausgewählte Datei ist kein gültiges Mausprofil oder beschädigt.</value>
|
||||
</data>
|
||||
<data name="MouseLiftOffDistance" xml:space="preserve">
|
||||
<value>Lift Off Distance</value>
|
||||
@@ -621,7 +621,7 @@ Trotzdem fortfahren?</value>
|
||||
<value>Schließen</value>
|
||||
</data>
|
||||
<data name="Reset" xml:space="preserve">
|
||||
<value>Reset</value>
|
||||
<value>Zurücksetzen</value>
|
||||
</data>
|
||||
<data name="RestartGPU" xml:space="preserve">
|
||||
<value>Ein Prozess verhindert den Wechsel in den Eco-Modus. dGPU neu starten? Fortfahren auf eigene Gefahr.</value>
|
||||
@@ -639,7 +639,7 @@ Trotzdem fortfahren?</value>
|
||||
<value>Beim Start ausführen</value>
|
||||
</data>
|
||||
<data name="ScalingQuality" xml:space="preserve">
|
||||
<value>Scaling Quality</value>
|
||||
<value>Skalierungsqualität</value>
|
||||
</data>
|
||||
<data name="ScreenPadDown" xml:space="preserve">
|
||||
<value>Screenpad Helligkeit verringern</value>
|
||||
@@ -720,7 +720,7 @@ Trotzdem fortfahren?</value>
|
||||
<value>Version</value>
|
||||
</data>
|
||||
<data name="VibrationStrength" xml:space="preserve">
|
||||
<value>Vibration Strength</value>
|
||||
<value>Vibrationsstärke</value>
|
||||
</data>
|
||||
<data name="VolumeDown" xml:space="preserve">
|
||||
<value>Lautstärke verringern</value>
|
||||
|
||||
BIN
app/RTSSSharedMemoryNET.dll
Normal file
BIN
app/RTSSSharedMemoryNET.dll
Normal file
Binary file not shown.
47
app/Settings.Designer.cs
generated
47
app/Settings.Designer.cs
generated
@@ -67,6 +67,8 @@ namespace GHelper
|
||||
labelCPUFan = new Label();
|
||||
panelGPU = new Panel();
|
||||
labelTipGPU = new Label();
|
||||
tableAdditionalGPUFeature = new TableLayoutPanel();
|
||||
buttonAutoTDP = new RButton();
|
||||
tableAMD = new TableLayoutPanel();
|
||||
buttonOverlay = new RButton();
|
||||
buttonFPS = new RButton();
|
||||
@@ -143,6 +145,7 @@ namespace GHelper
|
||||
panelCPUTitle.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)picturePerf).BeginInit();
|
||||
panelGPU.SuspendLayout();
|
||||
tableAdditionalGPUFeature.SuspendLayout();
|
||||
tableAMD.SuspendLayout();
|
||||
tableGPU.SuspendLayout();
|
||||
panelGPUTitle.SuspendLayout();
|
||||
@@ -723,6 +726,7 @@ namespace GHelper
|
||||
panelGPU.AutoSize = true;
|
||||
panelGPU.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
panelGPU.Controls.Add(labelTipGPU);
|
||||
panelGPU.Controls.Add(tableAdditionalGPUFeature);
|
||||
panelGPU.Controls.Add(tableAMD);
|
||||
panelGPU.Controls.Add(tableGPU);
|
||||
panelGPU.Controls.Add(panelGPUTitle);
|
||||
@@ -745,6 +749,46 @@ namespace GHelper
|
||||
labelTipGPU.Size = new Size(787, 36);
|
||||
labelTipGPU.TabIndex = 20;
|
||||
//
|
||||
// tableAdditionalGPUFeature
|
||||
//
|
||||
tableAdditionalGPUFeature.AutoSize = true;
|
||||
tableAdditionalGPUFeature.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
tableAdditionalGPUFeature.ColumnCount = 3;
|
||||
tableAdditionalGPUFeature.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33.3333321F));
|
||||
tableAdditionalGPUFeature.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33.3333321F));
|
||||
tableAdditionalGPUFeature.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33.3333321F));
|
||||
tableAdditionalGPUFeature.Controls.Add(buttonAutoTDP, 0, 0);
|
||||
tableAdditionalGPUFeature.Dock = DockStyle.Top;
|
||||
tableAdditionalGPUFeature.Location = new Point(10, 198);
|
||||
tableAdditionalGPUFeature.Margin = new Padding(2, 1, 2, 1);
|
||||
tableAdditionalGPUFeature.Name = "tableAdditionalGPUFeature";
|
||||
tableAdditionalGPUFeature.RowCount = 1;
|
||||
tableAdditionalGPUFeature.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F));
|
||||
tableAdditionalGPUFeature.Size = new Size(392, 60);
|
||||
tableAdditionalGPUFeature.TabIndex = 25;
|
||||
//
|
||||
// buttonAutoTDP
|
||||
//
|
||||
buttonAutoTDP.Activated = false;
|
||||
buttonAutoTDP.BackColor = SystemColors.ControlLightLight;
|
||||
buttonAutoTDP.BorderColor = Color.Transparent;
|
||||
buttonAutoTDP.BorderRadius = 5;
|
||||
buttonAutoTDP.Dock = DockStyle.Fill;
|
||||
buttonAutoTDP.FlatAppearance.BorderSize = 0;
|
||||
buttonAutoTDP.FlatStyle = FlatStyle.Flat;
|
||||
buttonAutoTDP.ForeColor = SystemColors.ControlText;
|
||||
buttonAutoTDP.Image = Properties.Resources.icons8_processor_32;
|
||||
buttonAutoTDP.ImageAlign = ContentAlignment.MiddleRight;
|
||||
buttonAutoTDP.Location = new Point(1, 1);
|
||||
buttonAutoTDP.Margin = new Padding(1, 1, 1, 1);
|
||||
buttonAutoTDP.Name = "buttonAutoTDP";
|
||||
buttonAutoTDP.Secondary = false;
|
||||
buttonAutoTDP.Size = new Size(128, 38);
|
||||
buttonAutoTDP.TabIndex = 11;
|
||||
buttonAutoTDP.Text = "Auto TDP";
|
||||
buttonAutoTDP.TextImageRelation = TextImageRelation.ImageBeforeText;
|
||||
buttonAutoTDP.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// tableAMD
|
||||
//
|
||||
tableAMD.AutoSize = true;
|
||||
@@ -1790,6 +1834,7 @@ namespace GHelper
|
||||
((System.ComponentModel.ISupportInitialize)picturePerf).EndInit();
|
||||
panelGPU.ResumeLayout(false);
|
||||
panelGPU.PerformLayout();
|
||||
tableAdditionalGPUFeature.ResumeLayout(false);
|
||||
tableAMD.ResumeLayout(false);
|
||||
tableGPU.ResumeLayout(false);
|
||||
panelGPUTitle.ResumeLayout(false);
|
||||
@@ -1931,5 +1976,7 @@ namespace GHelper
|
||||
private Label labelGammaTitle;
|
||||
private CheckBox checkMatrixLid;
|
||||
private Panel panelMatrixAuto;
|
||||
private TableLayoutPanel tableAdditionalGPUFeature;
|
||||
private RButton buttonAutoTDP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GHelper.Ally;
|
||||
using GHelper.AnimeMatrix;
|
||||
using GHelper.AutoTDP;
|
||||
using GHelper.AutoUpdate;
|
||||
using GHelper.Battery;
|
||||
using GHelper.Display;
|
||||
@@ -28,6 +29,7 @@ namespace GHelper
|
||||
AutoUpdateControl updateControl;
|
||||
|
||||
AsusMouseSettings? mouseSettings;
|
||||
AutoTDPUI? autoTdpUi;
|
||||
|
||||
public AniMatrixControl matrixControl;
|
||||
|
||||
@@ -244,6 +246,8 @@ namespace GHelper
|
||||
buttonFPS.Click += ButtonFPS_Click;
|
||||
buttonOverlay.Click += ButtonOverlay_Click;
|
||||
|
||||
buttonAutoTDP.Click += ButtonAutoTDP_Click;
|
||||
|
||||
Text = "G-Helper " + (ProcessHelper.IsUserAdministrator() ? "—" : "-") + " " + AppConfig.GetModelShort();
|
||||
TopMost = AppConfig.Is("topmost");
|
||||
|
||||
@@ -254,16 +258,58 @@ namespace GHelper
|
||||
VisualiseFnLock();
|
||||
buttonFnLock.Click += ButtonFnLock_Click;
|
||||
|
||||
panelGamma.Visible = AppConfig.IsOLED();
|
||||
sliderGamma.ValueChanged += SliderGamma_ValueChanged;
|
||||
labelGamma.Text = "100%";
|
||||
|
||||
panelPerformance.Focus();
|
||||
|
||||
InitBrightness();
|
||||
}
|
||||
|
||||
public void InitBrightness()
|
||||
{
|
||||
if (!AppConfig.IsOLED()) return;
|
||||
|
||||
panelGamma.Visible = true;
|
||||
|
||||
int brightness = AppConfig.Get("brightness");
|
||||
if (brightness >= 0) sliderGamma.Value = brightness;
|
||||
|
||||
sliderGamma.ValueChanged += SliderGamma_ValueChanged;
|
||||
labelGamma.Text = sliderGamma.Value + "%";
|
||||
}
|
||||
|
||||
|
||||
private void ButtonAutoTDP_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (autoTdpUi is not null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
autoTdpUi = new AutoTDPUI();
|
||||
autoTdpUi.FormClosed += AutoTdpUi_FormClosed;
|
||||
autoTdpUi.Disposed += AutoTdpUi_Disposed;
|
||||
if (!autoTdpUi.IsDisposed)
|
||||
{
|
||||
autoTdpUi.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
autoTdpUi = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void AutoTdpUi_Disposed(object? sender, EventArgs e)
|
||||
{
|
||||
autoTdpUi = null;
|
||||
}
|
||||
|
||||
private void AutoTdpUi_FormClosed(object? sender, FormClosedEventArgs e)
|
||||
{
|
||||
autoTdpUi = null;
|
||||
}
|
||||
|
||||
private void SliderGamma_ValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
screenControl.SetGamma(sliderGamma.Value);
|
||||
screenControl.SetBrightness(sliderGamma.Value);
|
||||
labelGamma.Text = sliderGamma.Value + "%";
|
||||
}
|
||||
|
||||
@@ -411,6 +457,8 @@ namespace GHelper
|
||||
|
||||
Task.Run((Action)RefreshPeripheralsBattery);
|
||||
updateControl.CheckForUpdates();
|
||||
|
||||
tableAdditionalGPUFeature.Visible = AutoTDPService.IsAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1081,6 +1129,7 @@ namespace GHelper
|
||||
|
||||
private void ButtonQuit_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Program.autoTDPService.Shutdown();
|
||||
matrixControl.Dispose();
|
||||
Close();
|
||||
Program.trayIcon.Visible = false;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace GHelper
|
||||
(bios, model) = AppConfig.GetBiosAndModel();
|
||||
|
||||
buttonRefresh.TabStop = false;
|
||||
|
||||
|
||||
updatesCount = 0;
|
||||
labelUpdates.ForeColor = colorEco;
|
||||
labelUpdates.Text = Properties.Strings.NoNewUpdates;
|
||||
@@ -83,13 +83,12 @@ namespace GHelper
|
||||
InitializeComponent();
|
||||
InitTheme(true);
|
||||
|
||||
LoadUpdates(true);
|
||||
|
||||
//buttonRefresh.Visible = false;
|
||||
buttonRefresh.Click += ButtonRefresh_Click;
|
||||
Shown += Updates_Shown;
|
||||
}
|
||||
|
||||
|
||||
private void ButtonRefresh_Click(object? sender, EventArgs e)
|
||||
{
|
||||
LoadUpdates();
|
||||
@@ -100,7 +99,9 @@ namespace GHelper
|
||||
Height = Program.settingsForm.Height;
|
||||
Top = Program.settingsForm.Top;
|
||||
Left = Program.settingsForm.Left - Width - 5;
|
||||
LoadUpdates(true);
|
||||
}
|
||||
|
||||
private Dictionary<string, string> GetDeviceVersions()
|
||||
{
|
||||
using (ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("Select * from Win32_PnPSignedDriver"))
|
||||
@@ -160,24 +161,36 @@ namespace GHelper
|
||||
});
|
||||
}
|
||||
|
||||
public void VisualiseNewDriver(int position, int newer, TableLayoutPanel table)
|
||||
private void _VisualiseNewDriver(int position, int newer, TableLayoutPanel table)
|
||||
{
|
||||
var label = table.GetControlFromPosition(3, position) as LinkLabel;
|
||||
if (label != null)
|
||||
{
|
||||
if (newer == DRIVER_NEWER)
|
||||
{
|
||||
label.AccessibleName = label.AccessibleName + Properties.Strings.NewUpdates;
|
||||
label.Font = new Font(label.Font, FontStyle.Underline | FontStyle.Bold);
|
||||
label.LinkColor = colorTurbo;
|
||||
}
|
||||
|
||||
if (newer == DRIVER_NOT_FOUND) label.LinkColor = Color.Gray;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void VisualiseNewDriver(int position, int newer, TableLayoutPanel table)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(delegate
|
||||
{
|
||||
if (newer == DRIVER_NEWER)
|
||||
{
|
||||
label.AccessibleName = label.AccessibleName + Properties.Strings.NewUpdates;
|
||||
label.Font = new Font(label.Font, FontStyle.Underline | FontStyle.Bold);
|
||||
label.LinkColor = colorTurbo;
|
||||
}
|
||||
|
||||
if (newer == DRIVER_NOT_FOUND) label.LinkColor = Color.Gray;
|
||||
|
||||
_VisualiseNewDriver(position, newer, table);
|
||||
});
|
||||
} else
|
||||
{
|
||||
_VisualiseNewDriver(position, newer, table);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void VisualiseNewCount(int updatesCount, TableLayoutPanel table)
|
||||
@@ -193,7 +206,7 @@ namespace GHelper
|
||||
});
|
||||
}
|
||||
|
||||
public async void DriversAsync(string url, int type, TableLayoutPanel table)
|
||||
public async void DriversAsync(string url, int type, TableLayoutPanel table)
|
||||
{
|
||||
|
||||
try
|
||||
@@ -266,7 +279,7 @@ namespace GHelper
|
||||
foreach (var localVersion in localVersions)
|
||||
{
|
||||
newer = Math.Min(newer, new Version(driver.version).CompareTo(new Version(localVersion)));
|
||||
Logger.WriteLine(driver.title + " " + deviceID + " "+ driver.version + " vs " + localVersion + " = " + newer);
|
||||
Logger.WriteLine(driver.title + " " + deviceID + " " + driver.version + " vs " + localVersion + " = " + newer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# G-Helper - Lightweight control tool for Asus laptops
|
||||
[](https://u24.gov.ua/)
|
||||
[](https://GitHub.com/seerge/g-helper/releases/)
|
||||
[](https://GitHub.com/seerge/g-helper/releases/) [](https://GitHub.com/seerge/g-helper/stargazers/)
|
||||
[](https://GitHub.com/seerge/g-helper/releases/)
|
||||
[](https://GitHub.com/seerge/g-helper/releases/) [](https://GitHub.com/seerge/g-helper/stargazers/)
|
||||
|
||||
Small and lightweight Armoury Crate alternative for Asus laptops offering almost same functionality without extra bloat and unnecessary services.
|
||||
Works with all popular models, such as ROG Zephyrus G14, G15, G16, M16, Flow X13, Flow X16, Flow Z13, TUF Series, Strix / Scar Series, ProArt, VivoBook, Ally and many more!
|
||||
|
||||
Reference in New Issue
Block a user