mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e096699909 | ||
|
|
bf1ffddf15 | ||
|
|
fad7396c8f | ||
|
|
af4a5e8af7 | ||
|
|
3d2be97cf6 | ||
|
|
b6fe7c9ddf | ||
|
|
f2085b836b | ||
|
|
ccf2ae9eed | ||
|
|
e4bcc8f66c | ||
|
|
0f11ffe8f0 | ||
|
|
96cbcbaf7f | ||
|
|
0c1ababcf8 | ||
|
|
36eae610e8 | ||
|
|
69757ff460 | ||
|
|
744bce1819 |
@@ -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");
|
return ContainsModel("G614JV") || ContainsModel("G614JZ") || ContainsModel("G512LI") || ContainsModel("G513RS") || ContainsModel("G513RM") || ContainsModel("G713PV");
|
||||||
}
|
}
|
||||||
|
|
||||||
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.132</AssemblyVersion>
|
<AssemblyVersion>0.133</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@@ -194,7 +194,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[3]);
|
KeyboardHook.KeyKeyKeyPress((Keys)hexKeys[0], (Keys)hexKeys[1], (Keys)hexKeys[2]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LaunchProcess(command);
|
LaunchProcess(command);
|
||||||
@@ -311,9 +311,6 @@ 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;
|
||||||
|
|||||||
2
app/Settings.Designer.cs
generated
2
app/Settings.Designer.cs
generated
@@ -1439,7 +1439,7 @@ namespace GHelper
|
|||||||
MinimumSize = new Size(822, 71);
|
MinimumSize = new Size(822, 71);
|
||||||
Name = "SettingsForm";
|
Name = "SettingsForm";
|
||||||
Padding = new Padding(11);
|
Padding = new Padding(11);
|
||||||
ShowIcon = true;
|
ShowIcon = false;
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "G-Helper";
|
Text = "G-Helper";
|
||||||
panelMatrix.ResumeLayout(false);
|
panelMatrix.ResumeLayout(false);
|
||||||
|
|||||||
@@ -12,67 +12,89 @@ public static class AsusHid
|
|||||||
|
|
||||||
static int[] deviceIds = { 0x1a30, 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0, 0x18c6, 0x1abe };
|
static int[] deviceIds = { 0x1a30, 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0, 0x18c6, 0x1abe };
|
||||||
|
|
||||||
static HidStream auraStream;
|
static HidStream? auraStream;
|
||||||
|
|
||||||
public static HidStream FindHidStream(byte reportId, int minFeatureLength = 1)
|
public static IEnumerable<HidDevice>? FindDevices(byte reportId)
|
||||||
{
|
{
|
||||||
HidDeviceLoader loader = new HidDeviceLoader();
|
HidDeviceLoader loader = new HidDeviceLoader();
|
||||||
var deviceList = loader.GetDevices(ASUS_ID).Where(device => deviceIds.Contains(device.ProductID));
|
IEnumerable<HidDevice> deviceList;
|
||||||
|
|
||||||
foreach (var device in deviceList) if (device.CanOpen)
|
try
|
||||||
{
|
{
|
||||||
try
|
deviceList = loader.GetDevices(ASUS_ID).Where(device => deviceIds.Contains(device.ProductID) && device.CanOpen && device.GetMaxFeatureReportLength() > 0);
|
||||||
{
|
}
|
||||||
var config = new OpenConfiguration();
|
catch (Exception ex)
|
||||||
config.SetOption(OpenOption.Interruptible, false);
|
{
|
||||||
config.SetOption(OpenOption.Exclusive, false);
|
Logger.WriteLine($"Error enumerating HID devices: {ex.Message}");
|
||||||
config.SetOption(OpenOption.Priority, 10);
|
yield break;
|
||||||
HidStream hidStream = device.Open();
|
}
|
||||||
|
|
||||||
if (device.GetMaxFeatureReportLength() >= minFeatureLength)
|
foreach (var device in deviceList)
|
||||||
{
|
if (device.GetReportDescriptor().TryGetReport(ReportType.Feature, reportId, out _))
|
||||||
var reportDescriptor = device.GetReportDescriptor();
|
yield return device;
|
||||||
if (reportDescriptor.TryGetReport(ReportType.Feature, reportId, out _))
|
}
|
||||||
{
|
|
||||||
return hidStream;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hidStream.Close();
|
public static HidStream? FindHidStream(byte reportId)
|
||||||
hidStream.Dispose();
|
{
|
||||||
}
|
try
|
||||||
catch (Exception ex)
|
{
|
||||||
{
|
return FindDevices(reportId)?.FirstOrDefault()?.Open();
|
||||||
Debug.WriteLine($"Error accessing HID device: {ex.Message}");
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
|
Logger.WriteLine($"Error accessing HID device: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteData(HidStream stream, byte[] data, string log = "USB")
|
public static void WriteInput(byte[] data, string log = "USB")
|
||||||
{
|
{
|
||||||
try
|
foreach (var device in FindDevices(INPUT_ID))
|
||||||
{
|
{
|
||||||
stream.Write(data);
|
try
|
||||||
Logger.WriteLine($"{log} " + stream.Device.ProductID + ": " + BitConverter.ToString(data));
|
{
|
||||||
}
|
using (var stream = device.Open())
|
||||||
catch (Exception ex)
|
{
|
||||||
{
|
var payload = new byte[device.GetMaxFeatureReportLength()];
|
||||||
Debug.WriteLine($"Error writing {log} to HID device: {ex.Message} {BitConverter.ToString(data)}");
|
Array.Copy(data, payload, data.Length);
|
||||||
|
stream.SetFeature(payload);
|
||||||
|
Logger.WriteLine($"{log} Feature {device.ProductID.ToString("X")}|{device.GetMaxFeatureReportLength()}: {BitConverter.ToString(data)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.WriteLine($"Error setting feature {device.GetMaxFeatureReportLength()} {device.DevicePath}: {BitConverter.ToString(data)} {ex.Message}");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Write(byte[] data, byte reportId = AURA_ID, string log = "USB")
|
public static void Write(byte[] data, string log = "USB")
|
||||||
{
|
{
|
||||||
using (var stream = FindHidStream(reportId))
|
Write(new List<byte[]> { data }, log);
|
||||||
WriteData(stream, data, log);
|
|
||||||
}
|
}
|
||||||
public static void Write(List<byte[]> dataList, byte reportId = AURA_ID)
|
|
||||||
|
public static void Write(List<byte[]> dataList, string log = "USB")
|
||||||
{
|
{
|
||||||
using (var stream = FindHidStream(reportId))
|
var devices = FindDevices(AURA_ID);
|
||||||
foreach (var data in dataList)
|
if (devices is null) return;
|
||||||
WriteData(stream, data);
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var device in devices)
|
||||||
|
using (var stream = device.Open())
|
||||||
|
foreach (var data in dataList)
|
||||||
|
{
|
||||||
|
stream.Write(data);
|
||||||
|
Logger.WriteLine($"{log} {device.ProductID.ToString("X")}: {BitConverter.ToString(data)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.WriteLine($"Error writing {log}: {ex.Message} ");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteAura(byte[] data)
|
public static void WriteAura(byte[] data)
|
||||||
@@ -88,7 +110,7 @@ public static class AsusHid
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
auraStream.Dispose();
|
auraStream.Dispose();
|
||||||
Debug.WriteLine($"Error writing data to HID device: {ex.Message}");
|
Debug.WriteLine($"Error writing data to HID device: {ex.Message} {BitConverter.ToString(data)}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
265
app/USB/Aura.cs
265
app/USB/Aura.cs
@@ -68,7 +68,7 @@ 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;
|
static readonly int AURA_ZONES = 8;
|
||||||
|
|
||||||
private static AuraMode mode = AuraMode.AuraStatic;
|
private static AuraMode mode = AuraMode.AuraStatic;
|
||||||
private static AuraSpeed speed = AuraSpeed.Normal;
|
private static AuraSpeed speed = AuraSpeed.Normal;
|
||||||
@@ -78,6 +78,7 @@ namespace GHelper.USB
|
|||||||
|
|
||||||
static bool isACPI = AppConfig.IsTUF() || AppConfig.IsVivobook();
|
static bool isACPI = AppConfig.IsTUF() || AppConfig.IsVivobook();
|
||||||
static bool isStrix = AppConfig.IsStrix();
|
static bool isStrix = AppConfig.IsStrix();
|
||||||
|
static bool isStrix4Zone = AppConfig.IsStrixLimitedRGB();
|
||||||
|
|
||||||
static public bool isSingleColor = false;
|
static public bool isSingleColor = false;
|
||||||
|
|
||||||
@@ -128,12 +129,11 @@ namespace GHelper.USB
|
|||||||
isSingleColor = AppConfig.IsSingleColor(); // Mono Color
|
isSingleColor = AppConfig.IsSingleColor(); // Mono Color
|
||||||
|
|
||||||
if (AppConfig.ContainsModel("GA402X") || AppConfig.ContainsModel("GA402N"))
|
if (AppConfig.ContainsModel("GA402X") || AppConfig.ContainsModel("GA402N"))
|
||||||
using (var stream = AsusHid.FindHidStream(AsusHid.AURA_ID))
|
{
|
||||||
{
|
var device = AsusHid.FindDevices(AsusHid.AURA_ID).FirstOrDefault();
|
||||||
if (stream is null) return;
|
if (device is null) return;
|
||||||
if (stream.Device.ReleaseNumberBcd == 22 || stream.Device.ReleaseNumberBcd == 23) isSingleColor = true;
|
if (device.ReleaseNumberBcd == 22 || device.ReleaseNumberBcd == 23) isSingleColor = true;
|
||||||
stream.Close();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<AuraSpeed, string> GetSpeeds()
|
public static Dictionary<AuraSpeed, string> GetSpeeds()
|
||||||
@@ -264,9 +264,9 @@ namespace GHelper.USB
|
|||||||
if (delay) await Task.Delay(TimeSpan.FromSeconds(1));
|
if (delay) await Task.Delay(TimeSpan.FromSeconds(1));
|
||||||
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 }, 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.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, log);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -359,69 +359,182 @@ namespace GHelper.USB
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ApplyColor(Color color, bool init = false)
|
static byte[] packetMap = new byte[]
|
||||||
{
|
{
|
||||||
Color[] color_list = Enumerable.Repeat(color, 0x12).ToArray();
|
/*00 ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 */
|
||||||
ApplyColor(color_list, init);
|
21, 23, 24, 25, 26, 28, 29, 30, 31, 33,
|
||||||
|
|
||||||
|
/*10 F10 F11 F12 DEL ` 1 2 3 4 5 */
|
||||||
|
34, 35, 36, 37, 42, 43, 44, 45, 46, 47,
|
||||||
|
|
||||||
|
/*20 6 7 8 9 0 - = BSP BSP BSP */
|
||||||
|
48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
|
||||||
|
|
||||||
|
/*30 PLY TAB Q W E R T Y U I */
|
||||||
|
58, 63, 64, 65, 66, 67, 68, 69, 70, 71,
|
||||||
|
|
||||||
|
/*40 O P [ ] \ STP CAP A S D */
|
||||||
|
72, 73, 74, 75, 76, 79, 84, 85, 86, 87,
|
||||||
|
|
||||||
|
/*50 F G H J K L ; ' ENT PRV */
|
||||||
|
88, 89, 90, 91, 92, 93, 94, 95, 98, 100,
|
||||||
|
|
||||||
|
/*60 LSH Z X C V B N M , . */
|
||||||
|
105, 107, 108, 109, 110, 111, 112, 113, 114, 115,
|
||||||
|
|
||||||
|
/*70 / RSH UP NXT LCTL LFN LWIN LALT SPC RALT */
|
||||||
|
116, 119, 139, 121, 126, 127, 128, 129, 131, 135,
|
||||||
|
|
||||||
|
/*80 RCTL LFT DWN RGT PRT KSTN VDN VUP MICM HPFN */
|
||||||
|
137, 159, 160, 161, 142, 0, 2, 3, 4, 5,
|
||||||
|
|
||||||
|
/*90 ARMC LB1 LB2 LB3 LB4 LB5 LB6 LOGO LIDL LIDR */
|
||||||
|
6, 174, 173, 172, 171, 170, 169, 167, 176, 177,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static byte[] packetZone = new byte[]
|
||||||
|
{
|
||||||
|
/*00 ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 */
|
||||||
|
0, 0, 0, 1, 1, 1, 1, 1, 2, 2,
|
||||||
|
|
||||||
|
/*10 F10 F11 F12 DEL ` 1 2 3 4 5 */
|
||||||
|
2, 3, 3, 3, 0, 0, 0, 0, 1 , 1,
|
||||||
|
|
||||||
|
/*20 6 7 8 9 0 - = BSP BSP BSP */
|
||||||
|
1, 2, 2, 2, 2, 2, 3, 3, 3, 3,
|
||||||
|
|
||||||
|
/*30 PLY TAB Q W E R T Y U I */
|
||||||
|
3, 0, 0, 0, 1, 1, 1, 1, 2, 2,
|
||||||
|
|
||||||
|
/*40 O P [ ] \ STP CAP A S D */
|
||||||
|
2, 2, 3, 3, 3, 3, 0, 0, 0, 1,
|
||||||
|
|
||||||
|
/*50 F G H J K L ; ' ENT PRV */
|
||||||
|
1, 1, 1, 2, 2, 2, 2, 3, 3, 3,
|
||||||
|
|
||||||
|
/*60 LSH Z X C V B N M , . */
|
||||||
|
0, 0, 0, 1, 1, 1, 1, 2, 2, 2,
|
||||||
|
|
||||||
|
/*70 / RSH UP NXT LCTL LFN LWIN LALT SPC RALT */
|
||||||
|
3, 3, 3, 3, 0, 0, 0, 0, 1, 2,
|
||||||
|
|
||||||
|
/*80 RCTL LFT DWN RGT PRT KSTN VDN VUP MICM HPFN */
|
||||||
|
2, 3, 3, 3, 3, 3, 0, 0, 1, 1,
|
||||||
|
|
||||||
|
/*90 ARMC LB1 LB2 LB3 LB4 LB5 LB6 LOGO LIDL LIDR */
|
||||||
|
2, 4, 4, 5, 6, 7, 7, 0, 0, 3,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static byte[] packet4Zone = new byte[]
|
||||||
|
{
|
||||||
|
/*01 Z1 Z2 Z3 Z4 NA NA KeyZone */
|
||||||
|
0, 1, 2, 3, 0, 0,
|
||||||
|
|
||||||
|
/*02 RR R RM LM L LL LighBar */
|
||||||
|
7, 7, 6, 5, 4, 4,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public static void ApplyDirect(Color[] color, bool init = false)
|
||||||
|
{
|
||||||
|
const byte keySet = 167;
|
||||||
|
const byte ledCount = 178;
|
||||||
|
const ushort mapSize = 3 * ledCount;
|
||||||
|
const byte ledsPerPacket = 16;
|
||||||
|
|
||||||
|
byte[] buffer = new byte[64];
|
||||||
|
byte[] keyBuf = new byte[mapSize];
|
||||||
|
|
||||||
|
buffer[0] = AsusHid.AURA_ID;
|
||||||
|
buffer[1] = 0xbc;
|
||||||
|
buffer[2] = 0;
|
||||||
|
buffer[3] = 1;
|
||||||
|
buffer[4] = 1;
|
||||||
|
buffer[5] = 1;
|
||||||
|
buffer[6] = 0;
|
||||||
|
buffer[7] = 0x10;
|
||||||
|
|
||||||
|
if (init)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
AsusHid.WriteAura(new byte[] { AsusHid.AURA_ID, 0xbc });
|
||||||
|
}
|
||||||
|
|
||||||
|
Array.Clear(keyBuf, 0, keyBuf.Length);
|
||||||
|
|
||||||
|
if (!isStrix4Zone) // per key
|
||||||
|
{
|
||||||
|
for (int ledIndex = 0; ledIndex < packetMap.Count(); ledIndex++)
|
||||||
|
{
|
||||||
|
ushort offset = (ushort)(3 * packetMap[ledIndex]);
|
||||||
|
byte zone = packetZone[ledIndex];
|
||||||
|
|
||||||
|
keyBuf[offset] = color[zone].R;
|
||||||
|
keyBuf[offset + 1] = color[zone].G;
|
||||||
|
keyBuf[offset + 2] = color[zone].B;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < keySet; i += ledsPerPacket)
|
||||||
|
{
|
||||||
|
byte ledsRemaining = (byte)(keySet - i);
|
||||||
|
|
||||||
|
if (ledsRemaining < ledsPerPacket)
|
||||||
|
{
|
||||||
|
buffer[7] = ledsRemaining;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[6] = (byte)i;
|
||||||
|
Buffer.BlockCopy(keyBuf, 3 * i, buffer, 9, 3 * buffer[7]);
|
||||||
|
AsusHid.WriteAura(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[4] = 0x04;
|
||||||
|
buffer[5] = 0x00;
|
||||||
|
buffer[6] = 0x00;
|
||||||
|
buffer[7] = 0x00;
|
||||||
|
|
||||||
|
if (isStrix4Zone) { // per zone
|
||||||
|
var leds_4_zone = packet4Zone.Count();
|
||||||
|
for (int ledIndex = 0; ledIndex < leds_4_zone; ledIndex++)
|
||||||
|
{
|
||||||
|
byte zone = packet4Zone[ledIndex];
|
||||||
|
keyBuf[ledIndex * 3] = color[zone].R;
|
||||||
|
keyBuf[ledIndex * 3 + 1] = color[zone].G;
|
||||||
|
keyBuf[ledIndex * 3 + 2] = color[zone].B;
|
||||||
|
}
|
||||||
|
Buffer.BlockCopy(keyBuf, 0, buffer, 9, 3 * leds_4_zone);
|
||||||
|
AsusHid.WriteAura(buffer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Buffer.BlockCopy(keyBuf, 3 * keySet, buffer, 9, 3 * (ledCount - keySet));
|
||||||
|
AsusHid.WriteAura(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ApplyColor(Color[] color, bool init = false)
|
|
||||||
|
public static void ApplyColor(Color color, bool init = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (isACPI)
|
if (isACPI)
|
||||||
{
|
{
|
||||||
Program.acpi.TUFKeyboardRGB(0, color[0], 0, null);
|
Program.acpi.TUFKeyboardRGB(0, color, 0, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isStrix && !isOldHeatmap)
|
if (isStrix && !isOldHeatmap)
|
||||||
{
|
{
|
||||||
byte[] msg = new byte[0x40];
|
ApplyDirect(Enumerable.Repeat(color, AURA_ZONES).ToArray(), init);
|
||||||
|
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 < 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AsusHid.WriteAura(AuraMessage(0, color[0], color[0], 0));
|
AsusHid.WriteAura(AuraMessage(0, color, color, 0));
|
||||||
AsusHid.WriteAura(MESSAGE_SET);
|
AsusHid.WriteAura(MESSAGE_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +562,7 @@ namespace GHelper.USB
|
|||||||
{
|
{
|
||||||
CustomRGB.ApplyAmbient(true);
|
CustomRGB.ApplyAmbient(true);
|
||||||
timer.Enabled = true;
|
timer.Enabled = true;
|
||||||
timer.Interval = 120;
|
timer.Interval = 100;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,33 +627,32 @@ namespace GHelper.USB
|
|||||||
bound.Y += bound.Height / 3;
|
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
|
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, 512, 288);
|
Bitmap screen_low;
|
||||||
Bitmap screeb_pxl;
|
Bitmap screeb_pxl;
|
||||||
|
|
||||||
if (isStrix) //laptop with lightbar
|
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
|
screen_low = AmbientData.CamptureScreen(bound, 512, 288); //quality decreases greatly if it is less 512
|
||||||
|
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_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));
|
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[4].RGB = ColorUtils.HSV.UpSaturation(screeb_pxl.GetPixel(1, 1)); // left bck
|
||||||
AmbientData.Colors[11].RGB = ColorUtils.HSV.UpSaturation(screeb_pxl.GetPixel(1, 1)); // left bck
|
AmbientData.Colors[5].RGB = ColorUtils.HSV.UpSaturation(mid_left); // center left
|
||||||
|
AmbientData.Colors[6].RGB = ColorUtils.HSV.UpSaturation(mid_right); // center right
|
||||||
AmbientData.Colors[7].RGB = AmbientData.Colors[6].RGB; // right
|
AmbientData.Colors[7].RGB = ColorUtils.HSV.UpSaturation(screeb_pxl.GetPixel(3, 1)); // right bck
|
||||||
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
|
for (int i = 0; i < 4; i++) // keyboard
|
||||||
AmbientData.Colors[i].RGB = ColorUtils.HSV.UpSaturation(screeb_pxl.GetPixel(i, 0));
|
AmbientData.Colors[i].RGB = ColorUtils.HSV.UpSaturation(screeb_pxl.GetPixel(i, 0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
zones = 1;
|
||||||
|
screen_low = AmbientData.CamptureScreen(bound, 256, 144);
|
||||||
screeb_pxl = AmbientData.ResizeImage(screen_low, 1, 1);
|
screeb_pxl = AmbientData.ResizeImage(screen_low, 1, 1);
|
||||||
var average = ColorUtils.HSV.UpSaturation(screeb_pxl.GetPixel(0, 0), (float)0.3);
|
AmbientData.Colors[0].RGB = ColorUtils.HSV.UpSaturation(screeb_pxl.GetPixel(0, 0), (float)0.3);
|
||||||
for (int i = 0; i < 4; i++) //just color transfer from the bottom screen on keyboard
|
|
||||||
AmbientData.Colors[i].RGB = average;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -550,15 +662,18 @@ namespace GHelper.USB
|
|||||||
|
|
||||||
bool is_fresh = false;
|
bool is_fresh = false;
|
||||||
|
|
||||||
for (int i = 0; i < AURA_ZONES; i++)
|
for (int i = 0; i < zones; i++)
|
||||||
{
|
{
|
||||||
if (AmbientData.result[i].ToArgb() != AmbientData.Colors[i].RGB.ToArgb())
|
if (AmbientData.result[i].ToArgb() != AmbientData.Colors[i].RGB.ToArgb()) is_fresh = true;
|
||||||
is_fresh = true;
|
|
||||||
AmbientData.result[i] = AmbientData.Colors[i].RGB;
|
AmbientData.result[i] = AmbientData.Colors[i].RGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_fresh)
|
if (is_fresh)
|
||||||
ApplyColor(AmbientData.result, init);
|
{
|
||||||
|
if (isStrix) ApplyDirect(AmbientData.result, init);
|
||||||
|
else ApplyColor(AmbientData.result[0], init);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class AmbientData
|
static class AmbientData
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ To disable automatic touchpad toggling when laptop enters / leaves tablet mode
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Extra Keybindings
|
### Extra Keybindings
|
||||||
- ``Ctrl + Shift + F5`` - Toggle Performance Modes
|
- ``Ctrl + Shift + F5`` / ``Ctrl + Shift + Alt + F5`` - Toggle Performance Modes
|
||||||
- ``Ctrl + Shift + F12`` - Open G-Helper window
|
- ``Ctrl + Shift + F12`` - Open G-Helper window
|
||||||
- ``Ctrl + M1 / M2`` - Screen brightness Down / Up
|
- ``Ctrl + M1 / M2`` - Screen brightness Down / Up
|
||||||
- ``Shift + M1 / M2`` - Backlight brightness Down / Up
|
- ``Shift + M1 / M2`` - Backlight brightness Down / Up
|
||||||
|
|||||||
Reference in New Issue
Block a user