view USBLib/Windows/USB/UsbBus.cs @ 32:ff1bc8445743

FBGUI: Changed event handling and propagation to be more extensible
author Ivo Smits <Ivo@UCIS.nl>
date Fri, 19 Apr 2013 16:54:51 +0200
parents 5b14fed54a89
children
line wrap: on
line source

using System;
using System.Collections.Generic;
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]));
			}
		}
	}
}