mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
3 Commits
v0.133
...
hidsharp-m
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
435ddbb951 | ||
|
|
96ade7c9a0 | ||
|
|
3249072ee5 |
@@ -355,7 +355,7 @@ public static class AppConfig
|
|||||||
|
|
||||||
public static bool IsStrixLimitedRGB()
|
public static bool IsStrixLimitedRGB()
|
||||||
{
|
{
|
||||||
return ContainsModel("G614JV") || ContainsModel("G614JZ") || ContainsModel("G512LI") || ContainsModel("G513RS") || ContainsModel("G513RM");
|
return ContainsModel("G614JV") || ContainsModel("G614JZ") || ContainsModel("G512LI") || ContainsModel("G513RS");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsZ13()
|
public static bool IsZ13()
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<AssemblyVersion>0.133</AssemblyVersion>
|
<AssemblyVersion>0.131</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace GHelper.Gpu
|
|||||||
AppConfig.Set("gpu_mode", gpuMode);
|
AppConfig.Set("gpu_mode", gpuMode);
|
||||||
settings.VisualiseGPUMode(gpuMode);
|
settings.VisualiseGPUMode(gpuMode);
|
||||||
|
|
||||||
Aura.CustomRGB.ApplyGPUColor();
|
Aura.ApplyGPUColor();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using System.Runtime.CompilerServices;
|
namespace GHelper.Helpers
|
||||||
|
|
||||||
namespace GHelper.Helpers
|
|
||||||
{
|
{
|
||||||
public class ColorUtils
|
public class ColorUtilities
|
||||||
{
|
{
|
||||||
// Method to get the weighted average between two colors
|
// Method to get the weighted average between two colors
|
||||||
public static Color GetWeightedAverage(Color color1, Color color2, float weight)
|
public static Color GetWeightedAverage(Color color1, Color color2, float weight)
|
||||||
@@ -18,144 +16,6 @@ namespace GHelper.Helpers
|
|||||||
|
|
||||||
return Color.FromArgb(red, green, blue);
|
return Color.FromArgb(red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Color GetMidColor(Color color1, Color color2)
|
|
||||||
{
|
|
||||||
return Color.FromArgb((color1.R + color2.R) / 2,
|
|
||||||
(color1.G + color2.G) / 2,
|
|
||||||
(color1.B + color2.B) / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class HSV
|
|
||||||
{
|
|
||||||
public double Hue { get; set; }
|
|
||||||
public double Saturation { get; set; }
|
|
||||||
public double Value { get; set; }
|
|
||||||
|
|
||||||
public Color ToRGB()
|
|
||||||
{
|
|
||||||
var hue = Hue * 6;
|
|
||||||
var saturation = Saturation;
|
|
||||||
var value = Value;
|
|
||||||
|
|
||||||
double red;
|
|
||||||
double green;
|
|
||||||
double blue;
|
|
||||||
|
|
||||||
if (saturation == 0)
|
|
||||||
{
|
|
||||||
red = green = blue = value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var i = Convert.ToInt32(Math.Floor(hue));
|
|
||||||
var f = hue - i;
|
|
||||||
var p = value * (1 - saturation);
|
|
||||||
var q = value * (1 - saturation * f);
|
|
||||||
var t = value * (1 - saturation * (1 - f));
|
|
||||||
int mod = i % 6;
|
|
||||||
|
|
||||||
red = new[] { value, q, p, p, t, value }[mod];
|
|
||||||
green = new[] { t, value, value, q, p, p }[mod];
|
|
||||||
blue = new[] { p, p, t, value, value, q }[mod];
|
|
||||||
}
|
|
||||||
|
|
||||||
return Color.FromArgb(Convert.ToInt32(red * 255), Convert.ToInt32(green * 255), Convert.ToInt32(blue * 255));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HSV ToHSV(Color rgb)
|
|
||||||
{
|
|
||||||
double red = rgb.R / 255.0;
|
|
||||||
double green = rgb.G / 255.0;
|
|
||||||
double blue = rgb.B / 255.0;
|
|
||||||
var min = Math.Min(red, Math.Min(green, blue));
|
|
||||||
var max = Math.Max(red, Math.Max(green, blue));
|
|
||||||
var delta = max - min;
|
|
||||||
double hue;
|
|
||||||
double saturation = 0;
|
|
||||||
var value = max;
|
|
||||||
|
|
||||||
if (max != 0)
|
|
||||||
saturation = delta / max;
|
|
||||||
|
|
||||||
if (delta == 0)
|
|
||||||
hue = 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (red == max)
|
|
||||||
hue = (green - blue) / delta + (green < blue ? 6 : 0);
|
|
||||||
else if (green == max)
|
|
||||||
hue = 2 + (blue - red) / delta;
|
|
||||||
else
|
|
||||||
hue = 4 + (red - green) / delta;
|
|
||||||
|
|
||||||
hue /= 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new HSV { Hue = hue, Saturation = saturation, Value = value };
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Color UpSaturation(Color rgb, float increse = 0.2f) //make color more colored
|
|
||||||
{
|
|
||||||
if (rgb.R == rgb.G && rgb.G == rgb.B)
|
|
||||||
return rgb;
|
|
||||||
var hsv_color = ToHSV(rgb);
|
|
||||||
hsv_color.Saturation = Math.Min(hsv_color.Saturation + increse, 1.00f);
|
|
||||||
return hsv_color.ToRGB();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SmoothColor
|
|
||||||
{
|
|
||||||
public Color RGB
|
|
||||||
{
|
|
||||||
get { return Interpolate(); }
|
|
||||||
set { clr = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
Color Interpolate()
|
|
||||||
{
|
|
||||||
clr_ = ColorInterpolator.InterpolateBetween(clr, clr_, smooth);
|
|
||||||
return clr_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private float smooth = 0.65f; //smooth
|
|
||||||
private Color clr = new Color();
|
|
||||||
private Color clr_ = new Color();
|
|
||||||
|
|
||||||
static class ColorInterpolator
|
|
||||||
{
|
|
||||||
delegate byte ComponentSelector(Color color);
|
|
||||||
static ComponentSelector _redSelector = color => color.R;
|
|
||||||
static ComponentSelector _greenSelector = color => color.G;
|
|
||||||
static ComponentSelector _blueSelector = color => color.B;
|
|
||||||
|
|
||||||
public static Color InterpolateBetween(Color endPoint1, Color endPoint2, double lambda)
|
|
||||||
{
|
|
||||||
if (lambda < 0 || lambda > 1)
|
|
||||||
throw new ArgumentOutOfRangeException("lambda");
|
|
||||||
|
|
||||||
if (endPoint1 != endPoint2)
|
|
||||||
{
|
|
||||||
return Color.FromArgb(
|
|
||||||
InterpolateComponent(endPoint1, endPoint2, lambda, _redSelector),
|
|
||||||
InterpolateComponent(endPoint1, endPoint2, lambda, _greenSelector),
|
|
||||||
InterpolateComponent(endPoint1, endPoint2, lambda, _blueSelector)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return endPoint1;
|
|
||||||
}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
static byte InterpolateComponent(Color end1, Color end2, double lambda, ComponentSelector selector)
|
|
||||||
{
|
|
||||||
return (byte)(selector(end1) + (selector(end2) - selector(end1)) * lambda);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -84,9 +84,6 @@ namespace GHelper.Input
|
|||||||
Logger.WriteLine("Optimization service is running");
|
Logger.WriteLine("Optimization service is running");
|
||||||
|
|
||||||
InitBacklightTimer();
|
InitBacklightTimer();
|
||||||
|
|
||||||
if (AppConfig.ContainsModel("VivoBook")) Program.acpi.DeviceSet(AsusACPI.FnLock, AppConfig.Is("fn_lock") ? 1 : 0, "FnLock");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitBacklightTimer()
|
public void InitBacklightTimer()
|
||||||
@@ -194,7 +191,7 @@ namespace GHelper.Input
|
|||||||
KeyboardHook.KeyKeyPress((Keys)hexKeys[0], (Keys)hexKeys[1]);
|
KeyboardHook.KeyKeyPress((Keys)hexKeys[0], (Keys)hexKeys[1]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
KeyboardHook.KeyKeyKeyPress((Keys)hexKeys[0], (Keys)hexKeys[1], (Keys)hexKeys[2]);
|
KeyboardHook.KeyKeyKeyPress((Keys)hexKeys[0], (Keys)hexKeys[1], (Keys)hexKeys[3]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LaunchProcess(command);
|
LaunchProcess(command);
|
||||||
@@ -311,6 +308,9 @@ namespace GHelper.Input
|
|||||||
case Keys.F11:
|
case Keys.F11:
|
||||||
SleepEvent();
|
SleepEvent();
|
||||||
break;
|
break;
|
||||||
|
case Keys.F12:
|
||||||
|
KeyboardHook.KeyKeyPress(Keys.LWin, Keys.A);
|
||||||
|
break;
|
||||||
case Keys.VolumeDown:
|
case Keys.VolumeDown:
|
||||||
KeyProcess("m1");
|
KeyProcess("m1");
|
||||||
break;
|
break;
|
||||||
@@ -509,7 +509,7 @@ namespace GHelper.Input
|
|||||||
AppConfig.Set("fn_lock", fnLock);
|
AppConfig.Set("fn_lock", fnLock);
|
||||||
|
|
||||||
if (AppConfig.ContainsModel("VivoBook"))
|
if (AppConfig.ContainsModel("VivoBook"))
|
||||||
Program.acpi.DeviceSet(AsusACPI.FnLock, fnLock == 1 ? 1 : 0, "FnLock");
|
Program.acpi.DeviceSet(AsusACPI.FnLock, fnLock == 1 ? 0 : 1, "FnLock");
|
||||||
else
|
else
|
||||||
Program.settingsForm.BeginInvoke(Program.inputDispatcher.RegisterKeys);
|
Program.settingsForm.BeginInvoke(Program.inputDispatcher.RegisterKeys);
|
||||||
|
|
||||||
|
|||||||
@@ -40,13 +40,10 @@ public sealed class KeyboardHook : IDisposable
|
|||||||
keybd_event((byte)key2, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
|
keybd_event((byte)key2, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
|
||||||
keybd_event((byte)key3, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
|
keybd_event((byte)key3, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
|
||||||
|
|
||||||
if (sleep > 0)
|
|
||||||
{
|
|
||||||
Thread.Sleep(sleep);
|
|
||||||
}
|
|
||||||
|
|
||||||
keybd_event((byte)key3, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
|
keybd_event((byte)key3, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
|
||||||
|
if (sleep > 0) Thread.Sleep(sleep);
|
||||||
keybd_event((byte)key2, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
|
keybd_event((byte)key2, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
|
||||||
|
if (sleep > 0) Thread.Sleep(sleep);
|
||||||
keybd_event((byte)key, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
|
keybd_event((byte)key, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ namespace GHelper.Input
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input.ReadTimeout = int.MaxValue;
|
||||||
|
|
||||||
Logger.WriteLine($"Input: {input.Device.DevicePath}");
|
Logger.WriteLine($"Input: {input.Device.DevicePath}");
|
||||||
|
|
||||||
var task = Task.Run(() =>
|
var task = Task.Run(() =>
|
||||||
@@ -42,7 +44,6 @@ namespace GHelper.Input
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
input.ReadTimeout = int.MaxValue;
|
|
||||||
|
|
||||||
var data = input.Read();
|
var data = input.Read();
|
||||||
if (data.Length > 1 && data[0] == AsusHid.INPUT_ID && data[1] > 0 && data[1] != 236)
|
if (data.Length > 1 && data[0] == AsusHid.INPUT_ID && data[1] > 0 && data[1] != 236)
|
||||||
|
|||||||
@@ -239,7 +239,6 @@ namespace GHelper.Peripherals
|
|||||||
timer.Stop();
|
timer.Stop();
|
||||||
Logger.WriteLine("HID Device Event: Checking for new ASUS Mice");
|
Logger.WriteLine("HID Device Event: Checking for new ASUS Mice");
|
||||||
DetectAllAsusMice();
|
DetectAllAsusMice();
|
||||||
if (AppConfig.IsZ13()) Program.inputDispatcher.Init();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ namespace GHelper
|
|||||||
|
|
||||||
gpuControl.InitXGM();
|
gpuControl.InitXGM();
|
||||||
|
|
||||||
SetAutoModes(init: true);
|
SetAutoModes(init : true);
|
||||||
|
|
||||||
// Subscribing for system power change events
|
// Subscribing for system power change events
|
||||||
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
||||||
|
|||||||
30
app/Properties/Resources.Designer.cs
generated
30
app/Properties/Resources.Designer.cs
generated
@@ -110,36 +110,6 @@ namespace GHelper.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Icon dot_eco {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("dot_eco", resourceCulture);
|
|
||||||
return ((System.Drawing.Icon)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Icon dot_standard {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("dot_standard", resourceCulture);
|
|
||||||
return ((System.Drawing.Icon)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Icon dot_ultimate {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("dot_ultimate", resourceCulture);
|
|
||||||
return ((System.Drawing.Icon)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -292,13 +292,4 @@
|
|||||||
<data name="MFont" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="MFont" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\Font.otf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>..\Resources\Font.otf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="dot_eco" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\dot-eco.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="dot_standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\dot-standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="dot_ultimate" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\dot-ultimate.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
</root>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
@@ -1177,13 +1177,11 @@ namespace GHelper
|
|||||||
buttonOptimized.Activated = GPUAuto;
|
buttonOptimized.Activated = GPUAuto;
|
||||||
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUModeEco;
|
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUModeEco;
|
||||||
Program.trayIcon.Icon = Properties.Resources.eco;
|
Program.trayIcon.Icon = Properties.Resources.eco;
|
||||||
Icon = Properties.Resources.dot_eco;
|
|
||||||
break;
|
break;
|
||||||
case AsusACPI.GPUModeUltimate:
|
case AsusACPI.GPUModeUltimate:
|
||||||
buttonUltimate.Activated = true;
|
buttonUltimate.Activated = true;
|
||||||
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUModeUltimate;
|
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUModeUltimate;
|
||||||
Program.trayIcon.Icon = Properties.Resources.ultimate;
|
Program.trayIcon.Icon = Properties.Resources.ultimate;
|
||||||
Icon = Properties.Resources.dot_ultimate;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
buttonOptimized.BorderColor = colorStandard;
|
buttonOptimized.BorderColor = colorStandard;
|
||||||
@@ -1191,7 +1189,6 @@ namespace GHelper
|
|||||||
buttonOptimized.Activated = GPUAuto;
|
buttonOptimized.Activated = GPUAuto;
|
||||||
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUModeStandard;
|
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUModeStandard;
|
||||||
Program.trayIcon.Icon = Properties.Resources.standard;
|
Program.trayIcon.Icon = Properties.Resources.standard;
|
||||||
Icon = Properties.Resources.dot_standard;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,34 +17,35 @@ public static class AsusHid
|
|||||||
public static HidStream FindHidStream(byte reportId, int minFeatureLength = 1)
|
public static HidStream FindHidStream(byte reportId, int minFeatureLength = 1)
|
||||||
{
|
{
|
||||||
HidDeviceLoader loader = new HidDeviceLoader();
|
HidDeviceLoader loader = new HidDeviceLoader();
|
||||||
try
|
var deviceList = loader.GetDevices(ASUS_ID).Where(device => deviceIds.Contains(device.ProductID));
|
||||||
{
|
|
||||||
var deviceList = loader.GetDevices(ASUS_ID).Where(device => deviceIds.Contains(device.ProductID) && device.CanOpen);
|
foreach (var device in deviceList) if (device.CanOpen)
|
||||||
foreach (var device in deviceList)
|
|
||||||
{
|
{
|
||||||
var config = new OpenConfiguration();
|
try
|
||||||
config.SetOption(OpenOption.Interruptible, false);
|
|
||||||
config.SetOption(OpenOption.Exclusive, false);
|
|
||||||
config.SetOption(OpenOption.Priority, 10);
|
|
||||||
HidStream hidStream = device.Open();
|
|
||||||
|
|
||||||
if (device.GetMaxFeatureReportLength() >= minFeatureLength)
|
|
||||||
{
|
{
|
||||||
var reportDescriptor = device.GetReportDescriptor();
|
var config = new OpenConfiguration();
|
||||||
if (reportDescriptor.TryGetReport(ReportType.Feature, reportId, out _))
|
config.SetOption(OpenOption.Interruptible, false);
|
||||||
{
|
config.SetOption(OpenOption.Exclusive, false);
|
||||||
return hidStream;
|
config.SetOption(OpenOption.Priority, 10);
|
||||||
}
|
HidStream hidStream = device.Open();
|
||||||
}
|
|
||||||
|
|
||||||
hidStream.Close();
|
if (device.GetMaxFeatureReportLength() >= minFeatureLength)
|
||||||
hidStream.Dispose();
|
{
|
||||||
|
var reportDescriptor = device.GetReportDescriptor();
|
||||||
|
if (reportDescriptor.TryGetReport(ReportType.Feature, reportId, out _))
|
||||||
|
{
|
||||||
|
return hidStream;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hidStream.Close();
|
||||||
|
hidStream.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"Error accessing HID device: {ex.Message}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine($"Error accessing HID device: {ex.Message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
379
app/USB/Aura.cs
379
app/USB/Aura.cs
@@ -1,9 +1,5 @@
|
|||||||
using GHelper.Gpu;
|
using GHelper.Gpu;
|
||||||
using GHelper.Helpers;
|
using GHelper.Helpers;
|
||||||
using GHelper.Input;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Drawing.Imaging;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace GHelper.USB
|
namespace GHelper.USB
|
||||||
@@ -51,7 +47,6 @@ namespace GHelper.USB
|
|||||||
Flash = 12,
|
Flash = 12,
|
||||||
HEATMAP = 20,
|
HEATMAP = 20,
|
||||||
GPUMODE = 21,
|
GPUMODE = 21,
|
||||||
AMBIENT = 22,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AuraSpeed : int
|
public enum AuraSpeed : int
|
||||||
@@ -68,8 +63,6 @@ namespace GHelper.USB
|
|||||||
static byte[] MESSAGE_APPLY = { AsusHid.AURA_ID, 0xb4 };
|
static byte[] MESSAGE_APPLY = { AsusHid.AURA_ID, 0xb4 };
|
||||||
static byte[] MESSAGE_SET = { AsusHid.AURA_ID, 0xb5, 0, 0, 0 };
|
static byte[] MESSAGE_SET = { AsusHid.AURA_ID, 0xb5, 0, 0, 0 };
|
||||||
|
|
||||||
static readonly int AURA_ZONES = 0x12;
|
|
||||||
|
|
||||||
private static AuraMode mode = AuraMode.AuraStatic;
|
private static AuraMode mode = AuraMode.AuraStatic;
|
||||||
private static AuraSpeed speed = AuraSpeed.Normal;
|
private static AuraSpeed speed = AuraSpeed.Normal;
|
||||||
|
|
||||||
@@ -100,8 +93,7 @@ namespace GHelper.USB
|
|||||||
{ AuraMode.AuraRainbow, Properties.Strings.AuraRainbow },
|
{ AuraMode.AuraRainbow, Properties.Strings.AuraRainbow },
|
||||||
{ AuraMode.AuraStrobe, Properties.Strings.AuraStrobe },
|
{ AuraMode.AuraStrobe, Properties.Strings.AuraStrobe },
|
||||||
{ AuraMode.HEATMAP, "Heatmap"},
|
{ AuraMode.HEATMAP, "Heatmap"},
|
||||||
{ AuraMode.GPUMODE, "GPU Mode" },
|
{ AuraMode.GPUMODE, "GPU Mode" }
|
||||||
{ AuraMode.AMBIENT, "Ambient"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Dictionary<AuraMode, string> _modesStrix = new Dictionary<AuraMode, string>
|
private static Dictionary<AuraMode, string> _modesStrix = new Dictionary<AuraMode, string>
|
||||||
@@ -119,7 +111,6 @@ namespace GHelper.USB
|
|||||||
{ AuraMode.Comet, "Comet" },
|
{ AuraMode.Comet, "Comet" },
|
||||||
{ AuraMode.Flash, "Flash" },
|
{ AuraMode.Flash, "Flash" },
|
||||||
{ AuraMode.HEATMAP, "Heatmap"},
|
{ AuraMode.HEATMAP, "Heatmap"},
|
||||||
{ AuraMode.AMBIENT, "Ambient"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static Aura()
|
static Aura()
|
||||||
@@ -136,6 +127,27 @@ namespace GHelper.USB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
SetHeatmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetHeatmap(bool init = false)
|
||||||
|
{
|
||||||
|
float cpuTemp = (float)HardwareControl.GetCPUTemp();
|
||||||
|
int freeze = 20, cold = 40, warm = 65, hot = 90;
|
||||||
|
Color color;
|
||||||
|
|
||||||
|
//Debug.WriteLine(cpuTemp);
|
||||||
|
|
||||||
|
if (cpuTemp < cold) color = ColorUtilities.GetWeightedAverage(Color.Blue, Color.Green, ((float)cpuTemp - freeze) / (cold - freeze));
|
||||||
|
else if (cpuTemp < warm) color = ColorUtilities.GetWeightedAverage(Color.Green, Color.Yellow, ((float)cpuTemp - cold) / (warm - cold));
|
||||||
|
else if (cpuTemp < hot) color = ColorUtilities.GetWeightedAverage(Color.Yellow, Color.Red, ((float)cpuTemp - warm) / (hot - warm));
|
||||||
|
else color = Color.Red;
|
||||||
|
|
||||||
|
ApplyColor(color, init);
|
||||||
|
}
|
||||||
|
|
||||||
public static Dictionary<AuraSpeed, string> GetSpeeds()
|
public static Dictionary<AuraSpeed, string> GetSpeeds()
|
||||||
{
|
{
|
||||||
return new Dictionary<AuraSpeed, string>
|
return new Dictionary<AuraSpeed, string>
|
||||||
@@ -206,22 +218,6 @@ namespace GHelper.USB
|
|||||||
return mode == AuraMode.AuraBreathe && !isACPI;
|
return mode == AuraMode.AuraBreathe && !isACPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
|
|
||||||
{
|
|
||||||
if (!InputDispatcher.backlightActivity)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (Mode == AuraMode.HEATMAP)
|
|
||||||
{
|
|
||||||
CustomRGB.ApplyHeatmap();
|
|
||||||
}
|
|
||||||
else if (Mode == AuraMode.AMBIENT)
|
|
||||||
{
|
|
||||||
CustomRGB.ApplyAmbient();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static byte[] AuraMessage(AuraMode mode, Color color, Color color2, int speed, bool mono = false)
|
public static byte[] AuraMessage(AuraMode mode, Color color, Color color2, int speed, bool mono = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -265,7 +261,7 @@ namespace GHelper.USB
|
|||||||
if (isACPI) Program.acpi.TUFKeyboardBrightness(brightness);
|
if (isACPI) Program.acpi.TUFKeyboardBrightness(brightness);
|
||||||
|
|
||||||
AsusHid.Write(new byte[] { AsusHid.AURA_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, AsusHid.AURA_ID, log);
|
AsusHid.Write(new byte[] { AsusHid.AURA_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, AsusHid.AURA_ID, log);
|
||||||
if (AppConfig.ContainsModel("GA503"))
|
if (AppConfig.ContainsModel("GA503"))
|
||||||
AsusHid.Write(new byte[] { AsusHid.INPUT_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, AsusHid.INPUT_ID, log);
|
AsusHid.Write(new byte[] { AsusHid.INPUT_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, AsusHid.INPUT_ID, log);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -359,51 +355,6 @@ namespace GHelper.USB
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ApplyColorStrix(Color[] color, bool init = false)
|
|
||||||
{
|
|
||||||
byte[] msg = new byte[0x40];
|
|
||||||
|
|
||||||
byte start = 9;
|
|
||||||
byte maxLeds = 0x93;
|
|
||||||
|
|
||||||
msg[0] = AsusHid.AURA_ID;
|
|
||||||
msg[1] = 0xbc;
|
|
||||||
msg[2] = 0;
|
|
||||||
msg[3] = 1;
|
|
||||||
msg[4] = 1;
|
|
||||||
msg[5] = 1;
|
|
||||||
msg[6] = 0;
|
|
||||||
msg[7] = 0x10;
|
|
||||||
|
|
||||||
for (byte i = 0; i < AURA_ZONES; i++)
|
|
||||||
{
|
|
||||||
msg[start + i * 3] = color[i].R; // R
|
|
||||||
msg[start + 1 + i * 3] = color[i].G; // G
|
|
||||||
msg[start + 2 + i * 3] = color[i].B; // B
|
|
||||||
}
|
|
||||||
|
|
||||||
if (init)
|
|
||||||
{
|
|
||||||
Init();
|
|
||||||
AsusHid.WriteAura(new byte[] { AsusHid.AURA_ID, 0xbc });
|
|
||||||
}
|
|
||||||
|
|
||||||
for (byte b = 0; b < maxLeds; b += 0x10)
|
|
||||||
{
|
|
||||||
msg[6] = b;
|
|
||||||
AsusHid.WriteAura(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg[6] = maxLeds;
|
|
||||||
AsusHid.WriteAura(msg);
|
|
||||||
|
|
||||||
msg[4] = 4;
|
|
||||||
msg[5] = 0;
|
|
||||||
msg[6] = 0;
|
|
||||||
msg[7] = 0;
|
|
||||||
AsusHid.WriteAura(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ApplyColor(Color color, bool init = false)
|
public static void ApplyColor(Color color, bool init = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -415,8 +366,47 @@ namespace GHelper.USB
|
|||||||
|
|
||||||
if (isStrix && !isOldHeatmap)
|
if (isStrix && !isOldHeatmap)
|
||||||
{
|
{
|
||||||
ApplyColorStrix(Enumerable.Repeat(color, AURA_ZONES).ToArray(), init);
|
byte[] msg = new byte[0x40];
|
||||||
return;
|
|
||||||
|
byte start = 9;
|
||||||
|
byte maxLeds = 0x93;
|
||||||
|
|
||||||
|
msg[0] = AsusHid.AURA_ID;
|
||||||
|
msg[1] = 0xbc;
|
||||||
|
msg[2] = 0;
|
||||||
|
msg[3] = 1;
|
||||||
|
msg[4] = 1;
|
||||||
|
msg[5] = 1;
|
||||||
|
msg[6] = 0;
|
||||||
|
msg[7] = 0x10;
|
||||||
|
|
||||||
|
for (byte i = 0; i < 0x12; i++)
|
||||||
|
{
|
||||||
|
msg[start + i * 3] = color.R; // R
|
||||||
|
msg[start + 1 + i * 3] = color.G; // G
|
||||||
|
msg[start + 2 + i * 3] = color.B; // B
|
||||||
|
}
|
||||||
|
|
||||||
|
if (init)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
AsusHid.WriteAura(new byte[] { AsusHid.AURA_ID, 0xbc });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (byte b = 0; b < maxLeds; b += 0x10)
|
||||||
|
{
|
||||||
|
msg[6] = b;
|
||||||
|
AsusHid.WriteAura(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg[6] = maxLeds;
|
||||||
|
AsusHid.WriteAura(msg);
|
||||||
|
|
||||||
|
msg[4] = 4;
|
||||||
|
msg[5] = 0;
|
||||||
|
msg[6] = 0;
|
||||||
|
msg[7] = 0;
|
||||||
|
AsusHid.WriteAura(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -427,6 +417,26 @@ namespace GHelper.USB
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void ApplyGPUColor()
|
||||||
|
{
|
||||||
|
if ((AuraMode)AppConfig.Get("aura_mode") != AuraMode.GPUMODE) return;
|
||||||
|
|
||||||
|
switch (GPUModeControl.gpuMode)
|
||||||
|
{
|
||||||
|
case AsusACPI.GPUModeUltimate:
|
||||||
|
ApplyColor(Color.Red, true);
|
||||||
|
break;
|
||||||
|
case AsusACPI.GPUModeEco:
|
||||||
|
ApplyColor(Color.Green, true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ApplyColor(Color.Yellow, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void ApplyAura()
|
public static void ApplyAura()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -439,23 +449,14 @@ namespace GHelper.USB
|
|||||||
|
|
||||||
if (Mode == AuraMode.HEATMAP)
|
if (Mode == AuraMode.HEATMAP)
|
||||||
{
|
{
|
||||||
CustomRGB.ApplyHeatmap(true);
|
SetHeatmap(true);
|
||||||
timer.Enabled = true;
|
timer.Enabled = true;
|
||||||
timer.Interval = 2000;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Mode == AuraMode.AMBIENT)
|
|
||||||
{
|
|
||||||
CustomRGB.ApplyAmbient(true);
|
|
||||||
timer.Enabled = true;
|
|
||||||
timer.Interval = 120;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Mode == AuraMode.GPUMODE)
|
if (Mode == AuraMode.GPUMODE)
|
||||||
{
|
{
|
||||||
CustomRGB.ApplyGPUColor();
|
ApplyGPUColor();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,214 +470,6 @@ namespace GHelper.USB
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class CustomRGB
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void ApplyGPUColor()
|
|
||||||
{
|
|
||||||
if ((AuraMode)AppConfig.Get("aura_mode") != AuraMode.GPUMODE) return;
|
|
||||||
|
|
||||||
switch (GPUModeControl.gpuMode)
|
|
||||||
{
|
|
||||||
case AsusACPI.GPUModeUltimate:
|
|
||||||
ApplyColor(Color.Red, true);
|
|
||||||
break;
|
|
||||||
case AsusACPI.GPUModeEco:
|
|
||||||
ApplyColor(Color.Green, true);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ApplyColor(Color.Yellow, true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ApplyHeatmap(bool init = false)
|
|
||||||
{
|
|
||||||
float cpuTemp = (float)HardwareControl.GetCPUTemp();
|
|
||||||
int freeze = 20, cold = 40, warm = 65, hot = 90;
|
|
||||||
Color color;
|
|
||||||
|
|
||||||
//Debug.WriteLine(cpuTemp);
|
|
||||||
|
|
||||||
if (cpuTemp < cold) color = ColorUtils.GetWeightedAverage(Color.Blue, Color.Green, ((float)cpuTemp - freeze) / (cold - freeze));
|
|
||||||
else if (cpuTemp < warm) color = ColorUtils.GetWeightedAverage(Color.Green, Color.Yellow, ((float)cpuTemp - cold) / (warm - cold));
|
|
||||||
else if (cpuTemp < hot) color = ColorUtils.GetWeightedAverage(Color.Yellow, Color.Red, ((float)cpuTemp - warm) / (hot - warm));
|
|
||||||
else color = Color.Red;
|
|
||||||
|
|
||||||
ApplyColor(color, init);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void ApplyAmbient(bool init = false)
|
|
||||||
{
|
|
||||||
var bound = Screen.GetBounds(Point.Empty);
|
|
||||||
bound.Y += bound.Height / 3;
|
|
||||||
bound.Height -= (int)Math.Round(bound.Height * (0.33f + 0.022f)); // cut 1/3 of the top screen + windows panel
|
|
||||||
|
|
||||||
var screen_low = AmbientData.CamptureScreen(bound, 256, 144);
|
|
||||||
Bitmap screeb_pxl;
|
|
||||||
|
|
||||||
int zones = AURA_ZONES;
|
|
||||||
|
|
||||||
if (isStrix) //laptop with lightbar
|
|
||||||
{
|
|
||||||
screeb_pxl = AmbientData.ResizeImage(screen_low, 4, 2); // 4x2 zone. top for keyboard and bot for lightbar
|
|
||||||
var mid_left = ColorUtils.GetMidColor(screeb_pxl.GetPixel(0, 1), screeb_pxl.GetPixel(1, 1));
|
|
||||||
var mid_right = ColorUtils.GetMidColor(screeb_pxl.GetPixel(2, 1), screeb_pxl.GetPixel(3, 1));
|
|
||||||
|
|
||||||
AmbientData.Colors[6].RGB = ColorUtils.HSV.UpSaturation(screeb_pxl.GetPixel(3, 1)); // right bck
|
|
||||||
AmbientData.Colors[11].RGB = ColorUtils.HSV.UpSaturation(screeb_pxl.GetPixel(1, 1)); // left bck
|
|
||||||
|
|
||||||
AmbientData.Colors[7].RGB = AmbientData.Colors[6].RGB; // right
|
|
||||||
AmbientData.Colors[10].RGB = AmbientData.Colors[11].RGB; // left
|
|
||||||
|
|
||||||
AmbientData.Colors[8].RGB = ColorUtils.HSV.UpSaturation(mid_right); // center right
|
|
||||||
AmbientData.Colors[9].RGB = ColorUtils.HSV.UpSaturation(mid_left); // center left
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) // keyboard
|
|
||||||
AmbientData.Colors[i].RGB = ColorUtils.HSV.UpSaturation(screeb_pxl.GetPixel(i, 0));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
zones = 1;
|
|
||||||
screeb_pxl = AmbientData.ResizeImage(screen_low, 1, 1);
|
|
||||||
AmbientData.Colors[0].RGB = ColorUtils.HSV.UpSaturation(screeb_pxl.GetPixel(0, 0), (float)0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//screeb_pxl.Save("test.jpg", ImageFormat.Jpeg);
|
|
||||||
screen_low.Dispose();
|
|
||||||
screeb_pxl.Dispose();
|
|
||||||
|
|
||||||
bool is_fresh = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < zones; i++)
|
|
||||||
{
|
|
||||||
if (AmbientData.result[i].ToArgb() != AmbientData.Colors[i].RGB.ToArgb()) is_fresh = true;
|
|
||||||
AmbientData.result[i] = AmbientData.Colors[i].RGB;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_fresh)
|
|
||||||
{
|
|
||||||
if (isStrix) ApplyColorStrix(AmbientData.result, init);
|
|
||||||
else ApplyColor(AmbientData.result[0], init);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static class AmbientData
|
|
||||||
{
|
|
||||||
|
|
||||||
public enum StretchMode
|
|
||||||
{
|
|
||||||
STRETCH_ANDSCANS = 1,
|
|
||||||
STRETCH_ORSCANS = 2,
|
|
||||||
STRETCH_DELETESCANS = 3,
|
|
||||||
STRETCH_HALFTONE = 4,
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
private static extern IntPtr GetDesktopWindow();
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
private static extern IntPtr GetWindowDC(IntPtr hWnd);
|
|
||||||
|
|
||||||
[DllImport("gdi32.dll")]
|
|
||||||
private static extern IntPtr CreateCompatibleDC(IntPtr hDC);
|
|
||||||
|
|
||||||
[DllImport("gdi32.dll")]
|
|
||||||
private static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, int nHeight);
|
|
||||||
|
|
||||||
[DllImport("gdi32.dll")]
|
|
||||||
private static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
private static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
|
||||||
|
|
||||||
[DllImport("gdi32.dll")]
|
|
||||||
private static extern bool DeleteDC(IntPtr hdc);
|
|
||||||
|
|
||||||
[DllImport("gdi32.dll")]
|
|
||||||
private static extern bool DeleteObject(IntPtr hObject);
|
|
||||||
|
|
||||||
[DllImport("gdi32.dll")]
|
|
||||||
private static extern bool StretchBlt(IntPtr hdcDest, int nXOriginDest, int nYOriginDest,
|
|
||||||
int nWidthDest, int nHeightDest,
|
|
||||||
IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, Int32 dwRop);
|
|
||||||
|
|
||||||
[DllImport("gdi32.dll")]
|
|
||||||
static extern bool SetStretchBltMode(IntPtr hdc, StretchMode iStretchMode);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Captures a screenshot.
|
|
||||||
/// </summary>
|
|
||||||
public static Bitmap CamptureScreen(Rectangle rec, int out_w, int out_h)
|
|
||||||
{
|
|
||||||
IntPtr desktop = GetDesktopWindow();
|
|
||||||
IntPtr hdc = GetWindowDC(desktop);
|
|
||||||
IntPtr hdcMem = CreateCompatibleDC(hdc);
|
|
||||||
|
|
||||||
IntPtr hBitmap = CreateCompatibleBitmap(hdc, out_w, out_h);
|
|
||||||
IntPtr hOld = SelectObject(hdcMem, hBitmap);
|
|
||||||
SetStretchBltMode(hdcMem, StretchMode.STRETCH_DELETESCANS);
|
|
||||||
StretchBlt(hdcMem, 0, 0, out_w, out_h, hdc, rec.X, rec.Y, rec.Width, rec.Height, 0x00CC0020);
|
|
||||||
SelectObject(hdcMem, hOld);
|
|
||||||
|
|
||||||
DeleteDC(hdcMem);
|
|
||||||
ReleaseDC(desktop, hdc);
|
|
||||||
var result = Image.FromHbitmap(hBitmap, IntPtr.Zero);
|
|
||||||
DeleteObject(hBitmap);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Bitmap ResizeImage(Image image, int width, int height)
|
|
||||||
{
|
|
||||||
var destRect = new Rectangle(0, 0, width, height);
|
|
||||||
var destImage = new Bitmap(width, height);
|
|
||||||
|
|
||||||
destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
|
|
||||||
|
|
||||||
using (var graphics = Graphics.FromImage(destImage))
|
|
||||||
{
|
|
||||||
graphics.CompositingMode = CompositingMode.SourceCopy;
|
|
||||||
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
|
||||||
graphics.InterpolationMode = InterpolationMode.Bicubic;
|
|
||||||
graphics.SmoothingMode = SmoothingMode.None;
|
|
||||||
graphics.PixelOffsetMode = PixelOffsetMode.None;
|
|
||||||
|
|
||||||
using (var wrapMode = new ImageAttributes())
|
|
||||||
{
|
|
||||||
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
|
|
||||||
graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return destImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
static public Color[] result = new Color[AURA_ZONES];
|
|
||||||
static public ColorUtils.SmoothColor[] Colors = Enumerable.Repeat(0, AURA_ZONES).
|
|
||||||
Select(h => new ColorUtils.SmoothColor()).ToArray();
|
|
||||||
|
|
||||||
public static Color GetMostUsedColor(Bitmap bitMap)
|
|
||||||
{
|
|
||||||
var colorIncidence = new Dictionary<int, int>();
|
|
||||||
for (var x = 0; x < bitMap.Size.Width; x++)
|
|
||||||
for (var y = 0; y < bitMap.Size.Height; y++)
|
|
||||||
{
|
|
||||||
var pixelColor = bitMap.GetPixel(x, y).ToArgb();
|
|
||||||
if (colorIncidence.Keys.Contains(pixelColor))
|
|
||||||
colorIncidence[pixelColor]++;
|
|
||||||
else
|
|
||||||
colorIncidence.Add(pixelColor, 1);
|
|
||||||
}
|
|
||||||
return Color.FromArgb(colorIncidence.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value).First().Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
// Reference : thanks to https://github.com/RomanYazvinsky/ for initial discovery of XGM payloads
|
// Reference : thanks to https://github.com/RomanYazvinsky/ for initial discovery of XGM payloads
|
||||||
|
|
||||||
using HidSharp;
|
using HidSharp;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace GHelper.USB
|
namespace GHelper.USB
|
||||||
@@ -8,37 +9,30 @@ namespace GHelper.USB
|
|||||||
public static class XGM
|
public static class XGM
|
||||||
{
|
{
|
||||||
const int XGM_ID = 0x1970;
|
const int XGM_ID = 0x1970;
|
||||||
const int ASUS_ID = 0x0b05;
|
public const int ASUS_ID = 0x0b05;
|
||||||
|
|
||||||
public static void Write(byte[] data)
|
public static void Write(byte[] data)
|
||||||
{
|
{
|
||||||
HidDeviceLoader loader = new HidDeviceLoader();
|
HidDeviceLoader loader = new HidDeviceLoader();
|
||||||
|
HidDevice device = loader.GetDevices(ASUS_ID, XGM_ID).Where(device => device.GetMaxFeatureReportLength() >= 300).FirstOrDefault();
|
||||||
|
if (device is null) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HidDevice device = loader.GetDevices(ASUS_ID, XGM_ID).Where(device => device.CanOpen && device.GetMaxFeatureReportLength() >= 300).FirstOrDefault();
|
|
||||||
|
|
||||||
if (device is null)
|
|
||||||
{
|
|
||||||
Logger.WriteLine("XGM SUB device not found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
using (HidStream hidStream = device.Open())
|
using (HidStream hidStream = device.Open())
|
||||||
{
|
{
|
||||||
var payload = new byte[300];
|
var payload = new byte[300];
|
||||||
Array.Copy(data, payload, data.Length);
|
Array.Copy(data, payload, data.Length);
|
||||||
|
|
||||||
hidStream.SetFeature(payload);
|
hidStream.Write(payload);
|
||||||
Logger.WriteLine("XGM-" + device.ProductID + "|" + device.GetMaxFeatureReportLength() + ":" + BitConverter.ToString(data));
|
Logger.WriteLine("XGM " + device.ProductID + "|" + device.GetMaxFeatureReportLength() + ":" + BitConverter.ToString(data));
|
||||||
|
|
||||||
hidStream.Close();
|
hidStream.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.WriteLine($"Error accessing XGM device: {ex}");
|
Debug.WriteLine($"Error accessing HID device: {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
|
|||||||
@@ -108,9 +108,7 @@ Ultimate mode is supported (by hardware) only on 2022+ models
|
|||||||
You don't have to, it's purely optional. From my experience built in (in BIOS) performance modes work well. Limit your power or apply custom fan curves only if you have issues. As soon as you click Apply in the ``Fans + Power`` section BIOS will consider your fan curve as "custom"! (no matter if you modified it or not)
|
You don't have to, it's purely optional. From my experience built in (in BIOS) performance modes work well. Limit your power or apply custom fan curves only if you have issues. As soon as you click Apply in the ``Fans + Power`` section BIOS will consider your fan curve as "custom"! (no matter if you modified it or not)
|
||||||
|
|
||||||
#### How does G-helper control my fan speeds?
|
#### How does G-helper control my fan speeds?
|
||||||
**It doesn't.** Your firmware / BIOS controls them in real-time. Armoury also doesn't control fans in real time anyhow.
|
**It doesn't.** Your BIOS does (same as in case with Armoury). What G-helper can do - is (optionally) set a custom fan profile to current performance mode consisting of 8 pairs of temperature + fan speed % via same endpoint armoury seem to use.
|
||||||
|
|
||||||
What G-helper can do - is (optionally) set a custom fan profile to the current performance mode consisting of 8 pairs of temperature + fan speed % via the same endpoint Armoury seems to use. How it will be interpreted - is still up to the firmware.
|
|
||||||
|
|
||||||
#### How do I change fan % to fan RPM?
|
#### How do I change fan % to fan RPM?
|
||||||
Click on them
|
Click on them
|
||||||
|
|||||||
Reference in New Issue
Block a user