summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2010-07-25 19:25:38 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2010-07-25 19:25:38 +0000
commit803a0edb58e46e2031358b09ac340b38f58a87b5 (patch)
tree9154c8be0aaf7b50f9e1ad3e64c8e8bb9925f4bb
parentd904597524f0dfeee537149f11c4472dc5f4d36e (diff)
downloadrockbox-803a0edb58e46e2031358b09ac340b38f58a87b5.tar.gz
rockbox-803a0edb58e46e2031358b09ac340b38f58a87b5.zip
Fix USB ID retrieval on Windows 7.
The device string containing the USB IDs differs in casing on Windows 7 so always convert to upper case before scanning the string. Use DEVICEDESC instead of LOCATION_INFORMATION for the user visible device string as the latter doesn't show anything useful to the user on W7, at least for the devices I've tried. Unfortunately DEVICEDESC is less descriptive than the previously used. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27561 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/base/system.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/rbutil/rbutilqt/base/system.cpp b/rbutil/rbutilqt/base/system.cpp
index 61a5b95cde..229becc40c 100644
--- a/rbutil/rbutilqt/base/system.cpp
+++ b/rbutil/rbutilqt/base/system.cpp
@@ -336,20 +336,7 @@ QMap<uint32_t, QString> System::listUsbDevices(void)
336 // get device desriptor first 336 // get device desriptor first
337 // for some reason not doing so results in bad things (tm) 337 // for some reason not doing so results in bad things (tm)
338 while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData, 338 while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
339 SPDRP_DEVICEDESC,&data, (PBYTE)buffer, buffersize, &buffersize)) { 339 SPDRP_DEVICEDESC, &data, (PBYTE)buffer, buffersize, &buffersize)) {
340 if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
341 if(buffer) free(buffer);
342 // double buffer size to avoid problems as per KB888609
343 buffer = (LPTSTR)malloc(buffersize * 2);
344 }
345 else {
346 break;
347 }
348 }
349
350 // now get the hardware id, which contains PID and VID.
351 while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
352 SPDRP_LOCATION_INFORMATION,&data, (PBYTE)buffer, buffersize, &buffersize)) {
353 if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) { 340 if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
354 if(buffer) free(buffer); 341 if(buffer) free(buffer);
355 // double buffer size to avoid problems as per KB888609 342 // double buffer size to avoid problems as per KB888609
@@ -361,8 +348,9 @@ QMap<uint32_t, QString> System::listUsbDevices(void)
361 } 348 }
362 description = QString::fromWCharArray(buffer); 349 description = QString::fromWCharArray(buffer);
363 350
351 // now get the hardware id, which contains PID and VID.
364 while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData, 352 while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
365 SPDRP_HARDWAREID,&data, (PBYTE)buffer, buffersize, &buffersize)) { 353 SPDRP_HARDWAREID, &data, (PBYTE)buffer, buffersize, &buffersize)) {
366 if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) { 354 if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
367 if(buffer) free(buffer); 355 if(buffer) free(buffer);
368 // double buffer size to avoid problems as per KB888609 356 // double buffer size to avoid problems as per KB888609
@@ -374,7 +362,11 @@ QMap<uint32_t, QString> System::listUsbDevices(void)
374 } 362 }
375 363
376 unsigned int vid, pid; 364 unsigned int vid, pid;
377 if(_stscanf(buffer, _TEXT("USB\\Vid_%x&Pid_%x"), &vid, &pid) == 2) { 365 // convert buffer text to upper case to avoid depending on the case of
366 // the keys (W7 uses different casing than XP at least).
367 int len = _tcslen(buffer);
368 while(len--) buffer[len] = _totupper(buffer[len]);
369 if(_stscanf(buffer, _TEXT("USB\\VID_%x&PID_%x"), &vid, &pid) == 2) {
378 uint32_t id; 370 uint32_t id;
379 id = vid << 16 | pid; 371 id = vid << 16 | pid;
380 usbids.insert(id, description); 372 usbids.insert(id, description);