From 1958f082c551dd49f92751f082fa3aeb73e11010 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Wed, 17 May 2017 00:57:06 -0700 Subject: [PATCH] Change battery status change reporting --- DS4Windows/DS4Control/ControlService.cs | 2 +- DS4Windows/DS4Control/ScpUtil.cs | 17 ++++++++++++----- DS4Windows/DS4Forms/DS4Form.cs | 20 ++++++++++++++++---- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index ae3c141..b9d6156 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -659,7 +659,7 @@ namespace DS4Windows } else if (pState.Battery != cState.Battery) { - OnBatteryStatusChange(this, ind, cState.Battery); + OnBatteryStatusChange(this, ind, cState.Battery, device.isCharging()); } if (getEnableTouchToggle(ind)) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 83a4ec7..7ea8537 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -147,21 +147,28 @@ namespace DS4Windows { private int index; private int level; + private bool charging; - public BatteryReportArgs(int index, int level) + public BatteryReportArgs(int index, int level, bool charging) { this.index = index; this.level = level; + this.charging = charging; } public int getIndex() { - return this.index; + return index; } public int getLevel() { - return this.level; + return level; + } + + public bool isCharging() + { + return charging; } } @@ -287,11 +294,11 @@ namespace DS4Windows } public static event EventHandler BatteryStatusChange; - public static void OnBatteryStatusChange(object sender, int index, int level) + public static void OnBatteryStatusChange(object sender, int index, int level, bool charging) { if (BatteryStatusChange != null) { - BatteryReportArgs args = new BatteryReportArgs(index, level); + BatteryReportArgs args = new BatteryReportArgs(index, level, charging); BatteryStatusChange(sender, args); } } diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 9bf5dd7..c08ea29 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -1054,10 +1054,18 @@ namespace DS4Windows { string battery; int level = args.getLevel(); - if (level >= 100) - battery = Properties.Resources.Full; + bool charging = args.isCharging(); + if (charging) + { + if (level >= 100) + battery = Properties.Resources.Full; + else + battery = level + "%+"; + } else - battery = level + "%+"; + { + battery = level + "%"; + } Batteries[args.getIndex()].Text = battery; } @@ -1166,6 +1174,7 @@ namespace DS4Windows } } + /* TODO: Possible remove method */ /*protected void ControllerStatusChange(object sender, EventArgs e) { if (InvokeRequired) @@ -1175,6 +1184,7 @@ namespace DS4Windows } */ + /* TODO: Possible remove method */ /*protected void ControllerStatusChanged() { String tooltip = "DS4Windows v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; @@ -1262,13 +1272,15 @@ namespace DS4Windows Batteries[device].Visible = on; } - void ScpForm_Report(object sender, EventArgs e) + /* TODO: Remove method in future */ + /*void ScpForm_Report(object sender, EventArgs e) { if (InvokeRequired) Invoke(new HotKeysDelegate(Hotkeys), new object[] { sender, e }); else Hotkeys(sender, e); } + */ protected void On_Debug(object sender, DebugEventArgs e) {