sinput: refactor to make unknown controllers fully dynamic #13593
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.
Currently, the generic raspberry pi vid:pid pair must be used for generic mask functionality. Moreover, the axes and buttons are hardcoded in different places in the hid driver, making them difficult to use.
First, refactor SDL_gamepad.c to always use autodetection for unknown controllers. Then, in the HID driver, generate valid masks based on a given subtype that will always match the output SDL string and compare them to the ones in the HID descriptor. If they are different, emit a warning but use the ones from the subtype anyway.
For already known controllers, add a path to skip the check and load the masks from firmware, assuming what is there matches SDL. This is done on faith, so it should be avoided for future controllers.
Moving forward, this commit allows following the same procedure. Assume company X releases controller Y. If the controller uses a completely new layout, company asks for a sub_type. Company gets sub_type and puts it into the controller firmware and releases the controller.
In the period that the bundled Steam SDL does not have that sub_type, it uses the full mapping which is correct for the controller and quite useable, but misses a capability match. If it does have the sub_type, capabilities are correct without any additions to SDL. And in the scenario that a controller is too obscure to warrant a sub_type, 0 can be used, and a mapping can be added to its vid:pid pair for proper capabilities to avoid using sub_types.
cc @mitchellcairns