From 11d9bcc670351af2426c98080d923af06bbc5a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Exterck=C3=B6tter=20Tj=C3=A4der?= Date: Tue, 18 Apr 2017 22:36:23 -0300 Subject: [PATCH] Fix index selection. --- mi/Program.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mi/Program.cs b/mi/Program.cs index 11a4c96..8bcecc0 100755 --- a/mi/Program.cs +++ b/mi/Program.cs @@ -165,13 +165,11 @@ private static void ManageControllers(ScpBus scpBus) device.ReadProduct(out product); + var usedIndexes = Gamepads.Select(g => g.Index); var index = 1; - try - { - index = Gamepads.Select(g => g.Index).Min(); - } - catch (InvalidOperationException) + while (usedIndexes.Contains(index)) { + index++; } Gamepads.Add(new Xiaomi_gamepad(device, scpBus, index)); }