diff --git a/HandheldCompanion/App.config b/HandheldCompanion/App.config
index 87f62a2e7..2269c726b 100644
--- a/HandheldCompanion/App.config
+++ b/HandheldCompanion/App.config
@@ -275,6 +275,9 @@
0
+
+ False
+
\ No newline at end of file
diff --git a/HandheldCompanion/Devices/Lenovo/LegionGo.cs b/HandheldCompanion/Devices/Lenovo/LegionGo.cs
index a3c5f54e0..87e4cebc6 100644
--- a/HandheldCompanion/Devices/Lenovo/LegionGo.cs
+++ b/HandheldCompanion/Devices/Lenovo/LegionGo.cs
@@ -97,6 +97,18 @@ public Task SetCPUPowerLimit(CapabilityID capabilityID, int limit) =>
{ "value", limit },
});
+ // InstantBootAc (0x03010001) controls the 80% power charge limit.
+ // https://github.com/aarron-lee/LegionGoRemapper/blob/ab823f2042fc857cca856687a385a033d68c58bf/py_modules/legion_space.py#L138
+ public Task SetBatteryChargeLimit(bool enabled) =>
+ WMI.CallAsync("root\\WMI",
+ $"SELECT * FROM LENOVO_OTHER_METHOD",
+ "SetFeatureValue",
+ new()
+ {
+ { "IDs", (int)CapabilityID.InstantBootAc },
+ { "value", enabled ? 1 : 0 },
+ });
+
public const byte INPUT_HID_ID = 0x04;
public override bool IsOpen => hidDevices.ContainsKey(INPUT_HID_ID) && hidDevices[INPUT_HID_ID].IsOpen;
@@ -211,6 +223,9 @@ public LegionGo()
DefaultLayout.ButtonLayout[ButtonFlags.B7] = new List() { new MouseActions { MouseType = MouseActionsType.ScrollUp } };
DefaultLayout.ButtonLayout[ButtonFlags.B8] = new List() { new MouseActions { MouseType = MouseActionsType.ScrollDown } };
+ SettingsManager.SettingValueChanged += SettingsManager_SettingValueChanged;
+ UpdateSettings();
+
/*
Task task = Task.Run(async () => await GetFanFullSpeedAsync());
bool FanFullSpeed = task.Result;
@@ -427,4 +442,19 @@ public override string GetGlyph(ButtonFlags button)
return defaultGlyph;
}
+
+ protected void UpdateSettings()
+ {
+ SetBatteryChargeLimit(SettingsManager.GetBoolean("LegionBatteryChargeLimit"));
+ }
+
+ private void SettingsManager_SettingValueChanged(string name, object value)
+ {
+ switch (name)
+ {
+ case "LegionBatteryChargeLimit":
+ SetBatteryChargeLimit(Convert.ToBoolean(value));
+ break;
+ }
+ }
}
\ No newline at end of file
diff --git a/HandheldCompanion/Properties/Resources.Designer.cs b/HandheldCompanion/Properties/Resources.Designer.cs
index f0db7f3b8..4dedb8854 100644
--- a/HandheldCompanion/Properties/Resources.Designer.cs
+++ b/HandheldCompanion/Properties/Resources.Designer.cs
@@ -1069,6 +1069,24 @@ public static string DevicePage_FullFanSpeedText {
}
}
+ ///
+ /// Looks up a localized string similar to 80% Battery Charge Limit.
+ ///
+ public static string DevicePage_LegionBatteryChargeLimit {
+ get {
+ return ResourceManager.GetString("DevicePage_LegionBatteryChargeLimit", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Sets the maximum charge level of the battery to 80%.
+ ///
+ public static string DevicePage_LegionBatteryChargeLimit_Desc {
+ get {
+ return ResourceManager.GetString("DevicePage_LegionBatteryChargeLimit_Desc", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Auto Sleep Time.
///
diff --git a/HandheldCompanion/Properties/Resources.resx b/HandheldCompanion/Properties/Resources.resx
index 06b43f3df..916b23624 100644
--- a/HandheldCompanion/Properties/Resources.resx
+++ b/HandheldCompanion/Properties/Resources.resx
@@ -2994,4 +2994,10 @@ Motion input toggle: press selected button(s) to switch motion state.
The best system settings that MSI recommends.
+
+ 80% Battery Charge Limit
+
+
+ Sets the maximum charge level of the battery to 80%
+
\ No newline at end of file
diff --git a/HandheldCompanion/Properties/Settings.Designer.cs b/HandheldCompanion/Properties/Settings.Designer.cs
index 558e82dda..426c698bf 100644
--- a/HandheldCompanion/Properties/Settings.Designer.cs
+++ b/HandheldCompanion/Properties/Settings.Designer.cs
@@ -1103,5 +1103,20 @@ public int LegionControllerGyroIndex {
this["LegionControllerGyroIndex"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool LegionBatteryChargeLimit
+ {
+ get
+ {
+ return ((bool)(this["LegionBatteryChargeLimit"]));
+ }
+ set
+ {
+ this["LegionBatteryChargeLimit"] = value;
+ }
+ }
}
}
diff --git a/HandheldCompanion/Properties/Settings.settings b/HandheldCompanion/Properties/Settings.settings
index b1e4ad014..97b03d5e1 100644
--- a/HandheldCompanion/Properties/Settings.settings
+++ b/HandheldCompanion/Properties/Settings.settings
@@ -272,5 +272,8 @@
0
+
+ False
+
\ No newline at end of file
diff --git a/HandheldCompanion/Views/Pages/AboutPage.xaml b/HandheldCompanion/Views/Pages/AboutPage.xaml
index abcca9358..dab6d9735 100644
--- a/HandheldCompanion/Views/Pages/AboutPage.xaml
+++ b/HandheldCompanion/Views/Pages/AboutPage.xaml
@@ -193,7 +193,7 @@
Margin="0,0,0,5"
Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}"
Style="{StaticResource BodyTextBlockStyle}"
- Text="Nefarius, CasperH2O, B-Core, Frank东, Toomy, Havner, CoryManson, MSeys, ShadowFlare, trippyone, MiguelLedesmaC, Cheng77777, thororen1234, fighterguard, micdah, Geckon01, Bagboii, MeikoMenmaHonma, cerahmed, indiesaudi, Radther, Staubgeborener, twjmy, m33ts4k0z, howanghk, Creaous, xerootg, quangmach, MrCivsteR, 0SkillAllLuck, DevL0rd, romracer, JT" />
+ Text="Nefarius, CasperH2O, B-Core, Frank东, Toomy, Havner, CoryManson, MSeys, ShadowFlare, trippyone, MiguelLedesmaC, Cheng77777, thororen1234, fighterguard, micdah, Geckon01, Bagboii, MeikoMenmaHonma, cerahmed, indiesaudi, Radther, Staubgeborener, twjmy, m33ts4k0z, howanghk, Creaous, xerootg, quangmach, MrCivsteR, 0SkillAllLuck, DevL0rd, romracer, JT, PlasmidEve" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+