Skip to content
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
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Port joystick and scrap to SDL3 #3208

wants to merge 2 commits into from

Conversation

ankith26
Copy link
Member

@ankith26 ankith26 commented Nov 2, 2024

This PR ports joystick and scrap to SDL3.

Porting scrap turned out to be surprisingly trivial, but it makes sense given that we are using like 3 functions of the SDL API, and the rest are custom implementations.
EDIT: There was some windows specific code that I initially missed when I made this comment, but that should hopefully be ported now as well.

@ankith26 ankith26 requested a review from a team as a code owner November 2, 2024 11:15
Copy link
Member

@Starbuck5 Starbuck5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Starbuck5 Starbuck5 added joystick pygame.joystick scrap pygame.scrap labels Nov 3, 2024
@@ -200,18 +210,53 @@ joy_get_guid(PyObject *self, PyObject *_null)
guid = SDL_JoystickGetGUID(joy);
}
else {
#if SDL_VERSION_ATLEAST(3, 0, 0)
guid = SDL_GetJoystickGUIDForID(pgJoystick_AsID(self));
Copy link
Member Author

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

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
joystick pygame.joystick scrap pygame.scrap sdl3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants