mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
003a19d94b | ||
|
|
6c3d4b9cb2 | ||
|
|
aa62330c1c | ||
|
|
954861f2b1 | ||
|
|
e3e9022111 | ||
|
|
24014dd20f | ||
|
|
321bc2623d | ||
|
|
52b07843a2 | ||
|
|
5038ff2315 | ||
|
|
c8f4c4b0d4 | ||
|
|
319401af5d | ||
|
|
aa30f472ad | ||
|
|
b40eb50e90 | ||
|
|
1f47b031f6 | ||
|
|
84a3f01267 | ||
|
|
f9488fbf2f | ||
|
|
43d2ed656a | ||
|
|
e9fa181d4e | ||
|
|
58aa838e51 | ||
|
|
96c85f69fe | ||
|
|
8f215dafab | ||
|
|
b3636fd447 | ||
|
|
ed579f25d6 | ||
|
|
6a71a64c96 | ||
|
|
ac69f1317e | ||
|
|
4b38d380b5 | ||
|
|
9a2f9afe5b | ||
|
|
ce9ec1b6df | ||
|
|
e68282050b | ||
|
|
6b8f61fab4 | ||
|
|
f59070cb96 | ||
|
|
f47a00fde2 | ||
|
|
b15c15974e |
28
ASUSWmi.cs
28
ASUSWmi.cs
@@ -1,6 +1,7 @@
|
||||
using System.Management;
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
|
||||
|
||||
public class ASUSWmi
|
||||
{
|
||||
@@ -25,8 +26,12 @@ public class ASUSWmi
|
||||
public const uint DevsCPUFanCurve = 0x00110024;
|
||||
public const uint DevsGPUFanCurve = 0x00110025;
|
||||
|
||||
public const int PPT_Total = 0x001200A0;
|
||||
public const int PPT_CPU = 0x001200B0;
|
||||
public const int PPT_TotalA0 = 0x001200A0;
|
||||
public const int PPT_TotalA1 = 0x001200A1;
|
||||
|
||||
public const int PPT_CPUB0 = 0x001200B0;
|
||||
public const int PPT_CPUB1 = 0x001200B1;
|
||||
public const int PPT_CPUA2 = 0x001200A2;
|
||||
|
||||
public const int PerformanceBalanced = 0;
|
||||
public const int PerformanceTurbo = 1;
|
||||
@@ -165,9 +170,14 @@ public class ASUSWmi
|
||||
public void SetFanCurve(int device, byte[] curve)
|
||||
{
|
||||
|
||||
if (device == 1)
|
||||
if (curve.Length != 16) return;
|
||||
if (curve.All(singleByte => singleByte == 0)) return;
|
||||
|
||||
Debug.WriteLine(BitConverter.ToString(curve));
|
||||
|
||||
if (device == 1)
|
||||
DeviceSet(DevsGPUFanCurve, curve);
|
||||
else
|
||||
else
|
||||
DeviceSet(DevsCPUFanCurve, curve);
|
||||
}
|
||||
|
||||
@@ -178,14 +188,14 @@ public class ASUSWmi
|
||||
// because it's asus, and modes are swapped here
|
||||
switch (mode)
|
||||
{
|
||||
case 1:fan_mode = 2; break;
|
||||
case 1: fan_mode = 2; break;
|
||||
case 2: fan_mode = 1; break;
|
||||
default: fan_mode = 0; break;
|
||||
}
|
||||
|
||||
if (device == 1)
|
||||
if (device == 1)
|
||||
return DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
|
||||
else
|
||||
else
|
||||
return DeviceGetBuffer(DevsCPUFanCurve, fan_mode);
|
||||
|
||||
}
|
||||
|
||||
292
AnimeMatrix/AnimeMatrixDevice.cs
Normal file
292
AnimeMatrix/AnimeMatrixDevice.cs
Normal file
@@ -0,0 +1,292 @@
|
||||
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
|
||||
|
||||
using Starlight.Communication;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace Starlight.AnimeMatrix
|
||||
{
|
||||
public class BuiltInAnimation
|
||||
{
|
||||
public enum Startup
|
||||
{
|
||||
GlitchConstruction,
|
||||
StaticEmergence
|
||||
}
|
||||
|
||||
public enum Shutdown
|
||||
{
|
||||
GlitchOut,
|
||||
SeeYa
|
||||
}
|
||||
|
||||
public enum Sleeping
|
||||
{
|
||||
BannerSwipe,
|
||||
Starfield
|
||||
}
|
||||
|
||||
public enum Running
|
||||
{
|
||||
BinaryBannerScroll,
|
||||
RogLogoGlitch
|
||||
}
|
||||
|
||||
public byte AsByte { get; }
|
||||
|
||||
public BuiltInAnimation(
|
||||
Running running,
|
||||
Sleeping sleeping,
|
||||
Shutdown shutdown,
|
||||
Startup startup
|
||||
)
|
||||
{
|
||||
AsByte |= (byte)(((int)running & 0x01) << 0);
|
||||
AsByte |= (byte)(((int)sleeping & 0x01) << 1);
|
||||
AsByte |= (byte)(((int)shutdown & 0x01) << 2);
|
||||
AsByte |= (byte)(((int)startup & 0x01) << 3);
|
||||
}
|
||||
}
|
||||
|
||||
internal class AnimeMatrixPacket : Packet
|
||||
{
|
||||
public AnimeMatrixPacket(byte[] command)
|
||||
: base(0x5E, 640, command)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public enum BrightnessMode : byte
|
||||
{
|
||||
Off = 0,
|
||||
Dim = 1,
|
||||
Medium = 2,
|
||||
Full = 3
|
||||
}
|
||||
|
||||
|
||||
public class AnimeMatrixDevice : Device
|
||||
{
|
||||
private const int UpdatePageLength = 0x0278;
|
||||
|
||||
public int LedCount => 1450;
|
||||
public int Rows => 61;
|
||||
|
||||
private byte[] _displayBuffer = new byte[UpdatePageLength * 3];
|
||||
private List<byte[]> frames = new List<byte[]>();
|
||||
|
||||
private int frameIndex = 0;
|
||||
|
||||
public AnimeMatrixDevice()
|
||||
: base(0x0B05, 0x193B, 640)
|
||||
{
|
||||
}
|
||||
|
||||
public byte[] GetBuffer()
|
||||
{
|
||||
return _displayBuffer;
|
||||
}
|
||||
|
||||
public void PresentNextFrame()
|
||||
{
|
||||
//Debug.WriteLine(frameIndex);
|
||||
if (frameIndex >= frames.Count) frameIndex = 0;
|
||||
_displayBuffer = frames[frameIndex];
|
||||
Present();
|
||||
frameIndex++;
|
||||
}
|
||||
|
||||
public void ClearFrames()
|
||||
{
|
||||
frames.Clear();
|
||||
frameIndex = 0;
|
||||
}
|
||||
|
||||
public void AddFrame()
|
||||
{
|
||||
frames.Add(_displayBuffer.ToArray());
|
||||
}
|
||||
|
||||
public void SendRaw(params byte[] data)
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(data));
|
||||
}
|
||||
|
||||
|
||||
public int EmptyColumns(int row)
|
||||
{
|
||||
return (int)Math.Ceiling(Math.Max(0, row - 11) / 2.0);
|
||||
}
|
||||
public int Columns(int row)
|
||||
{
|
||||
EnsureRowInRange(row);
|
||||
return 34 - EmptyColumns(row);
|
||||
}
|
||||
|
||||
public int RowToLinearAddress(int row)
|
||||
{
|
||||
EnsureRowInRange(row);
|
||||
|
||||
var ret = 0;
|
||||
|
||||
if (row > 0)
|
||||
{
|
||||
for (var i = 0; i < row; i++)
|
||||
ret += Columns(i);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void WakeUp()
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(Encoding.ASCII.GetBytes("ASUS Tech.Inc.")));
|
||||
}
|
||||
|
||||
public void SetLedLinear(int address, byte value)
|
||||
{
|
||||
EnsureAddressableLed(address);
|
||||
_displayBuffer[address] = value;
|
||||
}
|
||||
|
||||
public void SetLedLinearImmediate(int address, byte value)
|
||||
{
|
||||
EnsureAddressableLed(address);
|
||||
_displayBuffer[address] = value;
|
||||
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||
.AppendData(BitConverter.GetBytes((ushort)(address + 1)))
|
||||
.AppendData(BitConverter.GetBytes((ushort)0x0001))
|
||||
.AppendData(value)
|
||||
);
|
||||
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
|
||||
}
|
||||
|
||||
public void SetLedPlanar(int x, int y, byte value)
|
||||
{
|
||||
EnsureRowInRange(y);
|
||||
var start = RowToLinearAddress(y) - EmptyColumns(y);
|
||||
|
||||
if (x > EmptyColumns(y))
|
||||
SetLedLinear(start + x, value);
|
||||
}
|
||||
|
||||
public void Clear(bool present = false)
|
||||
{
|
||||
for (var i = 0; i < _displayBuffer.Length; i++)
|
||||
_displayBuffer[i] = 0;
|
||||
|
||||
if (present)
|
||||
Present();
|
||||
}
|
||||
|
||||
public void Present()
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 0 + 1)))
|
||||
.AppendData(BitConverter.GetBytes((ushort)UpdatePageLength))
|
||||
.AppendData(_displayBuffer[(UpdatePageLength * 0)..(UpdatePageLength * 1)])
|
||||
);
|
||||
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 1 + 1)))
|
||||
.AppendData(BitConverter.GetBytes((ushort)UpdatePageLength))
|
||||
.AppendData(_displayBuffer[(UpdatePageLength * 1)..(UpdatePageLength * 2)])
|
||||
);
|
||||
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 2 + 1)))
|
||||
.AppendData(BitConverter.GetBytes((ushort)(LedCount - UpdatePageLength * 2)))
|
||||
.AppendData(
|
||||
_displayBuffer[(UpdatePageLength * 2)..(UpdatePageLength * 2 + (LedCount - UpdatePageLength * 2))])
|
||||
);
|
||||
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
|
||||
}
|
||||
|
||||
public void SetDisplayState(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(0xC3, 0x01)
|
||||
.AppendData(0x00));
|
||||
}
|
||||
else
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(0xC3, 0x01)
|
||||
.AppendData(0x80));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBrightness(BrightnessMode mode)
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x04)
|
||||
.AppendData((byte)mode)
|
||||
);
|
||||
}
|
||||
|
||||
public void SetBuiltInAnimation(bool enable)
|
||||
{
|
||||
var enabled = enable ? (byte)0x00 : (byte)0x80;
|
||||
Set(Packet<AnimeMatrixPacket>(0xC4, 0x01, enabled));
|
||||
}
|
||||
|
||||
public void SetBuiltInAnimation(bool enable, BuiltInAnimation animation)
|
||||
{
|
||||
SetBuiltInAnimation(enable);
|
||||
Set(Packet<AnimeMatrixPacket>(0xC5, animation.AsByte));
|
||||
}
|
||||
|
||||
public void GenerateFrame(Image image)
|
||||
{
|
||||
|
||||
int width = 34 * 3;
|
||||
int height = 61;
|
||||
float scale;
|
||||
|
||||
Bitmap canvas = new Bitmap(width, height);
|
||||
|
||||
scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height);
|
||||
|
||||
var graph = Graphics.FromImage(canvas);
|
||||
var scaleWidth = (int)(image.Width * scale);
|
||||
var scaleHeight = (int)(image.Height * scale);
|
||||
|
||||
graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
|
||||
graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
|
||||
graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
||||
|
||||
graph.DrawImage(image, ((int)width - scaleWidth), ((int)height - scaleHeight) / 2, scaleWidth, scaleHeight);
|
||||
|
||||
Bitmap bmp = new Bitmap(canvas, 34, 61);
|
||||
|
||||
for (int y = 0; y < bmp.Height; y++)
|
||||
{
|
||||
for (int x = 0; x < bmp.Width; x++)
|
||||
{
|
||||
var pixel = bmp.GetPixel(x, y);
|
||||
byte color = (byte)(Math.Max((pixel.R + pixel.G + pixel.B) / 3 - 10, 0));
|
||||
SetLedPlanar(x, y, color);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void EnsureRowInRange(int row)
|
||||
{
|
||||
if (row < 0 || row >= Rows)
|
||||
{
|
||||
throw new IndexOutOfRangeException($"Y-coordinate should fall in range of [0, {Rows - 1}].");
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureAddressableLed(int address)
|
||||
{
|
||||
if (address < 0 || address >= LedCount)
|
||||
{
|
||||
throw new IndexOutOfRangeException($"Linear LED address must be in range of [0, {LedCount - 1}].");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
144
AppConfig.cs
Normal file
144
AppConfig.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System.Text.Json;
|
||||
|
||||
public class AppConfig
|
||||
{
|
||||
|
||||
public string appPath;
|
||||
string configFile;
|
||||
|
||||
public Dictionary<string, object> config = new Dictionary<string, object>();
|
||||
|
||||
public AppConfig()
|
||||
{
|
||||
|
||||
appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
||||
configFile = appPath + "\\config.json";
|
||||
|
||||
if (!System.IO.Directory.Exists(appPath))
|
||||
System.IO.Directory.CreateDirectory(appPath);
|
||||
|
||||
if (File.Exists(configFile))
|
||||
{
|
||||
string text = File.ReadAllText(configFile);
|
||||
try
|
||||
{
|
||||
config = JsonSerializer.Deserialize<Dictionary<string, object>>(text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
initConfig();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
initConfig();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initConfig()
|
||||
{
|
||||
config = new Dictionary<string, object>();
|
||||
config["performance_mode"] = 0;
|
||||
string jsonString = JsonSerializer.Serialize(config);
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public int getConfig(string name)
|
||||
{
|
||||
if (config.ContainsKey(name))
|
||||
return int.Parse(config[name].ToString());
|
||||
else return -1;
|
||||
}
|
||||
|
||||
public string getConfigString(string name)
|
||||
{
|
||||
if (config.ContainsKey(name))
|
||||
return config[name].ToString();
|
||||
else return null;
|
||||
}
|
||||
|
||||
public void setConfig(string name, int value)
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public void setConfig(string name, string value)
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public string getParamName(int device, string paramName = "fan_profile")
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
string name;
|
||||
|
||||
if (device == 1)
|
||||
name = "gpu";
|
||||
else
|
||||
name = "cpu";
|
||||
|
||||
return paramName + "_" + name + "_" + mode;
|
||||
}
|
||||
|
||||
public byte[] getFanConfig(int device)
|
||||
{
|
||||
string curveString = getConfigString(getParamName(device));
|
||||
byte[] curve = { };
|
||||
|
||||
if (curveString is not null)
|
||||
curve = StringToBytes(curveString);
|
||||
|
||||
return curve;
|
||||
}
|
||||
|
||||
public void setFanConfig(int device, byte[] curve)
|
||||
{
|
||||
string bitCurve = BitConverter.ToString(curve);
|
||||
setConfig(getParamName(device), bitCurve);
|
||||
}
|
||||
|
||||
|
||||
public static byte[] StringToBytes(string str)
|
||||
{
|
||||
String[] arr = str.Split('-');
|
||||
byte[] array = new byte[arr.Length];
|
||||
for (int i = 0; i < arr.Length; i++) array[i] = Convert.ToByte(arr[i], 16);
|
||||
return array;
|
||||
}
|
||||
|
||||
public byte[] getDefaultCurve(int device)
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
byte[] curve;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("14-3F-44-48-4C-50-54-62-16-1F-26-2D-39-47-55-5F");
|
||||
else
|
||||
curve = StringToBytes("14-3F-44-48-4C-50-54-62-11-1A-22-29-34-43-51-5A");
|
||||
break;
|
||||
case 2:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("3C-41-42-46-47-4B-4C-62-08-11-11-1D-1D-26-26-2D");
|
||||
else
|
||||
curve = StringToBytes("3C-41-42-46-47-4B-4C-62-03-0C-0C-16-16-22-22-29");
|
||||
break;
|
||||
default:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("3A-3D-40-44-48-4D-51-62-0C-16-1D-1F-26-2D-34-4A");
|
||||
else
|
||||
curve = StringToBytes("3A-3D-40-44-48-4D-51-62-08-11-16-1A-22-29-30-45");
|
||||
break;
|
||||
}
|
||||
|
||||
return curve;
|
||||
}
|
||||
|
||||
}
|
||||
20
Aura.cs
20
Aura.cs
@@ -3,14 +3,14 @@
|
||||
public class Aura
|
||||
{
|
||||
|
||||
static byte[] MESSAGE_SET = { 0x5d, 0xb5 };
|
||||
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4 };
|
||||
static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0,0,0 };
|
||||
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4};
|
||||
|
||||
public const int Static = 0;
|
||||
public const int Breathe = 1;
|
||||
public const int Strobe = 2;
|
||||
public const int Rainbow = 3;
|
||||
public const int Dingding = 10;
|
||||
public const int Dingding = 4;
|
||||
|
||||
public const int SpeedSlow = 0xe1;
|
||||
public const int SpeedMedium = 0xeb;
|
||||
@@ -47,6 +47,20 @@ public class Aura
|
||||
|
||||
HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
|
||||
|
||||
if (Mode == Dingding)
|
||||
{
|
||||
Mode = 10;
|
||||
Speed = SpeedMedium;
|
||||
}
|
||||
else if (Mode == Rainbow)
|
||||
{
|
||||
Speed = SpeedMedium;
|
||||
}
|
||||
else
|
||||
{
|
||||
Speed = SpeedSlow;
|
||||
}
|
||||
|
||||
foreach (HidDevice device in HidDeviceList)
|
||||
{
|
||||
if (device.IsConnected)
|
||||
|
||||
32
Communication/Device.cs
Normal file
32
Communication/Device.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
// Source thanks to https://github.com/vddCore/Starlight :)
|
||||
|
||||
using Starlight.Communication.Platform;
|
||||
|
||||
namespace Starlight.Communication
|
||||
{
|
||||
public abstract class Device : IDisposable
|
||||
{
|
||||
private static UsbProvider _usbProvider;
|
||||
|
||||
protected Device(ushort vendorId, ushort productId, int maxFeatureReportLength)
|
||||
{
|
||||
_usbProvider = new WindowsUsbProvider(vendorId, productId, maxFeatureReportLength);
|
||||
}
|
||||
|
||||
protected T Packet<T>(params byte[] command) where T : Packet
|
||||
{
|
||||
return (T)Activator.CreateInstance(typeof(T), command)!;
|
||||
}
|
||||
|
||||
public void Set(Packet packet)
|
||||
=> _usbProvider?.Set(packet.Data);
|
||||
|
||||
public byte[] Get(Packet packet)
|
||||
=> _usbProvider?.Get(packet.Data);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_usbProvider?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
58
Communication/Packet.cs
Normal file
58
Communication/Packet.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
// Source thanks to https://github.com/vddCore/Starlight :)
|
||||
|
||||
namespace Starlight.Communication
|
||||
{
|
||||
public abstract class Packet
|
||||
{
|
||||
private int _currentDataIndex = 1;
|
||||
|
||||
public byte[] Data { get; }
|
||||
|
||||
internal Packet(byte reportId, int packetLength, params byte[] data)
|
||||
{
|
||||
if (packetLength < 1)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(
|
||||
nameof(packetLength),
|
||||
"Packet length must be at least 1."
|
||||
);
|
||||
}
|
||||
|
||||
Data = new byte[packetLength];
|
||||
Data[0] = reportId;
|
||||
|
||||
if (data.Length > 0)
|
||||
{
|
||||
if (_currentDataIndex >= Data.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(
|
||||
nameof(data),
|
||||
"Your packet length does not allow for initial data to be appended."
|
||||
);
|
||||
}
|
||||
|
||||
AppendData(data);
|
||||
}
|
||||
}
|
||||
|
||||
public Packet AppendData(params byte[] data)
|
||||
=> AppendData(out _, data);
|
||||
|
||||
public Packet AppendData(out int bytesWritten, params byte[] data)
|
||||
{
|
||||
bytesWritten = 0;
|
||||
|
||||
for (var i = 0;
|
||||
i < data.Length && _currentDataIndex < Data.Length - 1;
|
||||
i++, bytesWritten++, _currentDataIndex++)
|
||||
{
|
||||
if (_currentDataIndex > Data.Length - 1)
|
||||
break;
|
||||
|
||||
Data[_currentDataIndex] = data[i];
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Communication/Platform/UsbProvider.cs
Normal file
19
Communication/Platform/UsbProvider.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Starlight.Communication.Platform
|
||||
{
|
||||
internal abstract class UsbProvider : IDisposable
|
||||
{
|
||||
protected ushort VendorID { get; }
|
||||
protected ushort ProductID { get; }
|
||||
|
||||
protected UsbProvider(ushort vendorId, ushort productId)
|
||||
{
|
||||
VendorID = vendorId;
|
||||
ProductID = productId;
|
||||
}
|
||||
|
||||
public abstract void Set(byte[] data);
|
||||
public abstract byte[] Get(byte[] data);
|
||||
|
||||
public abstract void Dispose();
|
||||
}
|
||||
}
|
||||
79
Communication/Platform/WindowsUsbProvider.cs
Normal file
79
Communication/Platform/WindowsUsbProvider.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System.ComponentModel;
|
||||
using HidSharp;
|
||||
|
||||
namespace Starlight.Communication.Platform
|
||||
{
|
||||
internal class WindowsUsbProvider : UsbProvider
|
||||
{
|
||||
protected HidDevice HidDevice { get; }
|
||||
protected HidStream HidStream { get; }
|
||||
|
||||
public WindowsUsbProvider(ushort vendorId, ushort productId, int maxFeatureReportLength)
|
||||
: base(vendorId, productId)
|
||||
{
|
||||
try
|
||||
{
|
||||
HidDevice = DeviceList.Local
|
||||
.GetHidDevices(vendorId, productId)
|
||||
.First(x => x.GetMaxFeatureReportLength() == maxFeatureReportLength);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new IOException("AniMe Matrix control device was not found on your machine.");
|
||||
}
|
||||
|
||||
var config = new OpenConfiguration();
|
||||
config.SetOption(OpenOption.Interruptible, true);
|
||||
config.SetOption(OpenOption.Exclusive, false);
|
||||
config.SetOption(OpenOption.Priority, 10);
|
||||
|
||||
HidStream = HidDevice.Open(config);
|
||||
}
|
||||
|
||||
public override void Set(byte[] data)
|
||||
{
|
||||
WrapException(() =>
|
||||
{
|
||||
HidStream.SetFeature(data);
|
||||
HidStream.Flush();
|
||||
});
|
||||
}
|
||||
|
||||
public override byte[] Get(byte[] data)
|
||||
{
|
||||
var outData = new byte[data.Length];
|
||||
Array.Copy(data, outData, data.Length);
|
||||
|
||||
WrapException(() =>
|
||||
{
|
||||
HidStream.GetFeature(outData);
|
||||
HidStream.Flush();
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
HidStream.Dispose();
|
||||
}
|
||||
|
||||
private void WrapException(Action action)
|
||||
{
|
||||
try
|
||||
{
|
||||
action();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
if (e.InnerException is Win32Exception w32e)
|
||||
{
|
||||
if (w32e.NativeErrorCode != 0)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
102
Fans.Designer.cs
generated
102
Fans.Designer.cs
generated
@@ -35,6 +35,7 @@
|
||||
buttonReset = new Button();
|
||||
chartGPU = new System.Windows.Forms.DataVisualization.Charting.Chart();
|
||||
groupBox1 = new GroupBox();
|
||||
labelApplied = new Label();
|
||||
pictureFine = new PictureBox();
|
||||
labelInfo = new Label();
|
||||
labelCPU = new Label();
|
||||
@@ -44,6 +45,7 @@
|
||||
trackCPU = new TrackBar();
|
||||
trackTotal = new TrackBar();
|
||||
buttonApplyPower = new Button();
|
||||
checkAuto = new CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)chartCPU).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)chartGPU).BeginInit();
|
||||
groupBox1.SuspendLayout();
|
||||
@@ -56,26 +58,29 @@
|
||||
//
|
||||
chartArea1.Name = "ChartArea1";
|
||||
chartCPU.ChartAreas.Add(chartArea1);
|
||||
chartCPU.Location = new Point(362, 30);
|
||||
chartCPU.Location = new Point(390, 28);
|
||||
chartCPU.Margin = new Padding(4, 2, 4, 2);
|
||||
chartCPU.Name = "chartCPU";
|
||||
chartCPU.Size = new Size(772, 464);
|
||||
chartCPU.Size = new Size(832, 436);
|
||||
chartCPU.TabIndex = 0;
|
||||
chartCPU.Text = "chartCPU";
|
||||
//
|
||||
// buttonApply
|
||||
//
|
||||
buttonApply.Location = new Point(879, 1016);
|
||||
buttonApply.Location = new Point(946, 952);
|
||||
buttonApply.Margin = new Padding(4, 2, 4, 2);
|
||||
buttonApply.Name = "buttonApply";
|
||||
buttonApply.Size = new Size(254, 46);
|
||||
buttonApply.Size = new Size(274, 44);
|
||||
buttonApply.TabIndex = 1;
|
||||
buttonApply.Text = "Apply Fan Curve";
|
||||
buttonApply.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonReset
|
||||
//
|
||||
buttonReset.Location = new Point(619, 1016);
|
||||
buttonReset.Location = new Point(390, 952);
|
||||
buttonReset.Margin = new Padding(4, 2, 4, 2);
|
||||
buttonReset.Name = "buttonReset";
|
||||
buttonReset.Size = new Size(254, 46);
|
||||
buttonReset.Size = new Size(274, 44);
|
||||
buttonReset.TabIndex = 2;
|
||||
buttonReset.Text = "Factory Defaults";
|
||||
buttonReset.UseVisualStyleBackColor = true;
|
||||
@@ -84,14 +89,16 @@
|
||||
//
|
||||
chartArea2.Name = "ChartArea1";
|
||||
chartGPU.ChartAreas.Add(chartArea2);
|
||||
chartGPU.Location = new Point(362, 511);
|
||||
chartGPU.Location = new Point(390, 480);
|
||||
chartGPU.Margin = new Padding(4, 2, 4, 2);
|
||||
chartGPU.Name = "chartGPU";
|
||||
chartGPU.Size = new Size(772, 480);
|
||||
chartGPU.Size = new Size(832, 450);
|
||||
chartGPU.TabIndex = 3;
|
||||
chartGPU.Text = "chart1";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(labelApplied);
|
||||
groupBox1.Controls.Add(pictureFine);
|
||||
groupBox1.Controls.Add(labelInfo);
|
||||
groupBox1.Controls.Add(labelCPU);
|
||||
@@ -101,19 +108,35 @@
|
||||
groupBox1.Controls.Add(trackCPU);
|
||||
groupBox1.Controls.Add(trackTotal);
|
||||
groupBox1.Location = new Point(12, 12);
|
||||
groupBox1.Margin = new Padding(4, 2, 4, 2);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(330, 979);
|
||||
groupBox1.Padding = new Padding(6, 4, 6, 4);
|
||||
groupBox1.Size = new Size(356, 918);
|
||||
groupBox1.TabIndex = 4;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Power Limits (PPT)";
|
||||
//
|
||||
// labelApplied
|
||||
//
|
||||
labelApplied.AutoSize = true;
|
||||
labelApplied.ForeColor = Color.Tomato;
|
||||
labelApplied.Location = new Point(16, 36);
|
||||
labelApplied.Margin = new Padding(4, 0, 4, 0);
|
||||
labelApplied.Name = "labelApplied";
|
||||
labelApplied.Size = new Size(143, 32);
|
||||
labelApplied.TabIndex = 13;
|
||||
labelApplied.Text = "Not Applied";
|
||||
//
|
||||
// pictureFine
|
||||
//
|
||||
pictureFine.BackgroundImage = Properties.Resources.everything_is_fine_itsfine;
|
||||
pictureFine.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
pictureFine.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureFine.Location = new Point(12, 725);
|
||||
pictureFine.Image = Properties.Resources.everything_is_fine_itsfine;
|
||||
pictureFine.Location = new Point(10, 682);
|
||||
pictureFine.Margin = new Padding(4, 2, 4, 2);
|
||||
pictureFine.Name = "pictureFine";
|
||||
pictureFine.Size = new Size(304, 240);
|
||||
pictureFine.Size = new Size(336, 226);
|
||||
pictureFine.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
pictureFine.TabIndex = 12;
|
||||
pictureFine.TabStop = false;
|
||||
pictureFine.Visible = false;
|
||||
@@ -121,7 +144,9 @@
|
||||
// labelInfo
|
||||
//
|
||||
labelInfo.AutoSize = true;
|
||||
labelInfo.Location = new Point(22, 644);
|
||||
labelInfo.Dock = DockStyle.Bottom;
|
||||
labelInfo.Location = new Point(6, 882);
|
||||
labelInfo.Margin = new Padding(4, 0, 4, 0);
|
||||
labelInfo.Name = "labelInfo";
|
||||
labelInfo.Size = new Size(65, 32);
|
||||
labelInfo.TabIndex = 11;
|
||||
@@ -131,7 +156,8 @@
|
||||
//
|
||||
labelCPU.AutoSize = true;
|
||||
labelCPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelCPU.Location = new Point(195, 99);
|
||||
labelCPU.Location = new Point(212, 118);
|
||||
labelCPU.Margin = new Padding(4, 0, 4, 0);
|
||||
labelCPU.Name = "labelCPU";
|
||||
labelCPU.Size = new Size(61, 32);
|
||||
labelCPU.TabIndex = 10;
|
||||
@@ -142,7 +168,8 @@
|
||||
//
|
||||
labelTotal.AutoSize = true;
|
||||
labelTotal.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelTotal.Location = new Point(37, 99);
|
||||
labelTotal.Location = new Point(42, 118);
|
||||
labelTotal.Margin = new Padding(4, 0, 4, 0);
|
||||
labelTotal.Name = "labelTotal";
|
||||
labelTotal.Size = new Size(70, 32);
|
||||
labelTotal.TabIndex = 9;
|
||||
@@ -152,7 +179,8 @@
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(198, 57);
|
||||
label2.Location = new Point(216, 86);
|
||||
label2.Margin = new Padding(4, 0, 4, 0);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(58, 32);
|
||||
label2.TabIndex = 8;
|
||||
@@ -162,7 +190,8 @@
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(39, 57);
|
||||
label1.Location = new Point(44, 86);
|
||||
label1.Margin = new Padding(4, 0, 4, 0);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(65, 32);
|
||||
label1.TabIndex = 7;
|
||||
@@ -171,24 +200,26 @@
|
||||
//
|
||||
// trackCPU
|
||||
//
|
||||
trackCPU.Location = new Point(203, 154);
|
||||
trackCPU.Location = new Point(218, 166);
|
||||
trackCPU.Margin = new Padding(4, 2, 4, 2);
|
||||
trackCPU.Maximum = 85;
|
||||
trackCPU.Minimum = 15;
|
||||
trackCPU.Name = "trackCPU";
|
||||
trackCPU.Orientation = Orientation.Vertical;
|
||||
trackCPU.Size = new Size(90, 470);
|
||||
trackCPU.Size = new Size(90, 416);
|
||||
trackCPU.TabIndex = 6;
|
||||
trackCPU.TickFrequency = 5;
|
||||
trackCPU.Value = 80;
|
||||
//
|
||||
// trackTotal
|
||||
//
|
||||
trackTotal.Location = new Point(45, 154);
|
||||
trackTotal.Location = new Point(46, 166);
|
||||
trackTotal.Margin = new Padding(4, 2, 4, 2);
|
||||
trackTotal.Maximum = 150;
|
||||
trackTotal.Minimum = 15;
|
||||
trackTotal.Name = "trackTotal";
|
||||
trackTotal.Orientation = Orientation.Vertical;
|
||||
trackTotal.Size = new Size(90, 470);
|
||||
trackTotal.Size = new Size(90, 416);
|
||||
trackTotal.TabIndex = 5;
|
||||
trackTotal.TickFrequency = 5;
|
||||
trackTotal.TickStyle = TickStyle.TopLeft;
|
||||
@@ -196,25 +227,39 @@
|
||||
//
|
||||
// buttonApplyPower
|
||||
//
|
||||
buttonApplyPower.Location = new Point(15, 1016);
|
||||
buttonApplyPower.Location = new Point(16, 952);
|
||||
buttonApplyPower.Margin = new Padding(4, 2, 4, 2);
|
||||
buttonApplyPower.Name = "buttonApplyPower";
|
||||
buttonApplyPower.Size = new Size(327, 46);
|
||||
buttonApplyPower.Size = new Size(352, 44);
|
||||
buttonApplyPower.TabIndex = 11;
|
||||
buttonApplyPower.Text = "Apply Power Limits";
|
||||
buttonApplyPower.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkAuto
|
||||
//
|
||||
checkAuto.AutoSize = true;
|
||||
checkAuto.Location = new Point(762, 958);
|
||||
checkAuto.Margin = new Padding(4, 2, 4, 2);
|
||||
checkAuto.Name = "checkAuto";
|
||||
checkAuto.Size = new Size(165, 36);
|
||||
checkAuto.TabIndex = 12;
|
||||
checkAuto.Text = "Auto Apply";
|
||||
checkAuto.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Fans
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1154, 1089);
|
||||
AutoScaleDimensions = new SizeF(192F, 192F);
|
||||
AutoScaleMode = AutoScaleMode.Dpi;
|
||||
AutoSize = true;
|
||||
ClientSize = new Size(1242, 1020);
|
||||
Controls.Add(checkAuto);
|
||||
Controls.Add(buttonApplyPower);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(chartGPU);
|
||||
Controls.Add(buttonReset);
|
||||
Controls.Add(buttonApply);
|
||||
Controls.Add(chartCPU);
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
Margin = new Padding(4, 2, 4, 2);
|
||||
MaximizeBox = false;
|
||||
MdiChildrenMinimizedAnchorBottom = false;
|
||||
MinimizeBox = false;
|
||||
@@ -231,6 +276,7 @@
|
||||
((System.ComponentModel.ISupportInitialize)trackCPU).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)trackTotal).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -249,5 +295,7 @@
|
||||
private Button buttonApplyPower;
|
||||
private Label labelInfo;
|
||||
private PictureBox pictureFine;
|
||||
private Label labelApplied;
|
||||
private CheckBox checkAuto;
|
||||
}
|
||||
}
|
||||
127
Fans.cs
127
Fans.cs
@@ -43,10 +43,19 @@ namespace GHelper
|
||||
chart.ChartAreas[0].AxisX.Minimum = 10;
|
||||
chart.ChartAreas[0].AxisX.Maximum = 100;
|
||||
chart.ChartAreas[0].AxisX.Interval = 10;
|
||||
|
||||
chart.ChartAreas[0].AxisY.Minimum = 0;
|
||||
chart.ChartAreas[0].AxisY.Maximum = 100;
|
||||
|
||||
chart.ChartAreas[0].AxisX.Interval = 10;
|
||||
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
|
||||
|
||||
chart.ChartAreas[0].AxisY.CustomLabels.Add(-2, 2, "OFF");
|
||||
|
||||
for (int i = 1; i <= 9; i++)
|
||||
chart.ChartAreas[0].AxisY.CustomLabels.Add(i * 10 - 2, i * 10 + 2, (1800 + 400 * i).ToString());
|
||||
|
||||
chart.ChartAreas[0].AxisY.CustomLabels.Add(98, 102, "RPM");
|
||||
|
||||
chart.ChartAreas[0].AxisY.Interval = 10;
|
||||
|
||||
if (chart.Legends.Count > 0)
|
||||
@@ -65,14 +74,14 @@ namespace GHelper
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
FormClosing += Fans_FormClosing;
|
||||
|
||||
seriesCPU = chartCPU.Series.Add("CPU");
|
||||
seriesGPU = chartGPU.Series.Add("GPU");
|
||||
|
||||
seriesCPU.Color = Color.Blue;
|
||||
seriesGPU.Color = Color.Red;
|
||||
|
||||
LoadFans();
|
||||
|
||||
chartCPU.MouseMove += ChartCPU_MouseMove;
|
||||
chartCPU.MouseUp += ChartCPU_MouseUp;
|
||||
|
||||
@@ -93,15 +102,37 @@ namespace GHelper
|
||||
|
||||
buttonApplyPower.Click += ButtonApplyPower_Click;
|
||||
|
||||
labelInfo.MaximumSize = new Size(300, 0);
|
||||
labelInfo.Text = "Power Limits (PPT) is experimental feature.\n\nValues will be applied only after you click 'Apply' and reset after performance mode change.\n\nUse carefully and on your own risk!";
|
||||
checkAuto.Click += CheckAuto_Click;
|
||||
|
||||
//labelInfo.MaximumSize = new Size(280, 0);
|
||||
labelInfo.Text = "Power Limits (PPT) is\nexperimental feature.\n\nValues will be applied\nonly after you click 'Apply'\nand reset after performance\nmode changes.\n\nUse carefully and\non your own risk!";
|
||||
|
||||
LoadFans();
|
||||
VisualisePower(true);
|
||||
|
||||
Shown += Fans_Shown;
|
||||
|
||||
}
|
||||
|
||||
private void CheckAuto_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null)
|
||||
return;
|
||||
|
||||
CheckBox chk = (CheckBox)sender;
|
||||
|
||||
Program.config.setConfig("auto_apply_" + Program.config.getConfig("performance_mode"), chk.Checked ? 1 : 0);
|
||||
}
|
||||
|
||||
private void Fans_FormClosing(object? sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (e.CloseReason == CloseReason.UserClosing)
|
||||
{
|
||||
e.Cancel = true;
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonApplyPower_Click(object? sender, EventArgs e)
|
||||
{
|
||||
int limit_total = trackTotal.Value;
|
||||
@@ -110,8 +141,14 @@ namespace GHelper
|
||||
Program.config.setConfig("limit_total", limit_total);
|
||||
Program.config.setConfig("limit_cpu", limit_cpu);
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_Total, limit_total);
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_CPU, limit_cpu);
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total);
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total);
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUA2, limit_cpu);
|
||||
|
||||
labelApplied.ForeColor = Color.Blue;
|
||||
labelApplied.Text = "Applied";
|
||||
|
||||
}
|
||||
|
||||
@@ -161,6 +198,12 @@ namespace GHelper
|
||||
VisualisePower();
|
||||
}
|
||||
|
||||
public void ResetApplyLabel()
|
||||
{
|
||||
labelApplied.ForeColor = Color.Red;
|
||||
labelApplied.Text = "Not Applied";
|
||||
}
|
||||
|
||||
public void LoadFans()
|
||||
{
|
||||
|
||||
@@ -170,28 +213,12 @@ namespace GHelper
|
||||
LoadProfile(seriesCPU, 0);
|
||||
LoadProfile(seriesGPU, 1);
|
||||
|
||||
int auto_apply = Program.config.getConfig("auto_apply_" + Program.config.getConfig("performance_mode"));
|
||||
|
||||
checkAuto.Checked = (auto_apply == 1);
|
||||
|
||||
}
|
||||
|
||||
byte[] StringToBytes(string str)
|
||||
{
|
||||
String[] arr = str.Split('-');
|
||||
byte[] array = new byte[arr.Length];
|
||||
for (int i = 0; i < arr.Length; i++) array[i] = Convert.ToByte(arr[i], 16);
|
||||
return array;
|
||||
}
|
||||
|
||||
string GetFanName(int device)
|
||||
{
|
||||
int mode = Program.config.getConfig("performance_mode");
|
||||
string name;
|
||||
|
||||
if (device == 1)
|
||||
name = "gpu";
|
||||
else
|
||||
name = "cpu";
|
||||
|
||||
return "fan_profile_" + name + "_" + mode;
|
||||
}
|
||||
|
||||
void LoadProfile(Series series, int device, int def = 0)
|
||||
{
|
||||
@@ -203,42 +230,13 @@ namespace GHelper
|
||||
series.Points.Clear();
|
||||
|
||||
int mode = Program.config.getConfig("performance_mode");
|
||||
string curveString = Program.config.getConfigString(GetFanName(device));
|
||||
byte[] curve = { };
|
||||
|
||||
if (curveString is not null)
|
||||
curve = StringToBytes(curveString);
|
||||
byte[] curve = Program.config.getFanConfig(device);
|
||||
|
||||
if (def == 1 || curve.Length != 16)
|
||||
curve = Program.wmi.GetFanCurve(device, mode);
|
||||
|
||||
if (curve.All(singleByte => singleByte == 0))
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("14-3F-44-48-4C-50-54-62-16-1F-26-2D-39-47-55-5F");
|
||||
else
|
||||
curve = StringToBytes("14-3F-44-48-4C-50-54-62-11-1A-22-29-34-43-51-5A");
|
||||
break;
|
||||
case 2:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("3C-41-42-46-47-4B-4C-62-08-11-11-1D-1D-26-26-2D");
|
||||
else
|
||||
curve = StringToBytes("3C-41-42-46-47-4B-4C-62-03-0C-0C-16-16-22-22-29");
|
||||
break;
|
||||
default:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("3A-3D-40-44-48-4D-51-62-0C-16-1D-1F-26-2D-34-4A");
|
||||
else
|
||||
curve = StringToBytes("3A-3D-40-44-48-4D-51-62-08-11-16-1A-22-29-30-45");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (curve.Length != 16 || curve.All(singleByte => singleByte == 0))
|
||||
curve = Program.config.getDefaultCurve(device);
|
||||
|
||||
//Debug.WriteLine(BitConverter.ToString(curve));
|
||||
|
||||
@@ -263,10 +261,7 @@ namespace GHelper
|
||||
i++;
|
||||
}
|
||||
|
||||
string bitCurve = BitConverter.ToString(curve);
|
||||
Debug.WriteLine(bitCurve);
|
||||
Program.config.setConfig(GetFanName(device), bitCurve);
|
||||
|
||||
Program.config.setFanConfig(device, curve);
|
||||
Program.wmi.SetFanCurve(device, curve);
|
||||
|
||||
}
|
||||
@@ -282,7 +277,13 @@ namespace GHelper
|
||||
{
|
||||
LoadProfile(seriesCPU, 0, 1);
|
||||
LoadProfile(seriesGPU, 1, 1);
|
||||
|
||||
checkAuto.Checked = false;
|
||||
Program.config.setConfig("auto_apply_" + Program.config.getConfig("performance_mode"), 0);
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"));
|
||||
|
||||
ResetApplyLabel();
|
||||
}
|
||||
|
||||
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
<AssemblyName>GHelper</AssemblyName>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
<AssemblyVersion>0.10.0</AssemblyVersion>
|
||||
<AssemblyVersion>0.16</AssemblyVersion>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -37,9 +38,9 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="hidlibrary" Version="3.3.40" />
|
||||
<PackageReference Include="HidSharpCore" Version="1.2.1.1" />
|
||||
<PackageReference Include="System.Management" Version="7.0.0" />
|
||||
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
||||
<PackageReference Include="UToolKit" Version="1.1.0.1" />
|
||||
<PackageReference Include="WinForms.DataVisualization" Version="1.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
40
Keyboard.Designer.cs
generated
40
Keyboard.Designer.cs
generated
@@ -35,11 +35,17 @@
|
||||
labelM4 = new Label();
|
||||
comboM3 = new ComboBox();
|
||||
labelM3 = new Label();
|
||||
textFNF4 = new TextBox();
|
||||
comboFNF4 = new ComboBox();
|
||||
labelFNF4 = new Label();
|
||||
groupBox1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(textFNF4);
|
||||
groupBox1.Controls.Add(comboFNF4);
|
||||
groupBox1.Controls.Add(labelFNF4);
|
||||
groupBox1.Controls.Add(textM4);
|
||||
groupBox1.Controls.Add(textM3);
|
||||
groupBox1.Controls.Add(comboM4);
|
||||
@@ -49,7 +55,7 @@
|
||||
groupBox1.Dock = DockStyle.Top;
|
||||
groupBox1.Location = new Point(10, 10);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(751, 196);
|
||||
groupBox1.Size = new Size(751, 242);
|
||||
groupBox1.TabIndex = 0;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Key Bindings";
|
||||
@@ -58,7 +64,7 @@
|
||||
//
|
||||
textM4.Location = new Point(411, 113);
|
||||
textM4.Name = "textM4";
|
||||
textM4.PlaceholderText = "notepad /p \"file.txt\"";
|
||||
textM4.PlaceholderText = "action";
|
||||
textM4.Size = new Size(320, 39);
|
||||
textM4.TabIndex = 5;
|
||||
//
|
||||
@@ -91,7 +97,7 @@
|
||||
// comboM3
|
||||
//
|
||||
comboM3.FormattingEnabled = true;
|
||||
comboM3.Items.AddRange(new object[] { "Volume Mute", "Play / Pause", "Toggle Aura", "Custom" });
|
||||
comboM3.Items.AddRange(new object[] { "Default", "Volume Mute", "Play / Pause", "PrintScreen", "Toggle Aura", "Custom" });
|
||||
comboM3.Location = new Point(93, 54);
|
||||
comboM3.Name = "comboM3";
|
||||
comboM3.Size = new Size(312, 40);
|
||||
@@ -106,6 +112,31 @@
|
||||
labelM3.TabIndex = 0;
|
||||
labelM3.Text = "M3:";
|
||||
//
|
||||
// textFNF4
|
||||
//
|
||||
textFNF4.Location = new Point(411, 176);
|
||||
textFNF4.Name = "textFNF4";
|
||||
textFNF4.PlaceholderText = "action";
|
||||
textFNF4.Size = new Size(320, 39);
|
||||
textFNF4.TabIndex = 8;
|
||||
//
|
||||
// comboFNF4
|
||||
//
|
||||
comboFNF4.FormattingEnabled = true;
|
||||
comboFNF4.Location = new Point(93, 175);
|
||||
comboFNF4.Name = "comboFNF4";
|
||||
comboFNF4.Size = new Size(312, 40);
|
||||
comboFNF4.TabIndex = 7;
|
||||
//
|
||||
// labelFNF4
|
||||
//
|
||||
labelFNF4.AutoSize = true;
|
||||
labelFNF4.Location = new Point(2, 178);
|
||||
labelFNF4.Name = "labelFNF4";
|
||||
labelFNF4.Size = new Size(90, 32);
|
||||
labelFNF4.TabIndex = 6;
|
||||
labelFNF4.Text = "FN+F4:";
|
||||
//
|
||||
// Keyboard
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
@@ -135,5 +166,8 @@
|
||||
private Label labelM4;
|
||||
private TextBox textM4;
|
||||
private TextBox textM3;
|
||||
private TextBox textFNF4;
|
||||
private ComboBox comboFNF4;
|
||||
private Label labelFNF4;
|
||||
}
|
||||
}
|
||||
101
Keyboard.cs
101
Keyboard.cs
@@ -2,71 +2,68 @@
|
||||
{
|
||||
public partial class Keyboard : Form
|
||||
{
|
||||
|
||||
Dictionary<string, string> customActions = new Dictionary<string, string>
|
||||
{
|
||||
{"","--------------" },
|
||||
{"mute", "Volume Mute"},
|
||||
{"screenshot", "Screenshot"},
|
||||
{"play", "Play/Pause"},
|
||||
{"aura", "Aura"},
|
||||
{"ghelper", "Open GHelper"},
|
||||
{"custom", "Custom"}
|
||||
};
|
||||
|
||||
private void SetKeyCombo(ComboBox combo, TextBox txbox, string name)
|
||||
{
|
||||
if (name == "m4")
|
||||
customActions[""] = "Performance";
|
||||
|
||||
if (name == "fnf4")
|
||||
{
|
||||
customActions[""] = "Aura";
|
||||
customActions.Remove("aura");
|
||||
}
|
||||
|
||||
combo.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
combo.DataSource = new BindingSource(customActions, null);
|
||||
combo.DisplayMember = "Value";
|
||||
combo.ValueMember = "Key";
|
||||
|
||||
string action = Program.config.getConfigString(name);
|
||||
|
||||
combo.SelectedValue = (action is not null) ? action : "";
|
||||
if (combo.SelectedValue is null) combo.SelectedValue = "";
|
||||
|
||||
combo.SelectedValueChanged += delegate
|
||||
{
|
||||
if (combo.SelectedValue is not null)
|
||||
Program.config.setConfig(name, combo.SelectedValue.ToString());
|
||||
};
|
||||
|
||||
txbox.Text = Program.config.getConfigString(name + "_custom");
|
||||
txbox.TextChanged += delegate
|
||||
{
|
||||
Program.config.setConfig(name + "_custom", txbox.Text);
|
||||
};
|
||||
}
|
||||
|
||||
public Keyboard()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
comboM3.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboM3.SelectedIndex = 0;
|
||||
|
||||
comboM4.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboM4.SelectedIndex = 0;
|
||||
|
||||
comboM3.SelectedValueChanged += ComboM3_SelectedValueChanged;
|
||||
comboM4.SelectedValueChanged += ComboM4_SelectedValueChanged;
|
||||
|
||||
textM3.TextChanged += TextM3_TextChanged;
|
||||
textM4.TextChanged += TextM4_TextChanged;
|
||||
SetKeyCombo(comboM3, textM3, "m3");
|
||||
SetKeyCombo(comboM4, textM4, "m4");
|
||||
SetKeyCombo(comboFNF4, textFNF4, "fnf4");
|
||||
|
||||
Shown += Keyboard_Shown;
|
||||
}
|
||||
|
||||
private void TextM3_TextChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null) return;
|
||||
TextBox tb = (TextBox)sender;
|
||||
Program.config.setConfig("m3_custom", tb.Text);
|
||||
}
|
||||
|
||||
private void TextM4_TextChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null) return;
|
||||
TextBox tb = (TextBox)sender;
|
||||
Program.config.setConfig("m4_custom", tb.Text);
|
||||
}
|
||||
|
||||
private void ComboM4_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null) return;
|
||||
ComboBox cmb = (ComboBox)sender;
|
||||
Program.config.setConfig("m4", cmb.SelectedIndex);
|
||||
}
|
||||
|
||||
private void ComboM3_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null) return;
|
||||
ComboBox cmb = (ComboBox)sender;
|
||||
Program.config.setConfig("m3", cmb.SelectedIndex);
|
||||
}
|
||||
|
||||
private void Keyboard_Shown(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
Top = Program.settingsForm.Top;
|
||||
Left = Program.settingsForm.Left - Width - 5;
|
||||
|
||||
int m3 = Program.config.getConfig("m3");
|
||||
int m4 = Program.config.getConfig("m4");
|
||||
|
||||
if (m3 != -1)
|
||||
comboM3.SelectedIndex = m3;
|
||||
|
||||
if (m4 != -1)
|
||||
comboM4.SelectedIndex = m4;
|
||||
|
||||
textM3.Text = Program.config.getConfigString("m3_custom");
|
||||
textM4.Text = Program.config.getConfigString("m4_custom");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ public class NativeMethods
|
||||
public const int VK_MEDIA_PLAY_PAUSE = 0xB3;
|
||||
public const int VK_MEDIA_PREV_TRACK = 0xB1;
|
||||
public const int VK_VOLUME_MUTE = 0xAD;
|
||||
public const int VK_SNAPSHOT = 0x2C;
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern void keybd_event(byte virtualKey, byte scanCode, uint flags, IntPtr extraInfo);
|
||||
|
||||
242
Program.cs
242
Program.cs
@@ -1,82 +1,6 @@
|
||||
using Microsoft.Win32;
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
using System.Text.Json;
|
||||
|
||||
public class AppConfig
|
||||
{
|
||||
|
||||
string appPath;
|
||||
string configFile;
|
||||
|
||||
public Dictionary<string, object> config = new Dictionary<string, object>();
|
||||
|
||||
public AppConfig()
|
||||
{
|
||||
|
||||
appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
||||
configFile = appPath + "\\config.json";
|
||||
|
||||
if (!System.IO.Directory.Exists(appPath))
|
||||
System.IO.Directory.CreateDirectory(appPath);
|
||||
|
||||
if (File.Exists(configFile))
|
||||
{
|
||||
string text = File.ReadAllText(configFile);
|
||||
try
|
||||
{
|
||||
config = JsonSerializer.Deserialize<Dictionary<string, object>>(text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
initConfig();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
initConfig();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initConfig()
|
||||
{
|
||||
config = new Dictionary<string, object>();
|
||||
config["performance_mode"] = 0;
|
||||
string jsonString = JsonSerializer.Serialize(config);
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public int getConfig(string name)
|
||||
{
|
||||
if (config.ContainsKey(name))
|
||||
return int.Parse(config[name].ToString());
|
||||
else return -1;
|
||||
}
|
||||
|
||||
public string getConfigString(string name)
|
||||
{
|
||||
if (config.ContainsKey(name))
|
||||
return config[name].ToString();
|
||||
else return null;
|
||||
}
|
||||
|
||||
public void setConfig(string name, int value)
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public void setConfig(string name, string value)
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class HardwareMonitor
|
||||
{
|
||||
@@ -119,7 +43,7 @@ namespace GHelper
|
||||
Visible = true
|
||||
};
|
||||
|
||||
public static ASUSWmi wmi = new ASUSWmi();
|
||||
public static ASUSWmi wmi;
|
||||
public static AppConfig config = new AppConfig();
|
||||
|
||||
public static SettingsForm settingsForm = new SettingsForm();
|
||||
@@ -128,6 +52,23 @@ namespace GHelper
|
||||
// The main entry point for the application
|
||||
public static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
wmi = new ASUSWmi();
|
||||
}
|
||||
catch
|
||||
{
|
||||
DialogResult dialogResult = MessageBox.Show("Can't connect to ASUS ACPI. Application can't function without it. Try to install Asus System Controll Interface", "Startup Error", MessageBoxButtons.YesNo);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo("https://www.asus.com/support/FAQ/1047338/") { UseShellExecute = true });
|
||||
}
|
||||
|
||||
Application.Exit();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
trayIcon.MouseClick += TrayIcon_MouseClick; ;
|
||||
|
||||
@@ -136,18 +77,13 @@ namespace GHelper
|
||||
settingsForm.InitGPUMode();
|
||||
settingsForm.InitBoost();
|
||||
settingsForm.InitAura();
|
||||
|
||||
settingsForm.SetPerformanceMode(config.getConfig("performance_mode"));
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
settingsForm.InitMatrix();
|
||||
|
||||
settingsForm.VisualiseGPUAuto(config.getConfig("gpu_auto"));
|
||||
settingsForm.VisualiseScreenAuto(config.getConfig("screen_auto"));
|
||||
|
||||
settingsForm.SetStartupCheck(Startup.IsScheduled());
|
||||
|
||||
bool isPlugged = (System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online);
|
||||
settingsForm.AutoGPUMode(isPlugged ? 1 : 0);
|
||||
settingsForm.AutoScreen(isPlugged ? 1 : 0);
|
||||
SetAutoModes();
|
||||
|
||||
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
||||
|
||||
@@ -157,15 +93,23 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||
private static void SetAutoModes()
|
||||
{
|
||||
bool isPlugged = (System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online);
|
||||
settingsForm.AutoGPUMode(isPlugged ? 1 : 0);
|
||||
settingsForm.AutoScreen(isPlugged ? 1 : 0);
|
||||
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||
settingsForm.AutoGPUMode(isPlugged);
|
||||
settingsForm.AutoScreen(isPlugged);
|
||||
settingsForm.AutoPerformance(isPlugged);
|
||||
|
||||
settingsForm.SetMatrix(isPlugged);
|
||||
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
}
|
||||
|
||||
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||
{
|
||||
SetAutoModes();
|
||||
}
|
||||
|
||||
|
||||
static void LaunchProcess(string fileName = "")
|
||||
{
|
||||
@@ -176,7 +120,8 @@ namespace GHelper
|
||||
try
|
||||
{
|
||||
Process proc = Process.Start(start);
|
||||
} catch
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Failed to run " + fileName);
|
||||
}
|
||||
@@ -184,6 +129,69 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
static void CustomKey(string configKey = "m3")
|
||||
{
|
||||
string command = config.getConfigString(configKey + "_custom");
|
||||
int intKey;
|
||||
|
||||
try
|
||||
{
|
||||
intKey = Convert.ToInt32(command, 16);
|
||||
}
|
||||
catch
|
||||
{
|
||||
intKey = -1;
|
||||
}
|
||||
|
||||
|
||||
if (intKey > 0)
|
||||
NativeMethods.KeyPress(intKey);
|
||||
else
|
||||
LaunchProcess(command);
|
||||
|
||||
}
|
||||
|
||||
static void KeyProcess(string name = "m3")
|
||||
{
|
||||
string action = config.getConfigString(name);
|
||||
|
||||
if (action is null || action.Length <= 1)
|
||||
{
|
||||
if (name == "m4")
|
||||
action = "performance";
|
||||
if (name == "fnf4")
|
||||
action = "aura";
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "mute":
|
||||
NativeMethods.KeyPress(NativeMethods.VK_VOLUME_MUTE);
|
||||
break;
|
||||
case "play":
|
||||
NativeMethods.KeyPress(NativeMethods.VK_MEDIA_PLAY_PAUSE);
|
||||
break;
|
||||
case "screenshot":
|
||||
NativeMethods.KeyPress(NativeMethods.VK_SNAPSHOT);
|
||||
break;
|
||||
case "aura":
|
||||
settingsForm.BeginInvoke(settingsForm.CycleAuraMode);
|
||||
break;
|
||||
case "performance":
|
||||
settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode);
|
||||
break;
|
||||
case "ghelper":
|
||||
settingsForm.BeginInvoke(SettingsToggle);
|
||||
break;
|
||||
case "custom":
|
||||
CustomKey(name);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void WatcherEventArrived(object sender, EventArrivedEventArgs e)
|
||||
{
|
||||
var collection = (ManagementEventWatcher)sender;
|
||||
@@ -197,64 +205,17 @@ namespace GHelper
|
||||
switch (EventID)
|
||||
{
|
||||
case 124: // M3
|
||||
switch (config.getConfig("m3"))
|
||||
{
|
||||
case 1:
|
||||
NativeMethods.KeyPress(NativeMethods.VK_MEDIA_PLAY_PAUSE);
|
||||
break;
|
||||
case 2:
|
||||
settingsForm.BeginInvoke(settingsForm.CycleAuraMode);
|
||||
break;
|
||||
case 3:
|
||||
LaunchProcess(config.getConfigString("m3_custom"));
|
||||
break;
|
||||
default:
|
||||
NativeMethods.KeyPress(NativeMethods.VK_VOLUME_MUTE);
|
||||
break;
|
||||
}
|
||||
KeyProcess("m3");
|
||||
return;
|
||||
case 56: // M4 / Rog button
|
||||
switch (config.getConfig("m4"))
|
||||
{
|
||||
case 1:
|
||||
settingsForm.BeginInvoke(SettingsToggle);
|
||||
break;
|
||||
case 2:
|
||||
LaunchProcess(config.getConfigString("m4_custom"));
|
||||
break;
|
||||
default:
|
||||
settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode);
|
||||
break;
|
||||
}
|
||||
KeyProcess("m4");
|
||||
return;
|
||||
case 174: // FN+F5
|
||||
settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode);
|
||||
return;
|
||||
case 179: // FN+F4
|
||||
settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
settingsForm.CycleAuraMode();
|
||||
});
|
||||
KeyProcess("fnf4");
|
||||
return;
|
||||
case 87: // Battery
|
||||
/*
|
||||
settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
settingsForm.AutoGPUMode(0);
|
||||
settingsForm.AutoScreen(0);
|
||||
});
|
||||
*/
|
||||
return;
|
||||
case 88: // Plugged
|
||||
/*
|
||||
settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
settingsForm.AutoScreen(1);
|
||||
settingsForm.AutoGPUMode(1);
|
||||
});
|
||||
*/
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -269,6 +230,9 @@ namespace GHelper
|
||||
settingsForm.Show();
|
||||
settingsForm.Activate();
|
||||
}
|
||||
|
||||
settingsForm.VisualiseGPUMode();
|
||||
|
||||
}
|
||||
|
||||
static void TrayIcon_MouseClick(object? sender, MouseEventArgs e)
|
||||
|
||||
10
Properties/Resources.Designer.cs
generated
10
Properties/Resources.Designer.cs
generated
@@ -120,6 +120,16 @@ namespace GHelper.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icons8_matrix_desktop_48 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icons8-matrix-desktop-48", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
||||
@@ -133,6 +133,9 @@
|
||||
<data name="icons8-speed-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-speed-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="everything-is-fine-itsfine" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\everything-is-fine-itsfine.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-speed-96" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-speed-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
@@ -148,7 +151,7 @@
|
||||
<data name="icons8-laptop-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-laptop-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="everything-is-fine-itsfine" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\everything-is-fine-itsfine.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="icons8-matrix-desktop-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-matrix-desktop-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
38
README.md
38
README.md
@@ -1,24 +1,31 @@
|
||||
# G-Helper (For G14, G15, ROG FLOW, and others)
|
||||
# G-Helper (For Asus ROG Zephyrus G14, G15, Flow X13, Flow X16, and others)
|
||||
|
||||
A small utility that allows you do almost everyting you could do with Armory Crate but without extra bloat and unnecessary services.
|
||||
|
||||
1. Switch between default **Performance modes** - Silent / Balanced / Turbo and apply default fan curves
|
||||
## NEW (and experimental) features
|
||||
|
||||
1. Set Power limits (PPT) for Total (APU + dGPU) and CPU.
|
||||
2. Anime matrix control thanks to https://github.com/vddCore/Starlight
|
||||
|
||||
## Main features
|
||||
|
||||
1. Switch between built-in system **Performance modes** Silent / Balanced / Turbo and apply default fan curves
|
||||
2. Switch between Eco / Standard or Ultimate **GPU modes**
|
||||
3. Change laptop screen refresh rate - 60hz or your maximum (120hz, 144hz, etc depending on the model) with display overdrive (OD)
|
||||
4. View default fan profiles for every mode and apply custom ones
|
||||
4. View default fan profiles for every mode and **auto apply** custom ones
|
||||
5. Control keyboard backlit animation and colors
|
||||
6. Set battery charge limit to preserve battery
|
||||
6. Set battery charge limit to preserve battery health
|
||||
7. Monitor CPU temperature, fan speeds and battery discharge rate
|
||||
8. **Automatically switch to Eco(iGPU)/60hz on battery** and back to Standard(GPU)/120hz modes when plugged
|
||||
9. Support for M4 key / FN+F5 to cycle through performance modes (with OSD notification) and FN+F4 to cycle through keeyboard animation modes
|
||||
10. Basic keybindings for M3 amd M4 keys
|
||||
9. Support for FN+F5 to cycle through performance modes (with OSD notification) and FN+F4 to cycle through keeyboard animation modes
|
||||
10. Basic keybindings for M3 and M4 keys
|
||||
11. Turn cpu turbo boost on/off with one checkbox to keep temps cooler
|
||||
|
||||
Designed and developer for Asus Zephyrus G14 2022 (with AMD Radeon iGPU and dGPU). But could and should potentially work for G14 of 2021 and 2020, G15, X FLOW, and other ROG models for relevant and supported features.
|
||||
Designed and developed for Asus Zephyrus G14 2022 (with AMD Radeon iGPU and dGPU). But could and should potentially work for G14 of 2021 and 2020, G15, X FLOW, and other ROG models for relevant and supported features.
|
||||
|
||||
To keep autoswitching and hotkeys work app needs to stay in running in tray. It doesn't consume any resources.
|
||||
|
||||
I also recommend to keep "Asus Optimization Service" running , as it keeps basic laptop hotkeys such as screen or keyboard brightness adjustment working. If you have (or had) MyASUS app installed, that service is most probably still up an running even after MyASUS uninstall.
|
||||
I recommend to keep "Asus Optimization Service" running, as it keeps basic laptop hotkeys such as screen or keyboard brightness adjustment working. If you have (or had) MyASUS app installed, that service is most probably still up an running even after MyASUS uninstall. It's part of [Asus System Controll Interface](https://www.asus.com/support/FAQ/1047338/). You can install it, and later disable / remove unnecesarily services by running [this bat file](https://raw.githubusercontent.com/seerge/g-helper/main/stop-asus-sv.bat ) as admin.
|
||||
|
||||
### [Download latest release](https://github.com/seerge/g-helper/releases)
|
||||
|
||||
@@ -26,7 +33,7 @@ I also recommend to keep "Asus Optimization Service" running , as it keeps basic
|
||||
|
||||
## Performance Profile switching
|
||||
|
||||
Profiles are **same** as in Armory Crate, including default fan curves
|
||||
Profiles are **same** as in Armory Crate (as they are stored in bios), including default fan curves
|
||||
|
||||
1. Silent (minimal or no fans, 70W PPT total, up to 45W PPT to CPU)
|
||||
2. Balanced (balanced fans, 100W PPT total, up to 45W PPT to CPU)
|
||||
@@ -40,26 +47,19 @@ PPTs are shown for G14 2022, for other models PPTs will be different as they are
|
||||
2. Standard mode (Windows Hybrid) : iGPU and dGPU enabled, iGPU drives built in display
|
||||
3. Ultimate mode: iGPU and dGPU enabled, but dGPU drives built in display (supported only on G14 2022 model)
|
||||
|
||||
## Things still missing
|
||||
|
||||
1. Anime matrix control
|
||||
|
||||
## How to install
|
||||
|
||||
1. Download latest release from https://github.com/seerge/g-helper/releases
|
||||
2. Unzip to a folder of your choice
|
||||
3. Run **GHelper.exe**
|
||||
|
||||
Note: Uses low level ASUS ACPI commands to do switching and doens't require Armory Crate to be isntalled at all.
|
||||
Doesn't require administrator privileges to run (anymore)!
|
||||
Note: Uses low level ASUS ACPI commands and doens't require Armory Crate to be installed at all! Doesn't need administrator privileges to run!
|
||||
|
||||
I don`t have Microsoft certificate to sign app yet, so if you set a warning from Windows Defender on launch (Windows Protected your PC), click More Info -> Run anyway.
|
||||
I don`t have Microsoft certificate to sign app yet, so if you get a warning from Windows Defender on launch (Windows Protected your PC), click More Info -> Run anyway. Alternatively you can compile and run project by yourself using Visual Studio :)
|
||||
|
||||
Alternatively you can comile and run project by yourself :)
|
||||
Settings file is storer at %AppData%\GHelper
|
||||
Settings file is stored at %AppData%\GHelper
|
||||
|
||||
P.S.: It's not recommended to use app in combination with Armory Crate, cause they adjust same settings.
|
||||
Please keep in mind, that if you also run MyASUS app periodically it will also try to adjust same battery charge settings
|
||||
|
||||
------------------
|
||||
|
||||
|
||||
BIN
Resources/icons8-matrix-desktop-48.png
Normal file
BIN
Resources/icons8-matrix-desktop-48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 428 B |
1066
Settings.Designer.cs
generated
1066
Settings.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
340
Settings.cs
340
Settings.cs
@@ -1,7 +1,8 @@
|
||||
using System.Diagnostics;
|
||||
using Starlight.AnimeMatrix;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Reflection;
|
||||
using System.Timers;
|
||||
using System.Windows.Forms.DataVisualization.Charting;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
@@ -17,12 +18,17 @@ namespace GHelper
|
||||
static int buttonActive = 5;
|
||||
|
||||
static System.Timers.Timer aTimer = default!;
|
||||
static System.Timers.Timer matrixTimer = default!;
|
||||
|
||||
public string perfName = "Balanced";
|
||||
|
||||
Fans fans;
|
||||
Keyboard keyb;
|
||||
|
||||
static AnimeMatrixDevice mat;
|
||||
static bool matEnabled = false;
|
||||
|
||||
|
||||
public SettingsForm()
|
||||
{
|
||||
|
||||
@@ -61,7 +67,6 @@ namespace GHelper
|
||||
|
||||
comboKeyboard.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboKeyboard.SelectedIndex = 0;
|
||||
|
||||
comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged;
|
||||
|
||||
buttonKeyboardColor.Click += ButtonKeyboardColor_Click;
|
||||
@@ -75,12 +80,190 @@ namespace GHelper
|
||||
labelVersion.Text = "Version " + Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
labelVersion.Click += LabelVersion_Click;
|
||||
|
||||
labelCPUFan.Click += LabelCPUFan_Click;
|
||||
labelGPUFan.Click += LabelCPUFan_Click;
|
||||
|
||||
comboMatrix.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboMatrixRunning.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
|
||||
comboMatrix.DropDownClosed += ComboMatrix_SelectedValueChanged;
|
||||
comboMatrixRunning.DropDownClosed += ComboMatrixRunning_SelectedValueChanged;
|
||||
|
||||
checkMatrix.CheckedChanged += CheckMatrix_CheckedChanged; ;
|
||||
|
||||
buttonMatrix.Click += ButtonMatrix_Click;
|
||||
|
||||
SetTimer();
|
||||
|
||||
}
|
||||
|
||||
private void CheckMatrix_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null) return;
|
||||
CheckBox check = (CheckBox)sender;
|
||||
Program.config.setConfig("matrix_auto", check.Checked ? 1 : 0);
|
||||
}
|
||||
|
||||
private static void StartMatrixTimer()
|
||||
{
|
||||
matrixTimer.Enabled = true;
|
||||
}
|
||||
|
||||
private static void StopMatrixTimer()
|
||||
{
|
||||
matrixTimer.Enabled = false;
|
||||
}
|
||||
|
||||
private static void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (mat is null) return;
|
||||
mat.PresentNextFrame();
|
||||
}
|
||||
|
||||
void SetMatrixPicture(string fileName)
|
||||
{
|
||||
|
||||
if (mat is null) return;
|
||||
|
||||
StopMatrixTimer();
|
||||
|
||||
Image image;
|
||||
|
||||
try
|
||||
{
|
||||
using (var fs = new FileStream(fileName, FileMode.Open))
|
||||
{
|
||||
var ms = new MemoryStream();
|
||||
fs.CopyTo(ms);
|
||||
ms.Position = 0;
|
||||
image = Image.FromStream(ms);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Error loading picture");
|
||||
return;
|
||||
}
|
||||
|
||||
mat.SetBuiltInAnimation(false);
|
||||
mat.ClearFrames();
|
||||
|
||||
FrameDimension dimension = new FrameDimension(image.FrameDimensionsList[0]);
|
||||
int frameCount = image.GetFrameCount(dimension);
|
||||
|
||||
if (frameCount > 1)
|
||||
{
|
||||
for (int i = 0; i < frameCount; i++)
|
||||
{
|
||||
image.SelectActiveFrame(dimension, i);
|
||||
mat.GenerateFrame(image);
|
||||
mat.AddFrame();
|
||||
}
|
||||
|
||||
StartMatrixTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.GenerateFrame(image);
|
||||
mat.Present();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ButtonMatrix_Click(object? sender, EventArgs e)
|
||||
{
|
||||
string fileName = "";
|
||||
|
||||
Thread t = new Thread((ThreadStart)(() =>
|
||||
{
|
||||
OpenFileDialog of = new OpenFileDialog();
|
||||
of.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png,*.gif)|*.BMP;*.JPG;*.JPEG;*.PNG;*.GIF";
|
||||
if (of.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = of.FileName;
|
||||
}
|
||||
return;
|
||||
}));
|
||||
|
||||
t.SetApartmentState(ApartmentState.STA);
|
||||
t.Start();
|
||||
t.Join();
|
||||
|
||||
Program.config.setConfig("matrix_picture", fileName);
|
||||
SetMatrixPicture(fileName);
|
||||
BeginInvoke(delegate
|
||||
{
|
||||
comboMatrixRunning.SelectedIndex = 2;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("matrix_running", comboMatrixRunning.SelectedIndex);
|
||||
SetMatrix();
|
||||
}
|
||||
|
||||
|
||||
private void ComboMatrix_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("matrix_brightness", comboMatrix.SelectedIndex);
|
||||
SetMatrix();
|
||||
}
|
||||
|
||||
public void SetMatrix(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||
{
|
||||
|
||||
if (mat is null) return;
|
||||
|
||||
int brightness = Program.config.getConfig("matrix_brightness");
|
||||
int running = Program.config.getConfig("matrix_running");
|
||||
bool auto = Program.config.getConfig("matrix_auto") == 1;
|
||||
|
||||
if (brightness < 0) brightness = 0;
|
||||
if (running < 0) running = 0;
|
||||
|
||||
BuiltInAnimation animation = new BuiltInAnimation(
|
||||
(BuiltInAnimation.Running)running,
|
||||
BuiltInAnimation.Sleeping.Starfield,
|
||||
BuiltInAnimation.Shutdown.SeeYa,
|
||||
BuiltInAnimation.Startup.StaticEmergence
|
||||
);
|
||||
|
||||
StopMatrixTimer();
|
||||
|
||||
if (brightness == 0 || (auto && Plugged != PowerLineStatus.Online))
|
||||
{
|
||||
mat.SetDisplayState(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.SetDisplayState(true);
|
||||
mat.SetBrightness((BrightnessMode)brightness);
|
||||
|
||||
if (running == 2)
|
||||
{
|
||||
string fileName = Program.config.getConfigString("matrix_picture");
|
||||
SetMatrixPicture(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.SetBuiltInAnimation(true, animation);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void LabelCPUFan_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1);
|
||||
RefreshSensors();
|
||||
}
|
||||
|
||||
private void LabelVersion_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo("http://github.com/seerge/g-helper/releases") { UseShellExecute = true });
|
||||
@@ -122,13 +305,19 @@ namespace GHelper
|
||||
if (fans == null || fans.Text == "")
|
||||
{
|
||||
fans = new Fans();
|
||||
fans.Show();
|
||||
Debug.WriteLine("Starting fans");
|
||||
}
|
||||
|
||||
if (fans.Visible)
|
||||
{
|
||||
fans.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
fans.Close();
|
||||
fans.Show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void ButtonKeyboardColor_Click(object? sender, EventArgs e)
|
||||
@@ -173,10 +362,45 @@ namespace GHelper
|
||||
SetAuraMode(mode, false);
|
||||
|
||||
Aura.Mode = mode;
|
||||
}
|
||||
|
||||
public void InitMatrix()
|
||||
{
|
||||
|
||||
matrixTimer = new System.Timers.Timer();
|
||||
matrixTimer.Enabled = false;
|
||||
matrixTimer.Interval = 100;
|
||||
|
||||
try
|
||||
{
|
||||
matEnabled = true;
|
||||
mat = new AnimeMatrixDevice();
|
||||
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
||||
}
|
||||
catch
|
||||
{
|
||||
matEnabled = false;
|
||||
Debug.WriteLine("Anime Matrix not detected");
|
||||
}
|
||||
|
||||
if (!matEnabled)
|
||||
{
|
||||
panelMatrix.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int brightness = Program.config.getConfig("matrix_brightness");
|
||||
int running = Program.config.getConfig("matrix_running");
|
||||
|
||||
comboMatrix.SelectedIndex = (brightness != -1) ? brightness : 0;
|
||||
comboMatrixRunning.SelectedIndex = (running != -1) ? running : 0;
|
||||
|
||||
checkMatrix.Checked = (Program.config.getConfig("matrix_auto") == 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void SetAuraColor(Color? color1 = null, Color? color2 = null, bool apply = true)
|
||||
{
|
||||
|
||||
@@ -205,14 +429,14 @@ namespace GHelper
|
||||
|
||||
//Debug.WriteLine(mode);
|
||||
|
||||
if (mode > 3) mode = 0;
|
||||
if (mode > 4) mode = 0;
|
||||
|
||||
pictureColor2.Visible = (mode == Aura.Breathe);
|
||||
|
||||
if (Aura.Mode == mode) return; // same mode
|
||||
|
||||
|
||||
Aura.Mode = mode;
|
||||
|
||||
Program.config.setConfig("aura_mode", mode);
|
||||
|
||||
comboKeyboard.SelectedValueChanged -= ComboKeyboard_SelectedValueChanged;
|
||||
@@ -397,10 +621,20 @@ namespace GHelper
|
||||
aTimer.Enabled = false;
|
||||
}
|
||||
|
||||
|
||||
private static string FormatFan(int fan)
|
||||
{
|
||||
if (Program.config.getConfig("fan_rpm") == 1)
|
||||
return " Fan: " + (fan * 100).ToString() + "RPM";
|
||||
else
|
||||
return " Fan: " + Math.Min(Math.Round(fan / 0.6), 100).ToString() + "%"; // relatively to 6000 rpm
|
||||
}
|
||||
|
||||
private static void RefreshSensors()
|
||||
{
|
||||
string cpuFan = " Fan: " + Math.Round(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan) / 0.6).ToString() + "%";
|
||||
string gpuFan = " Fan: " + Math.Round(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan) / 0.6).ToString() + "%";
|
||||
|
||||
string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
|
||||
string gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan));
|
||||
|
||||
string cpuTemp = "";
|
||||
string gpuTemp = "";
|
||||
@@ -438,7 +672,7 @@ namespace GHelper
|
||||
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
|
||||
this.Activate();
|
||||
|
||||
aTimer.Interval = 500;
|
||||
aTimer.Interval = 300;
|
||||
aTimer.Enabled = true;
|
||||
|
||||
}
|
||||
@@ -472,21 +706,25 @@ namespace GHelper
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
int oldMode = Program.config.getConfig("performance_mode");
|
||||
Program.config.setConfig("performance_" + (int)SystemInformation.PowerStatus.PowerLineStatus, PerformanceMode);
|
||||
Program.config.setConfig("performance_mode", PerformanceMode);
|
||||
try
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
|
||||
|
||||
if (Program.config.getConfig("auto_apply_" + PerformanceMode) == 1)
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
|
||||
}
|
||||
catch
|
||||
{
|
||||
labelPerf.Text = "Performance Mode: not supported";
|
||||
Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
|
||||
Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));
|
||||
}
|
||||
|
||||
if (fans != null && fans.Text != "")
|
||||
{
|
||||
fans.LoadFans();
|
||||
fans.ResetApplyLabel();
|
||||
}
|
||||
|
||||
if (notify)
|
||||
if (notify && (oldMode != PerformanceMode))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -506,12 +744,22 @@ namespace GHelper
|
||||
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, true);
|
||||
}
|
||||
|
||||
public void AutoScreen(int Plugged = 1)
|
||||
public void AutoPerformance(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||
{
|
||||
int mode = Program.config.getConfig("performance_" + (int)Plugged);
|
||||
if (mode != -1)
|
||||
SetPerformanceMode(mode, true);
|
||||
else
|
||||
SetPerformanceMode(Program.config.getConfig("performance_mode"));
|
||||
}
|
||||
|
||||
|
||||
public void AutoScreen(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||
{
|
||||
int ScreenAuto = Program.config.getConfig("screen_auto");
|
||||
if (ScreenAuto != 1) return;
|
||||
|
||||
if (Plugged == 1)
|
||||
if (Plugged == PowerLineStatus.Online)
|
||||
SetScreen(1000, 1);
|
||||
else
|
||||
SetScreen(60, 0);
|
||||
@@ -520,7 +768,7 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
public void AutoGPUMode(int Plugged = 1)
|
||||
public void AutoGPUMode(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||
{
|
||||
|
||||
int GpuAuto = Program.config.getConfig("gpu_auto");
|
||||
@@ -534,12 +782,12 @@ namespace GHelper
|
||||
return;
|
||||
else
|
||||
{
|
||||
if (eco == 1 && Plugged == 1) // Eco going Standard on plugged
|
||||
if (eco == 1 && Plugged == PowerLineStatus.Online) // Eco going Standard on plugged
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 0);
|
||||
InitGPUMode();
|
||||
}
|
||||
else if (eco == 0 && Plugged == 0) // Standard going Eco on plugged
|
||||
else if (eco == 0 && Plugged != PowerLineStatus.Online) // Standard going Eco on plugged
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 1);
|
||||
InitGPUMode();
|
||||
@@ -643,9 +891,14 @@ namespace GHelper
|
||||
checkScreen.Checked = (ScreenAuto == 1);
|
||||
}
|
||||
|
||||
public void VisualiseGPUMode(int GPUMode)
|
||||
public void VisualiseGPUMode(int GPUMode = -1)
|
||||
{
|
||||
|
||||
if (GPUMode == -1)
|
||||
{
|
||||
GPUMode = Program.config.getConfig("gpu_mode");
|
||||
}
|
||||
|
||||
buttonEco.FlatAppearance.BorderSize = buttonInactive;
|
||||
buttonStandard.FlatAppearance.BorderSize = buttonInactive;
|
||||
buttonUltimate.FlatAppearance.BorderSize = buttonInactive;
|
||||
@@ -717,55 +970,36 @@ namespace GHelper
|
||||
public void SetBatteryChargeLimit(int limit = 100)
|
||||
{
|
||||
|
||||
if (limit < 50 || limit > 100) limit = 100;
|
||||
if (limit < 40 || limit > 100) return;
|
||||
|
||||
labelBatteryTitle.Text = "Battery Charge Limit: " + limit.ToString() + "%";
|
||||
trackBattery.Value = limit;
|
||||
try
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Can't set battery charge limit");
|
||||
}
|
||||
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit);
|
||||
|
||||
Program.config.setConfig("charge_limit", limit);
|
||||
|
||||
}
|
||||
|
||||
private void trackBatteryChange(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null)
|
||||
return;
|
||||
|
||||
if (sender is null) return;
|
||||
TrackBar bar = (TrackBar)sender;
|
||||
SetBatteryChargeLimit(bar.Value);
|
||||
}
|
||||
|
||||
private void checkGPU_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null)
|
||||
return;
|
||||
|
||||
CheckBox chk = (CheckBox)sender;
|
||||
if (chk.Checked)
|
||||
Program.config.setConfig("gpu_auto", 1);
|
||||
else
|
||||
Program.config.setConfig("gpu_auto", 0);
|
||||
if (sender is null) return;
|
||||
CheckBox check = (CheckBox)sender;
|
||||
Program.config.setConfig("gpu_auto", check.Checked ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
private void checkScreen_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (sender is null)
|
||||
return;
|
||||
|
||||
CheckBox chk = (CheckBox)sender;
|
||||
if (chk.Checked)
|
||||
Program.config.setConfig("screen_auto", 1);
|
||||
else
|
||||
Program.config.setConfig("screen_auto", 0);
|
||||
if (sender is null) return;
|
||||
CheckBox check = (CheckBox)sender;
|
||||
Program.config.setConfig("screen_auto", check.Checked ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -69,19 +69,6 @@
|
||||
vtSpbWIlX5XHkK/OOiq2RE5+H2ZRgx1v4RpMqBhHG5XElccIHie4EPW9o82fP8yx11SyLuxDm9L38yy8
|
||||
gDa8UP+WK+UiLIIXaiZQiduQtYsv9Qme53kn5bWujY3NGqzFtin+5YMgCIIgCP4PVfUNWXMTLz5Z0sYA
|
||||
AAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="pictureGPU.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
|
||||
DAAACwwBP0AiyAAAAZVJREFUaEPtmTtOxDAURYcGGtgAsCJo6PisACE2ALTAvvgVsB0KQBRwT2HJGl3y
|
||||
EtloHPCRjiKNfJ/sOLGV8aLT6XSa4Fa+ya/MD3kjm2dNvsq888l3OQu408szkJwlfQCr5k8NoAVZEV/k
|
||||
vhyFK9KKBzLEBVvxWYa4YCuO2ptcsCVDXKim9/JQbst1uSOP5IN07ZcNcaEafspTOcSZpJ3LJ0NcCC8k
|
||||
d8zB75fS5ZJR5xMMwuWTIS6Em3KILelyeCen8ChdHQxxIeQOD83AlXQ55JmfwrF0dTDEhUrlhZ0CL7ar
|
||||
gyEuVOpPM/cTG9LVwRAXKnXqDOxKVwdDXAhLViHW+SmcSFcHQ1wIS1YhNqmx8Jn7JF0dDHEhLFmFkPV9
|
||||
DOfS5ZMhLlRDdthoEHT+13biWrJJsc7zojJzXHnmhx6b3BAXaskQF2rF2X8PzP6LbE+GuOAq5V8J7vyo
|
||||
zkMeniX/ZgB5u5oWM7ZY3q6mxYwtxsuVt61hlTOJdFbAdQjOFWoOglrXshg6xqnNLI6YOp1OZ1UsFt/W
|
||||
cWCm8IATjAAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="picturePerf.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
@@ -103,6 +90,19 @@
|
||||
nbLijqltby+mGSx+Qlk5AtuQ6LdryGR4dcrQliFkF7w6h1E6emm9fZEe+QpopVTDtrysQ1BbzfZJ2v+0
|
||||
/N10MWyDnbYUbUVfjr2GO+Eo2o5+I5f5EFWVyj4tKvrQehneibqDZqJ+qDR6EnrhcjZlrVLbOofOVadO
|
||||
nTr/fBqNP4sju3bXhjy/AAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="pictureGPU.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
|
||||
DAAACwwBP0AiyAAAAZVJREFUaEPtmTtOxDAURYcGGtgAsCJo6PisACE2ALTAvvgVsB0KQBRwT2HJGl3y
|
||||
EtloHPCRjiKNfJ/sOLGV8aLT6XSa4Fa+ya/MD3kjm2dNvsq888l3OQu408szkJwlfQCr5k8NoAVZEV/k
|
||||
vhyFK9KKBzLEBVvxWYa4YCuO2ptcsCVDXKim9/JQbst1uSOP5IN07ZcNcaEafspTOcSZpJ3LJ0NcCC8k
|
||||
d8zB75fS5ZJR5xMMwuWTIS6Em3KILelyeCen8ChdHQxxIeQOD83AlXQ55JmfwrF0dTDEhUrlhZ0CL7ar
|
||||
gyEuVOpPM/cTG9LVwRAXKnXqDOxKVwdDXAhLViHW+SmcSFcHQ1wIS1YhNqmx8Jn7JF0dDHEhLFmFkPV9
|
||||
DOfS5ZMhLlRDdthoEHT+13biWrJJsc7zojJzXHnmhx6b3BAXaskQF2rF2X8PzP6LbE+GuOAq5V8J7vyo
|
||||
zkMeniX/ZgB5u5oWM7ZY3q6mxYwtxsuVt61hlTOJdFbAdQjOFWoOglrXshg6xqnNLI6YOp1OZ1UsFt/W
|
||||
cWCm8IATjAAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="pictureScreen.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
|
||||
11
Startup.cs
11
Startup.cs
@@ -10,17 +10,6 @@ public class Startup
|
||||
public static bool IsScheduled()
|
||||
{
|
||||
TaskService taskService = new TaskService();
|
||||
|
||||
// cleanup of OLD autorun
|
||||
try
|
||||
{
|
||||
taskService.RootFolder.DeleteTask("GSharpHelper");
|
||||
} catch
|
||||
{
|
||||
Debug.WriteLine("Not running as admin");
|
||||
}
|
||||
|
||||
|
||||
return (taskService.RootFolder.AllTasks.Any(t => t.Name == taskName));
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
<windowsSettings>
|
||||
<!--<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitor/dpiAwareness>-->
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor, System</dpiAwareness>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
|
||||
|
||||
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
15
stop-asus-sv.bat
Normal file
15
stop-asus-sv.bat
Normal file
@@ -0,0 +1,15 @@
|
||||
sc STOP AsusAppService
|
||||
sc STOP ASUSLinkNear
|
||||
sc STOP ASUSLinkRemote
|
||||
sc STOP ASUSSoftwareManager
|
||||
sc STOP ASUSSwitch
|
||||
sc STOP ASUSSystemAnalysis
|
||||
sc STOP ASUSSystemDiagnosis
|
||||
|
||||
sc DELETE AsusAppService
|
||||
sc DELETE ASUSLinkNear
|
||||
sc DELETE ASUSLinkRemote
|
||||
sc DELETE ASUSSoftwareManager
|
||||
sc DELETE ASUSSwitch
|
||||
sc DELETE ASUSSystemAnalysis
|
||||
sc DELETE ASUSSystemDiagnosis
|
||||
Reference in New Issue
Block a user