From c788410b261496aa17988cafa17545612a4552fc Mon Sep 17 00:00:00 2001 From: Sparronator9999 <86388887+Sparronator9999@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:07:39 +1100 Subject: [PATCH] Config updates, including new Manufacturer field - Add required computer manufacturer field - if your config doesn't load anymore, try copying the value from one of the upstream configs - Update computer model and manufacturer in config when using EC-to-config feature - Change the default charge limit to disabled on all configs (accidentally left at 60% - the value I use on my laptop) - Change default fan curve selection to Default (instead of Custom) on the GF63 Thin 11SC config --- Configs/MSI-10th-gen-or-newer-nokeylight.xml | 3 +- Configs/MSI-10th-gen-or-newer.xml | 3 +- Configs/MSI-9th-gen-or-older.xml | 5 +- Configs/MSI-GF63-Thin-11SC.xml | 9 +-- YAMDCC.Config/YAMDCC_Config.cs | 9 ++- YAMDCC.Service/FanControlService.cs | 65 +++++++++++++++++++- 6 files changed, 83 insertions(+), 11 deletions(-) diff --git a/Configs/MSI-10th-gen-or-newer-nokeylight.xml b/Configs/MSI-10th-gen-or-newer-nokeylight.xml index 6dbd2bf..1ebabd4 100644 --- a/Configs/MSI-10th-gen-or-newer-nokeylight.xml +++ b/Configs/MSI-10th-gen-or-newer-nokeylight.xml @@ -1,6 +1,7 @@ - MSI laptop - generic 10th-gen Intel (or newer), sans keyboard backlight control + Micro-Star International Co., Ltd. + ~Generic: 10th-gen Intel (or newer) - no keyboard backlight support Sparronator9999 diff --git a/Configs/MSI-10th-gen-or-newer.xml b/Configs/MSI-10th-gen-or-newer.xml index c132d4a..f7c0aea 100644 --- a/Configs/MSI-10th-gen-or-newer.xml +++ b/Configs/MSI-10th-gen-or-newer.xml @@ -1,6 +1,7 @@ - MSI laptop - generic 10th-gen Intel (or newer) + Micro-Star International Co., Ltd. + ~Generic: 10th-gen Intel (or newer) Sparronator9999 diff --git a/Configs/MSI-9th-gen-or-older.xml b/Configs/MSI-9th-gen-or-older.xml index 63bf897..cb3ccb3 100644 --- a/Configs/MSI-9th-gen-or-older.xml +++ b/Configs/MSI-9th-gen-or-older.xml @@ -1,6 +1,7 @@ - MSI laptop - generic 9th-gen Intel (or older) + Micro-Star International Co., Ltd. + ~Generic: 9th-gen Intel (or older) Sparronator9999 @@ -180,7 +181,7 @@ 239 128 228 - 60 + 0 243 diff --git a/Configs/MSI-GF63-Thin-11SC.xml b/Configs/MSI-GF63-Thin-11SC.xml index 9fbc74a..c5839dc 100644 --- a/Configs/MSI-GF63-Thin-11SC.xml +++ b/Configs/MSI-GF63-Thin-11SC.xml @@ -1,13 +1,14 @@ - MSI GF63 Thin 11SC + Micro-Star International Co., Ltd. + GF63 Thin 11SC Sparronator9999 CPU Fan 0 100 - 1 + 0 113 104 @@ -132,7 +133,7 @@ GPU Fan 0 100 - 1 + 0 137 128 @@ -262,7 +263,7 @@ 215 128 228 - 60 + 0 210 diff --git a/YAMDCC.Config/YAMDCC_Config.cs b/YAMDCC.Config/YAMDCC_Config.cs index 6a3281b..43d003e 100644 --- a/YAMDCC.Config/YAMDCC_Config.cs +++ b/YAMDCC.Config/YAMDCC_Config.cs @@ -39,6 +39,12 @@ public sealed class YAMDCC_Config [XmlAttribute] public int Ver { get; set; } + /// + /// The manufacturer of the laptop the config was made for. + /// + [XmlElement] + public string Manufacturer { get; set; } + /// /// The laptop model the config was made for. /// @@ -173,7 +179,8 @@ private bool IsValid() return false; } - if (string.IsNullOrEmpty(Model) || + if (string.IsNullOrEmpty(Manufacturer) || + string.IsNullOrEmpty(Model) || string.IsNullOrEmpty(Author)) { return false; diff --git a/YAMDCC.Service/FanControlService.cs b/YAMDCC.Service/FanControlService.cs index 70d1e81..7e0eb16 100644 --- a/YAMDCC.Service/FanControlService.cs +++ b/YAMDCC.Service/FanControlService.cs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License along with // YAMDCC. If not, see . +using Microsoft.Win32; using System; using System.ComponentModel; using System.Globalization; @@ -735,9 +736,32 @@ private void FanCurveECToConf() try { + Log.Info("Getting computer manufacturer and model..."); + + string pcManufacturer = GetComputerManufacturer(), + pcModel = GetComputerModel(); + + if (string.IsNullOrEmpty(pcManufacturer)) + { + Log.Error("Failed to get computer manufacturer!"); + } + else + { + Config.Manufacturer = pcManufacturer.Trim(); + } + + if (string.IsNullOrEmpty(pcModel)) + { + Log.Error("Failed to get computer model!"); + } + else + { + Config.Model = pcModel.Trim(); + } + for (int i = 0; i < Config.FanConfs.Length; i++) { - Log.Debug($"Getting fan curve from EC ({i + 1}/{Config.FanConfs.Length})..."); + Log.Info($"Getting fan curve from EC ({i + 1}/{Config.FanConfs.Length})..."); FanConf cfg = Config.FanConfs[i]; @@ -785,7 +809,7 @@ private void FanCurveECToConf() } } - Log.Debug("Saving config..."); + Log.Info("Saving config..."); Config.Save(Paths.CurrentConfig); FileStream fs = File.Create(Paths.ECToConfSuccess); @@ -797,5 +821,42 @@ private void FanCurveECToConf() fs.Close(); } } + + /// + /// Gets the computer model name from registry. + /// + /// + /// The computer model if the function succeeds, + /// otherwise null. + /// + private static string GetComputerModel() + { + return GetBIOSRegValue("SystemProductName"); + } + + /// + /// Gets the computer manufacturer from registry. + /// + /// + /// The computer manufacturer if the function succeeds, + /// otherwise null. + /// + private static string GetComputerManufacturer() + { + return GetBIOSRegValue("SystemManufacturer"); + } + + private static string GetBIOSRegValue(string name) + { + RegistryKey biosKey = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\BIOS"); + try + { + return (string)biosKey?.GetValue(name, null); + } + finally + { + biosKey?.Close(); + } + } } }