-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
base: main
Are you sure you want to change the base?
Conversation
2e19b25
to
e6149e8
Compare
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.
Thanks!
@@ -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)); |
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.
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.