Support Push and Pop global items in report descriptor parsing - #29
Open
Nortaq-PlayNexus wants to merge 1 commit into
Open
Support Push and Pop global items in report descriptor parsing#29Nortaq-PlayNexus wants to merge 1 commit into
Nortaq-PlayNexus wants to merge 1 commit into
Conversation
The global item tags Push (0b1010) and Pop (0b1011) are part of the HID
spec (6.2.2.7 / 6.2.2.8) and save/restore the global item state table.
They were previously only recognized by the printer, while the parser
raised NotImplementedError('Unsupported global tag: 0b1010'). (fixes usb-tools#12)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support Push (0b1010) and Pop (0b1011) global items
Summary
The HID specification defines two global item tags that save and restore the global item state table (HID 1.11, sections 6.2.2.7 and 6.2.2.8):
Push(0b1010) — saves the current values of all global items onto a state stackPop(0b1011) — restores the most recently saved state and pops it from the stackThese tags are used by real devices (for example Wacom digitizers) to temporarily change a subset of global items inside a collection and restore them afterwards.
The library already recognized these tags in
print(), but_parse()raisedNotImplementedError('Unsupported global tag: 0b1010'), making it impossible to parse such descriptors. This PR implementsPush/Popsupport in_parse().Changes
hid_parser/__init__.py:_parse()and handleTagGlobal.PUSH/TagGlobal.POPPushsaves(usage_page, report_id, report_count, report_size, glob);Poprestores itPopwithout a matchingPushraisesInvalidReportDescriptor('Pop without a matching Push')Popcan restore a previously savedreport_id, report offsets are seeded for that id if missingtests/test_parse.py:PopraisesInvalidReportDescriptorVerification
Pushat byte 538 andPopat byte 704 (the 17-item pen collection in report id 6), plus a secondPush/Poppair75 passed(full test suite), mypy cleanFixes #12