1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 using Antmicro.Renode.Utilities; 8 9 namespace Antmicro.Renode.Core.USB.HID 10 { 11 public class Descriptor : DescriptorProvider 12 { Descriptor(ReportDescriptor reportDescriptor, short classSpecification = 0, byte countryCode = 0)13 public Descriptor(ReportDescriptor reportDescriptor, 14 short classSpecification = 0, 15 byte countryCode = 0) : base(9, (byte)HID.DescriptorType.HID) 16 { 17 NumberOfClassDescriptors = 1; 18 HID_ClassSpecification = classSpecification; 19 CountryCode = countryCode; 20 DescriptorType = (byte)HID.DescriptorType.Report; 21 HidDescriptorLength = checked((short)reportDescriptor.DescriptorLength); 22 } 23 24 public short HID_ClassSpecification { get; } 25 public byte CountryCode { get; } 26 public byte NumberOfClassDescriptors { get; } 27 public byte DescriptorType { get; } 28 public short HidDescriptorLength { get; } 29 FillDescriptor(BitStream buffer)30 protected override void FillDescriptor(BitStream buffer) 31 { 32 buffer 33 .Append(HID_ClassSpecification) 34 .Append(CountryCode) 35 .Append(NumberOfClassDescriptors) 36 .Append(DescriptorType) 37 .Append(HidDescriptorLength); 38 } 39 } 40 } 41