mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Added option to keep dGPU off on usb-c
This commit is contained in:
@@ -14,6 +14,11 @@ public class ASUSWmi
|
||||
public const int KB_Light_Up = 0xc4;
|
||||
public const int KB_Light_Down = 0xc5;
|
||||
|
||||
public const int ChargerMode = 0x0012006C;
|
||||
|
||||
public const int ChargerUSB = 2;
|
||||
public const int ChargerBarrel = 1;
|
||||
|
||||
public const uint CPU_Fan = 0x00110013;
|
||||
public const uint GPU_Fan = 0x00110014;
|
||||
public const uint Mid_Fan = 0x00110031;
|
||||
|
||||
@@ -6,6 +6,9 @@ using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OSD;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Starlight.AnimeMatrix
|
||||
{
|
||||
@@ -107,9 +110,6 @@ namespace Starlight.AnimeMatrix
|
||||
MaxColumns = 33;
|
||||
dx = 1;
|
||||
|
||||
//FullRows = 7;
|
||||
//FullEvenRows = 3;
|
||||
|
||||
MaxRows = 55;
|
||||
LedCount = 1245;
|
||||
|
||||
@@ -177,17 +177,8 @@ namespace Starlight.AnimeMatrix
|
||||
{
|
||||
return (y + 1) / 2 - 3;
|
||||
}
|
||||
case AnimeType.GA402:
|
||||
if (y < 11)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (y) / 2 - 5;
|
||||
}
|
||||
default:
|
||||
throw new ArgumentException("Invalid anime type", nameof(_model));
|
||||
return (int)Math.Ceiling(Math.Max(0, y - 11) / 2F);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,10 +188,8 @@ namespace Starlight.AnimeMatrix
|
||||
{
|
||||
case AnimeType.GA401:
|
||||
return 33;
|
||||
case AnimeType.GA402:
|
||||
return 34;
|
||||
default:
|
||||
throw new ArgumentException("Invalid anime type", nameof(_model));
|
||||
return 34;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,36 +210,15 @@ namespace Starlight.AnimeMatrix
|
||||
default:
|
||||
return 36 - y / 2;
|
||||
}
|
||||
case AnimeType.GA402:
|
||||
return Width(y) - FirstX(y);
|
||||
default:
|
||||
throw new ArgumentException("Invalid anime type", nameof(_model));
|
||||
return Width(y) - FirstX(y);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public int XStart(int row)
|
||||
{
|
||||
return (int)Math.Ceiling(Math.Max(0, row - FullRows) / 2.0);
|
||||
}
|
||||
|
||||
public int XEnd(int row)
|
||||
{
|
||||
if (row <= FullEvenRows)
|
||||
{
|
||||
if (row % 2 == 1) return MaxColumns + 2;
|
||||
else return MaxColumns;
|
||||
}
|
||||
return MaxColumns;
|
||||
}
|
||||
*/
|
||||
|
||||
public int RowToLinearAddress(int y)
|
||||
{
|
||||
EnsureRowInRange(y);
|
||||
|
||||
int ret = 0;
|
||||
|
||||
for (var i = 0; i < y; i++)
|
||||
ret += Pitch(i);
|
||||
|
||||
@@ -259,13 +227,10 @@ namespace Starlight.AnimeMatrix
|
||||
|
||||
public void SetLedPlanar(int x, int y, byte value)
|
||||
{
|
||||
EnsureRowInRange(y);
|
||||
if (!IsRowInRange(y)) return;
|
||||
|
||||
if (x >= FirstX(y) && x < Width(y))
|
||||
{
|
||||
SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x + dx, value);
|
||||
//Debug.Write((RowToLinearAddress(y) - FirstX(y) + x + dx).ToString() + " ");
|
||||
}
|
||||
}
|
||||
|
||||
public void WakeUp()
|
||||
@@ -366,9 +331,9 @@ namespace Starlight.AnimeMatrix
|
||||
int second = DateTime.Now.Second;
|
||||
|
||||
if (CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("H"))
|
||||
PresentText(DateTime.Now.ToString("H" + ((second % 2 == 0)?":":" ") + "mm"));
|
||||
PresentTextDiagonal(DateTime.Now.ToString("H" + ((second % 2 == 0)?":":" ") + "mm"));
|
||||
else
|
||||
PresentText(DateTime.Now.ToString("h" + ((second % 2 == 0) ? ":" : " ") + "mm"), DateTime.Now.ToString("tt"));
|
||||
PresentTextDiagonal(DateTime.Now.ToString("h" + ((second % 2 == 0) ? ":" : " ") + "mmtt"));
|
||||
}
|
||||
|
||||
public void PresentText(string text1, string text2 = "")
|
||||
@@ -442,12 +407,52 @@ namespace Starlight.AnimeMatrix
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureRowInRange(int row)
|
||||
|
||||
public void SetLedDiagonal(int x, int y, byte color, int delta = 10)
|
||||
{
|
||||
if (row < 0 || row >= MaxRows)
|
||||
{
|
||||
throw new IndexOutOfRangeException($"Y-coordinate should fall in range of [0, {MaxRows - 1}].");
|
||||
//x+=delta;
|
||||
y-=delta;
|
||||
|
||||
int dx = (x - y)/2;
|
||||
int dy = x + y;
|
||||
SetLedPlanar(dx, dy, color);
|
||||
}
|
||||
|
||||
public void PresentTextDiagonal(string text)
|
||||
{
|
||||
int maxX = (int)Math.Sqrt(MaxRows * MaxRows + MaxColumns * MaxColumns);
|
||||
|
||||
using (Bitmap bmp = new Bitmap(maxX, MaxRows))
|
||||
{
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
g.CompositingQuality = CompositingQuality.HighQuality;
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
using (Font font = new Font("Calibri", 16F, GraphicsUnit.Pixel))
|
||||
{
|
||||
SizeF textSize = g.MeasureString(text, font);
|
||||
g.DrawString(text, font, Brushes.White, 4, 0);
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < bmp.Height; y++)
|
||||
{
|
||||
for (int x = 0; x < bmp.Width; x++)
|
||||
{
|
||||
var pixel = bmp.GetPixel(x, y);
|
||||
var color = (pixel.R + pixel.G + pixel.B) / 3;
|
||||
SetLedDiagonal(x, y, (byte)color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Present();
|
||||
}
|
||||
|
||||
private bool IsRowInRange(int row)
|
||||
{
|
||||
return (row >= 0 && row < MaxRows);
|
||||
}
|
||||
|
||||
private bool IsAddressableLed(int address)
|
||||
|
||||
114
app/Keyboard.Designer.cs → app/Extra.Designer.cs
generated
114
app/Keyboard.Designer.cs → app/Extra.Designer.cs
generated
@@ -3,7 +3,7 @@ using GHelper.Properties;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
partial class Keyboard
|
||||
partial class Extra
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -31,7 +31,7 @@ namespace GHelper
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBox1 = new GroupBox();
|
||||
groupBindings = new GroupBox();
|
||||
pictureHelp = new PictureBox();
|
||||
textFNF4 = new TextBox();
|
||||
comboFNF4 = new RComboBox();
|
||||
@@ -52,39 +52,40 @@ namespace GHelper
|
||||
checkBoot = new CheckBox();
|
||||
checkAwake = new CheckBox();
|
||||
groupOther = new GroupBox();
|
||||
checkUSBC = new CheckBox();
|
||||
checkNoOverdrive = new CheckBox();
|
||||
checkKeyboardAuto = new CheckBox();
|
||||
checkTopmost = new CheckBox();
|
||||
groupBox1.SuspendLayout();
|
||||
groupBindings.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureHelp).BeginInit();
|
||||
groupLight.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackBrightness).BeginInit();
|
||||
groupOther.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
// groupBindings
|
||||
//
|
||||
groupBox1.Controls.Add(pictureHelp);
|
||||
groupBox1.Controls.Add(textFNF4);
|
||||
groupBox1.Controls.Add(comboFNF4);
|
||||
groupBox1.Controls.Add(labelFNF4);
|
||||
groupBox1.Controls.Add(textM4);
|
||||
groupBox1.Controls.Add(textM3);
|
||||
groupBox1.Controls.Add(comboM4);
|
||||
groupBox1.Controls.Add(labelM4);
|
||||
groupBox1.Controls.Add(comboM3);
|
||||
groupBox1.Controls.Add(labelM3);
|
||||
groupBox1.Dock = DockStyle.Top;
|
||||
groupBox1.Location = new Point(10, 10);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(840, 242);
|
||||
groupBox1.TabIndex = 0;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = Properties.Strings.KeyBindings;
|
||||
groupBindings.Controls.Add(pictureHelp);
|
||||
groupBindings.Controls.Add(textFNF4);
|
||||
groupBindings.Controls.Add(comboFNF4);
|
||||
groupBindings.Controls.Add(labelFNF4);
|
||||
groupBindings.Controls.Add(textM4);
|
||||
groupBindings.Controls.Add(textM3);
|
||||
groupBindings.Controls.Add(comboM4);
|
||||
groupBindings.Controls.Add(labelM4);
|
||||
groupBindings.Controls.Add(comboM3);
|
||||
groupBindings.Controls.Add(labelM3);
|
||||
groupBindings.Dock = DockStyle.Top;
|
||||
groupBindings.Location = new Point(10, 10);
|
||||
groupBindings.Name = "groupBindings";
|
||||
groupBindings.Size = new Size(844, 242);
|
||||
groupBindings.TabIndex = 0;
|
||||
groupBindings.TabStop = false;
|
||||
groupBindings.Text = "Key Bindings";
|
||||
//
|
||||
// pictureHelp
|
||||
//
|
||||
pictureHelp.BackgroundImage = Properties.Resources.icons8_help_64;
|
||||
pictureHelp.BackgroundImage = Resources.icons8_help_64;
|
||||
pictureHelp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureHelp.Cursor = Cursors.Hand;
|
||||
pictureHelp.Location = new Point(744, 57);
|
||||
@@ -141,7 +142,7 @@ namespace GHelper
|
||||
comboM4.BorderColor = Color.White;
|
||||
comboM4.ButtonColor = Color.FromArgb(255, 255, 255);
|
||||
comboM4.FormattingEnabled = true;
|
||||
comboM4.Items.AddRange(new object[] { Properties.Strings.PerformanceMode, Properties.Strings.OpenGHelper, Properties.Strings.Custom });
|
||||
comboM4.Items.AddRange(new object[] { Strings.PerformanceMode, Strings.OpenGHelper, Strings.Custom });
|
||||
comboM4.Location = new Point(93, 112);
|
||||
comboM4.Name = "comboM4";
|
||||
comboM4.Size = new Size(312, 40);
|
||||
@@ -161,7 +162,7 @@ namespace GHelper
|
||||
comboM3.BorderColor = Color.White;
|
||||
comboM3.ButtonColor = Color.FromArgb(255, 255, 255);
|
||||
comboM3.FormattingEnabled = true;
|
||||
comboM3.Items.AddRange(new object[] { Properties.Strings.Default, Properties.Strings.VolumeMute, Properties.Strings.PlayPause, Properties.Strings.PrintScreen, Properties.Strings.ToggleAura, Properties.Strings.Custom });
|
||||
comboM3.Items.AddRange(new object[] { Strings.Default, Strings.VolumeMute, Strings.PlayPause, Strings.PrintScreen, Strings.ToggleAura, Strings.Custom });
|
||||
comboM3.Location = new Point(93, 54);
|
||||
comboM3.Name = "comboM3";
|
||||
comboM3.Size = new Size(312, 40);
|
||||
@@ -189,11 +190,10 @@ namespace GHelper
|
||||
groupLight.Dock = DockStyle.Top;
|
||||
groupLight.Location = new Point(10, 252);
|
||||
groupLight.Name = "groupLight";
|
||||
groupLight.Size = new Size(840, 395);
|
||||
groupLight.Size = new Size(844, 395);
|
||||
groupLight.TabIndex = 1;
|
||||
groupLight.TabStop = false;
|
||||
groupLight.Text = Properties.Strings.KeyboardBacklight;
|
||||
//groupLight.AutoSize = true;
|
||||
groupLight.Text = "Keyboard Backlight";
|
||||
//
|
||||
// labelBrightness
|
||||
//
|
||||
@@ -201,16 +201,16 @@ namespace GHelper
|
||||
labelBrightness.Name = "labelBrightness";
|
||||
labelBrightness.Size = new Size(197, 49);
|
||||
labelBrightness.TabIndex = 0;
|
||||
labelBrightness.Text = Properties.Strings.Brightness;
|
||||
labelBrightness.Text = "Brightness";
|
||||
//
|
||||
// trackBrightness
|
||||
//
|
||||
trackBrightness.Location = new Point(228, 294);
|
||||
trackBrightness.Name = "trackBrightness";
|
||||
trackBrightness.Size = new Size(600, 30);
|
||||
trackBrightness.TabIndex = 1;
|
||||
trackBrightness.Minimum = 0;
|
||||
trackBrightness.Maximum = 3;
|
||||
trackBrightness.Name = "trackBrightness";
|
||||
trackBrightness.Size = new Size(600, 90);
|
||||
trackBrightness.TabIndex = 1;
|
||||
trackBrightness.TickStyle = TickStyle.TopLeft;
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
@@ -220,7 +220,7 @@ namespace GHelper
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(198, 32);
|
||||
labelSpeed.TabIndex = 40;
|
||||
labelSpeed.Text = Properties.Strings.AnimationSpeed;
|
||||
labelSpeed.Text = "Animation Speed";
|
||||
//
|
||||
// comboKeyboardSpeed
|
||||
//
|
||||
@@ -245,7 +245,7 @@ namespace GHelper
|
||||
checkShutdown.Name = "checkShutdown";
|
||||
checkShutdown.Size = new Size(154, 36);
|
||||
checkShutdown.TabIndex = 3;
|
||||
checkShutdown.Text = Properties.Strings.Shutdown;
|
||||
checkShutdown.Text = Strings.Shutdown;
|
||||
checkShutdown.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkSleep
|
||||
@@ -255,7 +255,7 @@ namespace GHelper
|
||||
checkSleep.Name = "checkSleep";
|
||||
checkSleep.Size = new Size(105, 36);
|
||||
checkSleep.TabIndex = 2;
|
||||
checkSleep.Text = Properties.Strings.Sleep;
|
||||
checkSleep.Text = Strings.Sleep;
|
||||
checkSleep.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoot
|
||||
@@ -265,7 +265,7 @@ namespace GHelper
|
||||
checkBoot.Name = "checkBoot";
|
||||
checkBoot.Size = new Size(96, 36);
|
||||
checkBoot.TabIndex = 1;
|
||||
checkBoot.Text = Properties.Strings.Boot;
|
||||
checkBoot.Text = Strings.Boot;
|
||||
checkBoot.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkAwake
|
||||
@@ -275,21 +275,32 @@ namespace GHelper
|
||||
checkAwake.Name = "checkAwake";
|
||||
checkAwake.Size = new Size(115, 36);
|
||||
checkAwake.TabIndex = 0;
|
||||
checkAwake.Text = Properties.Strings.Awake;
|
||||
checkAwake.Text = Strings.Awake;
|
||||
checkAwake.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupOther
|
||||
//
|
||||
groupOther.Controls.Add(checkUSBC);
|
||||
groupOther.Controls.Add(checkNoOverdrive);
|
||||
groupOther.Controls.Add(checkKeyboardAuto);
|
||||
groupOther.Controls.Add(checkTopmost);
|
||||
groupOther.Dock = DockStyle.Top;
|
||||
groupOther.Location = new Point(10, 626);
|
||||
groupOther.Location = new Point(10, 647);
|
||||
groupOther.Name = "groupOther";
|
||||
groupOther.Size = new Size(840, 225);
|
||||
groupOther.Size = new Size(844, 293);
|
||||
groupOther.TabIndex = 2;
|
||||
groupOther.TabStop = false;
|
||||
groupOther.Text = Properties.Strings.Other;
|
||||
groupOther.Text = "Other";
|
||||
//
|
||||
// checkUSBC
|
||||
//
|
||||
checkUSBC.AutoSize = true;
|
||||
checkUSBC.Location = new Point(25, 210);
|
||||
checkUSBC.Name = "checkUSBC";
|
||||
checkUSBC.Size = new Size(659, 36);
|
||||
checkUSBC.TabIndex = 4;
|
||||
checkUSBC.Text = "Keep GPU disabled on USB-C charger in Optimized mode";
|
||||
checkUSBC.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkNoOverdrive
|
||||
//
|
||||
@@ -298,7 +309,7 @@ namespace GHelper
|
||||
checkNoOverdrive.Name = "checkNoOverdrive";
|
||||
checkNoOverdrive.Size = new Size(307, 36);
|
||||
checkNoOverdrive.TabIndex = 3;
|
||||
checkNoOverdrive.Text = Properties.Strings.DisableOverdrive;
|
||||
checkNoOverdrive.Text = Strings.DisableOverdrive;
|
||||
checkNoOverdrive.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkKeyboardAuto
|
||||
@@ -309,7 +320,7 @@ namespace GHelper
|
||||
checkKeyboardAuto.Name = "checkKeyboardAuto";
|
||||
checkKeyboardAuto.Size = new Size(712, 36);
|
||||
checkKeyboardAuto.TabIndex = 2;
|
||||
checkKeyboardAuto.Text = Properties.Strings.KeyboardAuto;
|
||||
checkKeyboardAuto.Text = Strings.KeyboardAuto;
|
||||
checkKeyboardAuto.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkTopmost
|
||||
@@ -319,28 +330,28 @@ namespace GHelper
|
||||
checkTopmost.Name = "checkTopmost";
|
||||
checkTopmost.Size = new Size(390, 36);
|
||||
checkTopmost.TabIndex = 1;
|
||||
checkTopmost.Text = Properties.Strings.WindowTop;
|
||||
checkTopmost.Text = Strings.WindowTop;
|
||||
checkTopmost.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Keyboard
|
||||
// Extra
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(860, 890);
|
||||
ClientSize = new Size(864, 953);
|
||||
Controls.Add(groupOther);
|
||||
Controls.Add(groupLight);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(groupBindings);
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
MaximizeBox = false;
|
||||
MdiChildrenMinimizedAnchorBottom = false;
|
||||
MinimizeBox = false;
|
||||
Name = "Keyboard";
|
||||
Name = "Extra";
|
||||
Padding = new Padding(10);
|
||||
ShowIcon = false;
|
||||
ShowInTaskbar = false;
|
||||
Text = Properties.Strings.ExtraSettings;
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
Text = "Extra Settings";
|
||||
groupBindings.ResumeLayout(false);
|
||||
groupBindings.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureHelp).EndInit();
|
||||
groupLight.ResumeLayout(false);
|
||||
groupLight.PerformLayout();
|
||||
@@ -352,7 +363,7 @@ namespace GHelper
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBox1;
|
||||
private GroupBox groupBindings;
|
||||
private Label labelM3;
|
||||
private RComboBox comboM3;
|
||||
private RComboBox comboM4;
|
||||
@@ -376,5 +387,6 @@ namespace GHelper
|
||||
private PictureBox pictureHelp;
|
||||
private TrackBar trackBrightness;
|
||||
private Label labelBrightness;
|
||||
private CheckBox checkUSBC;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.Diagnostics;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
public partial class Keyboard : RForm
|
||||
public partial class Extra : RForm
|
||||
{
|
||||
|
||||
Dictionary<string, string> customActions = new Dictionary<string, string>
|
||||
@@ -15,6 +15,7 @@ namespace GHelper
|
||||
{"aura", Properties.Strings.ToggleAura},
|
||||
{"ghelper", Properties.Strings.OpenGHelper},
|
||||
{"screen", Properties.Strings.ToggleScreen},
|
||||
{"miniled", Properties.Strings.ToggleMiniled},
|
||||
{"custom", Properties.Strings.Custom}
|
||||
};
|
||||
|
||||
@@ -52,9 +53,29 @@ namespace GHelper
|
||||
};
|
||||
}
|
||||
|
||||
public Keyboard()
|
||||
public Extra()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
groupBindings.Text = Properties.Strings.KeyBindings;
|
||||
groupLight.Text = Properties.Strings.KeyboardBacklight;
|
||||
groupOther.Text = Properties.Strings.Other;
|
||||
|
||||
checkAwake.Text = Properties.Strings.Awake;
|
||||
checkSleep.Text = Properties.Strings.Sleep;
|
||||
checkBoot.Text = Properties.Strings.Boot;
|
||||
checkShutdown.Text = Properties.Strings.Shutdown;
|
||||
|
||||
labelSpeed.Text = Properties.Strings.AnimationSpeed;
|
||||
labelBrightness.Text = Properties.Strings.Brightness;
|
||||
|
||||
checkKeyboardAuto.Text = Properties.Strings.KeyboardAuto;
|
||||
checkNoOverdrive.Text = Properties.Strings.DisableOverdrive;
|
||||
checkTopmost.Text = Properties.Strings.WindowTop;
|
||||
checkUSBC.Text = Properties.Strings.OptimizedUSBC;
|
||||
|
||||
Text = Properties.Strings.ExtraSettings;
|
||||
|
||||
InitTheme();
|
||||
|
||||
SetKeyCombo(comboM3, textM3, "m3");
|
||||
@@ -89,6 +110,9 @@ namespace GHelper
|
||||
checkNoOverdrive.Checked = (Program.config.getConfig("no_overdrive") == 1);
|
||||
checkNoOverdrive.CheckedChanged += CheckNoOverdrive_CheckedChanged;
|
||||
|
||||
checkUSBC.Checked = (Program.config.getConfig("optimized_usbc") == 1);
|
||||
checkUSBC.CheckedChanged += CheckUSBC_CheckedChanged;
|
||||
|
||||
int kb_brightness = Program.config.getConfig("keyboard_brightness");
|
||||
trackBrightness.Value = (kb_brightness >= 0 && kb_brightness <= 3) ? kb_brightness : 3;
|
||||
|
||||
@@ -97,6 +121,11 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
private void CheckUSBC_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("optimized_usbc", (checkUSBC.Checked ? 1 : 0));
|
||||
}
|
||||
|
||||
private void TrackBrightness_Scroll(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("keyboard_brightness", trackBrightness.Value);
|
||||
14
app/Fans.cs
14
app/Fans.cs
@@ -86,14 +86,22 @@ namespace GHelper
|
||||
|
||||
private void InitGPUClocks()
|
||||
{
|
||||
|
||||
panelGPU.Visible = HardwareMonitor.GpuControl.IsNvidia;
|
||||
try
|
||||
{
|
||||
using (var _gpuControl = new NvidiaGpuControl())
|
||||
{
|
||||
panelGPU.Visible = _gpuControl.IsValid;
|
||||
|
||||
trackGPUCore.Value = Math.Min(Program.config.getConfig("GPUCore"), 300);
|
||||
trackGPUMemory.Value = Math.Min(Program.config.getConfig("GPUMemory"), 300);
|
||||
|
||||
VisualiseGPUClocks();
|
||||
}
|
||||
} catch (Exception ex)
|
||||
{
|
||||
panelGPU.Visible=false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ButtonResetGPU_Click(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -56,14 +56,9 @@ public class NvidiaGpuControl : IGpuControl
|
||||
return null;
|
||||
|
||||
PhysicalGPU internalGpu = _internalGpu!;
|
||||
|
||||
IUtilizationDomainInfo? gpuUsage = GPUApi.GetUsages(internalGpu.Handle).GPU;
|
||||
|
||||
if (gpuUsage == null)
|
||||
return null;
|
||||
|
||||
return
|
||||
(int)gpuUsage?.Percentage;
|
||||
return (int?)gpuUsage?.Percentage;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -124,22 +124,22 @@ public static class HardwareMonitor
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void RecreateGpuTemperatureProviderWithDelay()
|
||||
public static void RecreateGpuControlWithDelay(int delay = 5)
|
||||
{
|
||||
|
||||
// Re-enabling the discrete GPU takes a bit of time,
|
||||
// so a simple workaround is to refresh again after that happens
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||
RecreateGpuTemperatureProvider();
|
||||
await Task.Delay(TimeSpan.FromSeconds(delay));
|
||||
RecreateGpuControl();
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void RecreateGpuTemperatureProvider()
|
||||
public static void RecreateGpuControl()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace GHelper
|
||||
|
||||
SetAutoModes();
|
||||
|
||||
HardwareMonitor.RecreateGpuTemperatureProvider();
|
||||
HardwareMonitor.RecreateGpuControl();
|
||||
|
||||
// Subscribing for system power change events
|
||||
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
||||
@@ -172,10 +172,10 @@ namespace GHelper
|
||||
|
||||
|
||||
|
||||
public static void SetAutoModes()
|
||||
public static void SetAutoModes(bool monitor = true)
|
||||
{
|
||||
|
||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return;
|
||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 3000) return;
|
||||
lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
|
||||
isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||
@@ -184,7 +184,8 @@ namespace GHelper
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
settingsForm.AutoPerformance();
|
||||
|
||||
bool switched = settingsForm.AutoGPUMode();
|
||||
bool switched = false;
|
||||
if (monitor) switched = settingsForm.AutoGPUMode();
|
||||
|
||||
if (!switched)
|
||||
{
|
||||
@@ -270,6 +271,9 @@ namespace GHelper
|
||||
case "screen":
|
||||
NativeMethods.TurnOffScreen(Program.settingsForm.Handle);
|
||||
break;
|
||||
case "miniled":
|
||||
settingsForm.BeginInvoke(settingsForm.ToogleMiniled);
|
||||
break;
|
||||
case "aura":
|
||||
settingsForm.BeginInvoke(settingsForm.CycleAuraMode);
|
||||
break;
|
||||
|
||||
18
app/Properties/Strings.Designer.cs
generated
18
app/Properties/Strings.Designer.cs
generated
@@ -699,6 +699,15 @@ namespace GHelper.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Keep GPU disabled on USB-C charger in Optimized mode.
|
||||
/// </summary>
|
||||
internal static string OptimizedUSBC {
|
||||
get {
|
||||
return ResourceManager.GetString("OptimizedUSBC", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Other.
|
||||
/// </summary>
|
||||
@@ -861,6 +870,15 @@ namespace GHelper.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Toggle Miniled (if supported).
|
||||
/// </summary>
|
||||
internal static string ToggleMiniled {
|
||||
get {
|
||||
return ResourceManager.GetString("ToggleMiniled", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Toggle Screen.
|
||||
/// </summary>
|
||||
|
||||
@@ -330,6 +330,9 @@
|
||||
<data name="OptimizedGPUTooltip" xml:space="preserve">
|
||||
<value>Switch to Eco on battery and to Standard when plugged</value>
|
||||
</data>
|
||||
<data name="OptimizedUSBC" xml:space="preserve">
|
||||
<value>Keep GPU disabled on USB-C charger in Optimized mode</value>
|
||||
</data>
|
||||
<data name="Other" xml:space="preserve">
|
||||
<value>Other</value>
|
||||
</data>
|
||||
@@ -384,6 +387,9 @@
|
||||
<data name="ToggleAura" xml:space="preserve">
|
||||
<value>Toggle Aura</value>
|
||||
</data>
|
||||
<data name="ToggleMiniled" xml:space="preserve">
|
||||
<value>Toggle Miniled (if supported)</value>
|
||||
</data>
|
||||
<data name="ToggleScreen" xml:space="preserve">
|
||||
<value>Toggle Screen</value>
|
||||
</data>
|
||||
|
||||
@@ -367,7 +367,7 @@
|
||||
<value>關機時</value>
|
||||
</data>
|
||||
<data name="Silent" xml:space="preserve">
|
||||
<value>安静模式</value>
|
||||
<value>安靜模式</value>
|
||||
</data>
|
||||
<data name="Sleep" xml:space="preserve">
|
||||
<value>睡眠時</value>
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace GHelper
|
||||
public string perfName = "Balanced";
|
||||
|
||||
public Fans fans;
|
||||
public Keyboard keyb;
|
||||
public Extra keyb;
|
||||
|
||||
static AnimeMatrixDevice mat;
|
||||
static long lastRefresh;
|
||||
@@ -185,11 +185,8 @@ namespace GHelper
|
||||
var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString());
|
||||
|
||||
if (gitVersion.CompareTo(appVersion) > 0)
|
||||
{
|
||||
BeginInvoke(delegate
|
||||
{
|
||||
SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, url);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -294,7 +291,7 @@ namespace GHelper
|
||||
break;
|
||||
case 1:
|
||||
Logger.WriteLine("Monitor Power On");
|
||||
Program.SetAutoModes();
|
||||
Program.SetAutoModes(false);
|
||||
break;
|
||||
case 2:
|
||||
Logger.WriteLine("Monitor Dimmed");
|
||||
@@ -561,7 +558,7 @@ namespace GHelper
|
||||
{
|
||||
if (keyb == null || keyb.Text == "")
|
||||
{
|
||||
keyb = new Keyboard();
|
||||
keyb = new Extra();
|
||||
keyb.Show();
|
||||
}
|
||||
else
|
||||
@@ -692,13 +689,18 @@ namespace GHelper
|
||||
SetScreen(60, 0);
|
||||
}
|
||||
|
||||
private void ButtonMiniled_Click(object? sender, EventArgs e)
|
||||
public void ToogleMiniled()
|
||||
{
|
||||
int miniled = (Program.config.getConfig("miniled") == 1) ? 0 : 1;
|
||||
Program.config.setConfig("miniled", miniled);
|
||||
SetScreen(-1, -1, miniled);
|
||||
}
|
||||
|
||||
private void ButtonMiniled_Click(object? sender, EventArgs e)
|
||||
{
|
||||
ToogleMiniled();
|
||||
}
|
||||
|
||||
public void SetScreen(int frequency = -1, int overdrive = -1, int miniled = -1)
|
||||
{
|
||||
|
||||
@@ -853,6 +855,7 @@ namespace GHelper
|
||||
gpuTemp = $": {HardwareMonitor.gpuTemp}°C ";
|
||||
}
|
||||
|
||||
|
||||
Program.settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
labelCPUFan.Text = "CPU" + cpuTemp + HardwareMonitor.cpuFan;
|
||||
@@ -921,10 +924,12 @@ namespace GHelper
|
||||
customPower = limit_cpu;
|
||||
}
|
||||
|
||||
/*
|
||||
if (Program.wmi.DeviceGet(ASUSWmi.PPT_APUC2) >= 0)
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_APUC2, 87, "PowerLimit C2");
|
||||
}
|
||||
*/
|
||||
|
||||
Program.settingsForm.BeginInvoke(SetPerformanceLabel);
|
||||
|
||||
@@ -1137,11 +1142,18 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
public static bool IsPlugged()
|
||||
{
|
||||
bool optimizedUSBC = Program.config.getConfig("optimized_usbc") != 1;
|
||||
|
||||
return SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online &&
|
||||
(optimizedUSBC || Program.wmi.DeviceGet(ASUSWmi.ChargerMode) != ASUSWmi.ChargerUSB);
|
||||
|
||||
}
|
||||
|
||||
public bool AutoGPUMode()
|
||||
{
|
||||
|
||||
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||
|
||||
bool GpuAuto = Program.config.getConfig("gpu_auto") == 1;
|
||||
bool ForceGPU = Program.config.ContainsModel("503");
|
||||
|
||||
@@ -1156,14 +1168,17 @@ namespace GHelper
|
||||
return false;
|
||||
else
|
||||
{
|
||||
|
||||
if (ReEnableGPU()) return true;
|
||||
|
||||
if (eco == 1)
|
||||
if ((GpuAuto && Plugged == PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeStandard))
|
||||
if ((GpuAuto && IsPlugged()) || (ForceGPU && GpuMode == ASUSWmi.GPUModeStandard))
|
||||
{
|
||||
SetEcoGPU(0);
|
||||
return true;
|
||||
}
|
||||
if (eco == 0)
|
||||
if ((GpuAuto && Plugged != PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeEco))
|
||||
if ((GpuAuto && !IsPlugged()) || (ForceGPU && GpuMode == ASUSWmi.GPUModeEco))
|
||||
{
|
||||
|
||||
if (HardwareMonitor.IsUsedGPU())
|
||||
@@ -1181,6 +1196,20 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
public bool ReEnableGPU()
|
||||
{
|
||||
if (Screen.AllScreens.Length <= 1) return false;
|
||||
if (Program.config.getConfig("gpu_reenable") != 1) return false;
|
||||
|
||||
Logger.WriteLine("Re-enabling gpu for 503 model");
|
||||
|
||||
Thread.Sleep(1000);
|
||||
SetEcoGPU(1);
|
||||
Thread.Sleep(1000);
|
||||
SetEcoGPU(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UltimateUI(bool ultimate)
|
||||
{
|
||||
if (!ultimate)
|
||||
@@ -1269,7 +1298,7 @@ namespace GHelper
|
||||
Program.wmi.DeviceSet(ASUSWmi.GPUEco, eco, "GPUEco");
|
||||
|
||||
if (eco == 0)
|
||||
HardwareMonitor.RecreateGpuTemperatureProviderWithDelay();
|
||||
HardwareMonitor.RecreateGpuControlWithDelay();
|
||||
|
||||
Program.settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user