diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index 09c4a53..6aaa4f1 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -248,9 +248,11 @@ namespace DS4Windows if (disabledDevCount > 0) { List disabledDevList = new List(); - for (int i = 0, arlen = disabledDevCount; i < arlen; i++) + for (var devEnum = DisabledDevices.GetEnumerator(); devEnum.MoveNext();) + //for (int i = 0, arlen = disabledDevCount; i < arlen; i++) { - HidDevice tempDev = DisabledDevices.ElementAt(i); + //HidDevice tempDev = DisabledDevices.ElementAt(i); + HidDevice tempDev = devEnum.Current; if (tempDev != null) { if (tempDev.IsOpen && tempDev.IsConnected) diff --git a/DS4Windows/HidLibrary/HidDevices.cs b/DS4Windows/HidLibrary/HidDevices.cs index 00125eb..a3c35a0 100644 --- a/DS4Windows/HidLibrary/HidDevices.cs +++ b/DS4Windows/HidLibrary/HidDevices.cs @@ -46,9 +46,11 @@ namespace DS4Windows List foundDevs = new List(); int devInfoLen = devInfo.Length; IEnumerable temp = EnumerateDevices(); - for (int i = 0, len = temp.Count(); i < len; i++) + for (var devEnum = temp.GetEnumerator(); devEnum.MoveNext();) + //for (int i = 0, len = temp.Count(); i < len; i++) { - DeviceInfo x = temp.ElementAt(i); + DeviceInfo x = devEnum.Current; + //DeviceInfo x = temp.ElementAt(i); HidDevice tempDev = new HidDevice(x.Path, x.Description); bool found = false; for (int j = 0; !found && j < devInfoLen; j++)