You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
libusb hotplug for Windows is really important.
I have a program running on Linux/Window/MacOS, but Windows doesn't have hotplug support, I have to write my own device detection code for Windows.
But Windows only reports that there is a device arrived or there's a device removed, you have to find which one is added or removed.
So when I receive device remove event, I usb libusb_get_device_list() to get current device present in the system, and compare this list with the old one to find out which one is removed, and I use the same method to find which one is added, after I find the difference, my program will handle the removed/added device.
But if I unplug the device and plug it back to the same USB port very quickly, and Windows's driver searching program is disabled(to make system recognize device faster), my program can get device remove and device add event correctly, but libusb_get_device_list() will get a usb device list the same as the previous saved one.
Here is the reason:
When my program receives device remove event, and start to list all the USB devices, because the unplug/plug action is so fast, libusb_get_device_list() will give a list after the device is plugged back. So this USB device list is the same as the list before unplug/plug action, which means my program cannot find out which device is removed and which is added, there will be 2 missing actions for my program.
Because my program is event driven, this causes 2 events missing.
I really hope that hotplug feature can be implemented for Windows.
SimaWB, rjgc2015, zhengqijun0121, huigzi, sols000 and 3 more
I tried that before, I even tried to merge the change into libusb 1.0.19, but I failed to merge it to newer code. I still need to use latest branch, because there are tons of bug/leak fixes for Windows platform.
Hope Windows hotplug support can be implemented soon.
were there any changes regarding the hotplug issue since then? Currently having the problem with LibUsbDotNet that communication with an unplugged-replugged device is only possible again after reinstalling the driver using the Inf-Wizard OR restarting Windows. This device is a CardReader. On the other hand, i dont have issues hotplugging a USB Keyboard. Does anyone have suggestions?
@chrisba77 strange w/o any "hotplug" support you should be able to re-use the device without driver re-install reboot etc
if:
-release any claimed interface
-close the device
-call exit on the libsusb context
then run again lib usb init , device detect ,re-open re claim etc ..
That is what i do to get control again of unplugged and re-pluged device
not real nice but the simplest i did find.
@diabolo38 I do all this. And actually after plugging in the device again, communication is possible. BUT the read values coming from the device are not valid anymore.
After reading in a Tag / Card the device sends some HID reports with Number-Keys including a Return Hit. After unplug / replug, these values seem to be random. Checked with Port Sniffer that I read the right values coming from the device. But sent Key Hits are not valid anymore and change every time i read in the same Tag. Reconnecting or Restarting my Test-SW doesnt help. Only thing that helps is rerunning Inf-Wizard or a reboot.
@chrisba77 if device is hid using standard os hid device driver then the issue could be os driver or the device itlsef. I can't see such issue with non hid device at least.
I tested and found that the device change can be detected according to idVendor, idProduct, port from libusb_get_port_number, address from libusb_get_device_address.
I can confirm that using <vid, pid, port, address> tuplet works on Windows and Linux (the address is increased every time the device is connected).
Note that it does not work on Macos (both port and address are constant).
Not sure if this is the right place to comment, but is the hotplug for windows fully implemented now if it isn't. Are we getting it this year or next year?
36.0.0 (Apr 2025)
adb
Re-written libusb USB backend (uses sync API instead of async API). Improves reliability and fixes memory exhaustion on Linux.
Libusb USB backend hot-plug now supports for Windows (enables USB speed detection).
Improved server-status now displays if mdns is enabled.
@sonatique Please don't reply with just a quote. That's as helpful as just not saying anything at all. Use the edit button, please! Especially if your message before it was just a minute ago.
Activity
mcuee commentedon Nov 27, 2015
Last known tree back in the libusbx time.
https://github.com/dickens/libusbx-hp/tree/windows-hotplug-3
[-]libusb Windows hotplug support[/-][+]Windows: libusb Windows hotplug support[/+]changyp6 commentedon Mar 2, 2016
libusb hotplug for Windows is really important.
I have a program running on Linux/Window/MacOS, but Windows doesn't have hotplug support, I have to write my own device detection code for Windows.
But Windows only reports that there is a device arrived or there's a device removed, you have to find which one is added or removed.
So when I receive device remove event, I usb libusb_get_device_list() to get current device present in the system, and compare this list with the old one to find out which one is removed, and I use the same method to find which one is added, after I find the difference, my program will handle the removed/added device.
But if I unplug the device and plug it back to the same USB port very quickly, and Windows's driver searching program is disabled(to make system recognize device faster), my program can get device remove and device add event correctly, but libusb_get_device_list() will get a usb device list the same as the previous saved one.
Here is the reason:
When my program receives device remove event, and start to list all the USB devices, because the unplug/plug action is so fast, libusb_get_device_list() will give a list after the device is plugged back. So this USB device list is the same as the list before unplug/plug action, which means my program cannot find out which device is removed and which is added, there will be 2 missing actions for my program.
Because my program is event driven, this causes 2 events missing.
I really hope that hotplug feature can be implemented for Windows.
mcuee commentedon Mar 3, 2016
changyp6 commentedon Mar 3, 2016
I tried that before, I even tried to merge the change into libusb 1.0.19, but I failed to merge it to newer code. I still need to use latest branch, because there are tons of bug/leak fixes for Windows platform.
Hope Windows hotplug support can be implemented soon.
dickens commentedon Mar 3, 2016
Will be part of the next release. Unfortunately it is a complicated set of
changes.
Regards,
Chris
changyp6 commentedon Mar 3, 2016
This is a great news!
chrisba77 commentedon Sep 2, 2016
were there any changes regarding the hotplug issue since then? Currently having the problem with LibUsbDotNet that communication with an unplugged-replugged device is only possible again after reinstalling the driver using the Inf-Wizard OR restarting Windows. This device is a CardReader. On the other hand, i dont have issues hotplugging a USB Keyboard. Does anyone have suggestions?
diabolo38 commentedon Sep 3, 2016
@chrisba77 strange w/o any "hotplug" support you should be able to re-use the device without driver re-install reboot etc
if:
-release any claimed interface
-close the device
-call exit on the libsusb context
then run again lib usb init , device detect ,re-open re claim etc ..
That is what i do to get control again of unplugged and re-pluged device
not real nice but the simplest i did find.
chrisba77 commentedon Sep 5, 2016
@diabolo38 I do all this. And actually after plugging in the device again, communication is possible. BUT the read values coming from the device are not valid anymore.
After reading in a Tag / Card the device sends some HID reports with Number-Keys including a Return Hit. After unplug / replug, these values seem to be random. Checked with Port Sniffer that I read the right values coming from the device. But sent Key Hits are not valid anymore and change every time i read in the same Tag. Reconnecting or Restarting my Test-SW doesnt help. Only thing that helps is rerunning Inf-Wizard or a reboot.
diabolo38 commentedon Sep 5, 2016
@chrisba77 if device is hid using standard os hid device driver then the issue could be os driver or the device itlsef. I can't see such issue with non hid device at least.
97 remaining items
sonatique commentedon Dec 28, 2023
Please see #1406 . Comments welcome.
fabiensanglard commentedon Jan 29, 2024
@mcuee while #1406 is being reviewed, is there an official recommended way to poll on system without hotplug?
I tried the method mentioned by @Aii-Wei above.
I can confirm that using <
vid
,pid
,port
,address
> tuplet works on Windows and Linux (theaddress
is increased every time the device is connected).Note that it does not work on Macos (both port and address are constant).
mcuee commentedon Feb 6, 2024
@fabiensanglard
For Windows, I think we should focus on reviewing and testing PR #1406 to get it merged.
As for the work-around, let's see if @tormodvolden has some recommendations for platforms without hotplug support.
fabiensanglard commentedon May 20, 2024
I wrote a code sample to illustrate how to fallback on system without support for hotplug.
PR #1498
mosot624 commentedon Oct 3, 2024
Not sure if this is the right place to comment, but is the hotplug for windows fully implemented now if it isn't. Are we getting it this year or next year?
Timmmm commentedon Oct 3, 2024
You mean this decade or next right? 😬😄
mcuee commentedon Jun 6, 2025
#1406 has seen some updates recently now that @sonatique is part of the admin team.
Let's hope that Windows Hotplug will be added within year 2025.
ValeZAA commentedon Jul 8, 2025
adb from google added hotplug
sonatique commentedon Jul 9, 2025
@ValeZAA : Hello, I didn't get your point, sorry. Could you elaborate?
sonatique commentedon Jul 9, 2025
@mcuee : do you have any idea about things I can do to actually see this happens?
markg85 commentedon Jul 9, 2025
@sonatique Please don't reply with just a quote. That's as helpful as just not saying anything at all. Use the edit button, please! Especially if your message before it was just a minute ago.
Thank you for your understanding.
mcuee commentedon Jul 14, 2025
Let's discuss with @tormodvolden to see how to make progress with this one.