mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
XGM fix for HidSharp
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using GHelper.Gpu;
|
using GHelper.Gpu;
|
||||||
using GHelper.Helpers;
|
using GHelper.Helpers;
|
||||||
using GHelper.Input;
|
using GHelper.Input;
|
||||||
using Microsoft.VisualBasic.Devices;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -214,7 +212,7 @@ namespace GHelper.USB
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (Mode == AuraMode.HEATMAP)
|
if (Mode == AuraMode.HEATMAP)
|
||||||
{
|
{
|
||||||
CustomRGB.ApplyHeatmap();
|
CustomRGB.ApplyHeatmap();
|
||||||
}
|
}
|
||||||
else if (Mode == AuraMode.AMBIENT)
|
else if (Mode == AuraMode.AMBIENT)
|
||||||
@@ -267,7 +265,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);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -361,7 +359,8 @@ namespace GHelper.USB
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ApplyColor(Color color, bool init = false) {
|
public static void ApplyColor(Color color, bool init = false)
|
||||||
|
{
|
||||||
Color[] color_list = Enumerable.Repeat(color, 0x12).ToArray();
|
Color[] color_list = Enumerable.Repeat(color, 0x12).ToArray();
|
||||||
ApplyColor(color_list, init);
|
ApplyColor(color_list, init);
|
||||||
}
|
}
|
||||||
@@ -470,7 +469,8 @@ namespace GHelper.USB
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class CustomRGB {
|
public static class CustomRGB
|
||||||
|
{
|
||||||
|
|
||||||
public static void ApplyGPUColor()
|
public static void ApplyGPUColor()
|
||||||
{
|
{
|
||||||
@@ -538,7 +538,7 @@ namespace GHelper.USB
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
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.7);
|
var average = 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
|
for (int i = 0; i < 4; i++) //just color transfer from the bottom screen on keyboard
|
||||||
AmbientData.Colors[i].RGB = average;
|
AmbientData.Colors[i].RGB = average;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// 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
|
||||||
@@ -9,30 +8,37 @@ namespace GHelper.USB
|
|||||||
public static class XGM
|
public static class XGM
|
||||||
{
|
{
|
||||||
const int XGM_ID = 0x1970;
|
const int XGM_ID = 0x1970;
|
||||||
public const int ASUS_ID = 0x0b05;
|
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.Write(payload);
|
hidStream.SetFeature(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)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"Error accessing HID device: {ex.Message}");
|
Logger.WriteLine($"Error accessing XGM device: {ex}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
|
|||||||
Reference in New Issue
Block a user