I am executing the example code of LibUsbDotNet which will return me the information of all connected usb devices. You can find this code below.
using System;
using LibUsbDotNet;
using LibUsbDotNet.Info;
using LibUsbDotNet.Main;
using System.Collections.ObjectModel;
namespace Examples
{
internal class ShowInfo
{
public static UsbDevice MyUsbDevice;
public static void Main(string[] args)
{
// Dump all devices and descriptor information to console output.
UsbRegDeviceList allDevices = UsbDevice.AllDevices;
foreach (UsbRegistry usbRegistry in allDevices)
{
if (usbRegistry.Open(out MyUsbDevice))
{
Console.WriteLine(MyUsbDevice.Info.ToString());
for (int iConfig = 0; iConfig < MyUsbDevice.Configs.Count; iConfig++)
{
UsbConfigInfo configInfo = MyUsbDevice.Configs[iConfig];
Console.WriteLine(configInfo.ToString());
ReadOnlyCollection<UsbInterfaceInfo> interfaceList = configInfo.InterfaceInfoList;
for (int iInterface = 0; iInterface < interfaceList.Count; iInterface++)
{
UsbInterfaceInfo interfaceInfo = interfaceList[iInterface];
Console.WriteLine(interfaceInfo.ToString());
ReadOnlyCollection<UsbEndpointInfo> endpointList = interfaceInfo.EndpointInfoList;
for (int iEndpoint = 0; iEndpoint < endpointList.Count; iEndpoint++)
{
Console.WriteLine(endpointList[iEndpoint].ToString());
}
}
}
}
}
// Free usb resources.
// This is necessary for libusb-1.0 and Linux compatibility.
UsbDevice.Exit();
// Wait for user input..
Console.ReadKey();
}
}
}
My problem is that the second line executed in the code:
UsbRegDeviceList allDevices = UsbDevice.AllDevices;
does not not return any device at all, while I do have the device I want to find connected, my keyboard and mouse.
Has anyone encountered this problem before? And/or does anyone know how to solve it?
Thanks in Advance! Milan van Dijck