From 12794762a8f0a612646a86c12bc96f19e67c7ba4 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 25 Jun 2019 17:18:58 -0500 Subject: [PATCH] Fix "light panels" getting stuck on if the controller is disconnected while the button is pressed. --- smx-config/DiagnosticsWidgets.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/smx-config/DiagnosticsWidgets.cs b/smx-config/DiagnosticsWidgets.cs index a26be79..7af0619 100644 --- a/smx-config/DiagnosticsWidgets.cs +++ b/smx-config/DiagnosticsWidgets.cs @@ -201,6 +201,8 @@ namespace smx_config SMX.SMX.ForceRecalibration(pad); }; + // Note that we won't get a MouseUp if the display is hidden due to a controller + // disconnection while the mouse is held. We handle this in Refresh(). Button LightAll = Template.FindName("LightAll", this) as Button; LightAll.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs e) { @@ -257,6 +259,12 @@ namespace smx_config RefreshSelectedPanel(); + // Make sure SetShowAllLights is disabled if the controller is disconnected, since + // we can miss mouse up events. + bool EitherControllerConnected = args.controller[0].info.connected || args.controller[1].info.connected; + if(!EitherControllerConnected) + SetShowAllLights?.Invoke(false); + P1Diagnostics.Visibility = args.controller[0].info.connected? Visibility.Visible:Visibility.Collapsed; P2Diagnostics.Visibility = args.controller[1].info.connected? Visibility.Visible:Visibility.Collapsed;