From 1da838227dd033970d64f5bdb036f14906d10361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Mon, 19 Dec 2022 11:58:48 +0100 Subject: [PATCH] Require to acknowledge `Anti-Cheat` impact on `FanControl` --- FanControl/FanControlForm.cs | 63 ++++++++++++++++++++++++++++++++---- FanControl/FanController.cs | 17 ++++++++-- FanControl/Settings.cs | 11 +++++++ 3 files changed, 82 insertions(+), 9 deletions(-) diff --git a/FanControl/FanControlForm.cs b/FanControl/FanControlForm.cs index 8a80502..4b95720 100644 --- a/FanControl/FanControlForm.cs +++ b/FanControl/FanControlForm.cs @@ -55,18 +55,21 @@ namespace FanControl fanModeSelectMenu.Items.Add(item); } - setFanMode(Settings.Default.FanMode); - propertyGrid1.SelectedObject = fanControl; propertyGrid1.ExpandAllGridItems(); - notifyIcon.ShowBalloonTip(3000, Text, "Fan Control Started", ToolTipIcon.Info); - Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; Opacity = 0; } + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + setFanMode(Settings.Default.FanMode, !Settings.Default.AckAntiCheat); + notifyIcon.ShowBalloonTip(3000, Text, "Fan Control Started", ToolTipIcon.Info); + } + protected override void OnShown(EventArgs e) { base.OnShown(e); @@ -74,6 +77,36 @@ namespace FanControl Opacity = 100; } + private bool AckAntiCheat() + { + if (Settings.Default.AckAntiCheat && Settings.Default.EnableExperimentalFeatures) + return true; + + var result = MessageBox.Show( + String.Join("\n", + "WARNING!!!!", + "", + "Usage of SteamOS or Max Fan Curve might trigger anti-cheat protection in some games.", + "This might result in kicking from the application or even be banned.", + "", + "Ensure that you USE DEFAULT FAN when playing games with ANTI-CHEAT PROTECTION.", + "", + "CLICK YES TO ACKNOWLEDGE?", + "CLICK NO TO LEARN MORE." + ), Text, MessageBoxButtons.YesNo + ); + + if (result == DialogResult.Yes) + { + Settings.Default.AckAntiCheat = true; + return true; + } + + try { System.Diagnostics.Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev/#anti-cheat-and-antivirus-software"); } + catch { } + return false; + } + private void SystemEvents_PowerModeChanged(object sender, Microsoft.Win32.PowerModeChangedEventArgs e) { // Restore fan mode on resume @@ -84,8 +117,14 @@ namespace FanControl } } - private void setFanMode(FanMode mode) + private void setFanMode(FanMode mode, bool requireAck = true) { + if (mode != FanMode.Default && mode != fanControl.Mode) + { + if (requireAck && !AckAntiCheat()) + return; + } + fanControl.SetMode(mode); Settings.Default.FanMode = mode; @@ -157,8 +196,20 @@ namespace FanControl if (fanControl is null) return; - SharedData_Update(); + try + { + fanLoopTimer.Enabled = false; + SharedData_Update(); + } + finally + { + fanLoopTimer.Enabled = true; + } +#if DEBUG fanControl.Update(Visible); +#else + fanControl.Update(); +#endif } private void propertyGridUpdateTimer_Tick(object sender, EventArgs e) diff --git a/FanControl/FanController.cs b/FanControl/FanController.cs index ed6feae..d0b1f6a 100644 --- a/FanControl/FanController.cs +++ b/FanControl/FanController.cs @@ -17,7 +17,13 @@ namespace FanControl internal partial class FanController : IDisposable { [CategoryAttribute("Fan")] - public FanMode Mode { get; private set; } + public FanMode Mode { get; private set; } = FanMode.Default; + + [CategoryAttribute("Fan")] + public bool KernelDriversLoaded + { + get => Instance.UseKernelDrivers; + } [CategoryAttribute("Fan")] [NotifyParentProperty(true)] @@ -71,12 +77,13 @@ namespace FanControl return rpm; } + [Browsable(false)] public bool IsActive { get { return Vlv0100.IsOpen; } } - public void Update(bool visible) + public void Update(bool showForDefault = false) { var mutex = Instance.WaitGlobalMutex(200); if (mutex is null) @@ -88,9 +95,13 @@ namespace FanControl try { - if (Mode == FanMode.Default && !visible) + if (!Settings.Default.AckAntiCheat || Mode == FanMode.Default && !showForDefault) { Instance.UseKernelDrivers = false; + CurrentRPM = null; + DesiredRPM = 0; + foreach (var sensor in allSensors.Values) + sensor.Reset(); return; } else if (!Vlv0100.IsOpen) diff --git a/FanControl/Settings.cs b/FanControl/Settings.cs index 04ae3c4..776f67e 100644 --- a/FanControl/Settings.cs +++ b/FanControl/Settings.cs @@ -22,5 +22,16 @@ namespace FanControl get { return Get("AlwaysOnTop", true); } set { Set("AlwaysOnTop", value); } } + + public bool EnableExperimentalFeatures + { + get { return Instance.IsDEBUG; } + } + + public bool AckAntiCheat + { + get { return Get("AckAntiCheat", false); } + set { Set("AckAntiCheat", value); } + } } }