From 3bbdbe3a0f312899c2937a98f53c62ddfb2b9e9d Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 1 Oct 2018 19:18:52 -0500 Subject: [PATCH] Attempt to reset KB+M controls after unplugging controller Related to issue #438. --- DS4Windows/DS4Control/ControlService.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index 933b78f..31217d0 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -1020,6 +1020,13 @@ namespace DS4Windows LogDebug("X360 Controller # " + xinputIndex + " unplugged"); } + // Use Task to reset device synth state and commit it + Task.Run(() => + { + Mapping.deviceState[ind].SavePrevious(true); + Mapping.Commit(ind); + }).Wait(); + string removed = Properties.Resources.ControllerWasRemoved.Replace("*Mac address*", (ind + 1).ToString()); if (device.getBattery() <= 20 && device.getConnectionType() == ConnectionType.BT && !device.isCharging()) @@ -1163,14 +1170,6 @@ namespace DS4Windows } } - /*if (_udpServer != null) - { - DualShockPadMeta padDetail = new DualShockPadMeta(); - GetPadDetailForIdx(ind, ref padDetail); - _udpServer.NewReportIncoming(ref padDetail, CurrentState[ind]); - } - */ - // Output any synthetic events. Mapping.Commit(ind);