Skip to content

Commit

Permalink
Possible fix for crash
Browse files Browse the repository at this point in the history
  • Loading branch information
ciribob committed Jul 28, 2024
1 parent d65646e commit 7fd15a6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions DCS-SR-Client/Input/InputDeviceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,11 @@ private bool GetButtonState(InputDevice inputDeviceBinding)

private void DeviceError(Device device, Exception e)
{
Logger.Error(e, $"Failed to get current state of input device {device.Information.ProductName.Trim().Replace("\0", "")} " +
var deviceName = device.Information.ProductName.Trim().Replace("\0", "");
Logger.Error(e, $"Failed to get current state of input device {deviceName} " +
$"(ID: {device.Information.ProductGuid}) while retrieving button state, ignoring until next restart/rediscovery");


try
{
device.Unacquire();
Expand All @@ -901,14 +903,14 @@ private void DeviceError(Device device, Exception e)
// ignored
}

Application.Current.Dispatcher.Invoke(new Action(() => {
Application.Current.Dispatcher.Invoke(() => {
MessageBox.Show(
$"An error occurred while querying your {device.Information.ProductName.Trim().Replace("\0", "")} input device.\nThis could for example be caused by unplugging " +
$"An error occurred while querying your {deviceName} input device.\nThis could for example be caused by unplugging " +
$"your joystick or disabling it in the Windows settings.\n\nAll controls bound to this input device will not work anymore until your press 'Rescan Controller Input' in the SRS controls section or restart SRS",
"Input device error",
MessageBoxButton.OK,
MessageBoxImage.Error);
}));
});
}

public List<InputBindState> GenerateBindStateList()
Expand Down

0 comments on commit 7fd15a6

Please sign in to comment.