Aura tweaks

This commit is contained in:
Serge
2023-05-14 10:28:48 +02:00
parent 608b8571d4
commit fd3a139c47
3 changed files with 17 additions and 8 deletions

View File

@@ -161,13 +161,14 @@ namespace GHelper
Color2 = Color.FromArgb(colorCode); Color2 = Color.FromArgb(colorCode);
} }
private static IEnumerable<HidDevice> GetHidDevices(int[] deviceIds)
private static IEnumerable<HidDevice> GetHidDevices(int[] deviceIds, int minInput = 18)
{ {
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray(); HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
foreach (HidDevice device in HidDeviceList) foreach (HidDevice device in HidDeviceList)
if (device.IsConnected if (device.IsConnected
&& device.Capabilities.FeatureReportByteLength >= 64 && device.Capabilities.FeatureReportByteLength > 0
&& device.Capabilities.InputReportByteLength >= 12) // && device.Capabilities.InputReportByteLength >= minInput) //
yield return device; yield return device;
} }
@@ -275,7 +276,11 @@ namespace GHelper
byte[] msg = AuraMessage(Mode, Color1, Color2, _speed); byte[] msg = AuraMessage(Mode, Color1, Color2, _speed);
var devices = GetHidDevices(deviceIds); var devices = GetHidDevices(deviceIds);
//if (devices.Count() > 0) Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg)); if (devices.Count() == 0)
{
Logger.WriteLine("USB-KB : not found");
GetHidDevices(deviceIds, 0);
}
foreach (HidDevice device in devices) foreach (HidDevice device in devices)
{ {

View File

@@ -117,10 +117,10 @@ public class NvidiaGpuControl : IGpuControl
{ {
try try
{ {
string script = @"$device = Get-PnpDevice | Where-Object { $_.FriendlyName -imatch 'NVIDIA' -and $_.Class -eq 'Display' }; Disable-PnpDevice $device.InstanceId -Confirm:$false; Start-Sleep -Seconds 2; Enable-PnpDevice $device.InstanceId -Confirm:$false"; string script = @"$device = Get-PnpDevice | Where-Object { $_.FriendlyName -imatch 'NVIDIA' -and $_.Class -eq 'Display' }; Disable-PnpDevice $device.InstanceId -Confirm:$false; Start-Sleep -Seconds 3; Enable-PnpDevice $device.InstanceId -Confirm:$false";
Logger.WriteLine(script); Logger.WriteLine(script);
RunCMD("powershell", script); RunCMD("powershell", script);
Thread.Sleep(2000); //Thread.Sleep(2000);
return true; return true;
} }
catch (Exception ex ) catch (Exception ex )

View File

@@ -115,10 +115,14 @@ public static class HardwareControl
public static bool IsUsedGPU(int threshold = 20) public static bool IsUsedGPU(int threshold = 20)
{ {
if (GetGpuUse() > threshold) int use = GetGpuUse();
Logger.WriteLine("GPU usage: " + use);
if (use > threshold)
{ {
Thread.Sleep(1000); Thread.Sleep(1000);
return (GetGpuUse() > threshold); use = GetGpuUse();
Logger.WriteLine("GPU usage: " + use);
return (use > threshold);
} }
return false; return false;
} }