mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-12-23 23:21:49 +01:00
Another attempt at fixing Quick Charge to work better for other users
Hotplugging happens quicker now
This commit is contained in:
parent
95c5c7123d
commit
242843ab99
@ -248,6 +248,21 @@ namespace DS4Windows
|
||||
{
|
||||
if (running)
|
||||
{
|
||||
// Do first run check for Quick Charge checks. Needed so old device will
|
||||
// be removed before performing another controller scan
|
||||
for (int i = 0, devlen = DS4Controllers.Length; i < devlen; i++)
|
||||
{
|
||||
DS4Device device = DS4Controllers[i];
|
||||
if (device != null)
|
||||
{
|
||||
if (getQuickCharge() && device.getConnectionType() == ConnectionType.BT &&
|
||||
device.isCharging())
|
||||
{
|
||||
device.DisconnectBT();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DS4Devices.findControllers();
|
||||
IEnumerable<DS4Device> devices = DS4Devices.getDS4Controllers();
|
||||
//foreach (DS4Device device in devices)
|
||||
@ -258,13 +273,6 @@ namespace DS4Windows
|
||||
if (device.isDisconnectingStatus())
|
||||
continue;
|
||||
|
||||
if (getQuickCharge() && device?.getConnectionType() == ConnectionType.BT &&
|
||||
(bool)device?.isCharging())
|
||||
{
|
||||
device.DisconnectBT();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((Func<bool>)delegate
|
||||
{
|
||||
for (Int32 Index = 0, arlength = DS4Controllers.Length; Index < arlength; Index++)
|
||||
|
@ -934,9 +934,11 @@ namespace DS4Windows
|
||||
lbLastMessage.Text = string.Empty;
|
||||
}
|
||||
|
||||
//delegate void OldHotPlugDelegate();
|
||||
bool skipHotplug = false;
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (runHotPlug)
|
||||
if (runHotPlug && !skipHotplug)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -946,7 +948,14 @@ namespace DS4Windows
|
||||
|
||||
lock (this)
|
||||
{
|
||||
Program.rootHub.HotPlug();
|
||||
// Execute hotplug routine after a delay in time. Set flag so extra calls
|
||||
// to WndProc will be ignored
|
||||
skipHotplug = true;
|
||||
System.Threading.Tasks.Task.Delay(50).ContinueWith((t) => InnerHotplug());
|
||||
//OldHotPlugDelegate d = new OldHotPlugDelegate(InnerHotplug);
|
||||
//this.BeginInvoke(d);
|
||||
//skipHotplug = false;
|
||||
//Program.rootHub.HotPlug();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -961,6 +970,19 @@ namespace DS4Windows
|
||||
catch { }
|
||||
}
|
||||
|
||||
delegate bool HotPlugDelegate();
|
||||
protected void InnerHotplug()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
// Reset flag and execute hotplug routine in main thread
|
||||
skipHotplug = false;
|
||||
HotPlugDelegate d = new HotPlugDelegate(Program.rootHub.HotPlug);
|
||||
this.BeginInvoke(d);
|
||||
//Program.rootHub.HotPlug();
|
||||
}
|
||||
}
|
||||
|
||||
protected void BatteryStatusUpdate(object sender, BatteryReportArgs args)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
|
Loading…
Reference in New Issue
Block a user