Browse Source

Merge pull request #17 from mubes/hid_descriptor

Minimal change to allow support of HID descriptors
main
Kate Temkin 3 years ago
committed by GitHub
parent
commit
9fecaacef4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions
  1. +7
    -6
      usb_protocol/emitters/descriptors/standard.py

+ 7
- 6
usb_protocol/emitters/descriptors/standard.py View File

@@ -208,12 +208,14 @@ class DeviceDescriptorCollection:
return index


def add_descriptor(self, descriptor, index=0):
def add_descriptor(self, descriptor, index=0, descriptor_type=None):
""" Adds a descriptor to our collection.

Parameters:
descriptor -- The descriptor to be added.
index -- The index of the relevant descriptor. Defaults to 0.
descriptor -- The descriptor to be added.
index -- The index of the relevant descriptor. Defaults to 0.
descriptor_type -- The type of the descriptor to be added. If `None`,
this is automatically derived from the descriptor contents.
"""

# If this is an emitter rather than a descriptor itself, convert it.
@@ -221,7 +223,8 @@ class DeviceDescriptorCollection:
descriptor = descriptor.emit()

# Figure out the identifier (type + index) for this descriptor...
descriptor_type = descriptor[1]
if (descriptor_type is None):
descriptor_type = descriptor[1]
identifier = descriptor_type, index

# ... and store it.
@@ -566,5 +569,3 @@ class EmitterTests(unittest.TestCase):

if __name__ == "__main__":
unittest.main()



Loading…
Cancel
Save