mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Mouse refreshes battery again during "ReadSensors". But it does that nonblocking and event driven.
This commit is contained in:
@@ -63,6 +63,9 @@ namespace GHelper.Peripherals
|
|||||||
{
|
{
|
||||||
lock (_LOCK)
|
lock (_LOCK)
|
||||||
{
|
{
|
||||||
|
am.Disconnect -= Mouse_Disconnect;
|
||||||
|
am.MouseReadyChanged -= MouseReadyChanged;
|
||||||
|
am.BatteryUpdated -= BatteryUpdated;
|
||||||
ConnectedMice.Remove(am);
|
ConnectedMice.Remove(am);
|
||||||
}
|
}
|
||||||
if (DeviceChanged is not null)
|
if (DeviceChanged is not null)
|
||||||
@@ -110,6 +113,8 @@ namespace GHelper.Peripherals
|
|||||||
|
|
||||||
|
|
||||||
am.Disconnect += Mouse_Disconnect;
|
am.Disconnect += Mouse_Disconnect;
|
||||||
|
am.MouseReadyChanged += MouseReadyChanged;
|
||||||
|
am.BatteryUpdated += BatteryUpdated;
|
||||||
if (DeviceChanged is not null)
|
if (DeviceChanged is not null)
|
||||||
{
|
{
|
||||||
DeviceChanged(am, EventArgs.Empty);
|
DeviceChanged(am, EventArgs.Empty);
|
||||||
@@ -117,6 +122,16 @@ namespace GHelper.Peripherals
|
|||||||
UpdateSettingsView();
|
UpdateSettingsView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void BatteryUpdated(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UpdateSettingsView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void MouseReadyChanged(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UpdateSettingsView();
|
||||||
|
}
|
||||||
|
|
||||||
private static void Mouse_Disconnect(object? sender, EventArgs e)
|
private static void Mouse_Disconnect(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is null)
|
if (sender is null)
|
||||||
|
|||||||
@@ -814,6 +814,7 @@ namespace GHelper
|
|||||||
string battery = "";
|
string battery = "";
|
||||||
|
|
||||||
HardwareControl.ReadSensors();
|
HardwareControl.ReadSensors();
|
||||||
|
Task.Run((Action)PeripheralsProvider.RefreshBatteryForAllDevices);
|
||||||
|
|
||||||
if (HardwareControl.cpuTemp > 0)
|
if (HardwareControl.cpuTemp > 0)
|
||||||
cpuTemp = ": " + Math.Round((decimal)HardwareControl.cpuTemp).ToString() + "°C";
|
cpuTemp = ": " + Math.Round((decimal)HardwareControl.cpuTemp).ToString() + "°C";
|
||||||
|
|||||||
Reference in New Issue
Block a user