This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
Fix: controller indices from multiple peers would clash #165
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.
Problem
When multiple peers are connected, each peer's controllers will increment from 0.
This means that if player 0 has 2 gamepads, they'll be assigned index 0 and index 1 and when player 1 connects with two gamepads of its own, they'll also be assigned index 0 and index 1 as illustrated below:
Solution
The most suitable solution to this problem would be for the Pixel Streaming module to keep track of all of the in-use gamepad indices. When a new gamepad is detected by the peer, it sends a request to the application for a gamepad index that is free. The application responds with an index to use and the peer will then use this provided controller index for any subsequent calls to the application.
Compatibility
Backwards compatibility is preserved in this change by using the local controller index (the one that increments from 0) if the application doesn't provide the peer with an index. This case would happen if using a UE version less than 5.2 but using the latest frontend.