mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Added option to disable screen overdrive
This commit is contained in:
15
app/Keyboard.Designer.cs
generated
15
app/Keyboard.Designer.cs
generated
@@ -50,6 +50,7 @@ namespace GHelper
|
|||||||
groupOther = new GroupBox();
|
groupOther = new GroupBox();
|
||||||
checkKeyboardAuto = new CheckBox();
|
checkKeyboardAuto = new CheckBox();
|
||||||
checkTopmost = new CheckBox();
|
checkTopmost = new CheckBox();
|
||||||
|
checkNoOverdrive = new CheckBox();
|
||||||
groupBox1.SuspendLayout();
|
groupBox1.SuspendLayout();
|
||||||
groupLight.SuspendLayout();
|
groupLight.SuspendLayout();
|
||||||
groupOther.SuspendLayout();
|
groupOther.SuspendLayout();
|
||||||
@@ -234,12 +235,13 @@ namespace GHelper
|
|||||||
//
|
//
|
||||||
// groupOther
|
// groupOther
|
||||||
//
|
//
|
||||||
|
groupOther.Controls.Add(checkNoOverdrive);
|
||||||
groupOther.Controls.Add(checkKeyboardAuto);
|
groupOther.Controls.Add(checkKeyboardAuto);
|
||||||
groupOther.Controls.Add(checkTopmost);
|
groupOther.Controls.Add(checkTopmost);
|
||||||
groupOther.Dock = DockStyle.Top;
|
groupOther.Dock = DockStyle.Top;
|
||||||
groupOther.Location = new Point(10, 556);
|
groupOther.Location = new Point(10, 556);
|
||||||
groupOther.Name = "groupOther";
|
groupOther.Name = "groupOther";
|
||||||
groupOther.Size = new Size(756, 167);
|
groupOther.Size = new Size(756, 225);
|
||||||
groupOther.TabIndex = 2;
|
groupOther.TabIndex = 2;
|
||||||
groupOther.TabStop = false;
|
groupOther.TabStop = false;
|
||||||
groupOther.Text = "Other";
|
groupOther.Text = "Other";
|
||||||
@@ -264,6 +266,16 @@ namespace GHelper
|
|||||||
checkTopmost.Text = "Keep app window always on top";
|
checkTopmost.Text = "Keep app window always on top";
|
||||||
checkTopmost.UseVisualStyleBackColor = true;
|
checkTopmost.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
// checkNoOverdrive
|
||||||
|
//
|
||||||
|
checkNoOverdrive.AutoSize = true;
|
||||||
|
checkNoOverdrive.Location = new Point(25, 156);
|
||||||
|
checkNoOverdrive.Name = "checkNoOverdrive";
|
||||||
|
checkNoOverdrive.Size = new Size(307, 36);
|
||||||
|
checkNoOverdrive.TabIndex = 3;
|
||||||
|
checkNoOverdrive.Text = "Disable screen overdrive";
|
||||||
|
checkNoOverdrive.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
// Keyboard
|
// Keyboard
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||||
@@ -312,5 +324,6 @@ namespace GHelper
|
|||||||
private GroupBox groupOther;
|
private GroupBox groupOther;
|
||||||
private CheckBox checkTopmost;
|
private CheckBox checkTopmost;
|
||||||
private CheckBox checkKeyboardAuto;
|
private CheckBox checkKeyboardAuto;
|
||||||
|
private CheckBox checkNoOverdrive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,9 +84,17 @@ namespace GHelper
|
|||||||
checkKeyboardAuto.Checked = (Program.config.getConfig("keyboard_auto") == 1);
|
checkKeyboardAuto.Checked = (Program.config.getConfig("keyboard_auto") == 1);
|
||||||
checkKeyboardAuto.CheckedChanged += CheckKeyboardAuto_CheckedChanged;
|
checkKeyboardAuto.CheckedChanged += CheckKeyboardAuto_CheckedChanged;
|
||||||
|
|
||||||
|
checkNoOverdrive.Checked = (Program.config.getConfig("no_overdrive") == 1);
|
||||||
|
checkNoOverdrive.CheckedChanged += CheckNoOverdrive_CheckedChanged;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckNoOverdrive_CheckedChanged(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Program.config.setConfig("no_overdrive", (checkNoOverdrive.Checked ? 1 : 0));
|
||||||
|
Program.settingsForm.AutoScreen(true);
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckKeyboardAuto_CheckedChanged(object? sender, EventArgs e)
|
private void CheckKeyboardAuto_CheckedChanged(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Program.config.setConfig("keyboard_auto", (checkKeyboardAuto.Checked ? 1 : 0));
|
Program.config.setConfig("keyboard_auto", (checkKeyboardAuto.Checked ? 1 : 0));
|
||||||
|
|||||||
@@ -120,27 +120,22 @@ namespace GHelper
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void SetAutoModes(bool wait = false)
|
public static void SetAutoModes()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return;
|
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return;
|
||||||
lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
|
|
||||||
isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||||
|
|
||||||
Logger.WriteLine("AutoSetting for " + isPlugged.ToString());
|
Logger.WriteLine("AutoSetting for " + isPlugged.ToString());
|
||||||
|
|
||||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||||
|
settingsForm.AutoPerformance();
|
||||||
|
|
||||||
settingsForm.AutoPerformance(isPlugged);
|
bool switched = settingsForm.AutoGPUMode();
|
||||||
|
if (!switched) settingsForm.AutoScreen();
|
||||||
|
|
||||||
// waiting a bit before turning off dGPU
|
settingsForm.SetMatrix();
|
||||||
// if (wait && isPlugged != PowerLineStatus.Online) Thread.Sleep(3000);
|
|
||||||
|
|
||||||
bool switched = settingsForm.AutoGPUMode(isPlugged);
|
|
||||||
if (!switched) settingsForm.AutoScreen(isPlugged);
|
|
||||||
|
|
||||||
settingsForm.SetMatrix(isPlugged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||||
@@ -148,8 +143,8 @@ namespace GHelper
|
|||||||
if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return;
|
if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return;
|
||||||
|
|
||||||
Logger.WriteLine("Windows - Power Mode Changed");
|
Logger.WriteLine("Windows - Power Mode Changed");
|
||||||
settingsForm.AutoKeyboard(SystemInformation.PowerStatus.PowerLineStatus);
|
settingsForm.AutoKeyboard();
|
||||||
SetAutoModes(true);
|
SetAutoModes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ namespace GHelper
|
|||||||
|
|
||||||
private void Button120Hz_MouseHover(object? sender, EventArgs e)
|
private void Button120Hz_MouseHover(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
labelTipScreen.Text = "Max refresh rate + screen overdrive for lower latency";
|
labelTipScreen.Text = "Max refresh rate for lower latency";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button60Hz_MouseHover(object? sender, EventArgs e)
|
private void Button60Hz_MouseHover(object? sender, EventArgs e)
|
||||||
@@ -252,14 +252,14 @@ namespace GHelper
|
|||||||
{
|
{
|
||||||
Program.config.setConfig("gpu_auto", (Program.config.getConfig("gpu_auto") == 1) ? 0 : 1);
|
Program.config.setConfig("gpu_auto", (Program.config.getConfig("gpu_auto") == 1) ? 0 : 1);
|
||||||
VisualiseGPUMode();
|
VisualiseGPUMode();
|
||||||
AutoGPUMode(SystemInformation.PowerStatus.PowerLineStatus);
|
AutoGPUMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonScreenAuto_Click(object? sender, EventArgs e)
|
private void ButtonScreenAuto_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Program.config.setConfig("screen_auto", 1);
|
Program.config.setConfig("screen_auto", 1);
|
||||||
InitScreen();
|
InitScreen();
|
||||||
AutoScreen(SystemInformation.PowerStatus.PowerLineStatus);
|
AutoScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
protected override void WndProc(ref Message m)
|
||||||
@@ -458,7 +458,7 @@ namespace GHelper
|
|||||||
SetMatrix();
|
SetMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetMatrix(PowerLineStatus Plugged = PowerLineStatus.Online)
|
public void SetMatrix()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (mat is null) return;
|
if (mat is null) return;
|
||||||
@@ -481,7 +481,7 @@ namespace GHelper
|
|||||||
|
|
||||||
mat.SetProvider();
|
mat.SetProvider();
|
||||||
|
|
||||||
if (brightness == 0 || (auto && Plugged != PowerLineStatus.Online))
|
if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online))
|
||||||
{
|
{
|
||||||
mat.SetDisplayState(false);
|
mat.SetDisplayState(false);
|
||||||
}
|
}
|
||||||
@@ -700,8 +700,12 @@ namespace GHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (overdrive >= 0)
|
if (overdrive >= 0)
|
||||||
|
{
|
||||||
|
if (Program.config.getConfig("no_overdrive") == 1) overdrive = 0;
|
||||||
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive);
|
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (miniled >= 0)
|
if (miniled >= 0)
|
||||||
{
|
{
|
||||||
Program.wmi.DeviceSet(ASUSWmi.ScreenMiniled, miniled);
|
Program.wmi.DeviceSet(ASUSWmi.ScreenMiniled, miniled);
|
||||||
@@ -719,8 +723,10 @@ namespace GHelper
|
|||||||
int maxFrequency = NativeMethods.GetRefreshRate(true);
|
int maxFrequency = NativeMethods.GetRefreshRate(true);
|
||||||
|
|
||||||
bool screenAuto = (Program.config.getConfig("screen_auto") == 1);
|
bool screenAuto = (Program.config.getConfig("screen_auto") == 1);
|
||||||
|
bool overdriveSetting = (Program.config.getConfig("no_overdrive") != 1);
|
||||||
|
|
||||||
int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive);
|
int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive);
|
||||||
|
|
||||||
int miniled = Program.wmi.DeviceGet(ASUSWmi.ScreenMiniled);
|
int miniled = Program.wmi.DeviceGet(ASUSWmi.ScreenMiniled);
|
||||||
|
|
||||||
bool screenEnabled = (frequency >= 0);
|
bool screenEnabled = (frequency >= 0);
|
||||||
@@ -753,7 +759,7 @@ namespace GHelper
|
|||||||
|
|
||||||
if (maxFrequency > 60)
|
if (maxFrequency > 60)
|
||||||
{
|
{
|
||||||
button120Hz.Text = maxFrequency.ToString() + "Hz + OD";
|
button120Hz.Text = maxFrequency.ToString() + "Hz" + (overdriveSetting ? " + OD" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (miniled >= 0)
|
if (miniled >= 0)
|
||||||
@@ -998,11 +1004,11 @@ namespace GHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void AutoKeyboard(PowerLineStatus Plugged = PowerLineStatus.Online)
|
public void AutoKeyboard()
|
||||||
{
|
{
|
||||||
if (Program.config.getConfig("keyboard_auto") != 1) return;
|
if (Program.config.getConfig("keyboard_auto") != 1) return;
|
||||||
|
|
||||||
if (Plugged == PowerLineStatus.Online)
|
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
|
||||||
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up);
|
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up);
|
||||||
else
|
else
|
||||||
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down);
|
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down);
|
||||||
@@ -1010,8 +1016,10 @@ namespace GHelper
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AutoPerformance(PowerLineStatus Plugged = PowerLineStatus.Online)
|
public void AutoPerformance()
|
||||||
{
|
{
|
||||||
|
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||||
|
|
||||||
int mode = Program.config.getConfig("performance_" + (int)Plugged);
|
int mode = Program.config.getConfig("performance_" + (int)Plugged);
|
||||||
if (mode != -1)
|
if (mode != -1)
|
||||||
SetPerformanceMode(mode, true);
|
SetPerformanceMode(mode, true);
|
||||||
@@ -1020,11 +1028,11 @@ namespace GHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void AutoScreen(PowerLineStatus Plugged = PowerLineStatus.Online)
|
public void AutoScreen(bool force = false)
|
||||||
{
|
{
|
||||||
if (Program.config.getConfig("screen_auto") != 1) return;
|
if (!force && Program.config.getConfig("screen_auto") != 1) return;
|
||||||
|
|
||||||
if (Plugged == PowerLineStatus.Online)
|
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
|
||||||
SetScreen(1000, 1);
|
SetScreen(1000, 1);
|
||||||
else
|
else
|
||||||
SetScreen(60, 0);
|
SetScreen(60, 0);
|
||||||
@@ -1032,9 +1040,11 @@ namespace GHelper
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AutoGPUMode(PowerLineStatus Plugged = PowerLineStatus.Online)
|
public bool AutoGPUMode()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||||
|
|
||||||
bool GpuAuto = Program.config.getConfig("gpu_auto") == 1;
|
bool GpuAuto = Program.config.getConfig("gpu_auto") == 1;
|
||||||
if (!GpuAuto) return false;
|
if (!GpuAuto) return false;
|
||||||
|
|
||||||
@@ -1139,7 +1149,7 @@ namespace GHelper
|
|||||||
InitGPUMode();
|
InitGPUMode();
|
||||||
HardwareMonitor.RecreateGpuTemperatureProviderWithDelay();
|
HardwareMonitor.RecreateGpuTemperatureProviderWithDelay();
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
AutoScreen(SystemInformation.PowerStatus.PowerLineStatus);
|
AutoScreen();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user