Conversation
…tems The parser only keeps track of Usages attached to fields, and those are the one that can be found by SDL_DescriptorHasUsage(). However the HID Usage Tables spec (section 3.4) states that there are three basic types of information that are described by Usages: controls, collections, and data. A Usage such as Joystick or Game Pad on the Generic Desktop page is a Collection Application Usage: it is applied directly to a top-level Collection(Application) item via the Usage item that precedes it, and never appears on any data field. The parser discarded this kind of Usages entirely, only tracking collection nesting for debug logging. Add a growable list of collections to DescriptorContext, and store each Collection item's Usage (the first Usage local item seen before it) with AddCollection(), following the same reallocation mechanism as AddInputFields() for fields. Expose the list through SDL_ReportDescriptor and add a new function SDL_DescriptorHasCollectionUsage(), a collection-scoped counterpart of SDL_DescriptorHasUsage(), so callers can distinguish "this usage is on a collection" from "this usage is on a field" and query for device-identifying Usages like Joystick or Game Pad that only ever appear on collections. This only stores each collection's own Usage; it does not yet track which fields belong to which collection. That refinement can be implemented in a follow-up if needed. Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
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.
For the sake of transparency, an LLM helped me to explore the problem, but the code has been hand-crafted (given also the
AGENTS.mdfile in the SDL project).This is a prototype of how Gamepads could be detected by parsing the HID report descriptor
Description
We are investigating how to detect gamepads starting from their HID report descriptor, mainly because we would like to give hidraw uaccess ot all gamepdas, but only to gamepads.
The changes are for exploration only at the current stage.
The proposed changes seem to work for a restricted set of devices:
However the parsing might be incomplete and detection could fail for other devices.