mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Fix for turkish keyboard, tweak for default fan curves
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using GHelper;
|
using System.Globalization;
|
||||||
|
using System.IO.Pipes;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@@ -205,7 +206,7 @@ public class ASUSWmi
|
|||||||
byte[] args = new byte[8];
|
byte[] args = new byte[8];
|
||||||
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
|
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
|
||||||
byte[] status = CallMethod(DSTS, args);
|
byte[] status = CallMethod(DSTS, args);
|
||||||
|
|
||||||
return BitConverter.ToInt32(status, 0) - 65536;
|
return BitConverter.ToInt32(status, 0) - 65536;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -215,7 +216,7 @@ public class ASUSWmi
|
|||||||
byte[] args = new byte[8];
|
byte[] args = new byte[8];
|
||||||
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
|
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
|
||||||
BitConverter.GetBytes((uint)Status).CopyTo(args, 4);
|
BitConverter.GetBytes((uint)Status).CopyTo(args, 4);
|
||||||
|
|
||||||
return CallMethod(DSTS, args);
|
return CallMethod(DSTS, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,8 +243,8 @@ public class ASUSWmi
|
|||||||
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
//for (int i = 8; i < curve.Length; i++)
|
for (int i = 8; i < curve.Length; i++)
|
||||||
// curve[i] = Math.Max((byte)0, Math.Min((byte)99, curve[i])); // it seems to be a bug, when some old model's bios can go nuts if fan is set to 100%
|
curve[i] = Math.Max((byte)0, Math.Min((byte)99, curve[i])); // it seems to be a bug, when some old model's bios can go nuts if fan is set to 100%
|
||||||
|
|
||||||
switch (device)
|
switch (device)
|
||||||
{
|
{
|
||||||
@@ -285,6 +286,47 @@ public class ASUSWmi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static bool IsEmptyCurve(byte[] curve) {
|
||||||
|
return curve.Length != 16 || curve.All(singleByte => singleByte == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] FixFanCurve(byte[] curve)
|
||||||
|
{
|
||||||
|
if (curve.Length != 16) throw new Exception("Incorrect curve");
|
||||||
|
|
||||||
|
var points = new Dictionary<byte, byte>();
|
||||||
|
for (int i = 0; i < 8; i++) points[curve[i]] = curve[i+8];
|
||||||
|
|
||||||
|
var pointsFixed = new Dictionary<byte, byte>();
|
||||||
|
bool fix = false;
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (var pair in points.OrderBy(x => x.Key))
|
||||||
|
{
|
||||||
|
if (count == 0 && pair.Key >= 40)
|
||||||
|
{
|
||||||
|
fix = true;
|
||||||
|
pointsFixed.Add(20, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count != 3 || !fix)
|
||||||
|
pointsFixed.Add(pair.Key, pair.Value);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
foreach (var pair in pointsFixed.OrderBy(x => x.Key))
|
||||||
|
{
|
||||||
|
curve[count] =pair.Key;
|
||||||
|
curve[count+8] = pair.Value;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return curve;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void TUFKeyboardBrightness(int brightness)
|
public void TUFKeyboardBrightness(int brightness)
|
||||||
{
|
{
|
||||||
int param = 0x80 | (brightness & 0x7F);
|
int param = 0x80 | (brightness & 0x7F);
|
||||||
@@ -334,7 +376,8 @@ public class ASUSWmi
|
|||||||
watcher.Scope = new ManagementScope("root\\wmi");
|
watcher.Scope = new ManagementScope("root\\wmi");
|
||||||
watcher.Query = new WqlEventQuery("SELECT * FROM AsusAtkWmiEvent");
|
watcher.Query = new WqlEventQuery("SELECT * FROM AsusAtkWmiEvent");
|
||||||
watcher.Start();
|
watcher.Start();
|
||||||
} catch
|
}
|
||||||
|
catch
|
||||||
{
|
{
|
||||||
Logger.WriteLine("Can't connect to ASUS WMI events");
|
Logger.WriteLine("Can't connect to ASUS WMI events");
|
||||||
}
|
}
|
||||||
|
|||||||
26
app/Aura.cs
26
app/Aura.cs
@@ -1,8 +1,6 @@
|
|||||||
using HidLibrary;
|
using HidLibrary;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using OSD;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace GHelper
|
namespace GHelper
|
||||||
{
|
{
|
||||||
@@ -167,7 +165,9 @@ namespace GHelper
|
|||||||
{
|
{
|
||||||
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
|
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
|
||||||
foreach (HidDevice device in HidDeviceList)
|
foreach (HidDevice device in HidDeviceList)
|
||||||
if (device.IsConnected && device.Description.ToLower().Contains("hid") && device.Capabilities.FeatureReportByteLength >= 64)
|
if (device.IsConnected
|
||||||
|
&& device.Capabilities.FeatureReportByteLength >= 64
|
||||||
|
&& device.Capabilities.InputReportByteLength >= 12) //
|
||||||
yield return device;
|
yield return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,12 +196,13 @@ namespace GHelper
|
|||||||
byte[] msg = { 0x5d, 0xba, 0xc5, 0xc4, (byte)brightness };
|
byte[] msg = { 0x5d, 0xba, 0xc5, 0xc4, (byte)brightness };
|
||||||
|
|
||||||
var devices = GetHidDevices(deviceIds);
|
var devices = GetHidDevices(deviceIds);
|
||||||
if (devices.Count() > 0) Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
|
//Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
|
||||||
|
|
||||||
foreach (HidDevice device in devices)
|
foreach (HidDevice device in devices)
|
||||||
{
|
{
|
||||||
device.OpenDevice();
|
device.OpenDevice();
|
||||||
device.Write(msg);
|
device.Write(msg);
|
||||||
|
Logger.WriteLine("USB-KB " + device.Attributes.ProductHexId + ":" + BitConverter.ToString(msg));
|
||||||
device.CloseDevice();
|
device.CloseDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,27 +218,28 @@ namespace GHelper
|
|||||||
|
|
||||||
|
|
||||||
var devices = GetHidDevices(deviceIds);
|
var devices = GetHidDevices(deviceIds);
|
||||||
if (devices.Count() > 0) Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
|
//Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
|
||||||
|
|
||||||
foreach (HidDevice device in devices)
|
foreach (HidDevice device in devices)
|
||||||
{
|
{
|
||||||
device.OpenDevice();
|
device.OpenDevice();
|
||||||
device.Write(msg);
|
device.Write(msg);
|
||||||
|
Logger.WriteLine("USB-KB " + device.Attributes.ProductHexId + ":" + BitConverter.ToString(msg));
|
||||||
device.CloseDevice();
|
device.CloseDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Program.config.ContainsModel("TUF"))
|
if (Program.config.ContainsModel("TUF"))
|
||||||
Program.wmi.TUFKeyboardPower(
|
Program.wmi.TUFKeyboardPower(
|
||||||
flags.Contains(AuraDev19b6.AwakeKeyb),
|
flags.Contains(AuraDev19b6.AwakeKeyb),
|
||||||
flags.Contains(AuraDev19b6.BootKeyb),
|
flags.Contains(AuraDev19b6.BootKeyb),
|
||||||
flags.Contains(AuraDev19b6.SleepKeyb),
|
flags.Contains(AuraDev19b6.SleepKeyb),
|
||||||
flags.Contains(AuraDev19b6.ShutdownKeyb));
|
flags.Contains(AuraDev19b6.ShutdownKeyb));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ApplyXGMLight(bool status)
|
public static void ApplyXGMLight(bool status)
|
||||||
{
|
{
|
||||||
byte value = status? (byte)0x50:(byte)0;
|
byte value = status ? (byte)0x50 : (byte)0;
|
||||||
var msg = new byte[] { 0x5e, 0xc5, value };
|
var msg = new byte[] { 0x5e, 0xc5, value };
|
||||||
|
|
||||||
foreach (HidDevice device in GetHidDevices(new int[] { 0x1970 }))
|
foreach (HidDevice device in GetHidDevices(new int[] { 0x1970 }))
|
||||||
@@ -273,7 +275,7 @@ namespace GHelper
|
|||||||
byte[] msg = AuraMessage(Mode, Color1, Color2, _speed);
|
byte[] msg = AuraMessage(Mode, Color1, Color2, _speed);
|
||||||
|
|
||||||
var devices = GetHidDevices(deviceIds);
|
var devices = GetHidDevices(deviceIds);
|
||||||
if (devices.Count() > 0) Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
|
//if (devices.Count() > 0) Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
|
||||||
|
|
||||||
foreach (HidDevice device in devices)
|
foreach (HidDevice device in devices)
|
||||||
{
|
{
|
||||||
@@ -282,6 +284,7 @@ namespace GHelper
|
|||||||
device.Write(MESSAGE_SET);
|
device.Write(MESSAGE_SET);
|
||||||
device.Write(MESSAGE_APPLY);
|
device.Write(MESSAGE_APPLY);
|
||||||
device.CloseDevice();
|
device.CloseDevice();
|
||||||
|
Logger.WriteLine("USB-KB " + device.Capabilities.FeatureReportByteLength + "|" + device.Capabilities.InputReportByteLength + device.Description + device.DevicePath + ":" + BitConverter.ToString(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Program.config.ContainsModel("TUF"))
|
if (Program.config.ContainsModel("TUF"))
|
||||||
@@ -299,7 +302,8 @@ namespace GHelper
|
|||||||
myKey.SetValue("TurnOffKeybdLight", value, RegistryValueKind.DWord);
|
myKey.SetValue("TurnOffKeybdLight", value, RegistryValueKind.DWord);
|
||||||
myKey.Close();
|
myKey.Close();
|
||||||
}
|
}
|
||||||
} catch (Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.WriteLine(ex.Message);
|
Logger.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
|
|||||||
11
app/Fans.cs
11
app/Fans.cs
@@ -462,11 +462,16 @@ namespace GHelper
|
|||||||
int mode = Program.config.getConfig("performance_mode");
|
int mode = Program.config.getConfig("performance_mode");
|
||||||
byte[] curve = Program.config.getFanConfig(device);
|
byte[] curve = Program.config.getFanConfig(device);
|
||||||
|
|
||||||
if (def == 1 || curve.Length != 16)
|
if (def == 1 || ASUSWmi.IsEmptyCurve(curve))
|
||||||
|
{
|
||||||
curve = Program.wmi.GetFanCurve(device, mode);
|
curve = Program.wmi.GetFanCurve(device, mode);
|
||||||
|
|
||||||
|
if (ASUSWmi.IsEmptyCurve(curve))
|
||||||
|
curve = Program.config.getDefaultCurve(device);
|
||||||
|
|
||||||
if (curve.Length != 16 || curve.All(singleByte => singleByte == 0))
|
curve = ASUSWmi.FixFanCurve(curve);
|
||||||
curve = Program.config.getDefaultCurve(device);
|
|
||||||
|
}
|
||||||
|
|
||||||
//Debug.WriteLine(BitConverter.ToString(curve));
|
//Debug.WriteLine(BitConverter.ToString(curve));
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<AssemblyVersion>0.61</AssemblyVersion>
|
<AssemblyVersion>0.62</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
Reference in New Issue
Block a user