diff --git a/qt5_src/Bootloader/MainWindow.cpp b/qt5_src/Bootloader/MainWindow.cpp index c099bb2..1134800 100644 --- a/qt5_src/Bootloader/MainWindow.cpp +++ b/qt5_src/Bootloader/MainWindow.cpp @@ -82,6 +82,10 @@ struct USBDevIds {0x04D8, 0xECEE} // from microchip sublicense }; +// If the user ignores the popup to reset a device in normal mode into bootloader mode +// the path of the device that triggered the popup will be added to this list and will +// not prompt the user again unless it gets disconnected from the computer. +QList IgnoredHIDDevsList; //Surely the micro doesn't have a programmable memory region greater than 268 Megabytes... //Value used for error checking device reponse values. @@ -381,8 +385,28 @@ void MainWindow::Connection(void) // check if a device is found in normal non-bootloader mode hid_device_info *hidDevs = hid_enumerate(0, 0); hid_device_info *d = hidDevs; + // a new ignored list will be created & only currently ignored devices that are still connected will be saved + QList filteredIgnoredDevsList; + bool ignoreRemaining = false; while (d) { + // check if the device is ignored & add to new list if it is + QString qstrPath = QString::fromUtf8(d->path); + if (IgnoredHIDDevsList.contains(qstrPath)) + { + filteredIgnoredDevsList.append(qstrPath); + d = d->next; + continue; + } + + // if user ignored a previous device do not continue checking for matching devices + if (ignoreRemaining) + { + d = d->next; + continue; + } + + // check if the device matches any of our PID/VID combinations for (unsigned int i=0;ipath); if (dev == NULL) { @@ -414,12 +445,16 @@ void MainWindow::Connection(void) QMessageBox::critical(this, "Error", errMsg); } hid_close(dev); + + // do not continue iterating over the list of enumerated HID devices + ignoreRemaining = true; + break; } } - d = d->next; } - + // copy the latest ignored devices array to the global list + IgnoredHIDDevsList = QList(filteredIgnoredDevsList); hid_free_enumeration(hidDevs); }