39 GENERIC_READ | GENERIC_WRITE,
40 FILE_SHARE_READ | FILE_SHARE_WRITE,
46 auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end -
start).
count();
47 if (elapsed > timeout_ms)
49 std::this_thread::sleep_for(std::chrono::milliseconds(5));
54 auto lastResult = GetLastError();
55 LOG_ERROR(
"CreateFile failed, error: " << lastResult);
59 WINUSB_INTERFACE_HANDLE ah;
62 auto lastResult = GetLastError();
63 LOG_ERROR(
"WinUsb_Initialize failed, error: " << lastResult);
66 USB_INTERFACE_DESCRIPTOR desc;
67 if (!WinUsb_QueryInterfaceSettings(ah, 0, &desc)) {
68 throw winapi_error(
"WinUsb action failed, last error: " + GetLastError());
70 _handles[desc.bInterfaceNumber] = ah;
73 for (UCHAR interface_number = 0;
true; interface_number++) {
74 WINUSB_INTERFACE_HANDLE
h;
75 USB_INTERFACE_DESCRIPTOR descriptor;
77 if (!WinUsb_GetAssociatedInterface(ah, interface_number, &h)) {
78 auto error = GetLastError();
79 if (
error != ERROR_NO_MORE_ITEMS)
84 if (!WinUsb_QueryInterfaceSettings(h, 0, &descriptor)) {
85 throw winapi_error(
"WinUsb action failed, last error: " + GetLastError());
87 _handles[descriptor.bInterfaceNumber] =
h;
97 WinUsb_Free(
h.second);
112 throw std::runtime_error(
"get_interface_handle failed, interface not found");
GLsizei const GLchar *const * path
GLfloat GLfloat GLfloat GLfloat h