Skip to content

Commit d012c9e

Browse files
committed
XGM USB device detection cleanup
1 parent 2082cad commit d012c9e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

app/USB/XGM.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ public static class XGM
1010
{
1111
const byte XGM_REPORT_ID = 0x5e;
1212
const int ASUS_ID = 0x0b05;
13-
static readonly int[] deviceIds = { 0x1970, 0x1a9a, 0x1C29};
13+
static readonly int[] deviceIds = { 0x1970, 0x1a9a, 0x1C29, 0x19B6};
1414

1515
public static HidDevice? GetDevice()
1616
{
1717
try
1818
{
19+
/*
1920
var devices = DeviceList.Local.GetHidDevices(ASUS_ID).Where(device =>
2021
deviceIds.Contains(device.ProductID) &&
21-
device.CanOpen);
22+
device.CanOpen &&
23+
device.GetMaxFeatureReportLength() >= 300);
2224
23-
/*
2425
foreach (var device in devices)
2526
{
2627
var report = device.GetReportDescriptor().TryGetReport(ReportType.Feature, XGM_REPORT_ID, out _);
2728
Logger.WriteLine($"Found XGM Device: PID={device.ProductID}, MaxFeatureReportLength={device.GetMaxFeatureReportLength()}, Report={report}");
2829
}
2930
*/
30-
3131
return DeviceList.Local.GetHidDevices(ASUS_ID).FirstOrDefault(device =>
3232
deviceIds.Contains(device.ProductID) &&
3333
device.CanOpen &&
34-
device.GetReportDescriptor().TryGetReport(ReportType.Feature, XGM_REPORT_ID, out _));
34+
device.GetMaxFeatureReportLength() >= 300);
3535
}
3636
catch (Exception ex)
3737
{
@@ -58,7 +58,7 @@ public static void Write(byte[] data)
5858

5959
using (HidStream hidStream = device.Open())
6060
{
61-
byte[] payload = new byte[device.GetMaxFeatureReportLength()];
61+
byte[] payload = new byte[300];
6262
data.CopyTo(payload, 0);
6363
hidStream.SetFeature(payload);
6464
Logger.WriteLine($"XGM-{device.ProductID}|{device.GetMaxFeatureReportLength()}:{BitConverter.ToString(data)}");

0 commit comments

Comments
 (0)