예제 #1
0
        /// <summary>
        ///
        /// </summary>
        public virtual UsbInterface FindInterface(UsbDevice device)
        {
            UsbInterface        usbIntf = null;
            List <UsbInterface> usbIntfs = device.GetInterfaces();
            int i = 0, imax = usbIntfs.Count;

            if (m_Class != -1 && m_Subclass != -1 && m_Protocol != -1)  // Get the given UsbInterface.
            {
                for (; i < imax; ++i)
                {
                    usbIntf = usbIntfs[i];
                    if (usbIntf.GetInterfaceClass() == m_Class)
                    {
                        if (usbIntf.GetInterfaceSubclass() == m_Subclass)
                        {
                            if (usbIntf.GetInterfaceProtocol() == m_Protocol)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                usbIntf = usbIntfs[0];
            }
            //m_Class=m_Subclass=m_Protocol=-1;//Reset filters.???

            return(usbIntf);
        }