-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Extend PlayerIndex
Enum To Support 8 Players On Compatible Platforms
#8809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Extends the `PlayerIndex` enum support up to 8 players on compatible platforms: - Added `PlayerIndex.Five` through `PlayerIndex.Eight` - Use preprocessor directives to exclude `PlayerIndex.Five` through`PlayerIndex.Eight` on Playstation platforms since they are limited to four controllers
I remember @KelsamGames saying DesktopGL can have up to 16 controllers: |
This is because of the differences in DirectInput vs XInput. XInput API documentation states that the ID is in range 0 - 3. When using an ID outside this range with additional XInput devices they won't return back (from my understanding). Steam has the "Extended Xbox Feature Support" in the settings which bypasses the four gamepad limit. However i believe the new Microsoft GDK supports up to eight, which would go with with the DirectX 12 implementation from PR #8646 @tomspilman may be able to answer if this is the case, if so, then the only four gamepad limitation at that point is the Playstation platforms. |
@AristurtleDev I actually meant if MonoGame.DesktopGL can have 16 controllers, then maybe increase it to As for WindowsDX though (the current one without GDK), that is hardcoded to 4 controllers in multiple places:
|
Should update this as a part of this change too, and probably take a look at other platforms:
|
XInput is still limited to 4 controllers. I mentioned earlier that the GDK support would increase that amount for DX platforms which is worked on in #8646, but I'd need @tomspilman to verify for me since he's the one working on that PR |
MonoGame.Framework/PlayerIndex.cs
Outdated
@@ -24,6 +24,24 @@ public enum PlayerIndex | |||
/// <summary> | |||
/// The fourth player index. | |||
/// </summary> | |||
Four = 3 | |||
Four = 3, | |||
#if !PLAYSTATION4 && !PLAYSTATION5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't add a platform define for common API, even if the platform does not support it, there is no need for the define to hide the enum values / properties as its much easier to have your own game code without a bunch of defines for random MG props.
We have some of it in GameWindow right now and it just causes issues for no good reason 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the directives.
Should the XML documentation be updated with a <remark>
to state that users can use GamePads.MaximumGamePadCount
to find the limit for the current system? Something like
/// <summary>
/// Defines the index of player for various MonoGame components.
/// </summary>
/// <remark>
/// Use <see cref="GamePad.GetMaximumGamePadCount" /> to determine the number of supported
/// gamespads to ensure that a valid<see cref="PlayerIndex" /> is used when accessing gamepad input.
/// </remark>
public enum PlayerIndex
Summary
This PR extends the
PlayerIndex
enum to support up to 8 players on platforms that can handle more than 4 controllers simultaneously. The change uses preprocessor directives to maintain platform-specific limitations.Changes
PlayerIndex.Five
throughPlayerIndex.Eight
(values 4-7).#if !PLAYSTATION4 && !PLAYSTATION5
to exclude additional values on Playstation platforms as they only support a maximum of four controllers.