public static UsbDevice GetUsbDevice(DeviceNode node) { if (node == null) { return(null); } //UsbController controller = UsbController.GetControllerForDeviceNode(node); //if (controller != null) return controller; UsbHub hub = UsbHub.GetHubForDeviceNode(node); if (hub != null) { return(hub); } DeviceNode parent = node.GetParent(); if (parent == null) { return(null); } if (parent.Service == "usbccgp") { return(GetUsbDevice(parent)); } hub = UsbHub.GetHubForDeviceNode(parent); if (hub == null) { return(null); } return(hub.FindChildForDeviceNode(node)); }
private UsbHub GetParent() { if (mParent == null && mDeviceNode != null) { mParent = UsbHub.GetHubForDeviceNode(mDeviceNode.GetParent()); if (mParent != null) { UsbDevice self = mParent.FindChildForDeviceNode(mDeviceNode); if (self != null) { mAdapterNumber = self.AdapterNumber; } } } return(mParent); }