diff --git a/HandheldCompanion/Devices/IDevice.cs b/HandheldCompanion/Devices/IDevice.cs index 91423adf4..eb113cff1 100644 --- a/HandheldCompanion/Devices/IDevice.cs +++ b/HandheldCompanion/Devices/IDevice.cs @@ -189,7 +189,6 @@ private void GenericDeviceUpdated(PnPDevice device, Guid IntefaceGuid) public event KeyPressedEventHandler KeyPressed; public event KeyReleasedEventHandler KeyReleased; - public event PowerStatusChangedEventHandler PowerStatusChanged; public string ManufacturerName = string.Empty; public string ProductName = string.Empty; diff --git a/HandheldCompanion/Managers/DynamicLightingManager.cs b/HandheldCompanion/Managers/DynamicLightingManager.cs index 54a5a3f7e..e824242ec 100644 --- a/HandheldCompanion/Managers/DynamicLightingManager.cs +++ b/HandheldCompanion/Managers/DynamicLightingManager.cs @@ -73,9 +73,16 @@ public static void Start() // manage events SettingsManager.SettingValueChanged += SettingsManager_SettingValueChanged; MultimediaManager.DisplaySettingsChanged += MultimediaManager_DisplaySettingsChanged; - IDevice.GetCurrent().PowerStatusChanged += CurrentDevice_PowerStatusChanged; + // Some devices will modify the LED colors based on battery status, we need to overwrite it + SystemManager.PowerStatusChanged += PowerManager_PowerStatusChanged; // raise events + if (SettingsManager.IsInitialized) + { + SettingsManager_SettingValueChanged("LEDAmbilightVerticalBlackBarDetection", SettingsManager.GetString("LEDAmbilightVerticalBlackBarDetection"), false); + SettingsManager_SettingValueChanged("LEDSettingsEnabled", SettingsManager.GetString("LEDSettingsEnabled"), false); + } + if (MultimediaManager.IsInitialized) { MultimediaManager_DisplaySettingsChanged(MultimediaManager.PrimaryDesktop, MultimediaManager.PrimaryDesktop.GetResolution()); @@ -96,7 +103,7 @@ public static void Stop() // manage events SettingsManager.SettingValueChanged -= SettingsManager_SettingValueChanged; MultimediaManager.DisplaySettingsChanged -= MultimediaManager_DisplaySettingsChanged; - IDevice.GetCurrent().PowerStatusChanged -= CurrentDevice_PowerStatusChanged; + SystemManager.PowerStatusChanged -= PowerManager_PowerStatusChanged; IsInitialized = false; @@ -128,6 +135,11 @@ private static void MultimediaManager_DisplaySettingsChanged(DesktopScreen deskt } } + private static void PowerManager_PowerStatusChanged(System.Windows.Forms.PowerStatus status) + { + RequestUpdate(); + } + private static async void InitializeDirect3DDevice() { try @@ -183,11 +195,6 @@ private static void SettingsManager_SettingValueChanged(string name, object valu } } - private static void CurrentDevice_PowerStatusChanged(Devices.IDevice device) - { - RequestUpdate(); - } - private static void RequestUpdate() { DynamicLightingTimer.Stop();