diff --git a/app/Ally/AllyControl.cs b/app/Ally/AllyControl.cs index d2141814..b29d2681 100644 --- a/app/Ally/AllyControl.cs +++ b/app/Ally/AllyControl.cs @@ -347,6 +347,7 @@ namespace GHelper.Ally if (!autoTDP && _mode != ControllerMode.Auto) return; float fps = amdControl.GetFPS(); + int? usage = 0; if (autoTDP && fpsLimit > 0 && fpsLimit <= 120) { @@ -377,7 +378,8 @@ namespace GHelper.Ally if (_mode == ControllerMode.Auto) { - ControllerMode newMode = (fps > 0) ? ControllerMode.Gamepad : ControllerMode.Mouse; + if (fps > 0) usage = amdControl.GetiGpuUse(); + ControllerMode newMode = (fps > 0 && usage > 15) ? ControllerMode.Gamepad : ControllerMode.Mouse; if (_applyMode != newMode) _autoCount++; else _autoCount = 0; @@ -386,7 +388,7 @@ namespace GHelper.Ally { _autoCount = 0; ApplyMode(newMode); - Logger.WriteLine($"Controller Mode {fps}: {newMode}"); + Logger.WriteLine($"Controller Mode (FPS={fps}, USAGE={usage}%): {newMode}"); } } diff --git a/app/Gpu/AMD/AmdGpuControl.cs b/app/Gpu/AMD/AmdGpuControl.cs index e10bf191..3f774203 100644 --- a/app/Gpu/AMD/AmdGpuControl.cs +++ b/app/Gpu/AMD/AmdGpuControl.cs @@ -119,6 +119,18 @@ public class AmdGpuControl : IGpuControl } + public int? GetiGpuUse() + { + if (_adlContextHandle == nint.Zero || _iGPU == null) return null; + if (ADL2_New_QueryPMLogData_Get(_adlContextHandle, ((ADLAdapterInfo)_iGPU).AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS) return null; + + ADLSingleSensorData gpuUsage = adlpmLogDataOutput.Sensors[(int)ADLSensorType.PMLOG_INFO_ACTIVITY_GFX]; + if (gpuUsage.Supported == 0) return null; + + return gpuUsage.Value; + + } + public int? GetGpuPower() { if (_adlContextHandle == nint.Zero || _iGPU == null) return null;