fix(libusb): claim an interface for bulk transfers

This commit is contained in:
CLARATION committed 2026-07-07 15:34:46 -07:00
1 parent 489c6651f9
commit 6e7923a958
1 file changed
+11 -2
+11 -2
View File
@@ -11,6 +11,7 @@
#include "../../utils.h"
void close_usb_handle(usb_handle_t *handle) {
libusb_release_interface(handle->device, 0);
libusb_close(handle->device);
libusb_exit(NULL);
}
@@ -23,9 +24,17 @@ bool wait_usb_handle(usb_handle_t *handle) {
if(libusb_init(NULL) == LIBUSB_SUCCESS) {
for(;;) {
if((handle->device = libusb_open_device_with_vid_pid(NULL, handle->vid, handle->pid)) != NULL) {
if(libusb_set_configuration(handle->device, 1) == LIBUSB_SUCCESS) {
return true;
libusb_set_auto_detach_kernel_driver(handle->device, 1);
if(libusb_set_configuration(handle->device, 1) == LIBUSB_SUCCESS ||
libusb_set_configuration(handle->device, 1) == LIBUSB_ERROR_BUSY)
{
if(libusb_claim_interface(handle->device, 0) == LIBUSB_SUCCESS) {
return true;
}
}
libusb_close(handle->device);
}
sleep_ms(USB_TIMEOUT);