From 65c832da35a367024ada294979bdcf20332ba20f Mon Sep 17 00:00:00 2001 From: cranphin Date: Wed, 1 Sep 2010 18:49:18 +0000 Subject: [PATCH] Stop rawhid (Windows) from logging a debug message because it can't open all my input devices for writing. And also swap logging statements, so that we do qDebug after GetLastError, since qDebug seems to wipe the last error code. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1497 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/rawhid/pjrc_rawhid_win.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ground/src/plugins/rawhid/pjrc_rawhid_win.cpp b/ground/src/plugins/rawhid/pjrc_rawhid_win.cpp index 8150bebf8..8f3c0b144 100644 --- a/ground/src/plugins/rawhid/pjrc_rawhid_win.cpp +++ b/ground/src/plugins/rawhid/pjrc_rawhid_win.cpp @@ -133,14 +133,23 @@ int pjrc_rawhid::open(int max, int vid, int pid, int usage_page, int usage) OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); - if( GetLastError() != ERROR_SUCCESS ) + if( h == INVALID_HANDLE_VALUE ) { - qDebug("Problem openning handle"); - print_win32_err(); + // I get ERROR_ACCESS_DENIED with most/all my input devices (mice/trackballs/tablet). + // Let's not log it :) + if(GetLastError() == ERROR_ACCESS_DENIED) { + free(details); + continue; + } + // qDebug wipes the GetLastError() it seems, so do that after print_win32_err(). + print_win32_err(); + qDebug() << "Problem opening handle, path: " << QString().fromWCharArray(details->DevicePath); + free(details); + continue; } free(details); - if (h == INVALID_HANDLE_VALUE) continue; + attrib.Size = sizeof(HIDD_ATTRIBUTES); ret = HidD_GetAttributes(h, &attrib); //printf("vid: %4x\n", attrib.VendorID);