Mercurial > hg > ucis.core
annotate USBLib/Windows/USB/UsbController.cs @ 58:fd63c453ff65
Improved Windows USB enumeration classes
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Wed, 09 Oct 2013 20:54:15 +0200 |
parents | dcfec2be27c9 |
children | 3424fa5a12c9 |
rev | line source |
---|---|
21 | 1 using System; |
2 using System.Runtime.InteropServices; | |
3 using Microsoft.Win32.SafeHandles; | |
4 using UCIS.HWLib.Windows.Devices; | |
5 using UCIS.USBLib.Internal.Windows; | |
6 | |
7 namespace UCIS.HWLib.Windows.USB { | |
8 public class UsbController { | |
9 public String DevicePath { get; private set; } | |
10 public DeviceNode DeviceNode { get; private set; } | |
58
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
11 public String DeviceDescription { |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
12 get { return DeviceNode.GetPropertyString(SPDRP.DeviceDesc); } |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
13 } |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
14 public String DriverKey { |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
15 get { return DeviceNode.GetPropertyString(SPDRP.Driver); } |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
16 } |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
17 public UsbHub RootHub { |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
18 get { |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
19 String rootHubName; |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
20 using (SafeFileHandle handle = UsbHub.OpenHandle(DevicePath)) rootHubName = UsbHub.GetRootHubName(handle); |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
21 return new UsbHub(null, new USB_NODE_CONNECTION_INFORMATION_EX(), @"\\?\" + rootHubName, 0, true); |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
22 } |
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
23 } |
21 | 24 internal UsbController(UsbBus parent, DeviceNode di, String devicePath) { |
25 this.DeviceNode = di; | |
26 this.DevicePath = devicePath; | |
27 } | |
28 } | |
58
fd63c453ff65
Improved Windows USB enumeration classes
Ivo Smits <Ivo@UCIS.nl>
parents:
21
diff
changeset
|
29 } |