Search code examples
windowsusblibusbhotplugging

How does libusb detect an USB device via hotplug under Windows?


For research i looked into Libusb to see how hotluging is done. For Linux, i found the corresponding source in libusb\os\linux_udev.c where a thread is started which makes a poll() on udev. However, after spending hours in the sources of Libusb I can't figure out how hotpluging in Windows is done.

In libusb\os\windows_winusb.c obviously the winusb driver is used to get a device list (static int winusb_get_device_list(..)) but this is not necearilly a hotplug thing. Can someone point me int the right direction?

I use usb4java (a libusb Java wrapper) in my project and can detect an attach/detach event just fine, but I want to know how it works.


Solution

  • As of Jan 28, 2024, libusb does not support hotplug on Windows. That is why you can't find it in the source code. There is a bug open to add the feature since 2015 and it looks like it may get implemented soon.