From 2b86eda39eb96b1c73919ede52fcf99d0a5f6cd5 Mon Sep 17 00:00:00 2001 From: Ken Helberg Date: Sun, 14 Jan 2024 14:14:27 -0500 Subject: [PATCH] Bug fix: XOutputDevice.RefreshInput() is not thread safe. --- XOutput/Devices/XInput/XOutputDevice.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/XOutput/Devices/XInput/XOutputDevice.cs b/XOutput/Devices/XInput/XOutputDevice.cs index e7e1f23c..f5593e61 100644 --- a/XOutput/Devices/XInput/XOutputDevice.cs +++ b/XOutput/Devices/XInput/XOutputDevice.cs @@ -43,7 +43,6 @@ public sealed class XOutputDevice : IDevice private readonly InputMapper mapper; private readonly DPadDirection[] dPads = new DPadDirection[DPadCount]; private readonly XOutputSource[] sources; - private readonly DeviceState state; private DeviceInputChangedEventArgs deviceInputChangedEventArgs; /// @@ -55,7 +54,6 @@ public XOutputDevice(InputMapper mapper) { this.mapper = mapper; sources = XInputHelper.Instance.GenerateSources(); - state = new DeviceState(sources, DPadCount); deviceInputChangedEventArgs = new DeviceInputChangedEventArgs(this); } @@ -108,7 +106,7 @@ private void SourceInputChanged(object sender, DeviceInputChangedEventArgs e) /// if the input was available public bool RefreshInput(bool force = false) { - state.ResetChanges(); + DeviceState state = new DeviceState(sources, DPadCount); foreach (var s in sources) { if (s.Refresh(mapper))