mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
AsusHID tweaks
This commit is contained in:
@@ -17,35 +17,34 @@ public static class AsusHid
|
|||||||
public static HidStream FindHidStream(byte reportId, int minFeatureLength = 1)
|
public static HidStream FindHidStream(byte reportId, int minFeatureLength = 1)
|
||||||
{
|
{
|
||||||
HidDeviceLoader loader = new HidDeviceLoader();
|
HidDeviceLoader loader = new HidDeviceLoader();
|
||||||
var deviceList = loader.GetDevices(ASUS_ID).Where(device => deviceIds.Contains(device.ProductID));
|
try
|
||||||
|
{
|
||||||
foreach (var device in deviceList) if (device.CanOpen)
|
var deviceList = loader.GetDevices(ASUS_ID).Where(device => deviceIds.Contains(device.ProductID) && device.CanOpen);
|
||||||
|
foreach (var device in deviceList)
|
||||||
{
|
{
|
||||||
try
|
var config = new OpenConfiguration();
|
||||||
{
|
config.SetOption(OpenOption.Interruptible, false);
|
||||||
var config = new OpenConfiguration();
|
config.SetOption(OpenOption.Exclusive, false);
|
||||||
config.SetOption(OpenOption.Interruptible, false);
|
config.SetOption(OpenOption.Priority, 10);
|
||||||
config.SetOption(OpenOption.Exclusive, false);
|
HidStream hidStream = device.Open();
|
||||||
config.SetOption(OpenOption.Priority, 10);
|
|
||||||
HidStream hidStream = device.Open();
|
|
||||||
|
|
||||||
if (device.GetMaxFeatureReportLength() >= minFeatureLength)
|
if (device.GetMaxFeatureReportLength() >= minFeatureLength)
|
||||||
|
{
|
||||||
|
var reportDescriptor = device.GetReportDescriptor();
|
||||||
|
if (reportDescriptor.TryGetReport(ReportType.Feature, reportId, out _))
|
||||||
{
|
{
|
||||||
var reportDescriptor = device.GetReportDescriptor();
|
return hidStream;
|
||||||
if (reportDescriptor.TryGetReport(ReportType.Feature, reportId, out _))
|
|
||||||
{
|
|
||||||
return hidStream;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hidStream.Close();
|
hidStream.Close();
|
||||||
hidStream.Dispose();
|
hidStream.Dispose();
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine($"Error accessing HID device: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"Error accessing HID device: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user