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:
@@ -1,8 +1,6 @@
|
||||
using GHelper.Gpu;
|
||||
using GHelper.Helpers;
|
||||
using GHelper.Input;
|
||||
using Microsoft.VisualBasic.Devices;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -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();
|
||||
ApplyColor(color_list, init);
|
||||
}
|
||||
@@ -470,7 +469,8 @@ namespace GHelper.USB
|
||||
}
|
||||
|
||||
|
||||
public static class CustomRGB {
|
||||
public static class CustomRGB
|
||||
{
|
||||
|
||||
public static void ApplyGPUColor()
|
||||
{
|
||||
@@ -538,7 +538,7 @@ namespace GHelper.USB
|
||||
else
|
||||
{
|
||||
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
|
||||
AmbientData.Colors[i].RGB = average;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Reference : thanks to https://github.com/RomanYazvinsky/ for initial discovery of XGM payloads
|
||||
|
||||
using HidSharp;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace GHelper.USB
|
||||
@@ -9,30 +8,37 @@ namespace GHelper.USB
|
||||
public static class XGM
|
||||
{
|
||||
const int XGM_ID = 0x1970;
|
||||
public const int ASUS_ID = 0x0b05;
|
||||
const int ASUS_ID = 0x0b05;
|
||||
|
||||
public static void Write(byte[] data)
|
||||
{
|
||||
HidDeviceLoader loader = new HidDeviceLoader();
|
||||
HidDevice device = loader.GetDevices(ASUS_ID, XGM_ID).Where(device => device.GetMaxFeatureReportLength() >= 300).FirstOrDefault();
|
||||
if (device is null) return;
|
||||
|
||||
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())
|
||||
{
|
||||
var payload = new byte[300];
|
||||
Array.Copy(data, payload, data.Length);
|
||||
|
||||
hidStream.Write(payload);
|
||||
Logger.WriteLine("XGM " + device.ProductID + "|" + device.GetMaxFeatureReportLength() + ":" + BitConverter.ToString(data));
|
||||
hidStream.SetFeature(payload);
|
||||
Logger.WriteLine("XGM-" + device.ProductID + "|" + device.GetMaxFeatureReportLength() + ":" + BitConverter.ToString(data));
|
||||
|
||||
hidStream.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Error accessing HID device: {ex.Message}");
|
||||
Logger.WriteLine($"Error accessing XGM device: {ex}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
|
||||
Reference in New Issue
Block a user