Пример #1
0
        public byte[] GetDescriptor(USBPacket packet, USBSetupPacket setupPacket)
        {
            DescriptorType type;

            type = (DescriptorType)((setupPacket.value & 0xff00) >> 8);
            uint index = (uint)(setupPacket.value & 0xff);

            switch (type)
            {
            case DescriptorType.Device:
                controlPacket = new byte[deviceDescriptor.ToArray().Length];
                deviceDescriptor.ToArray().CopyTo(controlPacket, 0);
                return(deviceDescriptor.ToArray());

            case DescriptorType.Configuration:
                controlPacket = new byte[configurationDescriptor.ToArray().Length];
                configurationDescriptor.ToArray().CopyTo(controlPacket, 0);
                return(configurationDescriptor.ToArray());

            case DescriptorType.DeviceQualifier:
                controlPacket = new byte[deviceQualifierDescriptor.ToArray().Length];
                deviceQualifierDescriptor.ToArray().CopyTo(controlPacket, 0);
                return(deviceQualifierDescriptor.ToArray());

            case DescriptorType.InterfacePower:
                throw new NotImplementedException("Interface Power Descriptor is not yet implemented. Please contact AntMicro for further support.");

            case DescriptorType.OtherSpeedConfiguration:
                controlPacket = new byte[otherConfigurationDescriptor.ToArray().Length];
                otherConfigurationDescriptor.ToArray().CopyTo(controlPacket, 0);
                return(otherConfigurationDescriptor.ToArray());

            case DescriptorType.String:
                if (index == 0)
                {
                    stringDescriptor           = new StringUSBDescriptor(1);
                    stringDescriptor.LangId[0] = EnglishLangId;
                }
                else
                {
                    stringDescriptor = new StringUSBDescriptor(stringValues[setupPacket.index][index]);
                }
                controlPacket = new byte[stringDescriptor.ToArray().Length];
                stringDescriptor.ToArray().CopyTo(controlPacket, 0);
                return(stringDescriptor.ToArray());

            default:
                this.Log(LogLevel.Warning, "Unsupported HUB GetDescriptor request!!!");
                return(null);
            }
        }
Пример #2
0
        public byte[] GetDescriptor(USBPacket packet, USBSetupPacket setupPacket)
        {
            var type = (DescriptorType)((setupPacket.value & 0xff00) >> 8);

            switch (type)
            {
            case DescriptorType.Device:
                controlPacket = deviceDescriptor.ToArray();
                break;

            case DescriptorType.Configuration:
                controlPacket = configurationDescriptor.ToArray();
                break;

            case DescriptorType.DeviceQualifier:
                controlPacket = deviceQualifierDescriptor.ToArray();
                break;

            case DescriptorType.InterfacePower:
                throw new NotImplementedException("Interface Power Descriptor is not yet implemented. Please contact AntMicro for further support.");

            case DescriptorType.OtherSpeedConfiguration:
                controlPacket = otherConfigurationDescriptor.ToArray();
                break;

            case DescriptorType.String:
                uint index = (uint)(setupPacket.value & 0xff);
                if (index == 0)
                {
                    stringDescriptor           = new StringUSBDescriptor(1);
                    stringDescriptor.LangId[0] = EnglishLangId;
                }
                else
                {
                    stringDescriptor = new StringUSBDescriptor(stringValues[setupPacket.index][index]);
                }
                controlPacket = stringDescriptor.ToArray();
                break;

            default:
                this.Log(LogLevel.Warning, "Unsupported descriptor");
                return(null);
            }
            return(controlPacket);
        }
Пример #3
0
 public byte[] GetDescriptor(USBPacket packet, USBSetupPacket setupPacket)
 {
     DescriptorType type;
     type = (DescriptorType)((setupPacket.value & 0xff00) >> 8);
     uint index = (uint)(setupPacket.value & 0xff);
     switch(type)
     {
     case DescriptorType.Device:
         controlPacket = new byte[deviceDescriptor.ToArray().Length];
         deviceDescriptor.ToArray().CopyTo(controlPacket, 0);
         return deviceDescriptor.ToArray();
     case DescriptorType.Configuration:
         controlPacket = new byte[configurationDescriptor.ToArray().Length];
         configurationDescriptor.ToArray().CopyTo(controlPacket, 0);
         controlPacket = mouseConfigDescriptor;
         return configurationDescriptor.ToArray();
     case DescriptorType.DeviceQualifier:
         controlPacket = new byte[deviceQualifierDescriptor.ToArray().Length];
         deviceQualifierDescriptor.ToArray().CopyTo(controlPacket, 0);
         return deviceQualifierDescriptor.ToArray();
     case DescriptorType.InterfacePower:
         throw new NotImplementedException("Interface Power Descriptor is not yet implemented. Please contact AntMicro for further support.");
     case DescriptorType.OtherSpeedConfiguration:
         controlPacket = new byte[otherConfigurationDescriptor.ToArray().Length];
         otherConfigurationDescriptor.ToArray().CopyTo(controlPacket, 0);
         return otherConfigurationDescriptor.ToArray();
     case DescriptorType.String:
         if(index == 0)
         {
             stringDescriptor = new StringUSBDescriptor(1);
             stringDescriptor.LangId[0] = EnglishLangId;
         }
         else
         {
             stringDescriptor = new StringUSBDescriptor(stringValues[setupPacket.index][index]);
         }
         controlPacket = new byte[stringDescriptor.ToArray().Length];
         stringDescriptor.ToArray().CopyTo(controlPacket, 0);
         return stringDescriptor.ToArray();
     case (DescriptorType)0x22:
         controlPacket = mouseHIDReportDescriptor;
         break;
     default:
         this.Log(LogLevel.Warning, "Unsupported mouse request!!!");
         return null;
     }
     return null;
 }
Пример #4
0
 public byte[] GetDescriptor(USBPacket packet, USBSetupPacket setupPacket)
 {
     var type = (DescriptorType)((setupPacket.value & 0xff00) >> 8);
     switch(type)
     {
     case DescriptorType.Device:
         controlPacket = deviceDescriptor.ToArray();
         break;
     case DescriptorType.Configuration:
         controlPacket = configurationDescriptor.ToArray();
         break;
     case DescriptorType.DeviceQualifier:
         controlPacket = deviceQualifierDescriptor.ToArray();
         break;
     case DescriptorType.InterfacePower:
         throw new NotImplementedException("Interface Power Descriptor is not yet implemented. Please contact AntMicro for further support.");
     case DescriptorType.OtherSpeedConfiguration:
         controlPacket = otherConfigurationDescriptor.ToArray();
         break;
     case DescriptorType.String:
         uint index = (uint)(setupPacket.value & 0xff);
         if(index == 0)
         {
             stringDescriptor = new StringUSBDescriptor(1);
             stringDescriptor.LangId[0] = EnglishLangId;
         }
         else
         {
             stringDescriptor = new StringUSBDescriptor(stringValues[setupPacket.index][index]);
         }
         controlPacket = stringDescriptor.ToArray();
         break;
     default:
         this.Log(LogLevel.Warning, "Unsupported descriptor");
         return null;
     }
     return controlPacket;
 }