-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Port joystick and scrap to SDL3 #3208
Open
ankith26
wants to merge
2
commits into
main
Choose a base branch
from
ankith26-more-sdl3-3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Something I didn't think about while making the PR: SDL_GetJoystickGUIDForID uses the instance ID and not the device ID returned by pgJoystick_AsID. This block needs more attention and thought
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.
In general the joystick port will need some more thought. They removed device indices completely, meaning we need to rework the initialization of joystick objects in general. There is no easy way to emulate this either (and we shouldn't anyway!).
With that said, you can use
SDL_GetJoystickID
to get the instance_id of an already open joystick.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.
It seems like we may need to store something like
initial_instance_id
orlast_known_instance_id
on the pygame Joystick object.at the minute it has these attributes:
It is a bit of an odd code path here, as you only go down it when the SDLJoystick object is invalid - which shouldn't happen, and I'm not sure why you'd want the GUID of an invalid SDL Joystick or if it would even produce any usable output. Are we testing this code path at all?
The instance id of an SDLJoystick changes to a unique number whenever a joystick is connected or disconnected. We are checking the instance ID in this case when we explicitly cannot get the SDL Joystick object - perhaps because it has been disconnected.
At the minute the joystick module has no support for 'hot plugging' or plugging & unplugging controllers and we probably shouldn't try and add it in as simple conversion PR - we also have the newer controller module for that sort of thing.
I would probably just store the initial instance id when we first create the joystick, like we do the device id, and then add another pg function to get it like we do the device ID. We could also update the
last_known_instance_id
inget_guid()
I notice there was also a lot of renaming in the joystick module:
libsdl-org/SDL#6881
I'm sure this has been covered somewhere, but are we intending to eventually rename our SDL function calls as well? Or just relying on the SDL 'old names' wrapper?