Skip to content

Conversation

@Starbuck5
Copy link
Member

@Starbuck5 Starbuck5 commented Oct 6, 2024

A little bit more gnarly than I would like, but the code comment explains my approach here.

@Starbuck5 Starbuck5 added system pygame.system sdl3 labels Oct 6, 2024
@Starbuck5 Starbuck5 requested a review from a team as a code owner October 6, 2024 09:26
Copy link
Member

@damusss damusss left a comment

Choose a reason for hiding this comment

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

LGTM :)

Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

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

SDL_Locale **
PG_GetPreferredLocales(int *num_locales)
{
#if SDL_VERSION_ATLEAST(3, 0, 0)
    return SDL_GetPreferredLocales(num_locales);
#elif SDL_VERSION_ATLEAST(2, 0, 14)
    SDL_Locale *locales = SDL_GetPreferredLocales();
    if (locales) {
        SDL_Locale *current_locale = locales;
        *num_locales = 0;
        /* The array is terminated when the language attribute of the last
         * struct in the array is NULL */
        while (current_locale->language) {
            (*num_locales)++;
            current_locale++;
        }
        return &locales;
    }
#endif
    return NULL;
}

Untested code, somewhat based on your idea but written so that it can be abstracted out in a separate function

@Starbuck5
Copy link
Member Author

SDL2: array of SDL_locales
SDL3: array of pointers to SDL_locales

Is a pointer to an array of SDL_locales the same thing as an array of pointers to SDL_locales ?

This is what I was sidestepping worrying about with my implementation but would need to think about for your code suggestion.

@ankith26
Copy link
Member

ankith26 commented Oct 6, 2024

okay NVM my suggestion, they are probably not the same

Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks 🌟

@ankith26 ankith26 merged commit 1a57252 into pygame-community:main Oct 6, 2024
@Starbuck5 Starbuck5 deleted the system-compat-sdl3 branch October 6, 2024 10:09
@Starbuck5 Starbuck5 added this to the 2.5.2 milestone Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdl3 system pygame.system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants