fix race condition between OTK_Gamepad initialize and EnumerateDevices() from input thread
This commit is contained in:
parent
ebc49db08f
commit
3403ecacb7
|
@ -24,6 +24,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static readonly List<OTK_GamePad> Devices = new List<OTK_GamePad>();
|
||||
|
||||
volatile static bool initialized = false;
|
||||
|
||||
/// <remarks>Initialization is only called once when MainForm loads</remarks>
|
||||
public static void Initialize()
|
||||
{
|
||||
|
@ -37,13 +39,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
Devices.Add(new OTK_GamePad(i, ++playerCount));
|
||||
}
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public static IEnumerable<OTK_GamePad> EnumerateDevices()
|
||||
{
|
||||
lock (_syncObj)
|
||||
{
|
||||
foreach (var device in Devices) yield return device;
|
||||
if (initialized)
|
||||
foreach (var device in Devices) yield return device;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue