Skip to content

Commit ad0ec0b

Browse files
committed
libusbemu: implement libusb_set_debug and libusb_set_configuration
This also fixes the build in VS2010, which would apparently stop compiling when it saw the stub function #warning. Signed-off-by: Drew Fisher <[email protected]>
1 parent 73a22af commit ad0ec0b

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

platform/windows/libusb10emu/libusb-1.0/libusbemu.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ void libusb_exit(libusb_context* ctx)
141141

142142
void libusb_set_debug(libusb_context *ctx, int level)
143143
{
144-
#warning "libusb_set_debug is just a stub"
144+
// Note: libusb-win32 doesn't support context-specific loglevels, so this
145+
// sets the loglevel globally. If this is actually an issue for you, I
146+
// will be surprised.
147+
usb_set_debug(level);
145148
return;
146149
}
147150

@@ -263,8 +266,21 @@ void libusb_close(libusb_device_handle* dev_handle)
263266

264267
int libusb_set_configuration(libusb_device_handle *dev, int configuration)
265268
{
266-
#warning "libusb_set_configuration is just a stub"
267-
return 0;
269+
RAIIMutex lock (dev->dev->ctx->mutex);
270+
int ret = usb_set_configuration(dev->handle, configuration);
271+
if (0 != ret)
272+
{
273+
LIBUSBEMU_ERROR_LIBUSBWIN32();
274+
return ret;
275+
}
276+
// returns:
277+
// 0 on success
278+
// LIBUSB_ERROR_NOT_FOUND if the requested configuration does not exist
279+
// LIBUSB_ERROR_BUSY if interfaces are currently claimed
280+
// LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
281+
// another LIBUSB_ERROR code on other failure
282+
//
283+
return 0;
268284
}
269285

270286
int libusb_claim_interface(libusb_device_handle* dev, int interface_number)

0 commit comments

Comments
 (0)