Added support for saving multiple gamepad settings per project#1
Merged
Conversation
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.
Reason for changes
Multiplayer Scenario
Recently I've been working on a local multiplayer game where you connect two gamepads to control two different players. The current gamepad addon can only save one of those configurations, meaning I have to re-write one configuration every time
Multiple Different Gamepads Scenario
Another issue is that if I have a game where I save a configuration for one type of gamepad (ex. an N64 controller), but I sometimes want to play the game with a different gamepad (ex. a Nintendo Pro Controller), then I need to re-write the 2nd controller's configuration every time
Changes
Saving your gamepad settings now saves every connected gamepad's configuration independently. Whenever you connect a gamepad, it will try to use the configuration that best matches it (it will prefer configurations that match the gamepad's type and index). The index matching handles multiple gamepads of the same type (i.e. in the case of the Multiplayer Scenario above) while the type matching handles multiple different gamepads (i.e. in the case of the other scenario).
If you only ever use one gamepad in a project, then the addon functions exactly the same as it did before these changes. If you had a configuration saved previously (before upgrading to this version), then those settings are kept and will be used for newly connected gamepads
Configuration Selection Logic
When a gamepad is connected, it will perform the following logic to choose its configuration:
If a saved configuration with the same type and index as this gamepad is found, use it
else, if a saved configuration with the same type as this gamepad is found, use it
else, use the configuration that was saved earliest (the oldest one in the project)
Tests
Tested in Chrome and Edge