Merge pull request #887 from IceStormNG/asus-mouse-support

Asus mouse support (at least for 2 mice for now)
This commit is contained in:
Serge
2023-07-25 17:46:39 +02:00
committed by GitHub
27 changed files with 4159 additions and 209 deletions

View File

@@ -6,11 +6,17 @@ namespace GHelper.AnimeMatrix.Communication
{
public abstract class Device : IDisposable
{
private static UsbProvider _usbProvider;
protected UsbProvider? _usbProvider;
private static ushort _vendorId;
private static ushort _productId;
private static int _maxFeatureReportLength;
protected ushort _vendorId;
protected ushort _productId;
protected int _maxFeatureReportLength;
protected Device(ushort vendorId, ushort productId)
{
_vendorId = vendorId;
_productId = productId;
}
protected Device(ushort vendorId, ushort productId, int maxFeatureReportLength)
{
@@ -20,7 +26,17 @@ namespace GHelper.AnimeMatrix.Communication
SetProvider();
}
public void SetProvider()
public ushort VendorID()
{
return _vendorId;
}
public ushort ProductID()
{
return _productId;
}
public virtual void SetProvider()
{
_usbProvider = new WindowsUsbProvider(_vendorId, _productId, _maxFeatureReportLength);
}
@@ -36,7 +52,12 @@ namespace GHelper.AnimeMatrix.Communication
public byte[] Get(Packet packet)
=> _usbProvider?.Get(packet.Data);
public void Dispose()
public void Read(byte[] data)
=> _usbProvider?.Read(data);
public void Write(byte[] data)
=> _usbProvider?.Write(data);
public virtual void Dispose()
{
_usbProvider?.Dispose();
}

View File

@@ -1,6 +1,6 @@
namespace GHelper.AnimeMatrix.Communication.Platform
{
internal abstract class UsbProvider : IDisposable
public abstract class UsbProvider : IDisposable
{
protected ushort VendorID { get; }
protected ushort ProductID { get; }
@@ -13,6 +13,8 @@ namespace GHelper.AnimeMatrix.Communication.Platform
public abstract void Set(byte[] data);
public abstract byte[] Get(byte[] data);
public abstract void Read(byte[] data);
public abstract void Write(byte[] data);
public abstract void Dispose();
}

View File

@@ -8,6 +8,27 @@ namespace GHelper.AnimeMatrix.Communication.Platform
protected HidDevice HidDevice { get; }
protected HidStream HidStream { get; }
public WindowsUsbProvider(ushort vendorId, ushort productId, string path, int timeout = 500) : base(vendorId, productId)
{
try
{
HidDevice = DeviceList.Local.GetHidDevices(vendorId, productId)
.First(x => x.DevicePath.Contains(path));
}
catch
{
throw new IOException("HID device was not found on your machine.");
}
var config = new OpenConfiguration();
config.SetOption(OpenOption.Interruptible, true);
config.SetOption(OpenOption.Exclusive, false);
config.SetOption(OpenOption.Priority, 10);
HidStream = HidDevice.Open(config);
HidStream.ReadTimeout = timeout;
HidStream.WriteTimeout = timeout;
}
public WindowsUsbProvider(ushort vendorId, ushort productId, int maxFeatureReportLength)
: base(vendorId, productId)
{
@@ -53,6 +74,23 @@ namespace GHelper.AnimeMatrix.Communication.Platform
return data;
}
public override void Read(byte[] data)
{
WrapException(() =>
{
HidStream.Read(data);
});
}
public override void Write(byte[] data)
{
WrapException(() =>
{
HidStream.Write(data);
HidStream.Flush();
});
}
public override void Dispose()
{
HidStream.Dispose();

1051
app/AsusMouseSettings.Designer.cs generated Normal file

File diff suppressed because it is too large Load Diff

630
app/AsusMouseSettings.cs Normal file
View File

@@ -0,0 +1,630 @@
using GHelper.Peripherals.Mouse;
using GHelper.UI;
namespace GHelper
{
public partial class AsusMouseSettings : RForm
{
private static Dictionary<LightingMode, string> lightingModeNames = new Dictionary<LightingMode, string>()
{
{ LightingMode.Static,Properties.Strings.AuraStatic},
{ LightingMode.Breathing, Properties.Strings.AuraBreathe},
{ LightingMode.ColorCycle, Properties.Strings.AuraColorCycle},
{ LightingMode.Rainbow, Properties.Strings.AuraRainbow},
{ LightingMode.React, Properties.Strings.AuraReact},
{ LightingMode.Comet, Properties.Strings.AuraComet},
{ LightingMode.BatteryState, Properties.Strings.AuraBatteryState},
{ LightingMode.Off, Properties.Strings.MatrixOff},
};
private List<LightingMode> supportedLightingModes = new List<LightingMode>();
private readonly AsusMouse mouse;
private readonly RButton[] dpiButtons;
private bool updateMouseDPI = true;
public AsusMouseSettings(AsusMouse mouse)
{
this.mouse = mouse;
InitializeComponent();
dpiButtons = new RButton[] { buttonDPI1, buttonDPI2, buttonDPI3, buttonDPI4 };
labelPollingRate.Text = Properties.Strings.PollingRate;
labelLighting.Text = Properties.Strings.Lighting;
labelEnergy.Text = Properties.Strings.EnergySettings;
labelPerformance.Text = Properties.Strings.MousePerformance;
checkBoxRandomColor.Text = Properties.Strings.AuraRandomColor;
labelLowBatteryWarning.Text = Properties.Strings.MouseLowBatteryWarning;
labelAutoPowerOff.Text = Properties.Strings.MouseAutoPowerOff;
buttonSync.Text = Properties.Strings.MouseSynchronize;
checkBoxAngleSnapping.Text = Properties.Strings.MouseAngleSnapping;
labelLiftOffDistance.Text = Properties.Strings.MouseLiftOffDistance;
labelChargingState.Text = "(" + Properties.Strings.Charging + ")";
labelProfile.Text = Properties.Strings.Profile;
InitTheme();
this.Text = mouse.GetDisplayName();
Shown += AsusMouseSettings_Shown;
FormClosing += AsusMouseSettings_FormClosing;
mouse.Disconnect += Mouse_Disconnect;
mouse.BatteryUpdated += Mouse_BatteryUpdated;
comboProfile.DropDownClosed += ComboProfile_DropDownClosed;
sliderDPI.ValueChanged += SliderDPI_ValueChanged;
numericUpDownCurrentDPI.ValueChanged += NumericUpDownCurrentDPI_ValueChanged;
sliderDPI.MouseUp += SliderDPI_MouseUp;
sliderDPI.MouseDown += SliderDPI_MouseDown;
buttonDPIColor.Click += ButtonDPIColor_Click;
buttonDPI1.Click += ButtonDPI_Click;
buttonDPI2.Click += ButtonDPI_Click;
buttonDPI3.Click += ButtonDPI_Click;
buttonDPI4.Click += ButtonDPI_Click;
comboBoxPollingRate.DropDownClosed += ComboBoxPollingRate_DropDownClosed;
checkBoxAngleSnapping.CheckedChanged += CheckAngleSnapping_CheckedChanged;
sliderAngleAdjustment.ValueChanged += SliderAngleAdjustment_ValueChanged;
sliderAngleAdjustment.MouseUp += SliderAngleAdjustment_MouseUp;
comboBoxLiftOffDistance.DropDownClosed += ComboBoxLiftOffDistance_DropDownClosed;
buttonLightingColor.Click += ButtonLightingColor_Click;
comboBoxLightingMode.DropDownClosed += ComboBoxLightingMode_DropDownClosed;
sliderBrightness.MouseUp += SliderBrightness_MouseUp;
comboBoxAnimationSpeed.DropDownClosed += ComboBoxAnimationSpeed_DropDownClosed;
comboBoxAnimationDirection.DropDownClosed += ComboBoxAnimationDirection_DropDownClosed;
checkBoxRandomColor.CheckedChanged += CheckBoxRandomColor_CheckedChanged;
sliderLowBatteryWarning.ValueChanged += SliderLowBatteryWarning_ValueChanged;
sliderLowBatteryWarning.MouseUp += SliderLowBatteryWarning_MouseUp;
comboBoxAutoPowerOff.DropDownClosed += ComboBoxAutoPowerOff_DropDownClosed;
InitMouseCapabilities();
RefreshMouseData();
}
private void AsusMouseSettings_FormClosing(object? sender, FormClosingEventArgs e)
{
mouse.BatteryUpdated -= Mouse_BatteryUpdated;
mouse.Disconnect -= Mouse_Disconnect;
}
private void Mouse_BatteryUpdated(object? sender, EventArgs e)
{
this.Invoke(delegate
{
VisualizeBatteryState();
});
}
private void ComboProfile_DropDownClosed(object? sender, EventArgs e)
{
mouse.SetProfile(comboProfile.SelectedIndex);
RefreshMouseData();
}
private void ComboBoxPollingRate_DropDownClosed(object? sender, EventArgs e)
{
mouse.SetPollingRate(mouse.SupportedPollingrates()[comboBoxPollingRate.SelectedIndex]);
}
private void ButtonDPIColor_Click(object? sender, EventArgs e)
{
ColorDialog colorDlg = new ColorDialog
{
AllowFullOpen = true,
Color = pictureDPIColor.BackColor
};
if (colorDlg.ShowDialog() == DialogResult.OK)
{
AsusMouseDPI dpi = mouse.DpiSettings[mouse.DpiProfile - 1];
dpi.Color = colorDlg.Color;
mouse.SetDPIForProfile(dpi, mouse.DpiProfile);
VisualizeDPIButtons();
VisualizeCurrentDPIProfile();
}
}
private void ButtonDPI_Click(object? sender, EventArgs e)
{
int index = -1;
for (int i = 0; i < dpiButtons.Length; ++i)
{
if (sender == dpiButtons[i])
{
index = i;
break;
}
}
if (index == -1)
{
//huh?
return;
}
mouse.SetDPIProfile(index + 1);
VisualizeDPIButtons();
VisualizeCurrentDPIProfile();
}
private void CheckBoxRandomColor_CheckedChanged(object? sender, EventArgs e)
{
LightingSetting? ls = mouse.LightingSetting;
ls.RandomColor = checkBoxRandomColor.Checked;
mouse.SetLightingSetting(ls);
VisusalizeLightingSettings();
}
private void ComboBoxAnimationDirection_DropDownClosed(object? sender, EventArgs e)
{
LightingSetting? ls = mouse.LightingSetting;
ls.AnimationDirection = (AnimationDirection)comboBoxAnimationDirection.SelectedIndex;
mouse.SetLightingSetting(ls);
VisusalizeLightingSettings();
}
private void ComboBoxAnimationSpeed_DropDownClosed(object? sender, EventArgs e)
{
LightingSetting? ls = mouse.LightingSetting;
ls.AnimationSpeed = (AnimationSpeed)comboBoxAnimationSpeed.SelectedIndex;
mouse.SetLightingSetting(ls);
VisusalizeLightingSettings();
}
private void SliderBrightness_MouseUp(object? sender, MouseEventArgs e)
{
LightingSetting? ls = mouse.LightingSetting;
ls.Brightness = sliderBrightness.Value;
mouse.SetLightingSetting(ls);
}
private void ComboBoxLightingMode_DropDownClosed(object? sender, EventArgs e)
{
LightingMode lm = supportedLightingModes[comboBoxLightingMode.SelectedIndex];
LightingSetting? ls = mouse.LightingSetting;
ls.LightingMode = lm;
mouse.SetLightingSetting(ls);
VisusalizeLightingSettings();
}
private void ButtonLightingColor_Click(object? sender, EventArgs e)
{
ColorDialog colorDlg = new ColorDialog
{
AllowFullOpen = true,
Color = pictureBoxLightingColor.BackColor
};
if (colorDlg.ShowDialog() == DialogResult.OK)
{
LightingSetting? ls = mouse.LightingSetting;
ls.RGBColor = colorDlg.Color;
mouse.SetLightingSetting(ls);
VisusalizeLightingSettings();
}
}
private void SliderLowBatteryWarning_ValueChanged(object? sender, EventArgs e)
{
labelLowBatteryWarningValue.Text = sliderLowBatteryWarning.Value.ToString() + "%";
}
private void SliderLowBatteryWarning_MouseUp(object? sender, MouseEventArgs e)
{
mouse.SetEnergySettings(sliderLowBatteryWarning.Value, mouse.PowerOffSetting);
}
private void ComboBoxAutoPowerOff_DropDownClosed(object? sender, EventArgs e)
{
object? obj = Enum.GetValues(typeof(PowerOffSetting)).GetValue(comboBoxAutoPowerOff.SelectedIndex);
if (obj is null)
{
return;
}
PowerOffSetting pos = (PowerOffSetting)obj;
mouse.SetEnergySettings(mouse.LowBatteryWarning, pos);
}
private void SliderAngleAdjustment_ValueChanged(object? sender, EventArgs e)
{
labelAngleAdjustmentValue.Text = sliderAngleAdjustment.Value.ToString() + "°";
}
private void SliderAngleAdjustment_MouseUp(object? sender, MouseEventArgs e)
{
mouse.SetAngleAdjustment((short)sliderAngleAdjustment.Value);
}
private void ComboBoxLiftOffDistance_DropDownClosed(object? sender, EventArgs e)
{
mouse.SetLiftOffDistance((LiftOffDistance)comboBoxLiftOffDistance.SelectedIndex);
}
private void CheckAngleSnapping_CheckedChanged(object? sender, EventArgs e)
{
mouse.SetAngleSnapping(checkBoxAngleSnapping.Checked);
mouse.SetAngleAdjustment((short)sliderAngleAdjustment.Value);
}
private void SliderDPI_ValueChanged(object? sender, EventArgs e)
{
numericUpDownCurrentDPI.Value = sliderDPI.Value;
UpdateMouseDPISettings();
}
private void NumericUpDownCurrentDPI_ValueChanged(object? sender, EventArgs e)
{
sliderDPI.Value = (int)numericUpDownCurrentDPI.Value;
}
private void SliderDPI_MouseDown(object? sender, MouseEventArgs e)
{
updateMouseDPI = false;
}
private void SliderDPI_MouseUp(object? sender, MouseEventArgs e)
{
updateMouseDPI = true;
UpdateMouseDPISettings();
}
private void UpdateMouseDPISettings()
{
if (!updateMouseDPI)
{
return;
}
AsusMouseDPI dpi = mouse.DpiSettings[mouse.DpiProfile - 1];
dpi.DPI = (uint)sliderDPI.Value;
mouse.SetDPIForProfile(dpi, mouse.DpiProfile);
VisualizeDPIButtons();
VisualizeCurrentDPIProfile();
}
private void Mouse_Disconnect(object? sender, EventArgs e)
{
//Mouse disconnected. Bye bye.
this.Invoke(delegate
{
this.Close();
});
}
private void RefreshMouseData()
{
mouse.SynchronizeDevice();
if (!mouse.IsDeviceReady)
{
this.Invoke(delegate
{
this.Close();
});
return;
}
VisualizeMouseSettings();
VisualizeBatteryState();
}
private void InitMouseCapabilities()
{
for (int i = 0; i < mouse.ProfileCount(); ++i)
{
String prf = Properties.Strings.Profile + " " + (i + 1);
comboProfile.Items.Add(prf);
}
labelMinDPI.Text = mouse.MinDPI().ToString();
labelMaxDPI.Text = mouse.MaxDPI().ToString();
sliderDPI.Max = mouse.MaxDPI();
sliderDPI.Min = mouse.MinDPI();
numericUpDownCurrentDPI.Minimum = mouse.MinDPI();
numericUpDownCurrentDPI.Maximum = mouse.MaxDPI();
if (!mouse.HasDPIColors())
{
buttonDPIColor.Visible = false;
pictureDPIColor.Visible = false;
buttonDPI1.Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, Color.Red);
buttonDPI2.Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, Color.Purple);
buttonDPI3.Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, Color.Blue);
buttonDPI4.Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, Color.Green);
buttonDPI1.BorderColor = Color.Red;
buttonDPI1.BorderColor = Color.Purple;
buttonDPI1.BorderColor = Color.Blue;
buttonDPI1.BorderColor = Color.Green;
}
if (mouse.CanSetPollingRate())
{
foreach (PollingRate pr in mouse.SupportedPollingrates())
{
comboBoxPollingRate.Items.Add(mouse.PollingRateDisplayString(pr));
}
}
else
{
comboBoxPollingRate.Visible = false;
labelPollingRate.Visible = false;
}
if (!mouse.HasAngleSnapping())
{
checkBoxAngleSnapping.Visible = false;
}
if (!mouse.HasAngleTuning())
{
labelAngleAdjustmentValue.Visible = false;
sliderAngleAdjustment.Visible = false;
}
if (mouse.HasLiftOffSetting())
{
comboBoxLiftOffDistance.Items.AddRange(new string[] {
Properties.Strings.Low,
Properties.Strings.High,
});
}
else
{
comboBoxLiftOffDistance.Visible = false;
labelLiftOffDistance.Visible = false;
}
if (mouse.DPIProfileCount() < 4)
{
for (int i = 3; i > mouse.DPIProfileCount() - 1; --i)
{
dpiButtons[i].Visible = false;
}
}
if (!mouse.HasBattery())
{
panelBatteryState.Visible = false;
}
if (mouse.HasAutoPowerOff())
{
comboBoxAutoPowerOff.Items.AddRange(new string[]{
" 1 "+ Properties.Strings.Minute,
" 2 "+ Properties.Strings.Minutes,
" 3 "+ Properties.Strings.Minutes,
" 5 "+ Properties.Strings.Minutes,
"10 "+ Properties.Strings.Minutes,
Properties.Strings.Never,
});
}
if (!mouse.HasLowBatteryWarning())
{
labelLowBatteryWarning.Visible = false;
labelLowBatteryWarningValue.Visible = false;
sliderLowBatteryWarning.Visible = false;
}
if (!mouse.HasAutoPowerOff() && !mouse.HasLowBatteryWarning())
{
panelEnergy.Visible = false;
}
if (mouse.HasRGB())
{
foreach (LightingMode lm in Enum.GetValues(typeof(LightingMode)))
{
if (mouse.IsLightingModeSupported(lm))
{
comboBoxLightingMode.Items.Add(lightingModeNames.GetValueOrDefault(lm));
supportedLightingModes.Add(lm);
}
}
comboBoxAnimationDirection.Items.AddRange(new string[] {
Properties.Strings.AuraClockwise,
Properties.Strings.AuraCounterClockwise,
});
comboBoxAnimationSpeed.Items.AddRange(new string[] {
Properties.Strings.AuraSlow,
Properties.Strings.AuraNormal,
Properties.Strings.AuraFast
});
}
else
{
panelLighting.Visible = false;
}
}
private void VisualizeMouseSettings()
{
comboProfile.SelectedIndex = mouse.Profile;
VisualizeDPIButtons();
VisualizeCurrentDPIProfile();
VisusalizeLightingSettings();
if (mouse.CanSetPollingRate())
{
int idx = mouse.PollingRateIndex(mouse.PollingRate);
if (idx == -1)
{
return;
}
comboBoxPollingRate.SelectedIndex = idx;
}
if (mouse.HasAngleSnapping())
{
checkBoxAngleSnapping.Checked = mouse.AngleSnapping;
}
if (mouse.HasAngleTuning())
{
sliderAngleAdjustment.Value = mouse.AngleAdjustmentDegrees;
}
if (mouse.HasAutoPowerOff())
{
if (mouse.PowerOffSetting == PowerOffSetting.Never)
{
comboBoxAutoPowerOff.SelectedIndex = comboBoxAutoPowerOff.Items.Count - 1;
}
else
{
comboBoxAutoPowerOff.SelectedIndex = (int)mouse.PowerOffSetting;
}
}
if (mouse.HasLowBatteryWarning())
{
sliderLowBatteryWarning.Value = mouse.LowBatteryWarning;
}
if (mouse.HasLiftOffSetting())
{
comboBoxLiftOffDistance.SelectedIndex = (int)mouse.LiftOffDistance;
}
}
private void VisualizeBatteryState()
{
if (!mouse.HasBattery())
{
return;
}
labelBatteryState.Text = mouse.Battery + "%";
labelChargingState.Visible = mouse.Charging;
if (mouse.Charging)
{
pictureBoxBatteryState.BackgroundImage = ControlHelper.TintImage(Properties.Resources.icons8_ladende_batterie_48, foreMain);
}
else
{
pictureBoxBatteryState.BackgroundImage = ControlHelper.TintImage(Properties.Resources.icons8_batterie_voll_geladen_48, foreMain);
}
}
private void VisusalizeLightingSettings()
{
if (!mouse.HasRGB())
{
return;
}
LightingSetting? ls = mouse.LightingSetting;
if (ls is null)
{
//Lighting settings not loaded?
return;
}
sliderBrightness.Value = ls.Brightness;
checkBoxRandomColor.Visible = mouse.SupportsRandomColor(ls.LightingMode);
pictureBoxLightingColor.Visible = mouse.SupportsColorSetting(ls.LightingMode);
buttonLightingColor.Visible = mouse.SupportsColorSetting(ls.LightingMode);
comboBoxAnimationSpeed.Visible = mouse.SupportsAnimationSpeed(ls.LightingMode);
labelAnimationSpeed.Visible = mouse.SupportsAnimationSpeed(ls.LightingMode);
comboBoxAnimationDirection.Visible = mouse.SupportsAnimationDirection(ls.LightingMode);
labelAnimationDirection.Visible = mouse.SupportsAnimationDirection(ls.LightingMode);
comboBoxLightingMode.SelectedIndex = supportedLightingModes.IndexOf(ls.LightingMode);
if (mouse.SupportsRandomColor(ls.LightingMode))
{
checkBoxRandomColor.Checked = ls.RandomColor;
buttonLightingColor.Visible = !ls.RandomColor;
}
if (ls.RandomColor && mouse.SupportsRandomColor(ls.LightingMode))
pictureBoxLightingColor.BackColor = Color.Transparent;
else
pictureBoxLightingColor.BackColor = ls.RGBColor;
comboBoxAnimationSpeed.SelectedIndex = (((int)ls.AnimationSpeed) - 5) / 2;
comboBoxAnimationDirection.SelectedIndex = (int)ls.AnimationDirection;
}
private void VisualizeDPIButtons()
{
if (mouse.HasDPIColors())
{
for (int i = 0; i < mouse.DPIProfileCount() && i < 4; ++i)
{
AsusMouseDPI dpi = mouse.DpiSettings[i];
dpiButtons[i].Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, dpi.Color);
dpiButtons[i].Activated = (mouse.DpiProfile - 1) == i;
dpiButtons[i].BorderColor = dpi.Color;
dpiButtons[i].Text = "DPI " + (i + 1) + "\n" + dpi.DPI;
}
}
}
private void VisualizeCurrentDPIProfile()
{
AsusMouseDPI dpi = mouse.DpiSettings[mouse.DpiProfile - 1];
sliderDPI.Value = (int)dpi.DPI;
pictureDPIColor.BackColor = dpi.Color;
}
private void AsusMouseSettings_Shown(object? sender, EventArgs e)
{
if (Height > Program.settingsForm.Height)
{
Top = Program.settingsForm.Top + Program.settingsForm.Height - Height;
}
else
{
Top = Program.settingsForm.Top;
}
Left = Program.settingsForm.Left - Width - 5;
}
private void ButtonSync_Click(object sender, EventArgs e)
{
RefreshMouseData();
}
}
}

