Index: ps/trunk/source/lib/external_libraries/libsdl.h =================================================================== --- ps/trunk/source/lib/external_libraries/libsdl.h +++ ps/trunk/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,7 @@ SDL_Event ev; }; +// Returns a windowing subsystem used for the window. +const char* GetSDLSubsystem(SDL_Window* window); + #endif // INCLUDED_SDL Index: ps/trunk/source/lib/external_libraries/libsdl.cpp =================================================================== --- ps/trunk/source/lib/external_libraries/libsdl.cpp +++ ps/trunk/source/lib/external_libraries/libsdl.cpp @@ -0,0 +1,97 @@ +/* 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 + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "precompiled.h" + +#include "libsdl.h" + +#include "lib/debug.h" + +#include + +const char* GetSDLSubsystem(SDL_Window* window) +{ + SDL_SysWMinfo wminfo; + // The info structure must be initialized with the SDL version. + SDL_VERSION(&wminfo.version); + + if (!SDL_GetWindowWMInfo(window, &wminfo)) + { + debug_printf("Failed to query SDL WM info: %s", SDL_GetError()); + return nullptr; + } + + const char* subsystem = "unknown"; + switch (wminfo.subsystem) + { + case SDL_SYSWM_WAYLAND: + subsystem = "Wayland"; + break; + case SDL_SYSWM_X11: + subsystem = "X11"; + break; + case SDL_SYSWM_WINDOWS: + subsystem = "Windows"; + break; + case SDL_SYSWM_COCOA: + subsystem = "Cocoa"; + break; + case SDL_SYSWM_UIKIT: + subsystem = "UIKit"; + break; + case SDL_SYSWM_DIRECTFB: + subsystem = "DirectFB"; + break; + case SDL_SYSWM_MIR: + subsystem = "Mir"; + break; +#if SDL_VERSION_ATLEAST(2, 0, 3) + case SDL_SYSWM_WINRT: + subsystem = "WinRT"; + break; +#endif +#if SDL_VERSION_ATLEAST(2, 0, 4) + case SDL_SYSWM_ANDROID: + subsystem = "Android"; + break; +#endif +#if SDL_VERSION_ATLEAST(2, 0, 5) + case SDL_SYSWM_VIVANTE: + subsystem = "Vivante"; + break; +#endif +#if SDL_VERSION_ATLEAST(2, 0, 6) + case SDL_SYSWM_OS2: + subsystem = "OS/2"; + break; +#endif + // Insert newer supported platforms here. +#if SDL_VERSION_ATLEAST(2, 0, 11) + default: + debug_printf("Unknown platform, please add it to source/lib/external_libraries/libsdl.cpp\n"); +#endif + case SDL_SYSWM_UNKNOWN: + break; + } + + return subsystem; +} Index: ps/trunk/source/ps/GameSetup/HWDetect.cpp =================================================================== --- ps/trunk/source/ps/GameSetup/HWDetect.cpp +++ ps/trunk/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, "sdl_build_version", version); + + SDL_GetVersion(&runtime); + snprintf(version, ARRAY_SIZE(version), "%d.%d.%d", runtime.major, runtime.minor, runtime.patch); + scriptInterface.SetProperty(settings, "sdl_runtime_version", version); + + const char* backend = GetSDLSubsystem(g_VideoMode.GetWindow()); + scriptInterface.SetProperty(settings, "sdl_video_backend", backend ? backend : "unknown"); +} + static void ReportGLLimits(const ScriptInterface& scriptInterface, JS::HandleValue settings) { const char* errstr = "(error)";