🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.9 KiB

  1. /*
  2. Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
  3. This software is provided 'as-is', without any express or implied
  4. warranty. In no event will the authors be held liable for any damages
  5. arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it
  8. freely.
  9. */
  10. #include <stdio.h>
  11. #include "SDL.h"
  12. /* !!! FIXME: move this to the test framework */
  13. static void log_locales(void)
  14. {
  15. SDL_Locale *locales = SDL_GetPreferredLocales();
  16. if (locales == NULL) {
  17. SDL_Log("Couldn't determine locales: %s", SDL_GetError());
  18. } else {
  19. SDL_Locale *l;
  20. unsigned int total = 0;
  21. SDL_Log("Locales, in order of preference:");
  22. for (l = locales; l->language; l++) {
  23. const char *c = l->country;
  24. SDL_Log(" - %s%s%s", l->language, c ? "_" : "", c ? c : "");
  25. total++;
  26. }
  27. SDL_Log("%u locales seen.", total);
  28. SDL_free(locales);
  29. }
  30. }
  31. int main(int argc, char **argv)
  32. {
  33. /* Enable standard application logging */
  34. SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
  35. /* Print locales and languages */
  36. if (SDL_Init(SDL_INIT_VIDEO) != -1) {
  37. log_locales();
  38. if ((argc == 2) && (SDL_strcmp(argv[1], "--listen") == 0)) {
  39. SDL_bool keep_going = SDL_TRUE;
  40. while (keep_going) {
  41. SDL_Event e;
  42. while (SDL_PollEvent(&e)) {
  43. if (e.type == SDL_QUIT) {
  44. keep_going = SDL_FALSE;
  45. } else if (e.type == SDL_LOCALECHANGED) {
  46. SDL_Log("Saw SDL_LOCALECHANGED event!");
  47. log_locales();
  48. }
  49. }
  50. SDL_Delay(10);
  51. }
  52. }
  53. SDL_Quit();
  54. }
  55. return 0;
  56. }
  57. /* vi: set ts=4 sw=4 expandtab: */