Closed Tunghohin closed 5 months ago
The problem here is that the Windows.Devices.Usb documentation states that it doesn't provide access to some USB devices. In particular, it states that this namespace is for WinUSB devices only. Have you verified that the device you are trying to access is WinUSB compatible?
To give an example, my system does have a WinUSB compatible device.
#include <Windows.h>
#include <string>
#include <format>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Devices.h>
#include <winrt/Windows.Devices.Enumeration.h>
#include <winrt/Windows.Devices.Usb.h>
int wmain()
{
auto devices = winrt::Windows::Devices::Enumeration::DeviceInformation::FindAllAsync(
winrt::Windows::Devices::Usb::UsbDevice::GetDeviceSelector(0x1e71, 0x300c)
).get();
for (auto device : devices)
{
auto fmt_string = std::format(L"{}", std::wstring_view(device.Id()));
_putws(fmt_string.c_str());
}
return 0;
}
This gave me the following output:
\\?\USB#VID_1E71&PID_300C&MI_00#9&fbe3bfd&0&0000#{dee824ef-729b-4a0e-9c14-b7117d33a817}
So it works fine for me on my system when the device is properly declared as a WinUSB device.
As a follow up to this, I did get an opportunity to try this out with a video capture USB device.
The code used was the same as above, except it had the VID changed to 0x07ca and PID changed to 0xd553 to reflect the device. As you can see, it successfully obtained an instance of the DeviceInformation. So again, can you confirm that the device is a WinUSB device?
As a follow up to this, I did get an opportunity to try this out with a video capture USB device.
The code used was the same as above, except it had the VID changed to 0x07ca and PID changed to 0xd553 to reflect the device. As you can see, it successfully obtained an instance of the DeviceInformation. So again, can you confirm that the device is a WinUSB device?
I observed that my usb capture uses the usbccgp.sys driver instead of the winusb.sys driver, is this technically considered a winusb device? Very much appreciate it if you could provide me with more relevant information.
I observed that my usb capture uses the usbccgp.sys driver instead of the winusb.sys driver, is this technically considered a winusb device?
No.
While usbccgp is in the driver stack for a WinUSB device, as clearly documented by the Windows.Devices.Usb Namespace documentation, a WinUSB device will have a very specific compatible ID. If the device does not have the USB\MS_COMP_WINUSB compatible ID then it is not a valid WinUSB device.
This information can be easily obtained from device manager.
Describe the bug
DeviceInformation::FindAddAsync returns empty collection when specifying a usb device.
https://github.com/microsoft/cppwinrt/issues/1420
Steps to reproduce the bug
output:
gets a empty collection