Skip to content

Commit

Permalink
Bug fix: XOutputDevice.RefreshInput() is not thread safe.
Browse files Browse the repository at this point in the history
  • Loading branch information
kenh6942 committed Jan 14, 2024
1 parent 1f85847 commit 2b86eda
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions XOutput/Devices/XInput/XOutputDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
Expand All @@ -55,7 +54,6 @@ public XOutputDevice(InputMapper mapper)
{
this.mapper = mapper;
sources = XInputHelper.Instance.GenerateSources();
state = new DeviceState(sources, DPadCount);
deviceInputChangedEventArgs = new DeviceInputChangedEventArgs(this);
}

Expand Down Expand Up @@ -108,7 +106,7 @@ private void SourceInputChanged(object sender, DeviceInputChangedEventArgs e)
/// <returns>if the input was available</returns>
public bool RefreshInput(bool force = false)
{
state.ResetChanges();
DeviceState state = new DeviceState(sources, DPadCount);
foreach (var s in sources)
{
if (s.Refresh(mapper))
Expand Down

0 comments on commit 2b86eda

Please sign in to comment.