private void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     foreach (var device in foundDevices)
     {
         HID.CloseHidDevice(device);
     }
 }
        void RefreshDevices()
        {
            Devices.Items.Clear();
            foreach (var device in foundDevices)
            {
                HID.CloseHidDevice(device);
            }
            foundDevices.Clear();
            var devices = HID.FindKnownHidDevices();

            var vendor = int.Parse(Constants.Config.IniReadValue("Controller", "VendorID", "1118"));

            foreach (var device in devices)
            {
                if (device.Attributes.VendorID == vendor)
                {
                    var split  = device.DevicePath.Split('\\');
                    var split2 = split.Last();
                    var split3 = split2.Split('#');

                    var devicePath = string.Join(@"\", split3, 0, 3).ToUpper();

                    var name = HID.GetProductString(device);

                    if (Constants.ControllerIDs.ContainsKey(device.Attributes.ProductID))
                    {
                        name = Constants.ControllerIDs[device.Attributes.ProductID];
                    }

                    var split4 = split3[1].Split('&');
                    foreach (var test in split4)
                    {
                        if (test.StartsWith("ig"))
                        {
                            var split5 = test.Split('_');

                            if (uint.TryParse(split5[1], NumberStyles.HexNumber, null, out uint id) && id > 0)
                            {
                                name += $" ({id / 2})";
                            }
                        }
                    }

                    var dev = new ListBoxItem()
                    {
                        ToolTip = new ToolTip {
                            Content = devicePath
                        },
                        Content = name,
                    };

                    foundDevices.Add(device);

                    Devices.Items.Add(dev);
                }
            }
        }