From a6600d7905903665e03f1898a645d9924dafb14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Sun, 18 Dec 2022 09:34:02 +0100 Subject: [PATCH] Properly support many display devices with the same name --- PowerControl/Helpers/AMD/VangoghGPU.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PowerControl/Helpers/AMD/VangoghGPU.cs b/PowerControl/Helpers/AMD/VangoghGPU.cs index 05f3141..88b043d 100644 --- a/PowerControl/Helpers/AMD/VangoghGPU.cs +++ b/PowerControl/Helpers/AMD/VangoghGPU.cs @@ -37,10 +37,15 @@ namespace PowerControl.Helpers.AMD public static bool Detect() { - var discoveredDevices = DeviceManager.GetDevices(DeviceManager.GUID_DISPLAY).ToDictionary((pnp) => + var discoveredDevices = new Dictionary(); + + foreach (var pnp in DeviceManager.GetDevices(DeviceManager.GUID_DISPLAY) ?? new string[0]) { - return DeviceManager.GetDeviceDesc(pnp) ?? ""; - }); + // Properly support many devices with the same name (pick the first one) + var name = DeviceManager.GetDeviceDesc(pnp); + if (name is not null && !discoveredDevices.ContainsKey(name)) + discoveredDevices[name] = pnp; + } foreach (var device in SupportedDevices) {