Mercurial > hg > ucis.core
comparison USBLib/Internal/Windows/UsbApi.cs @ 63:309c705d7460
Updates and cleanup in Windows USB enumeration code
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Sun, 13 Oct 2013 18:43:45 +0200 |
parents | edc41c861d96 |
children | e811297f5aa4 |
comparison
equal
deleted
inserted
replaced
62:edc41c861d96 | 63:309c705d7460 |
---|---|
24 public const int DICS_FLAG_GLOBAL = 0x00000001; | 24 public const int DICS_FLAG_GLOBAL = 0x00000001; |
25 | 25 |
26 public const int DICS_ENABLE = 0x00000001; | 26 public const int DICS_ENABLE = 0x00000001; |
27 public const int DICS_DISABLE = 0x00000002; | 27 public const int DICS_DISABLE = 0x00000002; |
28 } | 28 } |
29 | |
30 #region enumerations | |
31 | 29 |
32 enum UsbDeviceClass : byte { | 30 enum UsbDeviceClass : byte { |
33 UnspecifiedDevice = 0x00, | 31 UnspecifiedDevice = 0x00, |
34 AudioInterface = 0x01, | 32 AudioInterface = 0x01, |
35 CommunicationsAndCDCControlBoth = 0x02, | 33 CommunicationsAndCDCControlBoth = 0x02, |
52 } | 50 } |
53 | 51 |
54 enum HubCharacteristics : byte { | 52 enum HubCharacteristics : byte { |
55 GangedPowerSwitching = 0x00, | 53 GangedPowerSwitching = 0x00, |
56 IndividualPotPowerSwitching = 0x01, | 54 IndividualPotPowerSwitching = 0x01, |
57 // to do | |
58 } | |
59 | |
60 enum USB_HUB_NODE { | |
61 UsbHub, | |
62 UsbMIParent | |
63 } | 55 } |
64 | 56 |
65 enum USB_CONNECTION_STATUS : int { | 57 enum USB_CONNECTION_STATUS : int { |
66 NoDeviceConnected, | 58 NoDeviceConnected, |
67 DeviceConnected, | 59 DeviceConnected, |
98 Power = 0x0100, | 90 Power = 0x0100, |
99 LowSpeed = 0x0200, | 91 LowSpeed = 0x0200, |
100 HighSpeed = 0x0400, | 92 HighSpeed = 0x0400, |
101 TestMode = 0x0800, | 93 TestMode = 0x0800, |
102 Indicator = 0x1000, | 94 Indicator = 0x1000, |
103 // these are the bits which cause the hub port state machine to keep moving | |
104 //kHubPortStateChangeMask = kHubPortConnection | kHubPortEnabled | kHubPortSuspend | kHubPortOverCurrent | kHubPortBeingReset | |
105 } | 95 } |
106 | 96 |
107 enum HubStatus : byte { | 97 enum HubStatus : byte { |
108 LocalPowerStatus = 1, | 98 LocalPowerStatus = 1, |
109 OverCurrentIndicator = 2, | 99 OverCurrentIndicator = 2, |
123 SupportsIndividualPortPower = 1, | 113 SupportsIndividualPortPower = 1, |
124 SetPowerOff = 0, | 114 SetPowerOff = 0, |
125 SetPowerOn = 1 | 115 SetPowerOn = 1 |
126 } | 116 } |
127 | 117 |
128 #endregion | |
129 | |
130 #region structures | |
131 | |
132 [StructLayout(LayoutKind.Sequential)] | 118 [StructLayout(LayoutKind.Sequential)] |
133 struct SP_CLASSINSTALL_HEADER { | 119 struct SP_CLASSINSTALL_HEADER { |
134 public int cbSize; | 120 public int cbSize; |
135 public int InstallFunction; //DI_FUNCTION InstallFunction; | 121 public int InstallFunction; //DI_FUNCTION InstallFunction; |
136 } | 122 } |
141 public int StateChange; | 127 public int StateChange; |
142 public int Scope; | 128 public int Scope; |
143 public int HwProfile; | 129 public int HwProfile; |
144 } | 130 } |
145 | 131 |
146 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] | 132 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] |
147 struct USB_HCD_DRIVERKEY_NAME { | 133 struct USB_HCD_DRIVERKEY_NAME { |
148 public uint ActualLength; | 134 public UInt32 ActualLength; |
149 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = UsbApi.MAX_BUFFER_SIZE)] | 135 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = UsbApi.MAX_BUFFER_SIZE)] |
150 public string DriverKeyName; //WCHAR DriverKeyName[1]; | 136 public String DriverKeyName; |
151 } | 137 } |
152 | 138 |
153 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] | 139 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] |
154 struct USB_ROOT_HUB_NAME { | 140 struct USB_ROOT_HUB_NAME { |
155 public uint ActualLength; | 141 public UInt32 ActualLength; |
156 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = UsbApi.MAX_BUFFER_SIZE)] | 142 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = UsbApi.MAX_BUFFER_SIZE)] |
157 public string RootHubName; //WCHAR RootHubName[1]; | 143 public String RootHubName; |
158 } | 144 } |
159 | 145 |
160 [StructLayout(LayoutKind.Sequential, Pack = 1)] | 146 [StructLayout(LayoutKind.Sequential, Pack = 1)] |
161 struct USB_HUB_DESCRIPTOR { | 147 struct USB_HUB_DESCRIPTOR { |
162 public byte bDescriptorLength; | 148 public byte bDescriptorLength; |
175 public bool HubIsBusPowered; | 161 public bool HubIsBusPowered; |
176 } | 162 } |
177 | 163 |
178 [StructLayout(LayoutKind.Sequential)] | 164 [StructLayout(LayoutKind.Sequential)] |
179 struct USB_NODE_INFORMATION { | 165 struct USB_NODE_INFORMATION { |
180 //public int NodeType; | 166 public int NodeType; |
181 public USB_HUB_NODE NodeType; | 167 public USB_HUB_INFORMATION HubInformation; |
182 public USB_HUB_INFORMATION HubInformation; // union { USB_HUB_INFORMATION HubInformation; USB_MI_PARENT_INFORMATION MiParentInformation; } | |
183 } | 168 } |
184 | 169 |
185 [StructLayout(LayoutKind.Sequential, Pack = 1)] | 170 [StructLayout(LayoutKind.Sequential, Pack = 1)] |
186 struct USB_NODE_CONNECTION_INFORMATION_EX { | 171 struct USB_NODE_CONNECTION_INFORMATION_EX { |
187 public uint ConnectionIndex; | 172 public uint ConnectionIndex; |
223 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | 208 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] |
224 struct USB_NODE_CONNECTION_NAME { | 209 struct USB_NODE_CONNECTION_NAME { |
225 public uint ConnectionIndex; | 210 public uint ConnectionIndex; |
226 public uint ActualLength; | 211 public uint ActualLength; |
227 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = UsbApi.MAX_BUFFER_SIZE)] | 212 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = UsbApi.MAX_BUFFER_SIZE)] |
228 public string NodeName; //WCHAR NodeName[1]; | 213 public string NodeName; |
229 } | 214 } |
230 | 215 |
231 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | 216 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] |
232 struct USB_NODE_CONNECTION_DRIVERKEY_NAME { | 217 struct USB_NODE_CONNECTION_DRIVERKEY_NAME { |
233 public uint ConnectionIndex; | 218 public uint ConnectionIndex; |
234 public uint ActualLength; | 219 public uint ActualLength; |
235 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = UsbApi.MAX_BUFFER_SIZE)] | 220 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = UsbApi.MAX_BUFFER_SIZE)] |
236 public string DriverKeyName; //WCHAR DriverKeyName[1]; | 221 public string DriverKeyName; |
237 } | 222 } |
238 | 223 |
239 [StructLayout(LayoutKind.Sequential)] | 224 [StructLayout(LayoutKind.Sequential)] |
240 struct STORAGE_DEVICE_NUMBER { | 225 struct STORAGE_DEVICE_NUMBER { |
241 public int DeviceType; //DEVICE_TYPE DeviceType; | 226 public int DeviceType; //DEVICE_TYPE DeviceType; |
242 public uint DeviceNumber; | 227 public uint DeviceNumber; |
243 public uint PartitionNumber; | 228 public uint PartitionNumber; |
244 } | 229 } |
245 #endregion | |
246 } | 230 } |