-
-
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 key and mouse to SDL3 #3207
base: main
Are you sure you want to change the base?
Conversation
/* SDL3 changed the mouse API to deal with float coordinates, for now we | ||
* still truncate the result to int before returning to python side. | ||
* This can be changed in a breaking release in the future if needed. */ | ||
float x, y; |
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.
So it gets it as a float, how does it get converted to an int? Because it gets passed a function that takes ints.
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.
Yeah that just happens implicitly, I didn't bother documenting it because I didn't think it should cause any confusion
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.
If you had written int ix = (int)x;
I wouldn't have batted an eye. Even int ix = x;
So I assume that passing to into a parameter of a type is the same as assignment?
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.
Yeah, true. I can make the function call
return pg_tuple_couple_from_values_int((int)x, (int)y);
if that helps. It becomes more explicit but verbose
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.
Tbh, I'm not a fan of downcasting without explicitly checking that the value is within range of the destination data type. That just seems like a recipe for hard-to-diagnose bugs
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.
I think we use casts to ints from floats in other places, I don't see how we could check range elegantly. For this I think the mouse coordinates reported will be reasonable numbers.
Just following the footsteps of #3206 but separated out in a different PR because these changes are not as trivial as those