Index: source/lib/external_libraries/libsdl.h =================================================================== --- source/lib/external_libraries/libsdl.h +++ source/lib/external_libraries/libsdl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -53,4 +53,6 @@ SDL_Event ev; }; +const char* GetSDLPlatform(SDL_Window* window); + #endif // INCLUDED_SDL Index: source/lib/external_libraries/libsdl.cpp =================================================================== --- /dev/null +++ source/lib/external_libraries/libsdl.cpp @@ -0,0 +1,72 @@ +/* Copyright (C) 2020 Wildfire Games. + * This file is part of 0 A.D. + * + * 0 A.D. is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * 0 A.D. is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with 0 A.D. If not, see . + */ + +#include "precompiled.h" + +#include "SDL_syswm.h" + +const char* GetSDLPlatform(SDL_Window* window) +{ + SDL_SysWMinfo wminfo; + SDL_VERSION(&wminfo.version); + + if (!SDL_GetWindowWMInfo(window, &wminfo)) + { + LOGERROR("Failed to query SDL2 WM info: %s", SDL_GetError()); + return NULL; + } + + switch (wminfo.subsystem) + { + case SDL_SYSWM_WAYLAND: + return "Wayland"; + case SDL_SYSWM_X11: + return "X11"; + case SDL_SYSWM_WINDOWS: + return "Windows"; + case SDL_SYSWM_COCOA: + return "Cocoa"; + case SDL_SYSWM_UIKIT: + return "UIKit"; + case SDL_SYSWM_DIRECTFB: + return "DirectFB"; + case SDL_SYSWM_MIR: + return "Mir"; +#if SDL_VERSION_ATLEAST(2, 0, 3) + case SDL_SYSWM_WINRT: + return "WinRT"; +#endif +#if SDL_VERSION_ATLEAST(2, 0, 4) + case SDL_SYSWM_ANDROID: + return "Android"; +#endif +#if SDL_VERSION_ATLEAST(2, 0, 5) + case SDL_SYSWM_VIVANTE: + return "Vivante"; +#endif +#if SDL_VERSION_ATLEAST(2, 0, 6) + case SDL_SYSWM_OS2: + return "OS/2"; +#endif +#if SDL_VERSION_ATLEAST(2, 0, 11) + default: + LOGWARNING("Unknown platform, please add it to source/ps/GameSetup/HWDetect.cpp"); +#endif + case SDL_SYSWM_UNKNOWN: + return "unknown"; + } +} Index: source/ps/GameSetup/HWDetect.cpp =================================================================== --- source/ps/GameSetup/HWDetect.cpp +++ source/ps/GameSetup/HWDetect.cpp @@ -47,7 +47,7 @@ // TODO: Support OpenGL platforms which don’t use GLX as well. #if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES #include -#include "SDL_syswm.h" +#include // Define the GLX_MESA_query_renderer macros if built with // an old Mesa (<10.0) that doesn't provide them @@ -69,6 +69,7 @@ #endif +static void ReportSDL(const ScriptInterface& scriptInterface, JS::HandleValue settings); static void ReportGLLimits(const ScriptInterface& scriptInterface, JS::HandleValue settings); #if ARCH_X86_X64 @@ -285,6 +286,8 @@ scriptInterface.SetProperty(settings, "snd_card", snd_card); scriptInterface.SetProperty(settings, "snd_drv_ver", snd_drv_ver); + ReportSDL(scriptInterface, settings); + ReportGLLimits(scriptInterface, settings); scriptInterface.SetProperty(settings, "video_desktop_xres", g_VideoMode.GetDesktopXRes()); @@ -353,7 +356,7 @@ scriptInterface.SetProperty(settings, "timer_resolution", timer_Resolution()); // The version should be increased for every meaningful change. - const int reportVersion = 12; + const int reportVersion = 13; // Send the same data to the reporting system g_UserReporter.SubmitReport( @@ -367,6 +370,23 @@ scriptInterface.CallFunctionVoid(global, "RunHardwareDetection", settings); } +static void ReportSDL(const ScriptInterface& scriptInterface, JS::HandleValue settings) +{ + SDL_version build, runtime; + SDL_VERSION(&build); + + char version[16]; + snprintf(version, ARRAY_SIZE(version), "%d.%d.%d", build.major, build.minor, build.patch); + scriptInterface.SetProperty(settings, "sdl2_build_version", version); + + SDL_GetVersion(&runtime); + snprintf(version, ARRAY_SIZE(version), "%d.%d.%d", runtime.major, runtime.minor, runtime.patch); + scriptInterface.SetProperty(settings, "sdl2_runtime_version", version); + + const char* backend = GetSDLPlatform(g_VideoMode.GetWindow()); + scriptInterface.SetProperty(settings, "sdl2_video_backend", backend ? backend : "unknown"); +} + static void ReportGLLimits(const ScriptInterface& scriptInterface, JS::HandleValue settings) { const char* errstr = "(error)";