120
app/AsusMouseSettings.resx Normal file
View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GHelper.Peripherals
{
public enum PeripheralType
{
Mouse,
Keyboard
}
public interface IPeripheral
{
public bool IsDeviceReady { get; }
public bool Wireless { get; }
public int Battery { get; }
public bool Charging { get; }
public PeripheralType DeviceType();
public string GetDisplayName();
public bool HasBattery();
public void SynchronizeDevice();
public void ReadBattery();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,102 @@
namespace GHelper.Peripherals.Mouse.Models
{
public class ChakramX : AsusMouse
{
public ChakramX() : base(0x0B05, 0x1A1A, "mi_00", true)
{
}
protected ChakramX(ushort vendorId, bool wireless) : base(0x0B05, vendorId, "mi_00", wireless)
{
}
public override string GetDisplayName()
{
return "ROG Chakram X (Wireless)";
}
public override PollingRate[] SupportedPollingrates()
{
return new PollingRate[] {
PollingRate.PR250Hz,
PollingRate.PR500Hz,
PollingRate.PR1000Hz
};
}
public override bool HasAngleSnapping()
{
return true;
}
public override int ProfileCount()
{
return 5;
}
public override int DPIProfileCount()
{
return 4;
}
public override int MaxDPI()
{
return 36_000;
}
public override bool HasLiftOffSetting()
{
return true;
}
public override bool HasRGB()
{
return true;
}
public override bool HasAutoPowerOff()
{
return true;
}
public override bool HasAngleTuning()
{
return true;
}
public override bool HasLowBatteryWarning()
{
return true;
}
public override bool HasDPIColors()
{
return true;
}
}
public class ChakramXWired : ChakramX
{
public ChakramXWired() : base(0x1A18, false)
{
}
public override string GetDisplayName()
{
return "ROG Chakram X (Wired)";
}
public override PollingRate[] SupportedPollingrates()
{
return new PollingRate[] {
PollingRate.PR250Hz,
PollingRate.PR500Hz,
PollingRate.PR1000Hz,
PollingRate.PR2000Hz,
PollingRate.PR4000Hz,
PollingRate.PR8000Hz
};
}
}
}

View File

@@ -0,0 +1,90 @@
namespace GHelper.Peripherals.Mouse.Models
{
public class GladiusIII : AsusMouse
{
public GladiusIII() : base(0x0B05, 0x1A70, "mi_00", true)
{
}
protected GladiusIII(ushort vendorId, bool wireless) : base(0x0B05, vendorId, "mi_00", wireless)
{
}
public override int DPIProfileCount()
{
return 4;
}
public override string GetDisplayName()
{
return "ROG Gladius III (Wireless)";
}
public override PollingRate[] SupportedPollingrates()
{
return new PollingRate[] {
PollingRate.PR125Hz,
PollingRate.PR250Hz,
PollingRate.PR500Hz,
PollingRate.PR1000Hz
};
}
public override int ProfileCount()
{
return 5;
}
public override int MaxDPI()
{
return 36_000;
}
public override bool HasLiftOffSetting()
{
return true;
}
public override bool HasRGB()
{
return true;
}
public override bool HasAutoPowerOff()
{
return true;
}
public override bool HasAngleSnapping()
{
return true;
}
public override bool HasAngleTuning()
{
return true;
}
public override bool HasLowBatteryWarning()
{
return true;
}
public override bool HasDPIColors()
{
return true;
}
}
public class GladiusIIIWired : GladiusIII
{
public GladiusIIIWired() : base(0x1A72, false)
{
}
public override string GetDisplayName()
{
return "ROG Gladius III (Wired)";
}
}
}

View File

@@ -0,0 +1,169 @@
using GHelper.Peripherals.Mouse;
using GHelper.Peripherals.Mouse.Models;
using System.Runtime.CompilerServices;
namespace GHelper.Peripherals
{
public class PeripheralsProvider
{
public static object _LOCK = new object();
public static List<AsusMouse> ConnectedMice = new List<AsusMouse>();
public static event EventHandler? DeviceChanged;
public static bool IsMouseConnected()
{
return ConnectedMice.Count > 0;
}
//Expand if keyboards or other device get supported later.
public static bool IsAnyPeripheralConnect()
{
return IsMouseConnected();
}
public static List<IPeripheral> AllPeripherals()
{
List<IPeripheral> l = new List<IPeripheral>();
l.AddRange(ConnectedMice);
return l;
}
public static void RefreshBatteryForAllDevices()
{
lock (_LOCK)
{
foreach (IPeripheral m in AllPeripherals())
{
if (!m.IsDeviceReady)
{
//Try to sync the device if that hasn't been done yet
m.SynchronizeDevice();
}
else
{
m.ReadBattery();
}
}
}
}
public static void Disconnect(AsusMouse am)
{
lock (_LOCK)
{
ConnectedMice.Remove(am);
if (DeviceChanged is not null)
{
DeviceChanged(am, EventArgs.Empty);
}
}
}
public static void Connect(AsusMouse am)
{
lock (_LOCK)
{
if (ConnectedMice.Contains(am))
{
//Mouse already connected;
return;
}
try
{
am.Connect();
}
catch (IOException e)
{
Logger.WriteLine(am.GetDisplayName() + " failed to connect to device: " + e);
return;
}
am.Disconnect += Mouse_Disconnect;
//The Mouse might needs a few ms to register all its subdevices or the sync will fail.
//Retry 3 times. Do not call this on main thread! It would block the UI
int tries = 0;
while (!am.IsDeviceReady && tries < 3)
{
Thread.Sleep(250);
Logger.WriteLine(am.GetDisplayName() + " synchronising. Try " + (tries + 1));
am.SynchronizeDevice();
++tries;
}
ConnectedMice.Add(am);
Logger.WriteLine(am.GetDisplayName() + " added to the list: " + ConnectedMice.Count + " device are conneted.");
if (DeviceChanged is not null)
{
DeviceChanged(am, EventArgs.Empty);
}
UpdateSettingsView();
}
}
private static void Mouse_Disconnect(object? sender, EventArgs e)
{
if (sender is null)
{
return;
}
lock (_LOCK)
{
AsusMouse am = (AsusMouse)sender;
ConnectedMice.Remove(am);
Logger.WriteLine(am.GetDisplayName() + " reported disconnect. " + ConnectedMice.Count + " device are conneted.");
am.Dispose();
UpdateSettingsView();
}
}
private static void UpdateSettingsView()
{
Program.settingsForm.Invoke(delegate
{
Program.settingsForm.VisualizePeripherals();
});
}
[MethodImpl(MethodImplOptions.Synchronized)]
public static void DetectAllAsusMice()
{
//Add one line for every supported mouse class here to support them.
DetectMouse(new ChakramX());
DetectMouse(new ChakramXWired());
DetectMouse(new GladiusIII());
DetectMouse(new GladiusIIIWired());
}
public static void DetectMouse(AsusMouse am)
{
if (am.IsDeviceConnected() && !ConnectedMice.Contains(am))
{
Logger.WriteLine("Detected a new ROG Chakram X. Connecting...");
Connect(am);
}
}
public static void RegisterForDeviceEvents()
{
HidSharp.DeviceList.Local.Changed += Device_Changed;
}
public static void UnregisterForDeviceEvents()
{
HidSharp.DeviceList.Local.Changed -= Device_Changed;
}
private static void Device_Changed(object? sender, HidSharp.DeviceListChangedEventArgs e)
{
Logger.WriteLine("HID Device Event: Checking for new ASUS Mice");
Task task = Task.Run((Action)DetectAllAsusMice);
}
}
}

View File

@@ -4,6 +4,7 @@ using GHelper.Gpu;
using GHelper.Helpers;
using GHelper.Input;
using GHelper.Mode;
using GHelper.Peripherals;
using Microsoft.Win32;
using Ryzen;
using System.Diagnostics;
@@ -112,6 +113,9 @@ namespace GHelper
unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(settingsForm.Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
Task task = Task.Run((Action)PeripheralsProvider.DetectAllAsusMice);
PeripheralsProvider.RegisterForDeviceEvents();
if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\') || action.Length > 0)
{
SettingsToggle(action);
@@ -261,6 +265,7 @@ namespace GHelper
static void OnExit(object sender, EventArgs e)
{
trayIcon.Visible = false;
PeripheralsProvider.UnregisterForDeviceEvents();
clamshellControl.UnregisterDisplayEvents();
NativeMethods.UnregisterPowerSettingNotification(unRegPowerNotify);
Application.Exit();

View File

@@ -140,6 +140,16 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_batterie_voll_geladen_48 {
get {
object obj = ResourceManager.GetObject("icons8_batterie_voll_geladen_48", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@@ -280,6 +290,16 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_ladende_batterie_48 {
get {
object obj = ResourceManager.GetObject("icons8_ladende_batterie_48", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@@ -320,6 +340,36 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_maus_32 {
get {
object obj = ResourceManager.GetObject("icons8_maus_32", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_maus_48 {
get {
object obj = ResourceManager.GetObject("icons8_maus_48", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_mauszeiger_50 {
get {
object obj = ResourceManager.GetObject("icons8_mauszeiger_50", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@@ -521,7 +571,37 @@ namespace GHelper.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap lighting_dot_24 {
get {
object obj = ResourceManager.GetObject("lighting_dot_24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap lighting_dot_32 {
get {
object obj = ResourceManager.GetObject("lighting_dot_32", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap lighting_dot_48 {
get {
object obj = ResourceManager.GetObject("lighting_dot_48", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon ähnlich wie (Symbol).
/// </summary>
internal static System.Drawing.Icon standard {
get {

View File

@@ -262,4 +262,28 @@
<data name="icons8-software-32-white" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-software-32-white.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_maus_48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-maus-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_maus_32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-maus-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_mauszeiger_50" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-mauszeiger-50.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_batterie_voll_geladen_48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-batterie-voll-geladen-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_ladende_batterie_48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-ladende-batterie-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="lighting_dot_32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\lighting_dot_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="lighting_dot_48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\lighting_dot_48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="lighting_dot_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\lighting_dot_24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@@ -195,6 +195,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Battery State.
/// </summary>
internal static string AuraBatteryState {
get {
return ResourceManager.GetString("AuraBatteryState", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Breathe.
/// </summary>
@@ -204,6 +213,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Clockwise.
/// </summary>
internal static string AuraClockwise {
get {
return ResourceManager.GetString("AuraClockwise", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Color Cycle.
/// </summary>
@@ -213,6 +231,24 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Comet.
/// </summary>
internal static string AuraComet {
get {
return ResourceManager.GetString("AuraComet", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Counterclockwise.
/// </summary>
internal static string AuraCounterClockwise {
get {
return ResourceManager.GetString("AuraCounterClockwise", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Fast.
/// </summary>
@@ -240,6 +276,24 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Random.
/// </summary>
internal static string AuraRandomColor {
get {
return ResourceManager.GetString("AuraRandomColor", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to React.
/// </summary>
internal static string AuraReact {
get {
return ResourceManager.GetString("AuraReact", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Slow.
/// </summary>
@@ -503,6 +557,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Energy Settings.
/// </summary>
internal static string EnergySettings {
get {
return ResourceManager.GetString("EnergySettings", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Extra.
/// </summary>
@@ -701,6 +764,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to High.
/// </summary>
internal static string High {
get {
return ResourceManager.GetString("High", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Key Bindings.
/// </summary>
@@ -773,6 +845,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Lighting.
/// </summary>
internal static string Lighting {
get {
return ResourceManager.GetString("Lighting", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Logo.
/// </summary>
@@ -782,6 +863,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Low.
/// </summary>
internal static string Low {
get {
return ResourceManager.GetString("Low", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Audio Visualizer.
/// </summary>
@@ -881,6 +971,78 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Minute.
/// </summary>
internal static string Minute {
get {
return ResourceManager.GetString("Minute", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Minutes.
/// </summary>
internal static string Minutes {
get {
return ResourceManager.GetString("Minutes", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Angle Snapping.
/// </summary>
internal static string MouseAngleSnapping {
get {
return ResourceManager.GetString("MouseAngleSnapping", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Auto Power Off After.
/// </summary>
internal static string MouseAutoPowerOff {
get {
return ResourceManager.GetString("MouseAutoPowerOff", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Lift Off Distance.
/// </summary>
internal static string MouseLiftOffDistance {
get {
return ResourceManager.GetString("MouseLiftOffDistance", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Low Battery Warning at.
/// </summary>
internal static string MouseLowBatteryWarning {
get {
return ResourceManager.GetString("MouseLowBatteryWarning", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Performance.
/// </summary>
internal static string MousePerformance {
get {
return ResourceManager.GetString("MousePerformance", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Synchronize with mouse.
/// </summary>
internal static string MouseSynchronize {
get {
return ResourceManager.GetString("MouseSynchronize", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Multizone.
/// </summary>
@@ -899,6 +1061,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Never.
/// </summary>
internal static string Never {
get {
return ResourceManager.GetString("Never", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to New updates.
/// </summary>
@@ -916,6 +1087,15 @@ namespace GHelper.Properties {
return ResourceManager.GetString("NoNewUpdates", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Not Connected.
/// </summary>
internal static string NotConnected {
get {
return ResourceManager.GetString("NotConnected", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Open G-Helper window.
@@ -980,6 +1160,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Peripherals.
/// </summary>
internal static string Peripherals {
get {
return ResourceManager.GetString("Peripherals", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Picture / Gif.
/// </summary>
@@ -998,6 +1187,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Polling Rate.
/// </summary>
internal static string PollingRate {
get {
return ResourceManager.GetString("PollingRate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Power Limits.
/// </summary>
@@ -1025,6 +1223,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Profile.
/// </summary>
internal static string Profile {
get {
return ResourceManager.GetString("Profile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Quit.
/// </summary>

View File

@@ -162,12 +162,24 @@
<data name="AsusServicesRunning" xml:space="preserve">
<value>Asus Services Running</value>
</data>
<data name="AuraBatteryState" xml:space="preserve">
<value>Battery State</value>
</data>
<data name="AuraBreathe" xml:space="preserve">
<value>Breathe</value>
</data>
<data name="AuraClockwise" xml:space="preserve">
<value>Clockwise</value>
</data>
<data name="AuraColorCycle" xml:space="preserve">
<value>Color Cycle</value>
</data>
<data name="AuraComet" xml:space="preserve">
<value>Comet</value>
</data>
<data name="AuraCounterClockwise" xml:space="preserve">
<value>Counterclockwise</value>
</data>
<data name="AuraFast" xml:space="preserve">
<value>Fast</value>
</data>
@@ -177,6 +189,12 @@
<data name="AuraRainbow" xml:space="preserve">
<value>Rainbow</value>
</data>
<data name="AuraRandomColor" xml:space="preserve">
<value>Random</value>
</data>
<data name="AuraReact" xml:space="preserve">
<value>React</value>
</data>
<data name="AuraSlow" xml:space="preserve">
<value>Slow</value>
</data>
@@ -266,6 +284,9 @@ Do you still want to continue?</value>
<data name="EnableOptimusTitle" xml:space="preserve">
<value>NVIDIA Display Mode is not set to Optimus</value>
</data>
<data name="EnergySettings" xml:space="preserve">
<value>Energy Settings</value>
</data>
<data name="Extra" xml:space="preserve">
<value>Extra</value>
</data>
@@ -332,6 +353,9 @@ Do you still want to continue?</value>
<data name="GPUTempTarget" xml:space="preserve">
<value>Temperature Target</value>
</data>
<data name="High" xml:space="preserve">
<value>High</value>
</data>
<data name="KeyBindings" xml:space="preserve">
<value>Key Bindings</value>
</data>
@@ -356,9 +380,15 @@ Do you still want to continue?</value>
<data name="Lightbar" xml:space="preserve">
<value>Lightbar</value>
</data>
<data name="Lighting" xml:space="preserve">
<value>Lighting</value>
</data>
<data name="Logo" xml:space="preserve">
<value>Logo</value>
</data>
<data name="Low" xml:space="preserve">
<value>Low</value>
</data>
<data name="MatrixAudio" xml:space="preserve">
<value>Audio Visualizer</value>
</data>
@@ -392,18 +422,48 @@ Do you still want to continue?</value>
<data name="MinRefreshTooltip" xml:space="preserve">
<value>60Hz refresh rate to save battery</value>
</data>
<data name="Minute" xml:space="preserve">
<value>Minute</value>
</data>
<data name="Minutes" xml:space="preserve">
<value>Minutes</value>
</data>
<data name="MouseAngleSnapping" xml:space="preserve">
<value>Angle Snapping</value>
</data>
<data name="MouseAutoPowerOff" xml:space="preserve">
<value>Auto Power Off After</value>
</data>
<data name="MouseLiftOffDistance" xml:space="preserve">
<value>Lift Off Distance</value>
</data>
<data name="MouseLowBatteryWarning" xml:space="preserve">
<value>Low Battery Warning at</value>
</data>
<data name="MousePerformance" xml:space="preserve">
<value>Performance</value>
</data>
<data name="MouseSynchronize" xml:space="preserve">
<value>Synchronize with mouse</value>
</data>
<data name="Multizone" xml:space="preserve">
<value>Multizone</value>
</data>
<data name="MuteMic" xml:space="preserve">
<value>Mute Mic</value>
</data>
<data name="Never" xml:space="preserve">
<value>Never</value>
</data>
<data name="NewUpdates" xml:space="preserve">
<value>New updates</value>
</data>
<data name="NoNewUpdates" xml:space="preserve">
<value>No new updates</value>
</data>
<data name="NotConnected" xml:space="preserve">
<value>Not Connected</value>
</data>
<data name="OpenGHelper" xml:space="preserve">
<value>Open G-Helper window</value>
</data>
@@ -425,12 +485,18 @@ Do you still want to continue?</value>
<data name="PerformanceMode" xml:space="preserve">
<value>Mode</value>
</data>
<data name="Peripherals" xml:space="preserve">
<value>Peripherals</value>
</data>
<data name="PictureGif" xml:space="preserve">
<value>Picture / Gif</value>
</data>
<data name="PlayPause" xml:space="preserve">
<value>Play / Pause</value>
</data>
<data name="PollingRate" xml:space="preserve">
<value>Polling Rate</value>
</data>
<data name="PowerLimits" xml:space="preserve">
<value>Power Limits</value>
</data>
@@ -440,6 +506,9 @@ Do you still want to continue?</value>
<data name="PrintScreen" xml:space="preserve">
<value>PrintScreen</value>
</data>
<data name="Profile" xml:space="preserve">
<value>Profile</value>
</data>
<data name="Quit" xml:space="preserve">
<value>Quit</value>
</data>

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

537
app/Settings.Designer.cs generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,8 @@ using GHelper.Gpu;
using GHelper.Helpers;
using GHelper.Input;
using GHelper.Mode;
using GHelper.Peripherals;
using GHelper.Peripherals.Mouse;
using GHelper.UI;
using System.Diagnostics;
using System.Timers;
@@ -70,6 +72,7 @@ namespace GHelper
labelKeyboard.Text = Properties.Strings.LaptopKeyboard;
labelMatrix.Text = Properties.Strings.AnimeMatrix;
labelBatteryTitle.Text = Properties.Strings.BatteryChargeLimit;
labelPeripherals.Text = Properties.Strings.Peripherals;
checkMatrix.Text = Properties.Strings.TurnOffOnBattery;
checkStartup.Text = Properties.Strings.RunOnStartup;
@@ -181,11 +184,22 @@ namespace GHelper
labelBattery.MouseLeave += PanelBattery_MouseLeave;
labelBatteryTitle.MouseLeave += PanelBattery_MouseLeave;
buttonPeripheral1.Click += ButtonPeripheral_Click;
buttonPeripheral2.Click += ButtonPeripheral_Click;
buttonPeripheral3.Click += ButtonPeripheral_Click;
Text = "G-Helper " + (ProcessHelper.IsUserAdministrator() ? "—" : "-") + " " + AppConfig.GetModelShort();
TopMost = AppConfig.Is("topmost");
//This will auto position the window again when it resizes. Might mess with position if people drag the window somewhere else.
this.Resize += SettingsForm_Resize;
SetContextMenu();
}
private void SettingsForm_Resize(object? sender, EventArgs e)
{
Left = Screen.FromControl(this).WorkingArea.Width - 10 - Width;
Top = Screen.FromControl(this).WorkingArea.Height - 10 - Height;
}
private void PanelBattery_MouseEnter(object? sender, EventArgs e)
@@ -815,6 +829,7 @@ namespace GHelper
gpuTemp = $": {HardwareControl.gpuTemp}°C";
}
PeripheralsProvider.RefreshBatteryForAllDevices();
Program.settingsForm.BeginInvoke(delegate
{
@@ -824,6 +839,7 @@ namespace GHelper
labelMidFan.Text = "Mid " + HardwareControl.midFan;
if (!batteryMouseOver) labelBattery.Text = battery;
VisualizePeripherals();
});
string trayTip = "CPU" + cpuTemp + " " + HardwareControl.cpuFan;
@@ -1058,6 +1074,92 @@ namespace GHelper
}
public void VisualizePeripherals()
{
if (!PeripheralsProvider.IsAnyPeripheralConnect())
{
panelPeripherals.Visible = false;
return;
}
Button[] buttons = new Button[] { buttonPeripheral1, buttonPeripheral2, buttonPeripheral3 };
//we only support 4 devces for now. Who has more than 4 mice connected to the same PC anyways....
List<IPeripheral> lp = PeripheralsProvider.AllPeripherals();
for (int i = 0; i < lp.Count && i < buttons.Length; ++i)
{
IPeripheral m = lp.ElementAt(i);
Button b = buttons[i];
if (m.IsDeviceReady)
{
b.Text = m.GetDisplayName() + "\n" + m.Battery + "%"
+ (m.Charging ? "(" + Properties.Strings.Charging + ")" : "");
b.Enabled = true;
}
else
{
//Mouse is either not connected or in standby
b.Text = m.GetDisplayName() + "\n(" + Properties.Strings.NotConnected + ")";
b.Enabled = false;
}
switch (m.DeviceType())
{
case PeripheralType.Mouse:
b.Image = ControlHelper.TintImage(Properties.Resources.icons8_maus_32, b.ForeColor);
break;
case PeripheralType.Keyboard:
b.Image = ControlHelper.TintImage(Properties.Resources.icons8_keyboard_32, b.ForeColor);
break;
}
b.Visible = true;
}
for (int i = lp.Count; i < buttons.Length; ++i)
{
buttons[i].Visible = false;
}
panelPeripherals.Visible = true;
}
private void ButtonPeripheral_Click(object? sender, EventArgs e)
{
int index = 0;
if (sender == buttonPeripheral2) index = 1;
if (sender == buttonPeripheral3) index = 2;
IPeripheral iph = PeripheralsProvider.AllPeripherals().ElementAt(index);
if (iph is null)
{
//Can only happen when the user hits the button in the exact moment a device is disconnected.
return;
}
if (iph.DeviceType() == PeripheralType.Mouse)
{
AsusMouse? am = iph as AsusMouse;
if (am is null)
{
//Should not happen if all device classes are implemented correctly. But better safe than sorry.
return;
}
AsusMouseSettings s = new AsusMouseSettings(am);
if (!s.IsDisposed)
{
s.Show();
}
}
}
}

View File

@@ -77,6 +77,12 @@ public static class ControlHelper
combo.ButtonColor = RForm.buttonMain;
combo.ArrowColor = RForm.foreMain;
}
var numbericUpDown = control as NumericUpDown;
if(numbericUpDown is not null)
{
numbericUpDown.ForeColor = RForm.foreMain;
numbericUpDown.BackColor = RForm.buttonMain;
}
var gb = control as GroupBox;
if (gb != null)
@@ -172,4 +178,20 @@ public static class ControlHelper
}
public static Image TintImage(Image image, Color tintColor)
{
var pic = new Bitmap(image);
for (int y = 0; (y <= (pic.Height - 1)); y++)
{
for (int x = 0; (x <= (pic.Width - 1)); x++)
{
Color col = pic.GetPixel(x, y);
pic.SetPixel(x, y, Color.FromArgb(col.A, tintColor.R, tintColor.G, tintColor.B));
}
}
return pic;
}
}