From 5bf579fec5db62b206485127de3de16dd192d101 Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Sun, 30 Jul 2023 17:28:08 +0200 Subject: [PATCH] Imroved handling for mice with only a single lighting zone. --- app/AsusMouseSettings.cs | 18 ++++++++++++++---- app/Peripherals/Mouse/AsusMouse.cs | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/AsusMouseSettings.cs b/app/AsusMouseSettings.cs index ef5c4482..9f1f0b55 100644 --- a/app/AsusMouseSettings.cs +++ b/app/AsusMouseSettings.cs @@ -532,10 +532,20 @@ namespace GHelper if (mouse.HasRGB()) { - buttonLightingZoneLogo.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Logo); - buttonLightingZoneScroll.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Scrollwheel); - buttonLightingZoneUnderglow.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Underglow); - buttonLightingZoneDock.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Dock); + if (mouse.SupportedLightingZones().Length > 1) + { + buttonLightingZoneLogo.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Logo); + buttonLightingZoneScroll.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Scrollwheel); + buttonLightingZoneUnderglow.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Underglow); + buttonLightingZoneDock.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Dock); + } + else + { + buttonLightingZoneLogo.Visible = false; + buttonLightingZoneScroll.Visible = false; + buttonLightingZoneUnderglow.Visible = false; + buttonLightingZoneDock.Visible = false; + } sliderBrightness.Max = mouse.MaxBrightness(); diff --git a/app/Peripherals/Mouse/AsusMouse.cs b/app/Peripherals/Mouse/AsusMouse.cs index 2f89e5e8..abc0819b 100644 --- a/app/Peripherals/Mouse/AsusMouse.cs +++ b/app/Peripherals/Mouse/AsusMouse.cs @@ -174,7 +174,15 @@ namespace GHelper.Peripherals.Mouse this.path = path; this.Wireless = wireless; DpiSettings = new AsusMouseDPI[1]; - LightingSetting = new LightingSetting[SupportedLightingZones().Length]; + if (SupportedLightingZones().Length == 0) + { + LightingSetting = new LightingSetting[1]; + } + else + { + LightingSetting = new LightingSetting[SupportedLightingZones().Length]; + } + } public override bool Equals(object? obj) @@ -1068,7 +1076,7 @@ namespace GHelper.Peripherals.Mouse public virtual LightingZone[] SupportedLightingZones() { - return new LightingZone[] { }; + return new LightingZone[] { LightingZone.Logo }; } public virtual int IndexForZone(LightingZone zone) @@ -1086,6 +1094,11 @@ namespace GHelper.Peripherals.Mouse public virtual bool IsLightingZoned() { + if (LightingSetting.Length < 2) + { + return false; + } + //Check whether all zones are the same or not for (int i = 1; i < LightingSetting.Length; ++i) {