From 7c80a32fc2dc39a95687e160c5350dbe343bdca3 Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Sun, 30 Jul 2023 13:41:57 +0200 Subject: [PATCH] Added Lighting zones for supported mice. --- app/AsusMouseSettings.Designer.cs | 253 +++++++++++++++++- app/AsusMouseSettings.cs | 158 +++++++++-- app/Peripherals/Mouse/AsusMouse.cs | 179 ++++++++++--- app/Peripherals/Mouse/Models/ChakramX.cs | 5 + .../Mouse/Models/GladiusIIIAimpoint.cs | 5 + app/Properties/Strings.Designer.cs | 54 ++++ app/Properties/Strings.resx | 18 ++ 7 files changed, 600 insertions(+), 72 deletions(-) diff --git a/app/AsusMouseSettings.Designer.cs b/app/AsusMouseSettings.Designer.cs index c9323e25..01201957 100644 --- a/app/AsusMouseSettings.Designer.cs +++ b/app/AsusMouseSettings.Designer.cs @@ -60,6 +60,12 @@ labelPerformance = new Label(); panelLighting = new Panel(); panelLightingContent = new Panel(); + tableLayoutPanel3 = new TableLayoutPanel(); + buttonLightingZoneScroll = new UI.RButton(); + buttonLightingZoneLogo = new UI.RButton(); + buttonLightingZoneAll = new UI.RButton(); + buttonLightingZoneUnderglow = new UI.RButton(); + buttonLightingZoneDock = new UI.RButton(); comboBoxAnimationDirection = new UI.RComboBox(); labelAnimationDirection = new Label(); checkBoxRandomColor = new CheckBox(); @@ -89,6 +95,9 @@ pictureBoxBatteryState = new PictureBox(); buttonSync = new UI.RButton(); panelBottomButtons = new Panel(); + tableLayoutPanel2 = new TableLayoutPanel(); + rButton1 = new UI.RButton(); + rButton2 = new UI.RButton(); panelProfiles.SuspendLayout(); panelPerformance.SuspendLayout(); panelPerformanceOther.SuspendLayout(); @@ -102,6 +111,7 @@ ((System.ComponentModel.ISupportInitialize)pictureKeyboard).BeginInit(); panelLighting.SuspendLayout(); panelLightingContent.SuspendLayout(); + tableLayoutPanel3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxLightingColor).BeginInit(); panelLightingHeader.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxLighting).BeginInit(); @@ -112,6 +122,7 @@ panelBatteryState.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxBatteryState).BeginInit(); panelBottomButtons.SuspendLayout(); + tableLayoutPanel2.SuspendLayout(); SuspendLayout(); // // panelProfiles @@ -553,12 +564,13 @@ panelLighting.Location = new Point(11, 476); panelLighting.Name = "panelLighting"; panelLighting.Padding = new Padding(0, 0, 0, 25); - panelLighting.Size = new Size(654, 271); + panelLighting.Size = new Size(654, 329); panelLighting.TabIndex = 42; // // panelLightingContent // panelLightingContent.AutoSize = true; + panelLightingContent.Controls.Add(tableLayoutPanel3); panelLightingContent.Controls.Add(comboBoxAnimationDirection); panelLightingContent.Controls.Add(labelAnimationDirection); panelLightingContent.Controls.Add(checkBoxRandomColor); @@ -572,9 +584,148 @@ panelLightingContent.Location = new Point(0, 30); panelLightingContent.Name = "panelLightingContent"; panelLightingContent.Padding = new Padding(0, 0, 0, 11); - panelLightingContent.Size = new Size(654, 216); + panelLightingContent.Size = new Size(654, 274); panelLightingContent.TabIndex = 42; // + // tableLayoutPanel3 + // + tableLayoutPanel3.AutoSize = true; + tableLayoutPanel3.AutoSizeMode = AutoSizeMode.GrowAndShrink; + tableLayoutPanel3.ColumnCount = 5; + tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); + tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); + tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); + tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); + tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); + tableLayoutPanel3.Controls.Add(buttonLightingZoneScroll, 0, 0); + tableLayoutPanel3.Controls.Add(buttonLightingZoneLogo, 0, 0); + tableLayoutPanel3.Controls.Add(buttonLightingZoneAll, 0, 0); + tableLayoutPanel3.Controls.Add(buttonLightingZoneUnderglow, 1, 0); + tableLayoutPanel3.Controls.Add(buttonLightingZoneDock, 2, 0); + tableLayoutPanel3.Dock = DockStyle.Top; + tableLayoutPanel3.Location = new Point(0, 0); + tableLayoutPanel3.Margin = new Padding(6, 3, 6, 3); + tableLayoutPanel3.Name = "tableLayoutPanel3"; + tableLayoutPanel3.RowCount = 1; + tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F)); + tableLayoutPanel3.Size = new Size(654, 60); + tableLayoutPanel3.TabIndex = 56; + // + // buttonLightingZoneScroll + // + buttonLightingZoneScroll.AccessibleName = "DPI Setting 4"; + buttonLightingZoneScroll.Activated = false; + buttonLightingZoneScroll.AutoSize = true; + buttonLightingZoneScroll.AutoSizeMode = AutoSizeMode.GrowAndShrink; + buttonLightingZoneScroll.BackColor = SystemColors.ControlLightLight; + buttonLightingZoneScroll.BorderColor = Color.LightGreen; + buttonLightingZoneScroll.BorderRadius = 5; + buttonLightingZoneScroll.Dock = DockStyle.Fill; + buttonLightingZoneScroll.FlatAppearance.BorderSize = 0; + buttonLightingZoneScroll.FlatStyle = FlatStyle.Flat; + buttonLightingZoneScroll.ForeColor = SystemColors.ControlText; + buttonLightingZoneScroll.ImageAlign = ContentAlignment.BottomCenter; + buttonLightingZoneScroll.Location = new Point(263, 3); + buttonLightingZoneScroll.Name = "buttonLightingZoneScroll"; + buttonLightingZoneScroll.Secondary = false; + buttonLightingZoneScroll.Size = new Size(124, 54); + buttonLightingZoneScroll.TabIndex = 7; + buttonLightingZoneScroll.Text = "Scrollwheel"; + buttonLightingZoneScroll.TextImageRelation = TextImageRelation.ImageAboveText; + buttonLightingZoneScroll.UseVisualStyleBackColor = false; + // + // buttonLightingZoneLogo + // + buttonLightingZoneLogo.AccessibleName = "DPI Setting 2"; + buttonLightingZoneLogo.Activated = false; + buttonLightingZoneLogo.AutoSize = true; + buttonLightingZoneLogo.AutoSizeMode = AutoSizeMode.GrowAndShrink; + buttonLightingZoneLogo.BackColor = SystemColors.ControlLightLight; + buttonLightingZoneLogo.BorderColor = Color.LightGreen; + buttonLightingZoneLogo.BorderRadius = 5; + buttonLightingZoneLogo.Dock = DockStyle.Fill; + buttonLightingZoneLogo.FlatAppearance.BorderSize = 0; + buttonLightingZoneLogo.FlatStyle = FlatStyle.Flat; + buttonLightingZoneLogo.ForeColor = SystemColors.ControlText; + buttonLightingZoneLogo.ImageAlign = ContentAlignment.BottomCenter; + buttonLightingZoneLogo.Location = new Point(133, 3); + buttonLightingZoneLogo.Name = "buttonLightingZoneLogo"; + buttonLightingZoneLogo.Secondary = false; + buttonLightingZoneLogo.Size = new Size(124, 54); + buttonLightingZoneLogo.TabIndex = 4; + buttonLightingZoneLogo.Text = "Logo"; + buttonLightingZoneLogo.TextImageRelation = TextImageRelation.ImageAboveText; + buttonLightingZoneLogo.UseVisualStyleBackColor = false; + // + // buttonLightingZoneAll + // + buttonLightingZoneAll.AccessibleName = "DPI Setting 1"; + buttonLightingZoneAll.Activated = false; + buttonLightingZoneAll.AutoSize = true; + buttonLightingZoneAll.AutoSizeMode = AutoSizeMode.GrowAndShrink; + buttonLightingZoneAll.BackColor = SystemColors.ControlLightLight; + buttonLightingZoneAll.BorderColor = Color.LightGreen; + buttonLightingZoneAll.BorderRadius = 5; + buttonLightingZoneAll.CausesValidation = false; + buttonLightingZoneAll.Dock = DockStyle.Fill; + buttonLightingZoneAll.FlatAppearance.BorderSize = 0; + buttonLightingZoneAll.FlatStyle = FlatStyle.Flat; + buttonLightingZoneAll.ForeColor = SystemColors.ControlText; + buttonLightingZoneAll.Location = new Point(3, 3); + buttonLightingZoneAll.Name = "buttonLightingZoneAll"; + buttonLightingZoneAll.Secondary = false; + buttonLightingZoneAll.Size = new Size(124, 54); + buttonLightingZoneAll.TabIndex = 4; + buttonLightingZoneAll.Text = "All"; + buttonLightingZoneAll.TextImageRelation = TextImageRelation.ImageAboveText; + buttonLightingZoneAll.UseVisualStyleBackColor = false; + // + // buttonLightingZoneUnderglow + // + buttonLightingZoneUnderglow.AccessibleName = "DPI Setting 3"; + buttonLightingZoneUnderglow.Activated = false; + buttonLightingZoneUnderglow.AutoSize = true; + buttonLightingZoneUnderglow.AutoSizeMode = AutoSizeMode.GrowAndShrink; + buttonLightingZoneUnderglow.BackColor = SystemColors.ControlLightLight; + buttonLightingZoneUnderglow.BorderColor = Color.LightGreen; + buttonLightingZoneUnderglow.BorderRadius = 5; + buttonLightingZoneUnderglow.Dock = DockStyle.Fill; + buttonLightingZoneUnderglow.FlatAppearance.BorderSize = 0; + buttonLightingZoneUnderglow.FlatStyle = FlatStyle.Flat; + buttonLightingZoneUnderglow.ForeColor = SystemColors.ControlText; + buttonLightingZoneUnderglow.ImageAlign = ContentAlignment.BottomCenter; + buttonLightingZoneUnderglow.Location = new Point(393, 3); + buttonLightingZoneUnderglow.Name = "buttonLightingZoneUnderglow"; + buttonLightingZoneUnderglow.Secondary = false; + buttonLightingZoneUnderglow.Size = new Size(124, 54); + buttonLightingZoneUnderglow.TabIndex = 5; + buttonLightingZoneUnderglow.Text = "Underglow"; + buttonLightingZoneUnderglow.TextImageRelation = TextImageRelation.ImageAboveText; + buttonLightingZoneUnderglow.UseVisualStyleBackColor = false; + // + // buttonLightingZoneDock + // + buttonLightingZoneDock.AccessibleName = "DPI Setting 4"; + buttonLightingZoneDock.Activated = false; + buttonLightingZoneDock.AutoSize = true; + buttonLightingZoneDock.AutoSizeMode = AutoSizeMode.GrowAndShrink; + buttonLightingZoneDock.BackColor = SystemColors.ControlLightLight; + buttonLightingZoneDock.BorderColor = Color.LightGreen; + buttonLightingZoneDock.BorderRadius = 5; + buttonLightingZoneDock.Dock = DockStyle.Fill; + buttonLightingZoneDock.FlatAppearance.BorderSize = 0; + buttonLightingZoneDock.FlatStyle = FlatStyle.Flat; + buttonLightingZoneDock.ForeColor = SystemColors.ControlText; + buttonLightingZoneDock.ImageAlign = ContentAlignment.BottomCenter; + buttonLightingZoneDock.Location = new Point(523, 3); + buttonLightingZoneDock.Name = "buttonLightingZoneDock"; + buttonLightingZoneDock.Secondary = false; + buttonLightingZoneDock.Size = new Size(128, 54); + buttonLightingZoneDock.TabIndex = 6; + buttonLightingZoneDock.Text = "Dock"; + buttonLightingZoneDock.TextImageRelation = TextImageRelation.ImageAboveText; + buttonLightingZoneDock.UseVisualStyleBackColor = false; + // // comboBoxAnimationDirection // comboBoxAnimationDirection.BorderColor = Color.White; @@ -582,7 +733,7 @@ comboBoxAnimationDirection.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxAnimationDirection.FlatStyle = FlatStyle.Flat; comboBoxAnimationDirection.FormattingEnabled = true; - comboBoxAnimationDirection.Location = new Point(366, 172); + comboBoxAnimationDirection.Location = new Point(366, 230); comboBoxAnimationDirection.Margin = new Padding(16, 0, 16, 0); comboBoxAnimationDirection.Name = "comboBoxAnimationDirection"; comboBoxAnimationDirection.Size = new Size(284, 33); @@ -590,7 +741,7 @@ // // labelAnimationDirection // - labelAnimationDirection.Location = new Point(6, 172); + labelAnimationDirection.Location = new Point(6, 230); labelAnimationDirection.Margin = new Padding(6, 0, 6, 0); labelAnimationDirection.Name = "labelAnimationDirection"; labelAnimationDirection.Size = new Size(316, 33); @@ -599,7 +750,7 @@ // // checkBoxRandomColor // - checkBoxRandomColor.Location = new Point(520, 53); + checkBoxRandomColor.Location = new Point(520, 111); checkBoxRandomColor.Margin = new Padding(6, 0, 6, 0); checkBoxRandomColor.Name = "checkBoxRandomColor"; checkBoxRandomColor.Size = new Size(128, 37); @@ -614,7 +765,7 @@ comboBoxAnimationSpeed.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxAnimationSpeed.FlatStyle = FlatStyle.Flat; comboBoxAnimationSpeed.FormattingEnabled = true; - comboBoxAnimationSpeed.Location = new Point(366, 130); + comboBoxAnimationSpeed.Location = new Point(366, 188); comboBoxAnimationSpeed.Margin = new Padding(16, 0, 16, 0); comboBoxAnimationSpeed.Name = "comboBoxAnimationSpeed"; comboBoxAnimationSpeed.Size = new Size(284, 33); @@ -622,7 +773,7 @@ // // labelAnimationSpeed // - labelAnimationSpeed.Location = new Point(6, 130); + labelAnimationSpeed.Location = new Point(6, 188); labelAnimationSpeed.Margin = new Padding(6, 0, 6, 0); labelAnimationSpeed.Name = "labelAnimationSpeed"; labelAnimationSpeed.Size = new Size(316, 33); @@ -632,7 +783,7 @@ // pictureBoxLightingColor // pictureBoxLightingColor.Anchor = AnchorStyles.Top | AnchorStyles.Right; - pictureBoxLightingColor.Location = new Point(480, 62); + pictureBoxLightingColor.Location = new Point(480, 120); pictureBoxLightingColor.Margin = new Padding(6); pictureBoxLightingColor.Name = "pictureBoxLightingColor"; pictureBoxLightingColor.Size = new Size(20, 20); @@ -649,7 +800,7 @@ buttonLightingColor.BorderRadius = 2; buttonLightingColor.FlatStyle = FlatStyle.Flat; buttonLightingColor.ForeColor = SystemColors.ControlText; - buttonLightingColor.Location = new Point(373, 53); + buttonLightingColor.Location = new Point(373, 111); buttonLightingColor.Margin = new Padding(3, 6, 3, 6); buttonLightingColor.Name = "buttonLightingColor"; buttonLightingColor.Secondary = false; @@ -666,7 +817,7 @@ comboBoxLightingMode.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxLightingMode.FlatStyle = FlatStyle.Flat; comboBoxLightingMode.FormattingEnabled = true; - comboBoxLightingMode.Location = new Point(367, 14); + comboBoxLightingMode.Location = new Point(367, 72); comboBoxLightingMode.Margin = new Padding(16, 0, 16, 0); comboBoxLightingMode.Name = "comboBoxLightingMode"; comboBoxLightingMode.Size = new Size(284, 33); @@ -674,7 +825,7 @@ // // labelLightingMode // - labelLightingMode.Location = new Point(7, 14); + labelLightingMode.Location = new Point(7, 72); labelLightingMode.Margin = new Padding(6, 0, 6, 0); labelLightingMode.Name = "labelLightingMode"; labelLightingMode.Size = new Size(316, 33); @@ -739,7 +890,7 @@ panelEnergy.Controls.Add(labelAutoPowerOff); panelEnergy.Controls.Add(panelEnergyHeader); panelEnergy.Dock = DockStyle.Top; - panelEnergy.Location = new Point(11, 747); + panelEnergy.Location = new Point(11, 805); panelEnergy.Name = "panelEnergy"; panelEnergy.Padding = new Padding(0, 0, 0, 25); panelEnergy.Size = new Size(654, 143); @@ -920,11 +1071,72 @@ panelBottomButtons.AutoSizeMode = AutoSizeMode.GrowAndShrink; panelBottomButtons.Controls.Add(buttonSync); panelBottomButtons.Dock = DockStyle.Top; - panelBottomButtons.Location = new Point(11, 890); + panelBottomButtons.Location = new Point(11, 948); panelBottomButtons.Name = "panelBottomButtons"; panelBottomButtons.Size = new Size(654, 67); panelBottomButtons.TabIndex = 47; // + // tableLayoutPanel2 + // + tableLayoutPanel2.AutoSize = true; + tableLayoutPanel2.AutoSizeMode = AutoSizeMode.GrowAndShrink; + tableLayoutPanel2.ColumnCount = 4; + tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableLayoutPanel2.Controls.Add(rButton1, 0, 0); + tableLayoutPanel2.Location = new Point(0, 0); + tableLayoutPanel2.Name = "tableLayoutPanel2"; + tableLayoutPanel2.RowCount = 1; + tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); + tableLayoutPanel2.Size = new Size(200, 100); + tableLayoutPanel2.TabIndex = 0; + // + // rButton1 + // + rButton1.AccessibleName = "DPI Setting 2"; + rButton1.Activated = false; + rButton1.BackColor = SystemColors.ControlLightLight; + rButton1.BorderColor = Color.Transparent; + rButton1.BorderRadius = 5; + rButton1.Dock = DockStyle.Top; + rButton1.FlatAppearance.BorderSize = 0; + rButton1.FlatStyle = FlatStyle.Flat; + rButton1.ForeColor = SystemColors.ControlText; + rButton1.Image = Properties.Resources.lighting_dot_32; + rButton1.ImageAlign = ContentAlignment.BottomCenter; + rButton1.Location = new Point(3, 3); + rButton1.Name = "rButton1"; + rButton1.Secondary = false; + rButton1.Size = new Size(44, 90); + rButton1.TabIndex = 4; + rButton1.Text = "DPI 2\r\n1000"; + rButton1.TextImageRelation = TextImageRelation.ImageAboveText; + rButton1.UseVisualStyleBackColor = false; + // + // rButton2 + // + rButton2.AccessibleName = "DPI Setting 1"; + rButton2.Activated = false; + rButton2.BackColor = SystemColors.ControlLightLight; + rButton2.BorderColor = Color.Transparent; + rButton2.BorderRadius = 5; + rButton2.CausesValidation = false; + rButton2.Dock = DockStyle.Top; + rButton2.FlatAppearance.BorderSize = 0; + rButton2.FlatStyle = FlatStyle.Flat; + rButton2.ForeColor = SystemColors.ControlText; + rButton2.Image = Properties.Resources.lighting_dot_32; + rButton2.Location = new Point(3, 3); + rButton2.Name = "rButton2"; + rButton2.Secondary = false; + rButton2.Size = new Size(44, 90); + rButton2.TabIndex = 4; + rButton2.Text = "DPI 1\r\n800"; + rButton2.TextImageRelation = TextImageRelation.ImageAboveText; + rButton2.UseVisualStyleBackColor = false; + // // AsusMouseSettings // AutoScaleDimensions = new SizeF(144F, 144F); @@ -932,7 +1144,7 @@ AutoScroll = true; AutoSize = true; AutoSizeMode = AutoSizeMode.GrowAndShrink; - ClientSize = new Size(676, 1030); + ClientSize = new Size(676, 1072); Controls.Add(panelBottomButtons); Controls.Add(panelEnergy); Controls.Add(panelLighting); @@ -966,6 +1178,9 @@ panelLighting.ResumeLayout(false); panelLighting.PerformLayout(); panelLightingContent.ResumeLayout(false); + panelLightingContent.PerformLayout(); + tableLayoutPanel3.ResumeLayout(false); + tableLayoutPanel3.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxLightingColor).EndInit(); panelLightingHeader.ResumeLayout(false); panelLightingHeader.PerformLayout(); @@ -979,6 +1194,7 @@ panelBatteryState.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxBatteryState).EndInit(); panelBottomButtons.ResumeLayout(false); + tableLayoutPanel2.ResumeLayout(false); ResumeLayout(false); PerformLayout(); } @@ -1047,5 +1263,14 @@ private UI.RButton buttonSync; private Panel panelBottomButtons; private NumericUpDown numericUpDownCurrentDPI; + private TableLayoutPanel tableLayoutPanel3; + private UI.RButton buttonLightingZoneScroll; + private UI.RButton buttonLightingZoneLogo; + private UI.RButton buttonLightingZoneAll; + private UI.RButton buttonLightingZoneUnderglow; + private UI.RButton buttonLightingZoneDock; + private TableLayoutPanel tableLayoutPanel2; + private UI.RButton rButton1; + private UI.RButton rButton2; } } \ No newline at end of file diff --git a/app/AsusMouseSettings.cs b/app/AsusMouseSettings.cs index ac5b2a4a..ef5c4482 100644 --- a/app/AsusMouseSettings.cs +++ b/app/AsusMouseSettings.cs @@ -20,6 +20,7 @@ namespace GHelper private readonly AsusMouse mouse; private readonly RButton[] dpiButtons; + private LightingZone visibleZone = LightingZone.All; private bool updateMouseDPI = true; @@ -33,6 +34,7 @@ namespace GHelper labelPollingRate.Text = Properties.Strings.PollingRate; labelLighting.Text = Properties.Strings.Lighting; + labelLightingMode.Text = Properties.Strings.AuraLightingMode; labelEnergy.Text = Properties.Strings.EnergySettings; labelPerformance.Text = Properties.Strings.MousePerformance; checkBoxRandomColor.Text = Properties.Strings.AuraRandomColor; @@ -44,6 +46,12 @@ namespace GHelper labelChargingState.Text = "(" + Properties.Strings.Charging + ")"; labelProfile.Text = Properties.Strings.Profile; + buttonLightingZoneLogo.Text = Properties.Strings.AuraZoneLogo; + buttonLightingZoneScroll.Text = Properties.Strings.AuraZoneScroll; + buttonLightingZoneUnderglow.Text = Properties.Strings.AuraZoneUnderglow; + buttonLightingZoneAll.Text = Properties.Strings.AuraZoneAll; + buttonLightingZoneDock.Text = Properties.Strings.AuraZoneDock; + InitTheme(); this.Text = mouse.GetDisplayName(); @@ -80,11 +88,54 @@ namespace GHelper sliderLowBatteryWarning.MouseUp += SliderLowBatteryWarning_MouseUp; comboBoxAutoPowerOff.DropDownClosed += ComboBoxAutoPowerOff_DropDownClosed; + + buttonLightingZoneAll.Click += ButtonLightingZoneAll_Click; + buttonLightingZoneDock.Click += ButtonLightingZoneDock_Click; + buttonLightingZoneLogo.Click += ButtonLightingZoneLogo_Click; + buttonLightingZoneUnderglow.Click += ButtonLightingZoneUnderglow_Click; + buttonLightingZoneScroll.Click += ButtonLightingZoneScroll_Click; + InitMouseCapabilities(); Logger.WriteLine(mouse.GetDisplayName() + " (GUI): Initialized capabilities. Synchronizing mouse data"); RefreshMouseData(); } + private void SwitchLightingZone(LightingZone zone) + { + if (!mouse.HasRGB()) + { + return; + } + visibleZone = zone; + InitLightingModes(); + VisusalizeLightingSettings(); + } + + private void ButtonLightingZoneScroll_Click(object? sender, EventArgs e) + { + SwitchLightingZone(LightingZone.Scrollwheel); + } + + private void ButtonLightingZoneUnderglow_Click(object? sender, EventArgs e) + { + SwitchLightingZone(LightingZone.Underglow); + } + + private void ButtonLightingZoneLogo_Click(object? sender, EventArgs e) + { + SwitchLightingZone(LightingZone.Logo); + } + + private void ButtonLightingZoneDock_Click(object? sender, EventArgs e) + { + SwitchLightingZone(LightingZone.Dock); + } + + private void ButtonLightingZoneAll_Click(object? sender, EventArgs e) + { + SwitchLightingZone(LightingZone.All); + } + private void AsusMouseSettings_FormClosing(object? sender, FormClosingEventArgs e) { mouse.BatteryUpdated -= Mouse_BatteryUpdated; @@ -175,40 +226,42 @@ namespace GHelper VisualizeCurrentDPIProfile(); } + private void UpdateLightingSettings(LightingSetting settings, LightingZone zone) + { + mouse.SetLightingSetting(settings, visibleZone); + VisusalizeLightingSettings(); + } private void CheckBoxRandomColor_CheckedChanged(object? sender, EventArgs e) { - LightingSetting? ls = mouse.LightingSetting; + LightingSetting? ls = mouse.LightingSettingForZone(visibleZone); ls.RandomColor = checkBoxRandomColor.Checked; - mouse.SetLightingSetting(ls); - VisusalizeLightingSettings(); + UpdateLightingSettings(ls, visibleZone); } private void ComboBoxAnimationDirection_DropDownClosed(object? sender, EventArgs e) { - LightingSetting? ls = mouse.LightingSetting; + LightingSetting? ls = mouse.LightingSettingForZone(visibleZone); ls.AnimationDirection = (AnimationDirection)comboBoxAnimationDirection.SelectedIndex; - mouse.SetLightingSetting(ls); - VisusalizeLightingSettings(); + UpdateLightingSettings(ls, visibleZone); } private void ComboBoxAnimationSpeed_DropDownClosed(object? sender, EventArgs e) { - LightingSetting? ls = mouse.LightingSetting; + LightingSetting? ls = mouse.LightingSettingForZone(visibleZone); ls.AnimationSpeed = (AnimationSpeed)comboBoxAnimationSpeed.SelectedIndex; - mouse.SetLightingSetting(ls); - VisusalizeLightingSettings(); + UpdateLightingSettings(ls, visibleZone); } private void SliderBrightness_MouseUp(object? sender, MouseEventArgs e) { - LightingSetting? ls = mouse.LightingSetting; + LightingSetting? ls = mouse.LightingSettingForZone(visibleZone); ls.Brightness = sliderBrightness.Value; - mouse.SetLightingSetting(ls); + UpdateLightingSettings(ls, visibleZone); } private void ComboBoxLightingMode_DropDownClosed(object? sender, EventArgs e) @@ -220,11 +273,16 @@ namespace GHelper LightingMode lm = supportedLightingModes[comboBoxLightingMode.SelectedIndex]; - LightingSetting? ls = mouse.LightingSetting; + LightingSetting? ls = mouse.LightingSettingForZone(visibleZone); + if (ls.LightingMode == lm) + { + //Nothing to do here. + return; + } + ls.LightingMode = lm; - mouse.SetLightingSetting(ls); - VisusalizeLightingSettings(); + UpdateLightingSettings(ls, visibleZone); } private void ButtonLightingColor_Click(object? sender, EventArgs e) @@ -237,11 +295,10 @@ namespace GHelper if (colorDlg.ShowDialog() == DialogResult.OK) { - LightingSetting? ls = mouse.LightingSetting; + LightingSetting? ls = mouse.LightingSettingForZone(visibleZone); ls.RGBColor = colorDlg.Color; - mouse.SetLightingSetting(ls); - VisusalizeLightingSettings(); + UpdateLightingSettings(ls, visibleZone); } } @@ -475,16 +532,14 @@ 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); + sliderBrightness.Max = mouse.MaxBrightness(); - foreach (LightingMode lm in Enum.GetValues(typeof(LightingMode))) - { - if (mouse.IsLightingModeSupported(lm)) - { - comboBoxLightingMode.Items.Add(lightingModeNames.GetValueOrDefault(lm)); - supportedLightingModes.Add(lm); - } - } + InitLightingModes(); comboBoxAnimationDirection.Items.AddRange(new string[] { Properties.Strings.AuraClockwise, @@ -503,11 +558,37 @@ namespace GHelper } } + private void InitLightingModes() + { + comboBoxLightingMode.Items.Clear(); + supportedLightingModes.Clear(); + foreach (LightingMode lm in Enum.GetValues(typeof(LightingMode))) + { + if (mouse.IsLightingModeSupported(lm) && mouse.IsLightingModeSupportedForZone(lm, visibleZone)) + { + comboBoxLightingMode.Items.Add(lightingModeNames.GetValueOrDefault(lm)); + supportedLightingModes.Add(lm); + } + } + } + private void VisualizeMouseSettings() { comboProfile.SelectedIndex = mouse.Profile; + if (mouse.HasRGB()) + { + //If current lighting mode is zoned, pre-select the first zone and not "All". + bool zoned = mouse.IsLightingZoned(); + if (zoned) + { + visibleZone = mouse.SupportedLightingZones()[0]; + InitLightingModes(); + } + } + + VisualizeDPIButtons(); VisualizeCurrentDPIProfile(); VisusalizeLightingSettings(); @@ -575,6 +656,29 @@ namespace GHelper } } + public void VisusalizeLightingZones() + { + bool zoned = mouse.IsLightingZoned(); + + buttonLightingZoneAll.Activated = visibleZone == LightingZone.All; + buttonLightingZoneLogo.Activated = visibleZone == LightingZone.Logo; + buttonLightingZoneScroll.Activated = visibleZone == LightingZone.Scrollwheel; + buttonLightingZoneUnderglow.Activated = visibleZone == LightingZone.Underglow; + buttonLightingZoneDock.Activated = visibleZone == LightingZone.Dock; + + buttonLightingZoneAll.Secondary = zoned; + buttonLightingZoneLogo.Secondary = !zoned; + buttonLightingZoneScroll.Secondary = !zoned; + buttonLightingZoneUnderglow.Secondary = !zoned; + buttonLightingZoneDock.Secondary = !zoned; + + buttonLightingZoneAll.BackColor = buttonLightingZoneAll.Secondary ? RForm.buttonSecond : RForm.buttonMain; + buttonLightingZoneLogo.BackColor = buttonLightingZoneLogo.Secondary ? RForm.buttonSecond : RForm.buttonMain; + buttonLightingZoneScroll.BackColor = buttonLightingZoneScroll.Secondary ? RForm.buttonSecond : RForm.buttonMain; + buttonLightingZoneUnderglow.BackColor = buttonLightingZoneUnderglow.Secondary ? RForm.buttonSecond : RForm.buttonMain; + buttonLightingZoneDock.BackColor = buttonLightingZoneDock.Secondary ? RForm.buttonSecond : RForm.buttonMain; + } + private void VisusalizeLightingSettings() { if (!mouse.HasRGB()) @@ -582,7 +686,9 @@ namespace GHelper return; } - LightingSetting? ls = mouse.LightingSetting; + VisusalizeLightingZones(); + + LightingSetting? ls = mouse.LightingSettingForZone(visibleZone); if (ls is null) { diff --git a/app/Peripherals/Mouse/AsusMouse.cs b/app/Peripherals/Mouse/AsusMouse.cs index a49d6f33..2f89e5e8 100644 --- a/app/Peripherals/Mouse/AsusMouse.cs +++ b/app/Peripherals/Mouse/AsusMouse.cs @@ -56,6 +56,15 @@ namespace GHelper.Peripherals.Mouse BatteryState = 0x6 } + public enum LightingZone + { + Logo = 0x00, + Scrollwheel = 0x01, + Underglow = 0x02, + All = 0x03, + Dock = 0x04, + } + public class LightingSetting { public LightingSetting() @@ -77,11 +86,29 @@ namespace GHelper.Peripherals.Mouse public AnimationDirection AnimationDirection { get; set; } + public override bool Equals(object? obj) + { + return obj is LightingSetting setting && + LightingMode == setting.LightingMode && + Brightness == setting.Brightness && + RGBColor.Equals(setting.RGBColor) && + RandomColor == setting.RandomColor && + AnimationSpeed == setting.AnimationSpeed && + AnimationDirection == setting.AnimationDirection; + } + + public override int GetHashCode() + { + return HashCode.Combine(LightingMode, Brightness, RGBColor, RandomColor, AnimationSpeed, AnimationDirection); + } + public override string? ToString() { return "LightingMode: " + LightingMode + ", Color (" + RGBColor.R + ", " + RGBColor.G + ", " + RGBColor.B + "), Brightness: " + Brightness + "%, LightingSpeed: " + AnimationSpeed + ", RandomColor:" + RandomColor + ", AnimationDirection:" + AnimationDirection; } + + } public class AsusMouseDPI @@ -102,7 +129,7 @@ namespace GHelper.Peripherals.Mouse public abstract class AsusMouse : Device, IPeripheral { private static string[] POLLING_RATES = { "125 Hz", "250 Hz", "500 Hz", "1000 Hz", "2000 Hz", "4000 Hz", "8000 Hz", "16000 Hz" }; - internal const bool PACKET_LOGGER_ALWAYS_ON = false; + internal const bool PACKET_LOGGER_ALWAYS_ON = true; internal const int ASUS_MOUSE_PACKET_SIZE = 65; public event EventHandler? Disconnect; @@ -131,7 +158,7 @@ namespace GHelper.Peripherals.Mouse public bool Wireless { get; protected set; } public int Battery { get; protected set; } public bool Charging { get; protected set; } - public LightingSetting? LightingSetting { get; protected set; } + public LightingSetting[] LightingSetting { get; protected set; } public int LowBatteryWarning { get; protected set; } public PowerOffSetting PowerOffSetting { get; protected set; } public LiftOffDistance LiftOffDistance { get; protected set; } @@ -147,6 +174,7 @@ namespace GHelper.Peripherals.Mouse this.path = path; this.Wireless = wireless; DpiSettings = new AsusMouseDPI[1]; + LightingSetting = new LightingSetting[SupportedLightingZones().Length]; } public override bool Equals(object? obj) @@ -1038,31 +1066,97 @@ namespace GHelper.Peripherals.Mouse || lightingMode == LightingMode.React; } - protected virtual byte[] GetReadLightingModePacket() + public virtual LightingZone[] SupportedLightingZones() { - return new byte[] { 0x00, 0x12, 0x03 }; + return new LightingZone[] { }; } - protected virtual byte[] GetUpdateLightingModePacket(LightingSetting lightingSetting) + public virtual int IndexForZone(LightingZone zone) { - if (lightingSetting.Brightness < 0 || lightingSetting.Brightness > 100) + LightingZone[] lz = SupportedLightingZones(); + for (int i = 0; i < lz.Length; ++i) { - Logger.WriteLine(GetDisplayName() + ": Brightness " + lightingSetting.Brightness + " is out of range [0;100]. Setting to 25."); - lightingSetting.Brightness = 25; + if (lz[i] == zone) + { + return i; + } + } + return 0; + } + + public virtual bool IsLightingZoned() + { + //Check whether all zones are the same or not + for (int i = 1; i < LightingSetting.Length; ++i) + { + if (LightingSetting[i] is null + || LightingSetting[i - 1] is null + || !LightingSetting[i].Equals(LightingSetting[i - 1])) + { + return true; + } + } + return false; + } + + public virtual bool IsLightingModeSupportedForZone(LightingMode lm, LightingZone lz) + { + if (lz == LightingZone.All) + { + return true; + } + + return lm == LightingMode.Static + || lm == LightingMode.Breathing + || lm == LightingMode.ColorCycle + || lm == LightingMode.React; + } + + public virtual LightingSetting LightingSettingForZone(LightingZone zone) + { + if (zone == LightingZone.All) + { + //First zone is treated as ALL for reading purpose + return LightingSetting[0]; + } + + return LightingSetting[IndexForZone(zone)]; + } + + protected virtual byte[] GetReadLightingModePacket(LightingZone zone) + { + int idx = 0; + + if (zone != LightingZone.All) + { + idx = IndexForZone(zone); + } + + return new byte[] { 0x00, 0x12, 0x03, (byte)idx }; + } + + protected virtual byte[] GetUpdateLightingModePacket(LightingSetting lightingSetting, LightingZone zone) + { + if (lightingSetting.Brightness < 0 || lightingSetting.Brightness > MaxBrightness()) + { + Logger.WriteLine(GetDisplayName() + ": Brightness " + lightingSetting.Brightness + + " is out of range [0;" + MaxBrightness() + "]. Setting to " + (MaxBrightness() / 4) + " ."); + + lightingSetting.Brightness = MaxBrightness() / 4; // set t0 25% of max brightness } if (!IsLightingModeSupported(lightingSetting.LightingMode)) { - Logger.WriteLine(GetDisplayName() + ": Lighting Mode " + lightingSetting.LightingMode + " is not supported. Setting to Rainbow ;)"); - lightingSetting.LightingMode = LightingMode.Rainbow; + Logger.WriteLine(GetDisplayName() + ": Lighting Mode " + lightingSetting.LightingMode + " is not supported. Setting to Color Cycle ;)"); + lightingSetting.LightingMode = LightingMode.ColorCycle; } - return new byte[] { 0x00, 0x51, 0x28, 0x03, 0x00, + return new byte[] { 0x00, 0x51, 0x28, (byte)zone, 0x00, IndexForLightingMode(lightingSetting.LightingMode), (byte)lightingSetting.Brightness, lightingSetting.RGBColor.R, lightingSetting.RGBColor.G, lightingSetting.RGBColor.B, - (byte)lightingSetting.AnimationDirection, - (byte)(lightingSetting.RandomColor ? 0x01: 0x00), - (byte)lightingSetting.AnimationSpeed + (byte)(SupportsAnimationDirection(lightingSetting.LightingMode) ? lightingSetting.AnimationDirection : 0x00), + (byte)((lightingSetting.RandomColor && SupportsRandomColor(lightingSetting.LightingMode)) ? 0x01: 0x00), + (byte)(SupportsAnimationSpeed(lightingSetting.LightingMode) ? lightingSetting.AnimationSpeed : 0x00) }; } @@ -1079,11 +1173,18 @@ namespace GHelper.Peripherals.Mouse setting.Brightness = packet[6]; setting.RGBColor = Color.FromArgb(packet[7], packet[8], packet[9]); - setting.AnimationDirection = (AnimationDirection)packet[11]; - setting.RandomColor = packet[12] == 0x01; - setting.AnimationSpeed = (AnimationSpeed)packet[13]; - //If the mouse reports 0, which it does when the current setting has no speed option, chose medium as default + + setting.AnimationDirection = SupportsAnimationDirection(setting.LightingMode) + ? (AnimationDirection)packet[11] + : AnimationDirection.Clockwise; + + setting.RandomColor = SupportsRandomColor(setting.LightingMode) && packet[12] == 0x01; + setting.AnimationSpeed = SupportsAnimationSpeed(setting.LightingMode) + ? (AnimationSpeed)packet[13] + : AnimationSpeed.Medium; + + //If the mouse reports an out of range value, which it does when the current setting has no speed option, chose medium as default if (setting.AnimationSpeed != AnimationSpeed.Fast && setting.AnimationSpeed != AnimationSpeed.Medium && setting.AnimationSpeed != AnimationSpeed.Slow) @@ -1100,33 +1201,47 @@ namespace GHelper.Peripherals.Mouse { return; } - byte[]? response = WriteForResponse(GetReadLightingModePacket()); - if (response is null) return; - LightingSetting = ParseLightingSetting(response); + LightingZone[] lz = SupportedLightingZones(); + for (int i = 0; i < lz.Length; ++i) + { + byte[]? response = WriteForResponse(GetReadLightingModePacket(lz[i])); + if (response is null) return; - if (LightingSetting is not null) - { - Logger.WriteLine(GetDisplayName() + ": Read RGB Setting" + LightingSetting.ToString()); - } - else - { - Logger.WriteLine(GetDisplayName() + ": Failed to read RGB Setting"); + LightingSetting? ls = ParseLightingSetting(response); + if (ls is null) + { + Logger.WriteLine(GetDisplayName() + ": Failed to read RGB Setting for Zone " + lz[i].ToString()); + continue; + } + + Logger.WriteLine(GetDisplayName() + ": Read RGB Setting for Zone " + lz[i].ToString() + ": " + ls.ToString()); + LightingSetting[i] = ls; } } - public void SetLightingSetting(LightingSetting lightingSetting) + public void SetLightingSetting(LightingSetting lightingSetting, LightingZone zone) { if (!HasRGB() || lightingSetting is null) { return; } - WriteForResponse(GetUpdateLightingModePacket(lightingSetting)); + WriteForResponse(GetUpdateLightingModePacket(lightingSetting, zone)); FlushSettings(); - Logger.WriteLine(GetDisplayName() + ": Set RGB Setting " + lightingSetting.ToString()); - this.LightingSetting = lightingSetting; + Logger.WriteLine(GetDisplayName() + ": Set RGB Setting for zone " + zone.ToString() + ": " + lightingSetting.ToString()); + if (zone == LightingZone.All) + { + for (int i = 0; i < this.LightingSetting.Length; ++i) + { + this.LightingSetting[i] = lightingSetting; + } + } + else + { + this.LightingSetting[IndexForZone(zone)] = lightingSetting; + } } protected virtual byte[] GetSaveProfilePacket() diff --git a/app/Peripherals/Mouse/Models/ChakramX.cs b/app/Peripherals/Mouse/Models/ChakramX.cs index f630e3c2..b77e903a 100644 --- a/app/Peripherals/Mouse/Models/ChakramX.cs +++ b/app/Peripherals/Mouse/Models/ChakramX.cs @@ -60,6 +60,11 @@ namespace GHelper.Peripherals.Mouse.Models return true; } + public override LightingZone[] SupportedLightingZones() + { + return new LightingZone[] { LightingZone.Logo, LightingZone.Scrollwheel, LightingZone.Underglow }; + } + public override bool HasAutoPowerOff() { return true; diff --git a/app/Peripherals/Mouse/Models/GladiusIIIAimpoint.cs b/app/Peripherals/Mouse/Models/GladiusIIIAimpoint.cs index fedd5fc7..28af4409 100644 --- a/app/Peripherals/Mouse/Models/GladiusIIIAimpoint.cs +++ b/app/Peripherals/Mouse/Models/GladiusIIIAimpoint.cs @@ -55,6 +55,11 @@ return true; } + public override LightingZone[] SupportedLightingZones() + { + return new LightingZone[] { LightingZone.Logo, LightingZone.Scrollwheel, LightingZone.Underglow }; + } + public override bool HasAutoPowerOff() { return true; diff --git a/app/Properties/Strings.Designer.cs b/app/Properties/Strings.Designer.cs index 77290fe0..0314380e 100644 --- a/app/Properties/Strings.Designer.cs +++ b/app/Properties/Strings.Designer.cs @@ -258,6 +258,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Lighting Mode. + /// + internal static string AuraLightingMode { + get { + return ResourceManager.GetString("AuraLightingMode", resourceCulture); + } + } + /// /// Looks up a localized string similar to Normal. /// @@ -321,6 +330,51 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to All. + /// + internal static string AuraZoneAll { + get { + return ResourceManager.GetString("AuraZoneAll", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Dock. + /// + internal static string AuraZoneDock { + get { + return ResourceManager.GetString("AuraZoneDock", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Logo. + /// + internal static string AuraZoneLogo { + get { + return ResourceManager.GetString("AuraZoneLogo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Scrollwheel. + /// + internal static string AuraZoneScroll { + get { + return ResourceManager.GetString("AuraZoneScroll", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Underglow. + /// + internal static string AuraZoneUnderglow { + get { + return ResourceManager.GetString("AuraZoneUnderglow", resourceCulture); + } + } + /// /// Looks up a localized string similar to Auto Apply. /// diff --git a/app/Properties/Strings.resx b/app/Properties/Strings.resx index 52715934..bcbd0ddf 100644 --- a/app/Properties/Strings.resx +++ b/app/Properties/Strings.resx @@ -183,6 +183,9 @@ Fast + + Lighting Mode + Normal @@ -204,6 +207,21 @@ Strobe + + All + + + Dock + + + Logo + + + Scrollwheel + + + Underglow + Auto Apply