21
|
1 using System; |
|
2 using System.Collections.Generic; |
|
3 using System.Collections.ObjectModel; |
|
4 using UCIS.HWLib.Windows.Devices; |
|
5 using UCIS.USBLib.Internal.Windows; |
|
6 |
|
7 namespace UCIS.HWLib.Windows.USB { |
|
8 public class UsbBus { |
|
9 private List<UsbController> devices = null; |
|
10 public IList<UsbController> Controllers { |
|
11 get { |
|
12 if (devices == null) Refresh(); |
|
13 return devices.AsReadOnly(); |
|
14 } |
|
15 } |
|
16 public void Refresh() { |
|
17 devices = new List<UsbController>(); |
|
18 Guid m_Guid = new Guid(UsbApi.GUID_DEVINTERFACE_HUBCONTROLLER); |
|
19 foreach (DeviceNode dev in DeviceNode.GetDevices(m_Guid)) { |
|
20 String[] interfaces = dev.GetInterfaces(m_Guid); |
|
21 if (interfaces == null || interfaces.Length == 0) continue; |
|
22 devices.Add(new UsbController(this, dev, interfaces[0])); |
|
23 } |
|
24 } |
|
25 } |
|
26 } |