diff USBLib/Windows/USB/UsbBus.cs @ 21:dcfec2be27c9

Added USBLib
author Ivo Smits <Ivo@UCIS.nl>
date Mon, 15 Apr 2013 01:04:59 +0200
parents
children 5b14fed54a89
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBLib/Windows/USB/UsbBus.cs	Mon Apr 15 01:04:59 2013 +0200
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using UCIS.HWLib.Windows.Devices;
+using UCIS.USBLib.Internal.Windows;
+
+namespace UCIS.HWLib.Windows.USB {
+	public class UsbBus {
+		private List<UsbController> devices = null;
+		public IList<UsbController> Controllers {
+			get {
+				if (devices == null) Refresh();
+				return devices.AsReadOnly();
+			}
+		}
+		public void Refresh() {
+			devices = new List<UsbController>();
+			Guid m_Guid = new Guid(UsbApi.GUID_DEVINTERFACE_HUBCONTROLLER);
+			foreach (DeviceNode dev in DeviceNode.GetDevices(m_Guid)) {
+				String[] interfaces = dev.GetInterfaces(m_Guid);
+				if (interfaces == null || interfaces.Length == 0) continue;
+				devices.Add(new UsbController(this, dev, interfaces[0]));
+			}
+		}
+	}
+}
\ No newline at end of file