From f261424932397ea99fdebfb14a0f38517dbc2ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Mon, 28 Nov 2022 17:33:22 +0100 Subject: [PATCH] Fix crash on resume when X360 Controller is in use --- RELEASE.md | 1 + SteamController/Devices/Xbox360Controller.cs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 6978d78..c8c8fe2 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -33,3 +33,4 @@ It does help this project on being supported. - Properly apply X360 mappings for Back Panel keys - Setting `Keyboard[KEY] = false` and `Mouse[KEY] = false` does not cancel the press - Fix crash on startup when Steam is missing +- Fix crash on resume when X360 Controller is in use diff --git a/SteamController/Devices/Xbox360Controller.cs b/SteamController/Devices/Xbox360Controller.cs index 3ee83e9..9b778d4 100644 --- a/SteamController/Devices/Xbox360Controller.cs +++ b/SteamController/Devices/Xbox360Controller.cs @@ -114,7 +114,15 @@ namespace SteamController.Devices if (isConnected && submitReport) { - device?.SubmitReport(); + try + { + device?.SubmitReport(); + } + catch (VigemInvalidTargetException) + { + device?.Disconnect(); + isConnected = false; + } } if (FeedbackReceived is not null && FeedbackReceived.Value.Add(FeedbackTimeout) < DateTime.Now)