diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 2f95adb4..2f33845a 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -96,8 +96,15 @@ public static class AppConfig public static int Get(string name, int empty = -1) { if (config.ContainsKey(name)) + { + //Debug.WriteLine(name); return int.Parse(config[name].ToString()); - else return empty; + } + else + { + //Debug.WriteLine(name + "E"); + return empty; + } } public static bool Is(string name) diff --git a/app/AsusUSB.cs b/app/AsusUSB.cs index 29539fd2..e01b9929 100644 --- a/app/AsusUSB.cs +++ b/app/AsusUSB.cs @@ -1,6 +1,5 @@ using GHelper.Helpers; using HidLibrary; -using System.Drawing; using System.Text; namespace GHelper @@ -457,7 +456,13 @@ namespace GHelper } //Logger.WriteLine(BitConverter.ToString(msg)); - if (init) auraDevice.Write(new byte[] { AURA_HID_ID ,0xbc}); + if (init) + { + auraDevice.Write(AuraMessage(0,color,color, 0xe1)); + auraDevice.WriteFeatureData(MESSAGE_APPLY); + auraDevice.WriteFeatureData(MESSAGE_SET); + auraDevice.Write(new byte[] { AURA_HID_ID, 0xbc }); + } auraDevice.Write(msg); } diff --git a/app/AutoUpdate/AutoUpdateControl.cs b/app/AutoUpdate/AutoUpdateControl.cs index dfd10d91..e0759e38 100644 --- a/app/AutoUpdate/AutoUpdateControl.cs +++ b/app/AutoUpdate/AutoUpdateControl.cs @@ -41,6 +41,8 @@ namespace GHelper.AutoUpdate async void CheckForUpdatesAsync() { + if (AppConfig.Is("skip_updates")) return; + try { diff --git a/app/Fans.cs b/app/Fans.cs index 51ea7c30..b29c79f4 100644 --- a/app/Fans.cs +++ b/app/Fans.cs @@ -59,7 +59,7 @@ namespace GHelper InitTheme(true); MinRPM = 18; - MaxRPM = HardwareControl.GetFanMax(); + MaxRPM = HardwareControl.fanMax; labelTip.Visible = false; labelTip.BackColor = Color.Transparent; diff --git a/app/GHelper.csproj b/app/GHelper.csproj index 8713f123..b8e2b4a4 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -15,7 +15,7 @@ AnyCPU False True - 0.102 + 0.103 diff --git a/app/HardwareControl.cs b/app/HardwareControl.cs index 4d25b365..27bbaf0c 100644 --- a/app/HardwareControl.cs +++ b/app/HardwareControl.cs @@ -9,6 +9,10 @@ using System.Management; public static class HardwareControl { + + const int DEFAULT_FAN_MAX = 58; + const int INADEQUATE_MAX = 80; + public static IGpuControl? GpuControl; public static float? cpuTemp = -1; @@ -26,21 +30,48 @@ public static class HardwareControl static long lastUpdate; - public static int GetFanMax() - { - int max = 58; - int configMax = AppConfig.Get("fan_max"); - if (configMax > 80) configMax = 0; // skipping inadvequate settings + static int _fanMax = DEFAULT_FAN_MAX; + static bool _fanRpm = false; - if (AppConfig.ContainsModel("401")) max = 72; - else if (AppConfig.ContainsModel("503")) max = 68; - return Math.Max(max, configMax); + public static int fanMax + { + get + { + return _fanMax; + } + set + { + AppConfig.Set("fan_max", value); + _fanMax = value; + } } - public static void SetFanMax(int fan) + public static bool fanRpm { - AppConfig.Set("fan_max", fan); + get + { + return _fanRpm; + } + set + { + AppConfig.Set("fan_rpm", value ? 1 : 0); + _fanRpm = value; + } } + + static HardwareControl() + { + _fanMax = AppConfig.Get("fan_max"); + if (_fanMax > INADEQUATE_MAX) _fanMax = -1; // skipping inadvequate settings + + if (_fanMax < 0 && AppConfig.ContainsModel("401")) _fanMax = 72; + if (_fanMax < 0 && AppConfig.ContainsModel("503")) _fanMax = 68; + if (_fanMax < 0) _fanMax = DEFAULT_FAN_MAX; + + _fanRpm = AppConfig.Is("fan_rpm"); + + } + public static string FormatFan(int fan) { // fix for old models @@ -50,10 +81,9 @@ public static class HardwareControl if (fan <= 0 || fan > 100) return null; //nothing reasonable } - int fanMax = GetFanMax(); - if (fan > fanMax && fan < 80) SetFanMax(fan); + if (fan > fanMax && fan <= INADEQUATE_MAX) fanMax = fan; - if (AppConfig.Is("fan_rpm")) + if (fanRpm) return GHelper.Properties.Strings.FanSpeed + ": " + (fan * 100).ToString() + "RPM"; else return GHelper.Properties.Strings.FanSpeed + ": " + Math.Min(Math.Round((float)fan / fanMax * 100), 100).ToString() + "%"; // relatively to 6000 rpm diff --git a/app/Peripherals/PeripheralsProvider.cs b/app/Peripherals/PeripheralsProvider.cs index 3c23576a..c2edb5f9 100644 --- a/app/Peripherals/PeripheralsProvider.cs +++ b/app/Peripherals/PeripheralsProvider.cs @@ -12,6 +12,14 @@ namespace GHelper.Peripherals public static event EventHandler? DeviceChanged; + private static System.Timers.Timer timer = new System.Timers.Timer(1000); + + static PeripheralsProvider() + { + timer.Elapsed += DeviceTimer_Elapsed; + } + + private static long lastRefresh; public static bool IsMouseConnected() @@ -203,8 +211,14 @@ namespace GHelper.Peripherals private static void Device_Changed(object? sender, HidSharp.DeviceListChangedEventArgs e) { + timer.Start(); + } + + private static void DeviceTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e) + { + timer.Stop(); Logger.WriteLine("HID Device Event: Checking for new ASUS Mice"); - Task task = Task.Run((Action)DetectAllAsusMice); + DetectAllAsusMice(); } } } diff --git a/app/Properties/Strings.pl.resx b/app/Properties/Strings.pl.resx index 5d320f72..7be4cbd6 100644 --- a/app/Properties/Strings.pl.resx +++ b/app/Properties/Strings.pl.resx @@ -163,22 +163,22 @@ Uruchomione usługi Asus - Battery State + Stan baterii Oddychanie - Clockwise + W prawo Pętla kolorów - Comet + Kometa - Counterclockwise + W lewo Szybka @@ -190,10 +190,10 @@ Tęcza - Random + Losowo - React + Tryb reaktywny Powolna @@ -285,7 +285,7 @@ Nadal chcesz kontynuować? Tryb wyświetlania NVIDIA nie jest ustawiony na Optimus - Energy Settings + Ustawienia zasilania Ustawienia @@ -354,7 +354,7 @@ Nadal chcesz kontynuować? Temperatura docelowa - High + Wysoka Ustawienia klawiszy skrótów @@ -381,13 +381,13 @@ Nadal chcesz kontynuować? Lightbar - Lighting + Oświetlenie Logo - Low + Niska Wizualizer muzyki @@ -423,28 +423,28 @@ Nadal chcesz kontynuować? Częstotliwość odświeżania 60 Hz dla oszczędzania baterii - Minute + min. - Minutes + min. - Angle Snapping + Korekcja kąta ruchu - Auto Power Off After + Przejście w tryb uśpienia po - Lift Off Distance + Wysokość reakcji sensora - Low Battery Warning at + Ostrzeżenie o niskim poziomie baterii - Performance + Wydajność - Synchronize with mouse + Synchronizuj z myszką Multizone @@ -453,7 +453,7 @@ Nadal chcesz kontynuować? Wyciszenie mikrofonu - Never + Nigdy Nowe aktualizacje @@ -462,7 +462,7 @@ Nadal chcesz kontynuować? Brak aktualizacji - Not Connected + Nie połączono Otwórz okno G-Helper @@ -486,7 +486,7 @@ Nadal chcesz kontynuować? Tryb zasilania - Peripherals + Urządzenia peryferyjne Obraz / GIF @@ -495,7 +495,7 @@ Nadal chcesz kontynuować? Odtwórz / Pauza - Polling Rate + Częstotliwość raportowania Limit mocy @@ -507,7 +507,7 @@ Nadal chcesz kontynuować? Zrzut ekranu - Profile + Profil Zamknij diff --git a/app/Properties/Strings.uk.resx b/app/Properties/Strings.uk.resx index 327179e8..80919d35 100644 --- a/app/Properties/Strings.uk.resx +++ b/app/Properties/Strings.uk.resx @@ -163,7 +163,7 @@ Кількість запущених сервісів Asus - Battery State + Стан батареї Дихання @@ -426,25 +426,25 @@ Minute - Minutes + Хвилини - Angle Snapping + Привʼязка по куту - Auto Power Off After + Авто-вимикання - Lift Off Distance + Відстань підйому - Low Battery Warning at + Попередження про низький заряд Performance - Synchronize with mouse + Синхронізувати з мишею Мультизони @@ -453,7 +453,7 @@ Вимкнути мікрофон - Never + Ніколи Є оновлення @@ -462,7 +462,7 @@ Немає оновлень - Not Connected + Не під'єднано Відкрити вікно G-Helper @@ -486,7 +486,7 @@ Режим - Peripherals + Периферія Картинка / GIF @@ -495,7 +495,7 @@ Відтворення / Пауза - Polling Rate + Частота опитування Ліміти Потужності @@ -507,7 +507,7 @@ Print Screen - Profile + Профіль Вихід diff --git a/app/Properties/Strings.zh-CN.resx b/app/Properties/Strings.zh-CN.resx index ea7e1ff2..841b0405 100644 --- a/app/Properties/Strings.zh-CN.resx +++ b/app/Properties/Strings.zh-CN.resx @@ -163,22 +163,22 @@ 正在运行的 Asus 服务 - Battery State + 电池状态 呼吸 - Clockwise + 顺时针 彩色循环 - Comet + 彗星 - Counterclockwise + 逆时针 快速 @@ -190,10 +190,10 @@ 彩虹 - Random + 随机 - React + 触发 @@ -282,10 +282,10 @@ 确定还要继续吗? - nVIDIA显示模式尚未设置至Optimus + NVIDIA 显示模式未设置为自动切换 - Energy Settings + 电源设置 更多 @@ -318,7 +318,7 @@ 风扇 - 高级设置 + 风扇 + 电源 打开FnLock (无需按下FN使用FN+(F1-F12)热键) @@ -354,7 +354,7 @@ 温度目标 - High + 按键绑定 @@ -381,13 +381,13 @@ 灯条 - Lighting + 背光 徽标 - Low + 音频可视化器 @@ -423,28 +423,28 @@ 调整刷新率为60Hz以节省电量 - Minute + 分钟 - Minutes + 分组 - Angle Snapping + 角度校正 - Auto Power Off After + 自动关闭时间 - Lift Off Distance + 静默高度 - Low Battery Warning at + 低于该电量时警告 - Performance + 性能 - Synchronize with mouse + 和鼠标同步 多区域设置 @@ -453,7 +453,7 @@ 静音麦克风 - Never + 从不 有更新 @@ -462,7 +462,7 @@ 无更新 - Not Connected + 未连接 打开G-Helper窗口 @@ -480,13 +480,13 @@ 其他 - OD + 超频 性能模式 - Peripherals + 外设 图片/动图 @@ -495,7 +495,7 @@ 播放/暂停 - Polling Rate + 回报率 功率限制 @@ -507,7 +507,7 @@ 截图 - Profile + 配置 退出 @@ -564,7 +564,7 @@ 切换 Aura 模式 - 自动启用外接显示器模式 + 自动切换合盖模式 切换 Fn 锁定 diff --git a/app/Settings.cs b/app/Settings.cs index 9248ee7a..6cb45584 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -530,7 +530,7 @@ namespace GHelper private void LabelCPUFan_Click(object? sender, EventArgs e) { - AppConfig.Set("fan_rpm", (AppConfig.Get("fan_rpm") == 1) ? 0 : 1); + HardwareControl.fanRpm = !HardwareControl.fanRpm; RefreshSensors(true); } @@ -768,6 +768,7 @@ namespace GHelper this.Hide(); if (fans != null && fans.Text != "") fans.Close(); if (keyb != null && keyb.Text != "") keyb.Close(); + if (updates != null && updates.Text != "") updates.Close(); }