From 69ec75ff79b7c466311e1a19392c744aee0a22dd Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Thu, 4 Jan 2024 18:15:52 +0100 Subject: [PATCH 1/3] Support for Gladius II and Gladius II Origin (#1848) --- app/Peripherals/Mouse/Models/GladiusII.cs | 243 ++++++++++++++++++++++ app/Peripherals/PeripheralsProvider.cs | 2 + 2 files changed, 245 insertions(+) create mode 100644 app/Peripherals/Mouse/Models/GladiusII.cs diff --git a/app/Peripherals/Mouse/Models/GladiusII.cs b/app/Peripherals/Mouse/Models/GladiusII.cs new file mode 100644 index 00000000..638d4a65 --- /dev/null +++ b/app/Peripherals/Mouse/Models/GladiusII.cs @@ -0,0 +1,243 @@ +namespace GHelper.Peripherals.Mouse.Models +{ + //P504 + public class GladiusIIOrigin : AsusMouse + { + public GladiusIIOrigin() : base(0x0B05, 0x1877, "mi_02", false) + { + } + + public GladiusIIOrigin(ushort productId, string path) : base(0x0B05, productId, path, false) + { + } + + public override int DPIProfileCount() + { + return 2; + } + + public override string GetDisplayName() + { + return "Gladius II Origin"; + } + + + public override PollingRate[] SupportedPollingrates() + { + return new PollingRate[] { + PollingRate.PR125Hz, + PollingRate.PR250Hz, + PollingRate.PR500Hz, + PollingRate.PR1000Hz + }; + } + + public override int ProfileCount() + { + return 1; + } + public override int MaxDPI() + { + return 12_000; + } + + public override bool HasRGB() + { + return true; + } + + public override bool HasAutoPowerOff() + { + return false; + } + + public override bool HasAngleSnapping() + { + return true; + } + + public override bool HasAngleTuning() + { + return false; + } + + public override bool HasDebounceSetting() + { + return true; + } + public override bool HasLiftOffSetting() + { + return true; + } + + public override bool HasLowBatteryWarning() + { + return false; + } + + public override bool HasBattery() + { + return false; + } + + public override bool HasDPIColors() + { + return false; + } + + public override bool IsLightingModeSupported(LightingMode lightingMode) + { + return lightingMode == LightingMode.Static + || lightingMode == LightingMode.Breathing + || lightingMode == LightingMode.ColorCycle + || lightingMode == LightingMode.Rainbow + || lightingMode == LightingMode.React + || lightingMode == LightingMode.Comet; + } + + public override LightingZone[] SupportedLightingZones() + { + return new LightingZone[] { LightingZone.Logo, LightingZone.Scrollwheel, LightingZone.Underglow }; + } + + public override int DPIIncrements() + { + return 100; + } + + public override bool CanChangeDPIProfile() + { + return true; + } + + public override int MaxBrightness() + { + return 4; + } + + protected override byte[] GetUpdateLightingModePacket(LightingSetting lightingSetting, LightingZone zone) + { + /* + * This mouse uses different speed values for rainbow mode compared to others. + * 51 28 03 00 03 04 FF 00 00 00 00 [8C] 00 00 00 00 + * 51 28 03 00 03 04 FF 00 00 00 00 [64] 00 00 00 00 + * 51 28 03 00 03 04 FF 00 00 00 00 [3F] 00 00 00 00 + */ + + if (lightingSetting.LightingMode == LightingMode.Rainbow) + { + byte speed = 0x3F; + + switch (lightingSetting.AnimationSpeed) + { + case AnimationSpeed.Slow: + speed = 0x3F; + break; + case AnimationSpeed.Medium: + speed = 0x64; + break; + case AnimationSpeed.Fast: + speed = 0x8C; + break; + } + + return new byte[] { reportId, 0x51, 0x28, (byte)zone, 0x00, + IndexForLightingMode(lightingSetting.LightingMode), + (byte)lightingSetting.Brightness, + 0xFF, 0x00, 0x00, + (byte)(SupportsAnimationDirection(lightingSetting.LightingMode) ? lightingSetting.AnimationDirection : 0x00), + (byte)((lightingSetting.RandomColor && SupportsRandomColor(lightingSetting.LightingMode)) ? 0x01: 0x00), + (byte)(SupportsAnimationSpeed(lightingSetting.LightingMode) ? speed : 0x00) + }; + } + + return base.GetUpdateLightingModePacket(lightingSetting, zone); + } + + protected override byte[] GetReadLightingModePacket(LightingZone zone) + { + return new byte[] { 0x00, 0x12, 0x03, 0x00 }; + } + + protected LightingSetting? ParseLightingSetting(byte[] packet, LightingZone zone) + { + if (packet[1] != 0x12 || packet[2] != 0x03) + { + return null; + } + + int offset = 5 + (((int)zone) * 5); + + LightingSetting setting = new LightingSetting(); + + setting.LightingMode = LightingModeForIndex(packet[offset + 0]); + setting.Brightness = packet[offset + 1]; + + setting.RGBColor = Color.FromArgb(packet[offset + 2], packet[offset + 3], packet[offset + 4]); + + + return setting; + } + + public override void ReadLightingSetting() + { + if (!HasRGB()) + { + return; + } + //Mouse sends all lighting zones in one response Direction, Random col, Speed + //00 12 03 00 00 [00 04 ff 00 80] [00 04 00 ff ff] [00 04 ff ff ff] 00 [00] [00] [00] 00 00 + //00 12 03 00 00 [03 04 00 00 00] [03 04 00 00 00] [03 04 00 00 00] 00 [00] [00] [07] 00 00 + byte[]? response = WriteForResponse(GetReadLightingModePacket(LightingZone.All)); + if (response is null) return; + + LightingZone[] lz = SupportedLightingZones(); + for (int i = 0; i < lz.Length; ++i) + { + LightingSetting? ls = ParseLightingSetting(response, lz[i]); + if (ls is null) + { + Logger.WriteLine(GetDisplayName() + ": Failed to read RGB Setting for Zone " + lz[i].ToString()); + continue; + } + ls.AnimationDirection = SupportsAnimationDirection(ls.LightingMode) + ? (AnimationDirection)response[21] + : AnimationDirection.Clockwise; + + ls.RandomColor = SupportsRandomColor(ls.LightingMode) && response[22] == 0x01; + + ls.AnimationSpeed = SupportsAnimationSpeed(ls.LightingMode) + ? (AnimationSpeed)response[23] + : AnimationSpeed.Medium; + + if (ls.AnimationSpeed != AnimationSpeed.Fast + && ls.AnimationSpeed != AnimationSpeed.Medium + && ls.AnimationSpeed != AnimationSpeed.Slow) + { + ls.AnimationSpeed = AnimationSpeed.Medium; + } + + Logger.WriteLine(GetDisplayName() + ": Read RGB Setting for Zone " + lz[i].ToString() + ": " + ls.ToString()); + LightingSetting[i] = ls; + } + } + } + + //P502 + public class GladiusII : GladiusIIOrigin + { + public GladiusII() : base(0x1845, "mi_02") + { + + } + public override string GetDisplayName() + { + return "Gladius II Origin"; + } + + public override int ProfileCount() + { + return 3; + } + } +} diff --git a/app/Peripherals/PeripheralsProvider.cs b/app/Peripherals/PeripheralsProvider.cs index bfcfe7ff..3f72b611 100644 --- a/app/Peripherals/PeripheralsProvider.cs +++ b/app/Peripherals/PeripheralsProvider.cs @@ -187,6 +187,8 @@ namespace GHelper.Peripherals DetectMouse(new ChakramXWired()); DetectMouse(new GladiusIIIAimpoint()); DetectMouse(new GladiusIIIAimpointWired()); + DetectMouse(new GladiusIIOrigin()); + DetectMouse(new GladiusII()); DetectMouse(new ROGKerisWireless()); DetectMouse(new ROGKerisWirelessWired()); DetectMouse(new ROGKerisWirelessEvaEdition()); From 797381463d4feccce8e35c0aa15a5b49fe697f97 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Thu, 4 Jan 2024 18:30:00 +0100 Subject: [PATCH 2/3] Update README.md --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index 29b76304..69f08f14 100644 --- a/docs/README.md +++ b/docs/README.md @@ -90,6 +90,7 @@ Each BIOS mode is paired with matching Windows Power Mode. You can adjust this s - ROG Chakram X (P708) - ROG Chakram Core (P511) - ROG Strix III Gladius III Aimpoint Wireless (P711) +- ROG Gladius II and Gladius II Origin (P502 and P504) - ROG Gladius III - ROG Gladius III Wireless - ROG Strix Impact II Wireless From 096366de4ed5543bd332123e98fa95399e9ed47a Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Fri, 5 Jan 2024 11:34:46 +0100 Subject: [PATCH 3/3] New translations strings.resx (Chinese Simplified) (#1849) --- app/Properties/Strings.zh-CN.resx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Properties/Strings.zh-CN.resx b/app/Properties/Strings.zh-CN.resx index 12aace24..30cab1ee 100644 --- a/app/Properties/Strings.zh-CN.resx +++ b/app/Properties/Strings.zh-CN.resx @@ -250,10 +250,10 @@ 插电/电池时熄灭时间(0表示长亮) - Backlight Timeout when on battery + 充电模式下的背光超时 - Backlight Timeout when plugged + 电源模式下的背光超时 平衡模式