Skip to content

Commit

Permalink
Add missing DynamicLightingManager settings check
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Dec 26, 2024
1 parent d70b2ff commit dcf9a4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 0 additions & 1 deletion HandheldCompanion/Devices/IDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 14 additions & 7 deletions HandheldCompanion/Managers/DynamicLightingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit dcf9a4c

Please sign in to comment.