Changeset View
Changeset View
Standalone View
Standalone View
source/ps/GameSetup/HWDetect.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
#include "ps/scripting/JSInterface_Debug.h" | #include "ps/scripting/JSInterface_Debug.h" | ||||
#include "ps/UserReport.h" | #include "ps/UserReport.h" | ||||
#include "ps/VideoMode.h" | #include "ps/VideoMode.h" | ||||
#include "scriptinterface/FunctionWrapper.h" | #include "scriptinterface/FunctionWrapper.h" | ||||
#include "scriptinterface/JSON.h" | #include "scriptinterface/JSON.h" | ||||
#include "scriptinterface/Object.h" | #include "scriptinterface/Object.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
// FreeType headers might have an include order. | |||||
#include <ft2build.h> | |||||
#include <freetype/freetype.h> | |||||
#if OS_LINUX | #if OS_LINUX | ||||
#include <fstream> | #include <fstream> | ||||
#endif | #endif | ||||
// TODO: Support OpenGL platforms which don't use GLX as well. | // TODO: Support OpenGL platforms which don't use GLX as well. | ||||
#if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES | #if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES | ||||
#include <GL/glx.h> | #include <GL/glx.h> | ||||
#include <SDL_syswm.h> | #include <SDL_syswm.h> | ||||
Show All 17 Lines | |||||
#endif /* GLX_MESA_query_renderer */ | #endif /* GLX_MESA_query_renderer */ | ||||
#endif | #endif | ||||
#if SDL_VERSION_ATLEAST(2, 0, 8) | #if SDL_VERSION_ATLEAST(2, 0, 8) | ||||
#include <SDL_vulkan.h> | #include <SDL_vulkan.h> | ||||
#endif | #endif | ||||
#include <sstream> | |||||
#include <string> | #include <string> | ||||
static void ReportSDL(const ScriptRequest& rq, JS::HandleValue settings); | static void ReportSDL(const ScriptRequest& rq, JS::HandleValue settings); | ||||
static void ReportFreeType(const ScriptRequest& rq, JS::HandleValue settings); | |||||
static void ReportVulkan(const ScriptRequest& rq, JS::HandleValue settings); | static void ReportVulkan(const ScriptRequest& rq, JS::HandleValue settings); | ||||
static void ReportGLLimits(const ScriptRequest& rq, JS::HandleValue settings); | static void ReportGLLimits(const ScriptRequest& rq, JS::HandleValue settings); | ||||
void SetDisableAudio(bool disabled) | void SetDisableAudio(bool disabled) | ||||
{ | { | ||||
g_DisableAudio = disabled; | g_DisableAudio = disabled; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | #if CONFIG2_AUDIO | ||||
if (g_SoundManager) | if (g_SoundManager) | ||||
{ | { | ||||
Script::SetProperty(rq, settings, "snd_card", g_SoundManager->GetSoundCardNames()); | Script::SetProperty(rq, settings, "snd_card", g_SoundManager->GetSoundCardNames()); | ||||
Script::SetProperty(rq, settings, "snd_drv_ver", g_SoundManager->GetOpenALVersion()); | Script::SetProperty(rq, settings, "snd_drv_ver", g_SoundManager->GetOpenALVersion()); | ||||
} | } | ||||
#endif | #endif | ||||
ReportSDL(rq, settings); | ReportSDL(rq, settings); | ||||
ReportFreeType(rq, settings); | |||||
ReportVulkan(rq, settings); | ReportVulkan(rq, settings); | ||||
ReportGLLimits(rq, settings); | ReportGLLimits(rq, settings); | ||||
Script::SetProperty(rq, settings, "video_desktop_xres", g_VideoMode.GetDesktopXRes()); | Script::SetProperty(rq, settings, "video_desktop_xres", g_VideoMode.GetDesktopXRes()); | ||||
Script::SetProperty(rq, settings, "video_desktop_yres", g_VideoMode.GetDesktopYRes()); | Script::SetProperty(rq, settings, "video_desktop_yres", g_VideoMode.GetDesktopYRes()); | ||||
Script::SetProperty(rq, settings, "video_desktop_bpp", g_VideoMode.GetDesktopBPP()); | Script::SetProperty(rq, settings, "video_desktop_bpp", g_VideoMode.GetDesktopBPP()); | ||||
Script::SetProperty(rq, settings, "video_desktop_freq", g_VideoMode.GetDesktopFreq()); | Script::SetProperty(rq, settings, "video_desktop_freq", g_VideoMode.GetDesktopFreq()); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | #if ARCH_X86_X64 | ||||
Script::SetProperty(rq, settings, "x86_caps[1]", caps1); | Script::SetProperty(rq, settings, "x86_caps[1]", caps1); | ||||
Script::SetProperty(rq, settings, "x86_caps[2]", caps2); | Script::SetProperty(rq, settings, "x86_caps[2]", caps2); | ||||
Script::SetProperty(rq, settings, "x86_caps[3]", caps3); | Script::SetProperty(rq, settings, "x86_caps[3]", caps3); | ||||
#endif | #endif | ||||
Script::SetProperty(rq, settings, "timer_resolution", timer_Resolution()); | Script::SetProperty(rq, settings, "timer_resolution", timer_Resolution()); | ||||
// The version should be increased for every meaningful change. | // The version should be increased for every meaningful change. | ||||
const int reportVersion = 16; | const int reportVersion = 17; | ||||
// Send the same data to the reporting system | // Send the same data to the reporting system | ||||
g_UserReporter.SubmitReport( | g_UserReporter.SubmitReport( | ||||
"hwdetect", | "hwdetect", | ||||
reportVersion, | reportVersion, | ||||
Script::StringifyJSON(rq, &settings, false), | Script::StringifyJSON(rq, &settings, false), | ||||
Script::StringifyJSON(rq, &settings, true)); | Script::StringifyJSON(rq, &settings, true)); | ||||
Show All 15 Lines | static void ReportSDL(const ScriptRequest& rq, JS::HandleValue settings) | ||||
snprintf(version, ARRAY_SIZE(version), "%d.%d.%d", runtime.major, runtime.minor, runtime.patch); | snprintf(version, ARRAY_SIZE(version), "%d.%d.%d", runtime.major, runtime.minor, runtime.patch); | ||||
Script::SetProperty(rq, settings, "sdl_runtime_version", version); | Script::SetProperty(rq, settings, "sdl_runtime_version", version); | ||||
// This is null in atlas (and further the call triggers an assertion). | // This is null in atlas (and further the call triggers an assertion). | ||||
const char* backend = g_VideoMode.GetWindow() ? GetSDLSubsystem(g_VideoMode.GetWindow()) : "none"; | const char* backend = g_VideoMode.GetWindow() ? GetSDLSubsystem(g_VideoMode.GetWindow()) : "none"; | ||||
Script::SetProperty(rq, settings, "sdl_video_backend", backend ? backend : "unknown"); | Script::SetProperty(rq, settings, "sdl_video_backend", backend ? backend : "unknown"); | ||||
} | } | ||||
static void ReportFreeType(const ScriptRequest& rq, JS::HandleValue settings) | |||||
{ | |||||
FT_Library FTLibrary; | |||||
std::string FTSupport = "unsupported"; | |||||
if (!FT_Init_FreeType(&FTLibrary)) | |||||
{ | |||||
FT_Int major, minor, patch; | |||||
FT_Library_Version(FTLibrary, &major, &minor, &patch); | |||||
FT_Done_FreeType(FTLibrary); | |||||
std::stringstream version; | |||||
version << major << "." << minor << "." << patch; | |||||
FTSupport = version.str(); | |||||
} | |||||
else | |||||
{ | |||||
FTSupport = "cantload"; | |||||
Stan: Maybe those strings could be constexpr | |||||
} | |||||
Script::SetProperty(rq, settings, "freetype", FTSupport); | |||||
} | |||||
static void ReportVulkan(const ScriptRequest& rq, JS::HandleValue settings) | static void ReportVulkan(const ScriptRequest& rq, JS::HandleValue settings) | ||||
{ | { | ||||
std::string vulkanSupport = "unsupported"; | std::string vulkanSupport = "unsupported"; | ||||
// According to http://wiki.libsdl.org/SDL_Vulkan_LoadLibrary the following | // According to http://wiki.libsdl.org/SDL_Vulkan_LoadLibrary the following | ||||
// functionality is supported since SDL 2.0.8. | // functionality is supported since SDL 2.0.8. | ||||
#if SDL_VERSION_ATLEAST(2, 0, 8) | #if SDL_VERSION_ATLEAST(2, 0, 8) | ||||
if (!SDL_Vulkan_LoadLibrary(nullptr)) | if (!SDL_Vulkan_LoadLibrary(nullptr)) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 402 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Maybe those strings could be constexpr