Skip to content

Commit

Permalink
Merge pull request #17 from mubes/hid_descriptor
Browse files Browse the repository at this point in the history
Minimal change to allow support of HID descriptors
  • Loading branch information
ktemkin authored Apr 13, 2021
2 parents 03200d0 + 5fdadd8 commit 9fecaac
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions usb_protocol/emitters/descriptors/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,23 @@ def get_index_for_string(self, string):
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.
if hasattr(descriptor, 'emit'):
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.
Expand Down Expand Up @@ -566,5 +569,3 @@ def test_automatic_language_descriptor(self):

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


0 comments on commit 9fecaac

Please sign in to comment.