From ad65f8cc71bfe9e98936d5f781263850a9d50cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1stor=20Mu=C3=B1oz?= Date: Sun, 20 Dec 2015 12:25:41 +0100 Subject: [PATCH] Handle mixed case in Windows USB ID detection. Windows XP might use mixed case in hardware ID (VID / PID) string. Cherry-picked from G#1221. Change-Id: I86fa63e050cd9b9de5a1beac65b81028e0f86a9d Signed-off-by: Dominik Riebeling --- rbutil/rbutilqt/base/system.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rbutil/rbutilqt/base/system.cpp b/rbutil/rbutilqt/base/system.cpp index 855d9e3b06..3e3f18fd81 100644 --- a/rbutil/rbutilqt/base/system.cpp +++ b/rbutil/rbutilqt/base/system.cpp @@ -467,9 +467,10 @@ QMap System::listUsbDevices(void) if(buffer) { // convert buffer text to upper case to avoid depending on the case of - // the keys (W7 uses different casing than XP at least). - QString data = QString::fromWCharArray(buffer); - QRegExp rex("USB\\\\VID_([0-9a-fA-F]{4})&PID_([0-9a-fA-F]{4}).*"); + // the keys (W7 uses different casing than XP at least), in addition + // XP may use "Vid_" and "Pid_". + QString data = QString::fromWCharArray(buffer).toUpper(); + QRegExp rex("USB\\\\VID_([0-9A-F]{4})&PID_([0-9A-F]{4}).*"); if(rex.indexIn(data) >= 0) { uint32_t id; id = rex.cap(1).toUInt(0, 16) << 16 | rex.cap(2).toUInt(0, 16);