Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HID classes #47

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

electretmike
Copy link

Add support for HID class specific descriptors. This is different from #6, as it doesn't include the actual HID report itself. It is assumed that that is already known or created using a different tool.

Copy link
Member

@martinling martinling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to see this but I have some issues with naming.

Comment on lines 39 to 45
# This is not reallyy a stand-alone descriptor, but it is part of the HIDDescriptor above.
# That descriptor can contain multiple ReportDescriptors. To support this, a seperate
# descriptor format is used.
HIDReportDescriptor = DescriptorFormat(
"bDescriptorType" / DescriptorField("HID Descriptor Type", default=HidClassSpecificDescriptorTypes.CS_REPORT),
"wDescriptorLength" / DescriptorField("HID Descriptor Length")
)
Copy link
Member

@martinling martinling Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type should be called something other than HIDReportDescriptor, because:

  1. At some point we're going to want that name for the actual HID report descriptor (i.e. type 0x22).

  2. A report descriptor is not the only thing that can appear here. The other descriptors listed by the HID descriptor are usually report descriptors, but the HID spec also specifies physical descriptors (0x23) that would appear here, and further types could be also be included in theory. As you note, this particular sub-format isn't really a descriptor. It's a reference to a descriptor that may be retrieved separately. So my suggestion for the name here would be HIDDescriptorReference.

Comment on lines 14 to 27
def ReportDescriptor(self):
""" Context manager that allows addition of a subordinate report descriptor.

It can be used with a `with` statement; and yields an HIDReportDescriptorEmitter
that can be populated:

with hiddescriptor.ReportDescriptor() as r:
r.wDescriptorLength = 0x10

This adds the relevant descriptor, automatically.
"""

descriptor = HIDReportDescriptorEmitter()
yield descriptor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, I think ReportDescriptor should be changed to DescriptorReference throughout these lines.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, applied it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants