2020-05-04 06:27:29 +00:00
|
|
|
/*
|
2024-01-01 21:15:26 +00:00
|
|
|
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
2020-05-04 06:27:29 +00:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely.
|
|
|
|
*/
|
2022-11-27 04:43:38 +00:00
|
|
|
#include <SDL3/SDL.h>
|
2022-12-15 04:58:20 +00:00
|
|
|
#include <SDL3/SDL_main.h>
|
2023-03-16 23:25:39 +00:00
|
|
|
#include <SDL3/SDL_test.h>
|
2020-05-04 06:27:29 +00:00
|
|
|
|
|
|
|
static void log_locales(void)
|
|
|
|
{
|
2024-07-27 01:57:18 +00:00
|
|
|
SDL_Locale **locales = SDL_GetPreferredLocales(NULL);
|
2023-11-09 21:29:15 +00:00
|
|
|
if (!locales) {
|
2020-05-04 06:27:29 +00:00
|
|
|
SDL_Log("Couldn't determine locales: %s", SDL_GetError());
|
|
|
|
} else {
|
2024-07-19 05:07:05 +00:00
|
|
|
int i;
|
2020-05-04 06:27:29 +00:00
|
|
|
unsigned int total = 0;
|
|
|
|
SDL_Log("Locales, in order of preference:");
|
2024-07-19 05:07:05 +00:00
|
|
|
for (i = 0; locales[i]; ++i) {
|
|
|
|
const SDL_Locale *l = locales[i];
|
2020-05-04 06:27:29 +00:00
|
|
|
const char *c = l->country;
|
|
|
|
SDL_Log(" - %s%s%s", l->language, c ? "_" : "", c ? c : "");
|
|
|
|
total++;
|
|
|
|
}
|
|
|
|
SDL_Log("%u locales seen.", total);
|
2024-07-27 01:57:18 +00:00
|
|
|
SDL_free(locales);
|
2020-05-04 06:27:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2023-03-16 23:25:39 +00:00
|
|
|
int i;
|
|
|
|
int listen = 0;
|
|
|
|
SDLTest_CommonState *state;
|
|
|
|
|
|
|
|
/* Initialize test framework */
|
2023-07-18 20:21:19 +00:00
|
|
|
state = SDLTest_CommonCreateState(argv, 0);
|
2023-11-09 21:29:15 +00:00
|
|
|
if (!state) {
|
2023-03-16 23:25:39 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-05-04 06:27:29 +00:00
|
|
|
/* Enable standard application logging */
|
2024-05-16 17:00:50 +00:00
|
|
|
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
2020-05-04 06:27:29 +00:00
|
|
|
|
2023-03-16 23:25:39 +00:00
|
|
|
/* Parse commandline */
|
|
|
|
for (i = 1; i < argc;) {
|
|
|
|
int consumed;
|
|
|
|
|
|
|
|
consumed = SDLTest_CommonArg(state, i);
|
|
|
|
if (!consumed) {
|
|
|
|
if (SDL_strcmp(argv[1], "--listen") == 0) {
|
|
|
|
listen = 1;
|
|
|
|
consumed = 1;
|
2023-07-18 22:14:38 +00:00
|
|
|
state->flags |= SDL_INIT_VIDEO;
|
2023-03-16 23:25:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (consumed <= 0) {
|
|
|
|
static const char *options[] = { "[--listen]", NULL };
|
|
|
|
SDLTest_CommonLogUsage(state, argv[0], options);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
i += consumed;
|
|
|
|
}
|
|
|
|
|
2020-05-04 06:27:29 +00:00
|
|
|
/* Print locales and languages */
|
2023-03-16 23:25:39 +00:00
|
|
|
if (SDLTest_CommonInit(state) == SDL_FALSE) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
log_locales();
|
|
|
|
|
|
|
|
if (listen) {
|
|
|
|
int done = 0;
|
|
|
|
while (!done) {
|
|
|
|
SDL_Event e;
|
|
|
|
SDLTest_CommonEvent(state, &e, &done);
|
|
|
|
while (SDL_PollEvent(&e)) {
|
|
|
|
if (e.type == SDL_EVENT_QUIT) {
|
|
|
|
done = 1;
|
|
|
|
} else if (e.type == SDL_EVENT_LOCALE_CHANGED) {
|
|
|
|
SDL_Log("Saw SDL_EVENT_LOCALE_CHANGED event!");
|
|
|
|
log_locales();
|
2020-05-04 06:27:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-16 23:25:39 +00:00
|
|
|
for (i = 0; i < state->num_windows; i++) {
|
|
|
|
SDL_RenderPresent(state->renderers[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_Delay(10);
|
|
|
|
}
|
2020-05-04 06:27:29 +00:00
|
|
|
}
|
|
|
|
|
2023-03-16 23:25:39 +00:00
|
|
|
SDLTest_CommonQuit(state);
|
|
|
|
|
2022-11-30 20:51:59 +00:00
|
|
|
return 0;
|
2020-05-04 06:27:29 +00:00
|
|
|
}
|