From c26034004436acf6a6f894326574059acbac9c92 Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 27 Jan 2026 23:39:08 -0500 Subject: [PATCH 1/3] SDL3 Upgrade --- cmake/XRay.Compiler.GNULike.cmake | 2 +- cmake/XRay.Compiler.MSVC.cmake | 3 + src/Common/PlatformApple.inl | 4 +- src/Common/PlatformBSD.inl | 4 +- src/Common/PlatformLinux.inl | 4 +- src/Layers/xrRender/xr_effgamma.cpp | 2 +- src/Layers/xrRenderDX11/dx11HW.cpp | 11 +- src/Layers/xrRenderDX11/dx11HW.h | 2 +- src/Layers/xrRenderGL/glHW.cpp | 17 +- src/Layers/xrRenderGL/glHW.h | 2 +- src/Layers/xrRenderPC_GL/r2_test_hw.cpp | 2 +- src/Layers/xrRenderPC_GL/stdafx.h | 4 +- src/Layers/xrRender_R2/r2.cpp | 2 +- src/editors/xrWeatherEngine/engine_impl.cpp | 4 +- src/xrCore/CMakeLists.txt | 2 +- src/xrCore/LocatorAPI.cpp | 2 +- src/xrCore/ModuleLookup.cpp | 2 +- src/xrCore/Threading/TaskManager.cpp | 2 +- src/xrCore/_math.cpp | 11 +- src/xrCore/os_clipboard.cpp | 2 +- src/xrCore/xrCore.cpp | 24 +- src/xrCore/xrDebug.cpp | 4 +- src/xrCore/xrMemory.cpp | 2 +- src/xrCore/xrstring.cpp | 2 +- src/xrEngine/CMakeLists.txt | 2 +- src/xrEngine/Device_Initialize.cpp | 22 +- src/xrEngine/Device_imgui.cpp | 21 +- src/xrEngine/Device_mode.cpp | 166 ++++++++----- src/xrEngine/Engine.cpp | 3 +- src/xrEngine/device.cpp | 54 +++-- src/xrEngine/device.h | 10 +- src/xrEngine/editor_base_input.cpp | 31 +-- src/xrEngine/embedded_resources_management.h | 10 +- .../key_binding_registrator_script.cpp | 42 ++-- src/xrEngine/line_edit_control.cpp | 8 +- src/xrEngine/x_ray.cpp | 48 ++-- src/xrEngine/xrTheora_Surface.cpp | 6 +- src/xrEngine/xrTheora_Surface.h | 2 +- src/xrEngine/xr_input.cpp | 229 ++++++++++-------- src/xrEngine/xr_input.h | 16 +- src/xrEngine/xr_level_controller.cpp | 42 ++-- src/xrGame/MainMenu.cpp | 2 +- src/xrGame/UIDialogHolder.h | 2 +- src/xrUICore/Buttons/UIButton.h | 2 +- src/xrUICore/Cursor/UICursor.cpp | 3 +- 45 files changed, 472 insertions(+), 365 deletions(-) diff --git a/cmake/XRay.Compiler.GNULike.cmake b/cmake/XRay.Compiler.GNULike.cmake index a9f5c0cdfca..e353cbbeae5 100644 --- a/cmake/XRay.Compiler.GNULike.cmake +++ b/cmake/XRay.Compiler.GNULike.cmake @@ -141,7 +141,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") endif() if (NOT WIN32) - find_package(SDL2 2.0.18 REQUIRED) + find_package(SDL3 3.4.0 REQUIRED CONFIG COMPONENTS SDL3) find_package(OpenAL REQUIRED) find_package(JPEG) find_package(Ogg REQUIRED) diff --git a/cmake/XRay.Compiler.MSVC.cmake b/cmake/XRay.Compiler.MSVC.cmake index 05e7bfddaa7..1a25bd91e72 100644 --- a/cmake/XRay.Compiler.MSVC.cmake +++ b/cmake/XRay.Compiler.MSVC.cmake @@ -1,5 +1,8 @@ include_guard() +# Dependencies +find_package(SDL3 3.4.0 REQUIRED CONFIG COMPONENTS SDL3) + # The MSVC compiler settings: # Set properties: set(CMAKE_VS_USE_DEBUG_LIBRARIES "$") diff --git a/src/Common/PlatformApple.inl b/src/Common/PlatformApple.inl index 0546393157e..1873b82a5ac 100644 --- a/src/Common/PlatformApple.inl +++ b/src/Common/PlatformApple.inl @@ -197,8 +197,8 @@ typedef dirent DirEntryType; #define O_SEQUENTIAL 0 #define SH_DENYWR 0 -#if __has_include() -#include +#if __has_include() +#include #define itoa SDL_itoa #define _itoa_s SDL_itoa #else diff --git a/src/Common/PlatformBSD.inl b/src/Common/PlatformBSD.inl index 58f1edb59c4..57c86ef8f69 100644 --- a/src/Common/PlatformBSD.inl +++ b/src/Common/PlatformBSD.inl @@ -194,8 +194,8 @@ typedef dirent DirEntryType; #define O_SEQUENTIAL 0 #define SH_DENYWR 0 -#if __has_include() -#include +#if __has_include() +#include #define itoa SDL_itoa #define _itoa_s SDL_itoa #else diff --git a/src/Common/PlatformLinux.inl b/src/Common/PlatformLinux.inl index 48633621010..6ea0a54e69f 100644 --- a/src/Common/PlatformLinux.inl +++ b/src/Common/PlatformLinux.inl @@ -196,8 +196,8 @@ typedef dirent DirEntryType; #define O_SEQUENTIAL 0 #define SH_DENYWR 0 -#if __has_include() -#include +#if __has_include() +#include #define itoa SDL_itoa #define _itoa_s SDL_itoa #else diff --git a/src/Layers/xrRender/xr_effgamma.cpp b/src/Layers/xrRender/xr_effgamma.cpp index b319c8d41d7..d2e2cb26346 100644 --- a/src/Layers/xrRender/xr_effgamma.cpp +++ b/src/Layers/xrRender/xr_effgamma.cpp @@ -84,6 +84,6 @@ void CGammaControl::Update() const #endif u16 red[256], green[256], blue[256]; GenLUT(red, green, blue, 256); - SDL_SetWindowGammaRamp(Device.m_sdlWnd, red, green, blue); + // SDL3 removed window gamma ramp control; keep data prepared for future backends. } } // namespace xray::render::RENDER_NAMESPACE diff --git a/src/Layers/xrRenderDX11/dx11HW.cpp b/src/Layers/xrRenderDX11/dx11HW.cpp index 7a3134a41d6..b5dc5d7e9fc 100644 --- a/src/Layers/xrRenderDX11/dx11HW.cpp +++ b/src/Layers/xrRenderDX11/dx11HW.cpp @@ -5,7 +5,7 @@ #include "StateManager/dx11SamplerStateCache.h" #include "dx11TextureUtils.h" -#include +#include namespace xray::render::RENDER_NAMESPACE { @@ -241,18 +241,15 @@ void CHW::CreateDevice(SDL_Window* sdlWnd) } } - SDL_SysWMinfo info; - SDL_VERSION(&info.version); - - if (!SDL_GetWindowWMInfo(sdlWnd, &info)) + const SDL_PropertiesID props = SDL_GetWindowProperties(sdlWnd); + const HWND hwnd = static_cast(SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr)); + if (!hwnd) { Msg("! Failed to retrieve SDL window handle: %s", SDL_GetError()); Valid = false; return; } - const HWND hwnd = info.info.win.window; - if (!CreateSwapChain2(hwnd)) { if (!CreateSwapChain(hwnd)) diff --git a/src/Layers/xrRenderDX11/dx11HW.h b/src/Layers/xrRenderDX11/dx11HW.h index f213217d299..c7681be2ec0 100644 --- a/src/Layers/xrRenderDX11/dx11HW.h +++ b/src/Layers/xrRenderDX11/dx11HW.h @@ -5,7 +5,7 @@ #include "Layers/xrRender/HWCaps.h" #include "Layers/xrRender/stats_manager.h" -#include +#include namespace xray::render::RENDER_NAMESPACE { diff --git a/src/Layers/xrRenderGL/glHW.cpp b/src/Layers/xrRenderGL/glHW.cpp index 5e37a01d4e5..5f339e6695f 100644 --- a/src/Layers/xrRenderGL/glHW.cpp +++ b/src/Layers/xrRenderGL/glHW.cpp @@ -25,7 +25,7 @@ void UpdateVSync() if (psDeviceFlags.test(rsVSync)) { // Try adaptive vsync first - if (SDL_GL_SetSwapInterval(-1) == -1) + if (!SDL_GL_SetSwapInterval(-1)) SDL_GL_SetSwapInterval(1); } else @@ -80,12 +80,7 @@ void CHW::CreateDevice(SDL_Window* hWnd) R_ASSERT(m_window); - // Choose the closest pixel format - SDL_DisplayMode mode; - SDL_GetWindowDisplayMode(m_window, &mode); - mode.format = SDL_PIXELFORMAT_RGBA8888; - // Apply the pixel format to the device context - SDL_SetWindowDisplayMode(m_window, &mode); + // Display mode selection is handled via SDL_SetWindowFullscreenMode in device setup. Caps.fTarget = D3DFMT_A8R8G8B8; Caps.fDepth = D3DFMT_D24S8; @@ -98,7 +93,7 @@ void CHW::CreateDevice(SDL_Window* hWnd) return; } - if (MakeContextCurrent(IRender::PrimaryContext) != 0) + if (!MakeContextCurrent(IRender::PrimaryContext)) { Log("! OpenGL: could not make context current:", SDL_GetError()); return; @@ -158,7 +153,7 @@ void CHW::DestroyDevice() if (context == m_context) SDL_GL_MakeCurrent(nullptr, nullptr); - SDL_GL_DeleteContext(m_context); + SDL_GL_DestroyContext(m_context); m_context = nullptr; } @@ -206,7 +201,7 @@ IRender::RenderContext CHW::GetCurrentContext() const return IRender::NoContext; } -int CHW::MakeContextCurrent(IRender::RenderContext context) const +bool CHW::MakeContextCurrent(IRender::RenderContext context) const { switch (context) { @@ -219,7 +214,7 @@ int CHW::MakeContextCurrent(IRender::RenderContext context) const default: NODEFAULT; } - return -1; + return false; } void CHW::UpdateViews() diff --git a/src/Layers/xrRenderGL/glHW.h b/src/Layers/xrRenderGL/glHW.h index c0251c2f51b..3dc6ba9644f 100644 --- a/src/Layers/xrRenderGL/glHW.h +++ b/src/Layers/xrRenderGL/glHW.h @@ -21,7 +21,7 @@ class CHW void SetPrimaryAttributes(u32& windowFlags); IRender::RenderContext GetCurrentContext() const; - int MakeContextCurrent(IRender::RenderContext context) const; + bool MakeContextCurrent(IRender::RenderContext context) const; static std::pair GetSurfaceSize(); DeviceState GetDeviceState() const; diff --git a/src/Layers/xrRenderPC_GL/r2_test_hw.cpp b/src/Layers/xrRenderPC_GL/r2_test_hw.cpp index 42735fb3b71..b881f2161d2 100644 --- a/src/Layers/xrRenderPC_GL/r2_test_hw.cpp +++ b/src/Layers/xrRenderPC_GL/r2_test_hw.cpp @@ -12,7 +12,7 @@ class sdl_window_test_helper { u32 flags{}; m_hw.SetPrimaryAttributes(flags); - m_window = SDL_CreateWindow("TestOpenGLWindow", 0, 0, 1, 1, SDL_WINDOW_HIDDEN | flags); + m_window = SDL_CreateWindow("TestOpenGLWindow", 1, 1, SDL_WINDOW_HIDDEN | flags); if (!m_window) { Log("~ Cannot create helper window for OpenGL test:", SDL_GetError()); diff --git a/src/Layers/xrRenderPC_GL/stdafx.h b/src/Layers/xrRenderPC_GL/stdafx.h index 1602ed36155..dc7b8533a7f 100644 --- a/src/Layers/xrRenderPC_GL/stdafx.h +++ b/src/Layers/xrRenderPC_GL/stdafx.h @@ -15,8 +15,8 @@ #include "xrParticles/psystem.h" #include "glad/gl.h" -#include -#include +#include +#include #define R_GL 0 #define R_R1 1 diff --git a/src/Layers/xrRender_R2/r2.cpp b/src/Layers/xrRender_R2/r2.cpp index f377c694827..979c1bfc573 100644 --- a/src/Layers/xrRender_R2/r2.cpp +++ b/src/Layers/xrRender_R2/r2.cpp @@ -647,7 +647,7 @@ IRender::RenderContext CRender::GetCurrentContext() const void CRender::MakeContextCurrent(RenderContext context) { - R_ASSERT3(HW.MakeContextCurrent(context) == 0, + R_ASSERT3(HW.MakeContextCurrent(context), "Failed to switch OpenGL context", SDL_GetError()); } #endif diff --git a/src/editors/xrWeatherEngine/engine_impl.cpp b/src/editors/xrWeatherEngine/engine_impl.cpp index d6314227fc2..1421c42b672 100644 --- a/src/editors/xrWeatherEngine/engine_impl.cpp +++ b/src/editors/xrWeatherEngine/engine_impl.cpp @@ -68,7 +68,8 @@ void engine_impl::disconnect() { Console->Execute("quit"); } bool engine_impl::quit_requested() const { - return SDL_QuitRequested(); + SDL_PumpEvents(); + return SDL_PeepEvents(nullptr, 0, SDL_PEEKEVENT, SDL_EVENT_QUIT, SDL_EVENT_QUIT) > 0; } void engine_impl::value(pcstr value, shared_str& result) { result = value; } @@ -395,4 +396,3 @@ void engine_impl::reload_weathers() if (environment.Current[1]->exec_time == game_time) environment.SelectEnvs(game_time + .1f); } - diff --git a/src/xrCore/CMakeLists.txt b/src/xrCore/CMakeLists.txt index 7e1fc50a178..7c5164c073b 100644 --- a/src/xrCore/CMakeLists.txt +++ b/src/xrCore/CMakeLists.txt @@ -456,7 +456,7 @@ target_link_libraries(xrCore PUBLIC pthread $<$:execinfo> - SDL2::SDL2 + SDL3::SDL3 PRIVATE xrMiscMath diff --git a/src/xrCore/LocatorAPI.cpp b/src/xrCore/LocatorAPI.cpp index b53178946c0..c34642dfef7 100644 --- a/src/xrCore/LocatorAPI.cpp +++ b/src/xrCore/LocatorAPI.cpp @@ -10,7 +10,7 @@ #include #include #elif defined(XR_PLATFORM_POSIX) -#include +#include #include #endif diff --git a/src/xrCore/ModuleLookup.cpp b/src/xrCore/ModuleLookup.cpp index 6b0a9a5ac68..25bc27f22af 100644 --- a/src/xrCore/ModuleLookup.cpp +++ b/src/xrCore/ModuleLookup.cpp @@ -3,7 +3,7 @@ #if defined(XR_PLATFORM_LINUX) || defined(XR_PLATFORM_BSD) #include #else -#include +#include #endif #include "ModuleLookup.hpp" diff --git a/src/xrCore/Threading/TaskManager.cpp b/src/xrCore/Threading/TaskManager.cpp index 80df306932d..a0cad0fff64 100644 --- a/src/xrCore/Threading/TaskManager.cpp +++ b/src/xrCore/Threading/TaskManager.cpp @@ -21,7 +21,7 @@ #include "ScopeLock.hpp" #include -#include +#include #include "Math/fast_lc16.hpp" diff --git a/src/xrCore/_math.cpp b/src/xrCore/_math.cpp index 0fb873cb8a2..68e4773dd7c 100644 --- a/src/xrCore/_math.cpp +++ b/src/xrCore/_math.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include -#include +#include // Initialized on startup XRCORE_API Fmatrix Fidentity; @@ -59,9 +59,7 @@ void _initialize_cpu() }; // x86 - listFeature("RDTSC", SDL_HasRDTSC()); listFeature("MMX", SDL_HasMMX()); - listFeature("3DNow!", SDL_Has3DNow()); listFeature("SSE", SDL_HasSSE()); listFeature("SSE2", CPU::HasSSE2); listFeature("SSE3", SDL_HasSSE3()); @@ -98,6 +96,13 @@ void _initialize_cpu() #define _MM_SET_DENORMALS_ZERO_MODE(mode) #else #include +#if defined(__SSE3__) || defined(_MSC_VER) +#include +#endif +#ifndef _MM_DENORMALS_ZERO_ON +#define _MM_DENORMALS_ZERO_ON 0 +#define _MM_SET_DENORMALS_ZERO_MODE(mode) ((void)0) +#endif #endif static BOOL _denormals_are_zero_supported = TRUE; diff --git a/src/xrCore/os_clipboard.cpp b/src/xrCore/os_clipboard.cpp index e7b92d7c5c6..3b30742aa34 100644 --- a/src/xrCore/os_clipboard.cpp +++ b/src/xrCore/os_clipboard.cpp @@ -13,7 +13,7 @@ #include "os_clipboard.h" #include "Text/StringConversion.hpp" -#include +#include #include diff --git a/src/xrCore/xrCore.cpp b/src/xrCore/xrCore.cpp index ae9d57e386b..3f4f68e4d1c 100644 --- a/src/xrCore/xrCore.cpp +++ b/src/xrCore/xrCore.cpp @@ -17,7 +17,7 @@ #include "xrCore/_std_extensions.h" #include "Threading/TaskManager.hpp" -#include +#include #if __has_include(".GitInfo.hpp") #include ".GitInfo.hpp" @@ -200,18 +200,24 @@ void xrCore::Initialize(pcstr _ApplicationName, pcstr commandLine, bool init_fs, _splitpath(fn, dr, di, nullptr, nullptr); strconcat(sizeof(ApplicationPath), ApplicationPath, dr, di); #elif defined(XR_PLATFORM_POSIX) - char* base_path = SDL_GetBasePath(); - if (!base_path) + const char* base_path = SDL_GetBasePath(); + if (base_path) { + SDL_strlcpy(ApplicationPath, base_path, sizeof(ApplicationPath)); + } + else + { + char* pref_path = nullptr; if (strstr(Core.Params, "-shoc") || strstr(Core.Params, "-soc")) - base_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Shadow of Chernobyl"); + pref_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Shadow of Chernobyl"); else if (strstr(Core.Params, "-cs")) - base_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Clear Sky"); + pref_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Clear Sky"); else - base_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Call of Pripyat"); + pref_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Call of Pripyat"); + + SDL_strlcpy(ApplicationPath, pref_path ? pref_path : "", sizeof(ApplicationPath)); + SDL_free(pref_path); } - SDL_strlcpy(ApplicationPath, base_path, sizeof(ApplicationPath)); - SDL_free(base_path); #else # error Select or add implementation for your platform #endif @@ -271,7 +277,7 @@ void xrCore::Initialize(pcstr _ApplicationName, pcstr commandLine, bool init_fs, Memory._initialize(); - SDL_LogSetOutputFunction(SDLLogOutput, nullptr); + SDL_SetLogOutputFunction(SDLLogOutput, nullptr); Msg("\ncommand line %s\n", Params); _initialize_cpu(); TaskScheduler = xr_make_unique(); diff --git a/src/xrCore/xrDebug.cpp b/src/xrCore/xrDebug.cpp index 1edcda8f26e..480418fb904 100644 --- a/src/xrCore/xrDebug.cpp +++ b/src/xrCore/xrDebug.cpp @@ -7,7 +7,7 @@ #include "log.h" #include "Threading/ScopeLock.hpp" -#include +#include #include @@ -98,7 +98,7 @@ SDL_AssertState SDLAssertionHandler(const SDL_AssertData* data, if (data->always_ignore) return SDL_ASSERTION_ALWAYS_IGNORE; - static constexpr pcstr desc = "SDL2 assertion triggered"; + static constexpr pcstr desc = "SDL assertion triggered"; bool alwaysIgnore = false; const auto result = xrDebug::Fail(alwaysIgnore, diff --git a/src/xrCore/xrMemory.cpp b/src/xrCore/xrMemory.cpp index 8276fab3718..56ab361b488 100644 --- a/src/xrCore/xrMemory.cpp +++ b/src/xrCore/xrMemory.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -#include +#include #if defined(XR_PLATFORM_WINDOWS) #include diff --git a/src/xrCore/xrstring.cpp b/src/xrCore/xrstring.cpp index e498aaf6426..2782a111288 100644 --- a/src/xrCore/xrstring.cpp +++ b/src/xrCore/xrstring.cpp @@ -6,7 +6,7 @@ #include "xrCore/_std_extensions.h" #include "FS_impl.h" -#include +#include XRCORE_API str_container* g_pStringContainer = nullptr; diff --git a/src/xrEngine/CMakeLists.txt b/src/xrEngine/CMakeLists.txt index 6ee391fa94c..9d7a85d0d65 100644 --- a/src/xrEngine/CMakeLists.txt +++ b/src/xrEngine/CMakeLists.txt @@ -431,7 +431,7 @@ target_link_libraries(xrEngine OpenAL::OpenAL Ogg::Ogg Theora::Theora - SDL2::SDL2 + SDL3::SDL3 ) target_compile_definitions(xrEngine diff --git a/src/xrEngine/Device_Initialize.cpp b/src/xrEngine/Device_Initialize.cpp index 864a67297fc..17622428c80 100644 --- a/src/xrEngine/Device_Initialize.cpp +++ b/src/xrEngine/Device_Initialize.cpp @@ -6,9 +6,9 @@ #include "PerformanceAlert.hpp" #include "xrCore/ModuleLookup.hpp" -#include +#include #ifdef IMGUI_ENABLE_VIEWPORTS -# include +# include #endif SDL_HitTestResult WindowHitTest(SDL_Window* win, const SDL_Point* area, void* data); @@ -70,7 +70,7 @@ void CRenderDevice::Initialize() xr_strcpy(Core.ApplicationTitle, title); SetSDLSettings(title); - m_sdlWnd = SDL_CreateWindow(title, 0, 0, 640, 480, flags); + m_sdlWnd = SDL_CreateWindow(title, 640, 480, flags); R_ASSERT3(m_sdlWnd, "Unable to create SDL window", SDL_GetError()); SDL_SetWindowHitTest(m_sdlWnd, WindowHitTest, nullptr); @@ -89,16 +89,12 @@ void CRenderDevice::Initialize() main_viewport->PlatformUserData = IM_NEW(ImGuiViewportData){ m_sdlWnd }; main_viewport->PlatformHandle = m_sdlWnd; main_viewport->PlatformHandleRaw = nullptr; - SDL_SysWMinfo info; - SDL_VERSION(&info.version); - if (SDL_GetWindowWMInfo(m_sdlWnd, &info)) - { + const SDL_PropertiesID props = SDL_GetWindowProperties(m_sdlWnd); #if defined(SDL_VIDEO_DRIVER_WINDOWS) - main_viewport->PlatformHandleRaw = (void*)info.info.win.window; + main_viewport->PlatformHandleRaw = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr); #elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA) - main_viewport->PlatformHandleRaw = (void*)info.info.cocoa.window; + main_viewport->PlatformHandleRaw = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, nullptr); #endif - } } #endif @@ -168,10 +164,8 @@ SDL_HitTestResult WindowHitTest(SDL_Window* /*window*/, const SDL_Point* pArea, void* CRenderDevice::GetApplicationWindowHandle() const { #if defined(XR_PLATFORM_WINDOWS) - SDL_SysWMinfo info; - SDL_VERSION(&info.version); - if (SDL_GetWindowWMInfo(m_sdlWnd, &info)) - return info.info.win.window; + const SDL_PropertiesID props = SDL_GetWindowProperties(m_sdlWnd); + return SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr); #endif return nullptr; } diff --git a/src/xrEngine/Device_imgui.cpp b/src/xrEngine/Device_imgui.cpp index d4ad7842c55..f16a3cf0746 100644 --- a/src/xrEngine/Device_imgui.cpp +++ b/src/xrEngine/Device_imgui.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #ifdef IMGUI_ENABLE_VIEWPORTS -# include +# include #endif #include @@ -89,7 +89,9 @@ void CRenderDevice::InitializeImGui() .w = 1, .h = (int)data->InputLineHeight, }; - SDL_SetTextInputRect(&r); + auto* vp_data = (ImGuiViewportData*)viewport->PlatformUserData; + SDL_Window* window = vp_data ? vp_data->Window : Device.m_sdlWnd; + SDL_SetTextInputArea(window, &r, 0); } }; @@ -104,7 +106,7 @@ void CRenderDevice::InitializeImGui() sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? SDL_WINDOW_BORDERLESS : 0; sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE; #if !defined(XR_PLATFORM_WINDOWS) - // See SDL hack in ImGui_ImplSDL2_ShowWindow(). + // See SDL hack in ImGui_ImplSDL3_ShowWindow(). sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) ? SDL_WINDOW_SKIP_TASKBAR : 0; #endif sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0; @@ -118,21 +120,18 @@ void CRenderDevice::InitializeImGui() viewport->PlatformHandle = vd->Window; viewport->PlatformHandleRaw = nullptr; - SDL_SysWMinfo info; - SDL_VERSION(&info.version); - if (SDL_GetWindowWMInfo(vd->Window, &info)) - { + const SDL_PropertiesID props = SDL_GetWindowProperties(vd->Window); #if defined(XR_PLATFORM_WINDOWS) && defined(SDL_VIDEO_DRIVER_WINDOWS) - viewport->PlatformHandleRaw = info.info.win.window; + viewport->PlatformHandleRaw = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr); #elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA) - viewport->PlatformHandleRaw = (void*)info.info.cocoa.window; + viewport->PlatformHandleRaw = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, nullptr); #endif - } if (viewport->ParentViewportId) { const auto parentViewport = ImGui::FindViewportByID(viewport->ParentViewportId); - SDL_SetWindowModalFor(vd->Window, (SDL_Window*)parentViewport->PlatformHandle); + SDL_SetWindowParent(vd->Window, (SDL_Window*)parentViewport->PlatformHandle); + SDL_SetWindowModal(vd->Window, true); } }; diff --git a/src/xrEngine/Device_mode.cpp b/src/xrEngine/Device_mode.cpp index 7ef06408f76..2e248f50f33 100644 --- a/src/xrEngine/Device_mode.cpp +++ b/src/xrEngine/Device_mode.cpp @@ -6,26 +6,52 @@ xr_vector vid_monitor_token; xr_map> vid_mode_token; -void FillResolutionsForMonitor(const int monitorID) +SDL_DisplayID CRenderDevice::ResolveDisplayId(u32& monitorId) const { - const int modeCount = SDL_GetNumDisplayModes(monitorID); - R_ASSERT3(modeCount > 0, "Failed to find display modes", SDL_GetError()); + int displayCount = 0; + SDL_DisplayID* displays = SDL_GetDisplays(&displayCount); + if (!displays || displayCount <= 0) + return 0; - for (int i = modeCount - 1; i >= 0; --i) + SDL_DisplayID resolved = displays[0]; + for (int i = 0; i < displayCount; ++i) { - SDL_DisplayMode mode; - const int result = SDL_GetDisplayMode(monitorID, i, &mode); - R_ASSERT3(result == 0, "Failed to find specified display mode", SDL_GetError()); + if (displays[i] == monitorId) + { + resolved = displays[i]; + SDL_free(displays); + return resolved; + } + } + + if (monitorId < (u32)displayCount) + resolved = displays[monitorId]; + SDL_free(displays); + monitorId = resolved; + return resolved; +} + +void FillResolutionsForMonitor(const SDL_DisplayID monitorID) +{ + int modeCount = 0; + SDL_DisplayMode** modes = SDL_GetFullscreenDisplayModes(monitorID, &modeCount); + R_ASSERT3(modes && modeCount > 0, "Failed to find display modes", SDL_GetError()); + + for (int i = modeCount - 1; i >= 0; --i) + { + const SDL_DisplayMode* mode = modes[i]; string256 buf; - xr_sprintf(buf, sizeof(buf), "%ux%u (%dHz)", mode.w, mode.h, mode.refresh_rate); + xr_sprintf(buf, sizeof(buf), "%ux%u (%dHz)", mode->w, mode->h, (int)mode->refresh_rate); vid_mode_token[monitorID].emplace_back(xr_strdup(buf), i); } + SDL_free(modes); + vid_mode_token[monitorID].emplace_back(nullptr, -1); } -void FillImGuiMonitorData(const int monitorID) +void FillImGuiMonitorData(const SDL_DisplayID monitorID) { ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); @@ -44,9 +70,9 @@ void FillImGuiMonitorData(const int monitorID) // FIXME-VIEWPORT: On MacOS SDL reports actual monitor DPI scale, ignoring OS configuration. We may want to set // DpiScale to cocoa_window.backingScaleFactor here. - float dpi = 0.0f; - if (!SDL_GetDisplayDPI(monitorID, &dpi, nullptr, nullptr)) - monitor.DpiScale = dpi / 96.0f; + const float scale = SDL_GetDisplayContentScale(monitorID); + if (scale > 0.0f) + monitor.DpiScale = scale; monitor.PlatformHandle = (void*)(intptr_t)monitorID; platform_io.Monitors.push_back(monitor); @@ -56,18 +82,36 @@ void CRenderDevice::FillVideoModes() { ZoneScoped; - const int displayCount = SDL_GetNumVideoDisplays(); - R_ASSERT3(displayCount > 0, "Failed to find display", SDL_GetError()); + int displayCount = 0; + SDL_DisplayID* displays = SDL_GetDisplays(&displayCount); + R_ASSERT3(displays && displayCount > 0, "Failed to find display", SDL_GetError()); + SDL_DisplayID resolvedMonitor = displays[0]; + bool foundMonitor = false; for (int i = 0; i < displayCount; ++i) { + if (displays[i] == psDeviceMode.Monitor) + { + resolvedMonitor = displays[i]; + foundMonitor = true; + break; + } + } + if (!foundMonitor && psDeviceMode.Monitor < (u32)displayCount) + resolvedMonitor = displays[psDeviceMode.Monitor]; + psDeviceMode.Monitor = resolvedMonitor; + + for (int i = 0; i < displayCount; ++i) + { + const SDL_DisplayID displayId = displays[i]; string256 buf; - xr_sprintf(buf, "%d. %s", i, SDL_GetDisplayName(i)); - vid_monitor_token.emplace_back(xr_strdup(buf), i); + xr_sprintf(buf, "%d. %s", i, SDL_GetDisplayName(displayId)); + vid_monitor_token.emplace_back(xr_strdup(buf), displayId); - FillResolutionsForMonitor(i); - FillImGuiMonitorData(i); + FillResolutionsForMonitor(displayId); + FillImGuiMonitorData(displayId); } + SDL_free(displays); vid_monitor_token.emplace_back(nullptr, -1); } @@ -115,12 +159,14 @@ void CRenderDevice::UpdateWindowProps() // Changing monitor, unset fullscreen for the previous monitor // and move the window to the new monitor - if (SDL_GetWindowDisplayIndex(m_sdlWnd) != static_cast(psDeviceMode.Monitor)) + const SDL_DisplayID displayId = ResolveDisplayId(psDeviceMode.Monitor); + const SDL_DisplayID currentDisplay = SDL_GetDisplayForWindow(m_sdlWnd); + if (currentDisplay != displayId) { - SDL_SetWindowFullscreen(m_sdlWnd, SDL_DISABLE); + SDL_SetWindowFullscreen(m_sdlWnd, false); SDL_Rect rect; - SDL_GetDisplayBounds(psDeviceMode.Monitor, &rect); + SDL_GetDisplayBounds(displayId, &rect); SDL_SetWindowPosition(m_sdlWnd, rect.x, rect.y); } @@ -128,10 +174,9 @@ void CRenderDevice::UpdateWindowProps() SDL_SetWindowSize(m_sdlWnd, psDeviceMode.Width, psDeviceMode.Height); else { - SDL_DisplayMode current; - SDL_GetCurrentDisplayMode(psDeviceMode.Monitor, ¤t); - - SDL_SetWindowSize(m_sdlWnd, current.w, current.h); + const SDL_DisplayMode* current = SDL_GetCurrentDisplayMode(displayId); + if (current) + SDL_SetWindowSize(m_sdlWnd, current->w, current->h); } if (windowed) @@ -139,21 +184,23 @@ void CRenderDevice::UpdateWindowProps() const bool drawBorders = psDeviceMode.WindowStyle == rsWindowed; const bool useDesktopFullscreen = b_is_Ready && psDeviceMode.WindowStyle == rsFullscreenBorderless; - SDL_SetWindowBordered(m_sdlWnd, drawBorders ? SDL_TRUE : SDL_FALSE); - SDL_SetWindowResizable(m_sdlWnd, !useDesktopFullscreen ? SDL_TRUE : SDL_FALSE); - SDL_SetWindowFullscreen(m_sdlWnd, useDesktopFullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_DISABLE); + SDL_SetWindowBordered(m_sdlWnd, drawBorders); + SDL_SetWindowResizable(m_sdlWnd, !useDesktopFullscreen); + SDL_SetWindowFullscreenMode(m_sdlWnd, nullptr); + SDL_SetWindowFullscreen(m_sdlWnd, useDesktopFullscreen); } else if (b_is_Ready) { - SDL_SetWindowResizable(m_sdlWnd, SDL_FALSE); - SDL_SetWindowFullscreen(m_sdlWnd, SDL_WINDOW_FULLSCREEN); - - SDL_DisplayMode mode; - SDL_GetWindowDisplayMode(m_sdlWnd, &mode); - mode.w = psDeviceMode.Width; - mode.h = psDeviceMode.Height; - mode.refresh_rate = psDeviceMode.RefreshRate; - SDL_SetWindowDisplayMode(m_sdlWnd, &mode); + SDL_SetWindowResizable(m_sdlWnd, false); + + SDL_DisplayMode mode{}; + if (SDL_GetClosestFullscreenDisplayMode(displayId, + (int)psDeviceMode.Width, (int)psDeviceMode.Height, + (float)psDeviceMode.RefreshRate, false, &mode)) + { + SDL_SetWindowFullscreenMode(m_sdlWnd, &mode); + } + SDL_SetWindowFullscreen(m_sdlWnd, true); } SDL_PumpEvents(); @@ -193,11 +240,13 @@ void CRenderDevice::SelectResolution(const bool windowed) } else if (psDeviceMode.Width == 0 && psDeviceMode.Height == 0 && psDeviceMode.RefreshRate == 0) { - SDL_DisplayMode current; - SDL_GetCurrentDisplayMode(psDeviceMode.Monitor, ¤t); - psDeviceMode.Width = current.w; - psDeviceMode.Height = current.h; - psDeviceMode.RefreshRate = current.refresh_rate; + const SDL_DisplayMode* current = SDL_GetCurrentDisplayMode(ResolveDisplayId(psDeviceMode.Monitor)); + if (current) + { + psDeviceMode.Width = current->w; + psDeviceMode.Height = current->h; + psDeviceMode.RefreshRate = (u32)current->refresh_rate; + } } else if (!windowed) // check if safe for fullscreen { @@ -212,24 +261,25 @@ void CRenderDevice::SelectResolution(const bool windowed) if (it == modes.end()) // not found { - SDL_DisplayMode current = - { - SDL_PIXELFORMAT_UNKNOWN, - (int)psDeviceMode.Width, - (int)psDeviceMode.Height, - (int)psDeviceMode.RefreshRate, - nullptr - }; - - SDL_DisplayMode closest; // try closest or fallback to desktop mode - if (!SDL_GetClosestDisplayMode(psDeviceMode.Monitor, ¤t, &closest)) + SDL_DisplayMode closest{}; // try closest or fallback to desktop mode + const SDL_DisplayID displayId = ResolveDisplayId(psDeviceMode.Monitor); + if (!SDL_GetClosestFullscreenDisplayMode(displayId, + (int)psDeviceMode.Width, (int)psDeviceMode.Height, + (float)psDeviceMode.RefreshRate, false, &closest)) { - SDL_GetCurrentDisplayMode(psDeviceMode.Monitor, &closest); + if (const SDL_DisplayMode* current = SDL_GetCurrentDisplayMode(displayId)) + closest = *current; + else + { + closest.w = psDeviceMode.Width; + closest.h = psDeviceMode.Height; + closest.refresh_rate = (float)psDeviceMode.RefreshRate; + } } psDeviceMode.Width = closest.w; psDeviceMode.Height = closest.h; - psDeviceMode.RefreshRate = closest.refresh_rate; + psDeviceMode.RefreshRate = (u32)closest.refresh_rate; } } @@ -250,7 +300,7 @@ void CRenderDevice::OnErrorDialog(bool beforeDialog) if (restore) UpdateWindowProps(); else - SDL_SetWindowFullscreen(m_sdlWnd, SDL_FALSE); + SDL_SetWindowFullscreen(m_sdlWnd, false); if (needUpdateInput) pInput->GrabInput(restore); @@ -259,8 +309,8 @@ void CRenderDevice::OnErrorDialog(bool beforeDialog) void CRenderDevice::OnFatalError() { // make it sure window will hide in any way - SDL_SetWindowFullscreen(m_sdlWnd, SDL_FALSE); - SDL_SetWindowAlwaysOnTop(m_sdlWnd, SDL_FALSE); + SDL_SetWindowFullscreen(m_sdlWnd, false); + SDL_SetWindowAlwaysOnTop(m_sdlWnd, false); SDL_ShowWindow(m_sdlWnd); SDL_MinimizeWindow(m_sdlWnd); SDL_HideWindow(m_sdlWnd); diff --git a/src/xrEngine/Engine.cpp b/src/xrEngine/Engine.cpp index 6404ba31673..83b43163be7 100644 --- a/src/xrEngine/Engine.cpp +++ b/src/xrEngine/Engine.cpp @@ -104,7 +104,8 @@ void CEngine::OnEvent(EVENT E, u64 P1, u64 P2) if (pInput != nullptr) pInput->GrabInput(false); - SDL_Event quit = { SDL_QUIT }; + SDL_Event quit = {}; + quit.type = SDL_EVENT_QUIT; SDL_PushEvent(&quit); } } diff --git a/src/xrEngine/device.cpp b/src/xrEngine/device.cpp index 01a427c0d6f..f52bf7342c4 100644 --- a/src/xrEngine/device.cpp +++ b/src/xrEngine/device.cpp @@ -13,7 +13,7 @@ #include "xrScriptEngine/script_space.hpp" -#include +#include ENGINE_API CRenderDevice Device; ENGINE_API CLoadScreenRenderer load_screen_renderer; @@ -308,24 +308,30 @@ void CRenderDevice::ProcessEvent(const SDL_Event& event) switch (event.type) { - case SDL_DISPLAYEVENT: + case SDL_EVENT_DISPLAY_ORIENTATION: + case SDL_EVENT_DISPLAY_ADDED: + case SDL_EVENT_DISPLAY_REMOVED: + case SDL_EVENT_DISPLAY_MOVED: + case SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED: + case SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED: + case SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED: + case SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED: { - switch (event.display.type) - { - case SDL_DISPLAYEVENT_ORIENTATION: - case SDL_DISPLAYEVENT_CONNECTED: - case SDL_DISPLAYEVENT_DISCONNECTED: - CleanupVideoModes(); - FillVideoModes(); - if (event.display.display == psDeviceMode.Monitor && event.display.type != SDL_DISPLAYEVENT_CONNECTED) - Reset(); - else - UpdateWindowProps(); - break; - } // switch (event.display.type) + CleanupVideoModes(); + FillVideoModes(); + const SDL_DisplayID displayId = ResolveDisplayId(psDeviceMode.Monitor); + if (event.display.displayID == displayId && event.type != SDL_EVENT_DISPLAY_ADDED) + Reset(); + else + UpdateWindowProps(); break; } - case SDL_WINDOWEVENT: + + case SDL_EVENT_WINDOW_MOVED: + case SDL_EVENT_WINDOW_DISPLAY_CHANGED: + case SDL_EVENT_WINDOW_RESIZED: + case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED: + case SDL_EVENT_WINDOW_CLOSE_REQUESTED: { const auto window = SDL_GetWindowFromID(event.window.windowID); if (!window) @@ -334,9 +340,9 @@ void CRenderDevice::ProcessEvent(const SDL_Event& event) if (!viewport) break; - switch (event.window.event) + switch (event.type) { - case SDL_WINDOWEVENT_MOVED: + case SDL_EVENT_WINDOW_MOVED: { if (window == m_sdlWnd) { @@ -347,16 +353,16 @@ void CRenderDevice::ProcessEvent(const SDL_Event& event) break; } - case SDL_WINDOWEVENT_DISPLAY_CHANGED: - psDeviceMode.Monitor = event.window.data1; + case SDL_EVENT_WINDOW_DISPLAY_CHANGED: + psDeviceMode.Monitor = static_cast(event.window.data1); break; - case SDL_WINDOWEVENT_RESIZED: + case SDL_EVENT_WINDOW_RESIZED: if (window == m_sdlWnd) UpdateWindowRects(); break; - case SDL_WINDOWEVENT_SIZE_CHANGED: + case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED: { if (window == m_sdlWnd) { @@ -377,7 +383,7 @@ void CRenderDevice::ProcessEvent(const SDL_Event& event) break; } - case SDL_WINDOWEVENT_CLOSE: + case SDL_EVENT_WINDOW_CLOSE_REQUESTED: { if (viewport) viewport->PlatformRequestClose = true; @@ -389,7 +395,7 @@ void CRenderDevice::ProcessEvent(const SDL_Event& event) } break; } - } // switch (event.window.event) + } // switch (event.type) } } // switch (event.type) diff --git a/src/xrEngine/device.h b/src/xrEngine/device.h index 718d1a2d139..1f4cb9fe50b 100644 --- a/src/xrEngine/device.h +++ b/src/xrEngine/device.h @@ -23,7 +23,7 @@ #include "xrScriptEngine/ScriptExporter.hpp" -#include +#include // refs class Task; @@ -221,6 +221,8 @@ class ENGINE_API CRenderDevice : public IWindowHandler void* GetApplicationWindowHandle() const override; SDL_Window* GetApplicationWindow() override; + + SDL_DisplayID ResolveDisplayId(u32& monitorId) const; void OnErrorDialog(bool beforeDialog) override; void OnFatalError() override; @@ -287,7 +289,11 @@ class ENGINE_API CRenderDevice : public IWindowHandler ImGuiViewportData(ImVec2 pos, ImVec2 size, Uint32 flags) { Window = SDL_CreateWindow("ImGui Viewport (no title yet)", - (int)pos.x, (int)pos.y, (int)size.x, (int)size.y, flags); + (int)size.x, (int)size.y, flags); + if (Window) + { + SDL_SetWindowPosition(Window, (int)pos.x, (int)pos.y); + } WindowOwned = true; } diff --git a/src/xrEngine/editor_base_input.cpp b/src/xrEngine/editor_base_input.cpp index fe3fcc7103b..7e7022b34cd 100644 --- a/src/xrEngine/editor_base_input.cpp +++ b/src/xrEngine/editor_base_input.cpp @@ -125,7 +125,8 @@ void ide::ProcessEvent(const SDL_Event& event) switch (event.type) { - case SDL_WINDOWEVENT: + case SDL_EVENT_WINDOW_MOUSE_ENTER: + case SDL_EVENT_WINDOW_MOUSE_LEAVE: { const auto window = SDL_GetWindowFromID(event.window.windowID); if (!window) @@ -134,16 +135,16 @@ void ide::ProcessEvent(const SDL_Event& event) if (!viewport) break; - switch (event.window.event) + switch (event.type) { - case SDL_WINDOWEVENT_ENTER: + case SDL_EVENT_WINDOW_MOUSE_ENTER: bd.mouse_window_id = event.window.windowID; bd.mouse_last_leave_frame = 0; break; - case SDL_WINDOWEVENT_LEAVE: + case SDL_EVENT_WINDOW_MOUSE_LEAVE: bd.mouse_last_leave_frame = ImGui::GetFrameCount() + 1; break; - } // switch (event.window.event) + } } } // switch (event.type) } @@ -170,7 +171,7 @@ void ide::UpdateMouseData() // We forward mouse input when hovered or captured (via SDL_MOUSEMOTION) or when focused (below) #if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE && defined(IMGUI_ENABLE_VIEWPORTS) - SDL_CaptureMouse(anyMouseButtonPressed ? SDL_TRUE : SDL_FALSE); + SDL_CaptureMouse(anyMouseButtonPressed); SDL_Window* focused_window = SDL_GetKeyboardFocus(); const bool is_app_focused = focused_window && (Device.m_sdlWnd == focused_window || ImGui::FindViewportByPlatformHandle(focused_window)); #else @@ -206,15 +207,15 @@ SDL_SystemCursor get_sdl_cursor(ImGuiMouseCursor cursor) VERIFY(false); [[fallthrough]]; - case ImGuiMouseCursor_Arrow: return SDL_SYSTEM_CURSOR_ARROW; - case ImGuiMouseCursor_TextInput: return SDL_SYSTEM_CURSOR_IBEAM; - case ImGuiMouseCursor_ResizeAll: return SDL_SYSTEM_CURSOR_SIZEALL; - case ImGuiMouseCursor_ResizeNS: return SDL_SYSTEM_CURSOR_SIZENS; - case ImGuiMouseCursor_ResizeEW: return SDL_SYSTEM_CURSOR_SIZEWE; - case ImGuiMouseCursor_ResizeNESW: return SDL_SYSTEM_CURSOR_SIZENESW; - case ImGuiMouseCursor_ResizeNWSE: return SDL_SYSTEM_CURSOR_SIZENWSE; - case ImGuiMouseCursor_Hand: return SDL_SYSTEM_CURSOR_HAND; - case ImGuiMouseCursor_NotAllowed: return SDL_SYSTEM_CURSOR_NO; + case ImGuiMouseCursor_Arrow: return SDL_SYSTEM_CURSOR_DEFAULT; + case ImGuiMouseCursor_TextInput: return SDL_SYSTEM_CURSOR_TEXT; + case ImGuiMouseCursor_ResizeAll: return SDL_SYSTEM_CURSOR_MOVE; + case ImGuiMouseCursor_ResizeNS: return SDL_SYSTEM_CURSOR_NS_RESIZE; + case ImGuiMouseCursor_ResizeEW: return SDL_SYSTEM_CURSOR_EW_RESIZE; + case ImGuiMouseCursor_ResizeNESW: return SDL_SYSTEM_CURSOR_NESW_RESIZE; + case ImGuiMouseCursor_ResizeNWSE: return SDL_SYSTEM_CURSOR_NWSE_RESIZE; + case ImGuiMouseCursor_Hand: return SDL_SYSTEM_CURSOR_POINTER; + case ImGuiMouseCursor_NotAllowed: return SDL_SYSTEM_CURSOR_NOT_ALLOWED; } } diff --git a/src/xrEngine/embedded_resources_management.h b/src/xrEngine/embedded_resources_management.h index 9983616193b..ba91678ccfb 100644 --- a/src/xrEngine/embedded_resources_management.h +++ b/src/xrEngine/embedded_resources_management.h @@ -3,7 +3,7 @@ #include "xr_3da/resource.h" #ifdef XR_PLATFORM_WINDOWS -# include +# include #endif inline SDL_Surface* XRSDL_SurfaceVerticalFlip(SDL_Surface*& source) @@ -90,11 +90,9 @@ inline void ExtractAndSetWindowIcon(SDL_Window* wnd, int iconIdx) const HICON icon = (HICON)ExtractImage(iconIdx, IMAGE_ICON); - SDL_SysWMinfo info; - SDL_VERSION(&info.version); - R_ASSERT2(SDL_GetWindowWMInfo(wnd, &info), SDL_GetError()); - - const HWND hwnd = info.info.win.window; + const SDL_PropertiesID props = SDL_GetWindowProperties(wnd); + const HWND hwnd = static_cast(SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr)); + R_ASSERT2(hwnd, SDL_GetError()); SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon); SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon); } diff --git a/src/xrEngine/key_binding_registrator_script.cpp b/src/xrEngine/key_binding_registrator_script.cpp index dde638ec05f..97d66433b37 100644 --- a/src/xrEngine/key_binding_registrator_script.cpp +++ b/src/xrEngine/key_binding_registrator_script.cpp @@ -464,17 +464,18 @@ void key_binding_registrator::script_register(lua_State* luaState) value("DIK_MODE", int(SDL_SCANCODE_MODE)), - value("DIK_AUDIONEXT", int(SDL_SCANCODE_AUDIONEXT)), - value("DIK_AUDIOPREV", int(SDL_SCANCODE_AUDIOPREV)), - value("DIK_AUDIOSTOP", int(SDL_SCANCODE_AUDIOSTOP)), - value("DIK_AUDIOPLAY", int(SDL_SCANCODE_AUDIOPLAY)), - value("DIK_AUDIOMUTE", int(SDL_SCANCODE_AUDIOMUTE)), - - value("DIK_NUMPAD_MEDIASELECT", int(SDL_SCANCODE_MEDIASELECT)), - value("DIK_NUMPAD_WWW", int(SDL_SCANCODE_WWW)), - value("DIK_NUMPAD_MAIL", int(SDL_SCANCODE_MAIL)), - value("DIK_NUMPAD_CALCULATOR", int(SDL_SCANCODE_CALCULATOR)), - value("DIK_NUMPAD_COMPUTER", int(SDL_SCANCODE_COMPUTER)), + value("DIK_AUDIONEXT", int(SDL_SCANCODE_MEDIA_NEXT_TRACK)), + value("DIK_AUDIOPREV", int(SDL_SCANCODE_MEDIA_PREVIOUS_TRACK)), + value("DIK_AUDIOSTOP", int(SDL_SCANCODE_MEDIA_STOP)), + value("DIK_AUDIOPLAY", int(SDL_SCANCODE_MEDIA_PLAY)), + value("DIK_AUDIOMUTE", int(SDL_SCANCODE_MUTE)), + + value("DIK_NUMPAD_MEDIASELECT", int(SDL_SCANCODE_MEDIA_SELECT)), + // Removed in SDL3: + //value("DIK_NUMPAD_WWW", int(SDL_SCANCODE_WWW)), + //value("DIK_NUMPAD_MAIL", int(SDL_SCANCODE_MAIL)), + //value("DIK_NUMPAD_CALCULATOR", int(SDL_SCANCODE_CALCULATOR)), + //value("DIK_NUMPAD_COMPUTER", int(SDL_SCANCODE_COMPUTER)), value("DIK_NUMPAD_AC_SEARCH", int(SDL_SCANCODE_AC_SEARCH)), value("DIK_NUMPAD_AC_HOME", int(SDL_SCANCODE_AC_HOME)), @@ -484,19 +485,20 @@ void key_binding_registrator::script_register(lua_State* luaState) value("DIK_NUMPAD_AC_REFRESH", int(SDL_SCANCODE_AC_REFRESH)), value("DIK_NUMPAD_AC_BOOKMARKS", int(SDL_SCANCODE_AC_BOOKMARKS)), - value("DIK_BRIGHTNESSDOWN", int(SDL_SCANCODE_BRIGHTNESSDOWN)), - value("DIK_BRIGHTNESSUP", int(SDL_SCANCODE_BRIGHTNESSUP)), - value("DIK_DISPLAYSWITCH", int(SDL_SCANCODE_DISPLAYSWITCH)), + // Removed in SDL3: + //value("DIK_BRIGHTNESSDOWN", int(SDL_SCANCODE_BRIGHTNESSDOWN)), + //value("DIK_BRIGHTNESSUP", int(SDL_SCANCODE_BRIGHTNESSUP)), + //value("DIK_DISPLAYSWITCH", int(SDL_SCANCODE_DISPLAYSWITCH)), - value("DIK_KBDILLUMTOGGLE)", int(SDL_SCANCODE_KBDILLUMTOGGLE)), - value("DIK_KBDILLUMDOWN", int(SDL_SCANCODE_KBDILLUMDOWN)), - value("DIK_KBDILLUMUP", int(SDL_SCANCODE_KBDILLUMUP)), + //value("DIK_KBDILLUMTOGGLE)", int(SDL_SCANCODE_KBDILLUMTOGGLE)), + //value("DIK_KBDILLUMDOWN", int(SDL_SCANCODE_KBDILLUMDOWN)), + //value("DIK_KBDILLUMUP", int(SDL_SCANCODE_KBDILLUMUP)), - value("DIK_EJECT", int(SDL_SCANCODE_EJECT)), + value("DIK_EJECT", int(SDL_SCANCODE_MEDIA_EJECT)), value("DIK_SLEEP", int(SDL_SCANCODE_SLEEP)), - value("DIK_APP1", int(SDL_SCANCODE_APP1)), - value("DIK_APP2", int(SDL_SCANCODE_APP2)), + value("DIK_APP1", int(SDL_SCANCODE_APPLICATION)), + value("DIK_APP2", int(SDL_SCANCODE_APPLICATION)), value("MOUSE_1", int(MOUSE_1)), value("MOUSE_2", int(MOUSE_2)), diff --git a/src/xrEngine/line_edit_control.cpp b/src/xrEngine/line_edit_control.cpp index 10f49c4f581..76d340d7db8 100644 --- a/src/xrEngine/line_edit_control.cpp +++ b/src/xrEngine/line_edit_control.cpp @@ -16,7 +16,7 @@ #include "edit_actions.h" -#include +#include #include @@ -112,7 +112,7 @@ void line_edit_control::update_key_states() set_key_state(ks_RCtrl, pInput->iGetAsyncKeyState(SDL_SCANCODE_RCTRL)); set_key_state(ks_LAlt, pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT)); set_key_state(ks_RAlt, pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT)); - set_key_state(ks_CapsLock, SDL_GetModState() & KMOD_CAPS); + set_key_state(ks_CapsLock, SDL_GetModState() & SDL_KMOD_CAPS); } void line_edit_control::clear_states() @@ -689,9 +689,7 @@ void line_edit_control::compute_positions() void line_edit_control::clamp_cur_pos() { clamp(m_cur_pos, 0, xr_strlen(m_edit_str)); } void line_edit_control::SwitchKL() { - cpcstr hint = SDL_GetHint(SDL_HINT_GRAB_KEYBOARD); - // if SDL_HINT_GRAB_KEYBOARD is not set to 1 then return; - if (!hint || 0 != xr_strcmp("1", hint)) + if (!SDL_GetWindowKeyboardGrab(Device.m_sdlWnd)) return; // System will handle it #ifdef XR_PLATFORM_WINDOWS if (pInput->IsExclusiveMode()) diff --git a/src/xrEngine/x_ray.cpp b/src/xrEngine/x_ray.cpp index 20d2e576e1b..afa98692457 100644 --- a/src/xrEngine/x_ray.cpp +++ b/src/xrEngine/x_ray.cpp @@ -70,6 +70,12 @@ struct PathIncludePred }; } +static bool QuitRequested() +{ + SDL_PumpEvents(); + return SDL_PeepEvents(nullptr, 0, SDL_PEEKEVENT, SDL_EVENT_QUIT, SDL_EVENT_QUIT) > 0; +} + template void InitConfig(T& config, pcstr name, bool fatal = true, bool readOnly = true, bool loadAtStart = true, bool saveAtEnd = true, @@ -217,8 +223,8 @@ CApplication::CApplication(pcstr commandLine, GameModule* game, const std::array ZoneScopedN("SDL_Init"); u32 flags = SDL_INIT_VIDEO; if (!strstr(commandLine, "-no_gamepad")) - flags |= SDL_INIT_GAMECONTROLLER; - R_ASSERT3(SDL_Init(flags) == 0, "Unable to initialize SDL", SDL_GetError()); + flags |= SDL_INIT_GAMEPAD; + R_ASSERT3(SDL_Init(flags), "Unable to initialize SDL", SDL_GetError()); } #ifdef XR_PLATFORM_WINDOWS @@ -233,7 +239,7 @@ CApplication::CApplication(pcstr commandLine, GameModule* game, const std::array ShowSplash(topmost); } - SDL_StopTextInput(); // It's enabled by default for some reason, we don't want it + // SDL_StopTextInput() is called per-window in SDL3 - will be handled when windows are created const auto& inputTask = TaskManager::AddTask([] { const bool captureInput = !strstr(Core.Params, "-i"); @@ -369,7 +375,7 @@ int CApplication::Run() HideSplash(); Device.Run(); - while (!SDL_QuitRequested()) // SDL_PumpEvents is here + while (!QuitRequested()) // SDL_PumpEvents is here { FrameMarkStart(FRAME_MARK_APPLICATION_RUN); bool canCallActivate = false; @@ -377,7 +383,7 @@ int CApplication::Run() SDL_Event events[MAX_WINDOW_EVENTS]; const int count = SDL_PeepEvents(events, MAX_WINDOW_EVENTS, - SDL_GETEVENT, SDL_WINDOWEVENT, SDL_WINDOWEVENT); + SDL_GETEVENT, SDL_EVENT_WINDOW_FIRST, SDL_EVENT_WINDOW_LAST); for (int i = 0; i < count; ++i) { @@ -385,16 +391,12 @@ int CApplication::Run() switch (event.type) { - case SDL_WINDOWEVENT: + case SDL_EVENT_WINDOW_SHOWN: + case SDL_EVENT_WINDOW_FOCUS_GAINED: + case SDL_EVENT_WINDOW_RESTORED: + case SDL_EVENT_WINDOW_MAXIMIZED: { const auto window = SDL_GetWindowFromID(event.window.windowID); - - switch (event.window.event) - { - case SDL_WINDOWEVENT_SHOWN: - case SDL_WINDOWEVENT_FOCUS_GAINED: - case SDL_WINDOWEVENT_RESTORED: - case SDL_WINDOWEVENT_MAXIMIZED: if (window != Device.m_sdlWnd) Device.OnWindowActivate(window, true); else @@ -403,10 +405,13 @@ int CApplication::Run() shouldActivate = true; } continue; + } - case SDL_WINDOWEVENT_HIDDEN: - case SDL_WINDOWEVENT_FOCUS_LOST: - case SDL_WINDOWEVENT_MINIMIZED: + case SDL_EVENT_WINDOW_HIDDEN: + case SDL_EVENT_WINDOW_FOCUS_LOST: + case SDL_EVENT_WINDOW_MINIMIZED: + { + const auto window = SDL_GetWindowFromID(event.window.windowID); if (window != Device.m_sdlWnd) Device.OnWindowActivate(window, false); else @@ -415,7 +420,6 @@ int CApplication::Run() shouldActivate = false; } continue; - } // switch (event.window.event) } } // switch (event.type) @@ -434,7 +438,7 @@ int CApplication::Run() UpdateDiscordStatus(); FrameMarkEnd(FRAME_MARK_APPLICATION_RUN); - } // while (!SDL_QuitRequested()) + } // while (!QuitRequested()) Device.Shutdown(); @@ -460,7 +464,11 @@ void CApplication::ShowSplash(bool topmost) if (topmost) flags |= SDL_WINDOW_ALWAYS_ON_TOP; - m_window = SDL_CreateWindow("OpenXRay", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, m_surface->w, m_surface->h, flags); + m_window = SDL_CreateWindow("OpenXRay", m_surface->w, m_surface->h, flags); + if (m_window) + { + SDL_SetWindowPosition(m_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + } SDL_ShowWindow(m_window); m_splash_thread = Threading::RunThread("Splash Thread", &CApplication::SplashProc, this); @@ -497,7 +505,7 @@ void CApplication::HideSplash() SDL_DestroyWindow(m_window); m_window = nullptr; - SDL_FreeSurface(m_surface); + SDL_DestroySurface(m_surface); } void CApplication::InitializeDiscord() diff --git a/src/xrEngine/xrTheora_Surface.cpp b/src/xrEngine/xrTheora_Surface.cpp index b9ad39b0083..ea4b9a5b157 100644 --- a/src/xrEngine/xrTheora_Surface.cpp +++ b/src/xrEngine/xrTheora_Surface.cpp @@ -300,7 +300,7 @@ void CTheoraSurface::open_sdl_video() VERIFY(m_rgb); theora_info& t_info = m_rgb->t_info; - if (SDL_Init(SDL_INIT_VIDEO) < 0) + if (!SDL_Init(SDL_INIT_VIDEO)) { msg("Unable to init SDL: %s", SDL_GetError()); return; @@ -336,9 +336,9 @@ void CTheoraSurface::write_sdl_video() int crop_offset; // Lock SDL_yuv_overlay if (SDL_MUSTLOCK(sdl_screen)) - if (SDL_LockSurface(sdl_screen) < 0) + if (!SDL_LockSurface(sdl_screen)) return; - if (SDL_LockYUVOverlay(sdl_yuv_overlay) < 0) + if (!SDL_LockYUVOverlay(sdl_yuv_overlay)) return; // let's draw the data (*yuv[3]) on a SDL screen (*screen) // deal with border stride diff --git a/src/xrEngine/xrTheora_Surface.h b/src/xrEngine/xrTheora_Surface.h index 00599622f92..e611838a8df 100644 --- a/src/xrEngine/xrTheora_Surface.h +++ b/src/xrEngine/xrTheora_Surface.h @@ -3,7 +3,7 @@ #pragma once #ifdef SDL_OUTPUT -#include +#include #endif // refs diff --git a/src/xrEngine/xr_input.cpp b/src/xrEngine/xr_input.cpp index b8caddd9ab1..cad4ce6eb17 100644 --- a/src/xrEngine/xr_input.cpp +++ b/src/xrEngine/xr_input.cpp @@ -73,27 +73,30 @@ CInput::CInput(const bool exclusive) //===================== Dummy pack iCapture(&dummyController); - SDL_SetHint(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, "1"); // We need to handle it manually + SDL_SetHint(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, "0"); // We need to handle it manually Device.seqAppActivate.Add(this); Device.seqAppDeactivate.Add(this, REG_PRIORITY_HIGH); Device.seqFrame.Add(this, REG_PRIORITY_HIGH); - mouseCursors[SDL_SYSTEM_CURSOR_ARROW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); - mouseCursors[SDL_SYSTEM_CURSOR_IBEAM] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM); - mouseCursors[SDL_SYSTEM_CURSOR_WAIT] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT); - mouseCursors[SDL_SYSTEM_CURSOR_CROSSHAIR] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR); - mouseCursors[SDL_SYSTEM_CURSOR_WAITARROW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAITARROW); - mouseCursors[SDL_SYSTEM_CURSOR_SIZENWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE); - mouseCursors[SDL_SYSTEM_CURSOR_SIZENESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW); - mouseCursors[SDL_SYSTEM_CURSOR_SIZEWE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE); - mouseCursors[SDL_SYSTEM_CURSOR_SIZENS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS); - mouseCursors[SDL_SYSTEM_CURSOR_SIZEALL] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL); - mouseCursors[SDL_SYSTEM_CURSOR_NO] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO); - mouseCursors[SDL_SYSTEM_CURSOR_HAND] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND); - - for (int i = 0; i < SDL_NumJoysticks(); ++i) - OpenController(i); + mouseCursors[SDL_SYSTEM_CURSOR_DEFAULT] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT); + mouseCursors[SDL_SYSTEM_CURSOR_TEXT] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_TEXT); + mouseCursors[SDL_SYSTEM_CURSOR_WAIT] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT); + mouseCursors[SDL_SYSTEM_CURSOR_CROSSHAIR] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR); + mouseCursors[SDL_SYSTEM_CURSOR_PROGRESS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_PROGRESS); + mouseCursors[SDL_SYSTEM_CURSOR_NWSE_RESIZE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NWSE_RESIZE); + mouseCursors[SDL_SYSTEM_CURSOR_NESW_RESIZE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NESW_RESIZE); + mouseCursors[SDL_SYSTEM_CURSOR_EW_RESIZE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_EW_RESIZE); + mouseCursors[SDL_SYSTEM_CURSOR_NS_RESIZE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NS_RESIZE); + mouseCursors[SDL_SYSTEM_CURSOR_MOVE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_MOVE); + mouseCursors[SDL_SYSTEM_CURSOR_NOT_ALLOWED] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NOT_ALLOWED); + mouseCursors[SDL_SYSTEM_CURSOR_POINTER] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_POINTER); + + int controllerCount = 0; + SDL_JoystickID* gamepads = SDL_GetGamepads(&controllerCount); + for (int i = 0; i < controllerCount; ++i) + OpenController(gamepads[i]); + SDL_free(gamepads); } CInput::~CInput() @@ -103,11 +106,11 @@ CInput::~CInput() GrabInput(false); for (auto& controller : controllers) - SDL_GameControllerClose(controller); + SDL_CloseGamepad(controller); for (auto& cursor : mouseCursors) { - SDL_FreeCursor(cursor); + SDL_DestroyCursor(cursor); cursor = nullptr; } lastCursor = nullptr; @@ -117,17 +120,17 @@ CInput::~CInput() Device.seqAppActivate.Remove(this); } -void CInput::OpenController(int idx) +void CInput::OpenController(SDL_JoystickID instance_id) { - if (!SDL_IsGameController(idx)) + if (!SDL_IsGamepad(instance_id)) return; - const auto controller = SDL_GameControllerOpen(idx); + const auto controller = SDL_OpenGamepad(instance_id); if (!controller) return; if (psControllerFlags.test(ControllerEnableSensors)) - SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_GYRO, SDL_TRUE); + SDL_SetGamepadSensorEnabled(controller, SDL_SENSOR_GYRO, true); controllers.emplace_back(controller); } @@ -150,7 +153,7 @@ void CInput::SetCurrentInputType(InputType type) if (psControllerFlags.test(ControllerEnableSensors)) { for (auto controller : controllers) - SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_GYRO, SDL_FALSE); + SDL_SetGamepadSensorEnabled(controller, SDL_SENSOR_GYRO, false); } break; @@ -158,14 +161,14 @@ void CInput::SetCurrentInputType(InputType type) if (psControllerFlags.test(ControllerEnableSensors)) { for (auto controller : controllers) - SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_GYRO, SDL_TRUE); + SDL_SetGamepadSensorEnabled(controller, SDL_SENSOR_GYRO, true); } break; } // Always flush it. On the first controller invocation, // prefer to receive sensor updates "from scratch", // on the next frame. - SDL_FlushEvent(SDL_CONTROLLERSENSORUPDATE); + SDL_FlushEvent(SDL_EVENT_GAMEPAD_SENSOR_UPDATE); } void CInput::MouseUpdate() @@ -189,7 +192,7 @@ void CInput::MouseUpdate() SDL_Event events[MAX_MOUSE_EVENTS]; SDL_PumpEvents(); const auto count = SDL_PeepEvents(events, MAX_MOUSE_EVENTS, - SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEWHEEL); + SDL_GETEVENT, SDL_EVENT_MOUSE_MOTION, SDL_EVENT_MOUSE_WHEEL); for (int i = 0; i < count; ++i) { @@ -197,34 +200,34 @@ void CInput::MouseUpdate() switch (event.type) { - case SDL_MOUSEMOTION: + case SDL_EVENT_MOUSE_MOTION: mouseMoved = true; - offs[0] += event.motion.xrel; - offs[1] += event.motion.yrel; - mouseAxisState[0] = event.motion.x; - mouseAxisState[1] = event.motion.y; + offs[0] += static_cast(event.motion.xrel); + offs[1] += static_cast(event.motion.yrel); + mouseAxisState[0] = static_cast(event.motion.x); + mouseAxisState[1] = static_cast(event.motion.y); break; - case SDL_MOUSEBUTTONDOWN: + case SDL_EVENT_MOUSE_BUTTON_DOWN: { const auto idx = RemapIdx[event.button.button - 1]; mouseState[idx] = true; cbStack.back()->IR_OnMousePress(IdxToKey[idx]); break; } - case SDL_MOUSEBUTTONUP: + case SDL_EVENT_MOUSE_BUTTON_UP: { const auto idx = RemapIdx[event.button.button - 1]; mouseState[idx] = false; cbStack.back()->IR_OnMouseRelease(IdxToKey[idx]); break; } - case SDL_MOUSEWHEEL: + case SDL_EVENT_MOUSE_WHEEL: mouseMoved = true; - scroll[0] += event.wheel.preciseX; - scroll[1] += event.wheel.preciseY; - mouseAxisState[2] += event.wheel.x; - mouseAxisState[3] += event.wheel.y; + scroll[0] += event.wheel.x; + scroll[1] += event.wheel.y; + mouseAxisState[2] += event.wheel.integer_x; + mouseAxisState[3] += event.wheel.integer_y; break; } } @@ -251,7 +254,7 @@ void CInput::KeyUpdate() SDL_Event events[MAX_KEYBOARD_EVENTS]; const auto count = SDL_PeepEvents(events, MAX_KEYBOARD_EVENTS, - SDL_GETEVENT, SDL_KEYDOWN, SDL_KEYMAPCHANGED); + SDL_GETEVENT, SDL_EVENT_KEY_DOWN, SDL_EVENT_KEYMAP_CHANGED); // Let iGetAsyncKeyState work correctly during this frame immediately for (int i = 0; i < count; ++i) @@ -260,14 +263,14 @@ void CInput::KeyUpdate() switch (event.type) { - case SDL_KEYDOWN: + case SDL_EVENT_KEY_DOWN: if (event.key.repeat) continue; - keyboardState[event.key.keysym.scancode] = true; + keyboardState[event.key.scancode] = true; break; - case SDL_KEYUP: - keyboardState[event.key.keysym.scancode] = false; + case SDL_EVENT_KEY_UP: + keyboardState[event.key.scancode] = false; break; } } @@ -296,23 +299,23 @@ void CInput::KeyUpdate() switch (event.type) { - case SDL_KEYDOWN: + case SDL_EVENT_KEY_DOWN: if (event.key.repeat) continue; - cbStack.back()->IR_OnKeyboardPress(event.key.keysym.scancode); + cbStack.back()->IR_OnKeyboardPress(event.key.scancode); break; - case SDL_KEYUP: - cbStack.back()->IR_OnKeyboardRelease(event.key.keysym.scancode); + case SDL_EVENT_KEY_UP: + cbStack.back()->IR_OnKeyboardRelease(event.key.scancode); break; - case SDL_TEXTINPUT: + case SDL_EVENT_TEXT_INPUT: if (cnt != textInputCounter) continue; // if input target changed, skip this frame cbStack.back()->IR_OnTextInput(event.text.text); break; - case SDL_KEYMAPCHANGED: + case SDL_EVENT_KEYMAP_CHANGED: seqKeyMapChanged.Process(); break; } @@ -357,30 +360,43 @@ void CInput::ControllerUpdate() XR_CONTROLLER_BUTTON_PADDLE4, XR_CONTROLLER_BUTTON_TOUCHPAD, }; + static_assert(std::size(ControllerButtonToKey) == XR_CONTROLLER_BUTTON_COUNT); SDL_Event events[MAX_CONTROLLER_EVENTS]; auto count = SDL_PeepEvents(events, MAX_CONTROLLER_EVENTS, - SDL_GETEVENT, SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMAPPED); + SDL_GETEVENT, SDL_EVENT_GAMEPAD_ADDED, SDL_EVENT_GAMEPAD_REMAPPED); for (int i = 0; i < count; ++i) { const SDL_Event& event = events[i]; switch (event.type) { - case SDL_CONTROLLERDEVICEADDED: - OpenController(event.cdevice.which); + case SDL_EVENT_GAMEPAD_ADDED: + OpenController(event.gdevice.which); break; - case SDL_CONTROLLERDEVICEREMOVED: + case SDL_EVENT_GAMEPAD_REMOVED: { - const auto controller = SDL_GameControllerFromInstanceID(event.cdevice.which); - const auto it = std::find(controllers.begin(), controllers.end(), controller); + const auto instanceId = event.gdevice.which; + auto controller = SDL_GetGamepadFromID(instanceId); + auto it = std::find(controllers.begin(), controllers.end(), controller); + if (controller == nullptr) + { + it = std::find_if(controllers.begin(), controllers.end(), + [instanceId](SDL_Gamepad* pad) + { + return SDL_GetGamepadID(pad) == instanceId; + }); + } if (it != controllers.end()) + { + SDL_CloseGamepad(*it); controllers.erase(it); + } break; } - case SDL_CONTROLLERDEVICEREMAPPED: + case SDL_EVENT_GAMEPAD_REMAPPED: // We are skipping it, // but it's in the SDL_PeepEvents call // to make sure it's removed from event queue @@ -392,7 +408,7 @@ void CInput::ControllerUpdate() return; count = SDL_PeepEvents(nullptr, 0, - SDL_PEEKEVENT, SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERTOUCHPADUP); + SDL_PEEKEVENT, SDL_EVENT_GAMEPAD_AXIS_MOTION, SDL_EVENT_GAMEPAD_TOUCHPAD_UP); if (count) SetCurrentInputType(Controller); @@ -401,14 +417,14 @@ void CInput::ControllerUpdate() SDL_PumpEvents(); count = SDL_PeepEvents(events, MAX_CONTROLLER_EVENTS, - SDL_GETEVENT, SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERSENSORUPDATE); + SDL_GETEVENT, SDL_EVENT_GAMEPAD_AXIS_MOTION, SDL_EVENT_GAMEPAD_SENSOR_UPDATE); constexpr ControllerAxisState pressedAxis{ 1.0f }; constexpr ControllerAxisState releasedAxis{}; - static_assert(SDL_CONTROLLER_AXIS_MAX == 6, "Align the depending code with the changes in SDL_GameControllerAxis."); - static float axes[SDL_CONTROLLER_AXIS_MAX]{}; - bool axisMoved[SDL_CONTROLLER_AXIS_MAX]{}; + static_assert(SDL_GAMEPAD_AXIS_COUNT == 6, "Align the depending code with the changes in SDL_GamepadAxis."); + static float axes[SDL_GAMEPAD_AXIS_COUNT]{}; + bool axisMoved[SDL_GAMEPAD_AXIS_COUNT]{}; const auto controllerPrev = controllerState; for (int i = 0; i < count; ++i) @@ -417,40 +433,46 @@ void CInput::ControllerUpdate() switch (event.type) { - case SDL_CONTROLLERAXISMOTION: + case SDL_EVENT_GAMEPAD_AXIS_MOTION: { - if (controllerState.id != event.caxis.which) // don't write if don't really need to - controllerState.id = event.caxis.which; + if (controllerState.id != event.gaxis.which) // don't write if don't really need to + controllerState.id = event.gaxis.which; - axisMoved[event.caxis.axis] = true; - axes[event.caxis.axis] = event.caxis.value; + if (event.gaxis.axis >= SDL_GAMEPAD_AXIS_COUNT) + break; + axisMoved[event.gaxis.axis] = true; + axes[event.gaxis.axis] = event.gaxis.value; break; } - case SDL_CONTROLLERBUTTONDOWN: - if (controllerState.id != event.cbutton.which) // don't write if don't really need to - controllerState.id = event.cbutton.which; + case SDL_EVENT_GAMEPAD_BUTTON_DOWN: + if (controllerState.id != event.gbutton.which) // don't write if don't really need to + controllerState.id = event.gbutton.which; - controllerState.buttons[event.cbutton.button] = true; - cbStack.back()->IR_OnControllerPress(ControllerButtonToKey[event.cbutton.button], pressedAxis); + if (event.gbutton.button >= std::size(ControllerButtonToKey)) + break; + controllerState.buttons[event.gbutton.button] = true; + cbStack.back()->IR_OnControllerPress(ControllerButtonToKey[event.gbutton.button], pressedAxis); break; - case SDL_CONTROLLERBUTTONUP: - if (controllerState.id != event.cbutton.which) // don't write if don't really need to - controllerState.id = event.cbutton.which; + case SDL_EVENT_GAMEPAD_BUTTON_UP: + if (controllerState.id != event.gbutton.which) // don't write if don't really need to + controllerState.id = event.gbutton.which; - controllerState.buttons[event.cbutton.button] = false; - cbStack.back()->IR_OnControllerRelease(ControllerButtonToKey[event.cbutton.button], releasedAxis); + if (event.gbutton.button >= std::size(ControllerButtonToKey)) + break; + controllerState.buttons[event.gbutton.button] = false; + cbStack.back()->IR_OnControllerRelease(ControllerButtonToKey[event.gbutton.button], releasedAxis); break; - case SDL_CONTROLLERSENSORUPDATE: + case SDL_EVENT_GAMEPAD_SENSOR_UPDATE: { - if (controllerState.id != event.csensor.which) + if (controllerState.id != event.gsensor.which) break; // only use data from the recently used controller - if (event.csensor.sensor != SDL_SENSOR_GYRO) + if (event.gsensor.sensor != SDL_SENSOR_GYRO) break; - controllerState.gyroscope = Fvector{ -event.csensor.data[1], -event.csensor.data[0], -event.csensor.data[2] }; + controllerState.gyroscope = Fvector{ -event.gsensor.data[1], -event.gsensor.data[0], -event.gsensor.data[2] }; if (controllerState.attitude_changed()) cbStack.back()->IR_OnControllerAttitudeChange(controllerState.gyroscope); break; @@ -523,7 +545,7 @@ bool KbdKeyToButtonName(const int dik, xr_string& result) if (dik >= 0) { - cpcstr name = SDL_GetKeyName(SDL_GetKeyFromScancode((SDL_Scancode)dik)); + cpcstr name = SDL_GetKeyName(SDL_GetKeyFromScancode((SDL_Scancode)dik, SDL_KMOD_NONE, false)); if (name && name[0]) { result = StringFromUTF8(name, locale); @@ -598,14 +620,22 @@ bool CInput::iGetAsyncMousePos(Ivector2& p, bool global /*= false*/) const if (global) { #if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE - SDL_GetGlobalMouseState(&p.x, &p.y); + float x = 0.0f; + float y = 0.0f; + SDL_GetGlobalMouseState(&x, &y); + p.x = static_cast(x); + p.y = static_cast(y); return true; #endif // if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE unavailable // fallback to SDL_GetMouseState // but report false } - SDL_GetMouseState(&p.x, &p.y); + float x = 0.0f; + float y = 0.0f; + SDL_GetMouseState(&x, &y); + p.x = static_cast(x); + p.y = static_cast(y); return !global; } @@ -614,7 +644,7 @@ bool CInput::iSetMousePos(const Ivector2& p, bool global /*= false*/) const if (global) { #if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE - SDL_WarpMouseGlobal(p.x, p.y); + SDL_WarpMouseGlobal(static_cast(p.x), static_cast(p.y)); return true; #endif // if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE unavailable @@ -622,7 +652,7 @@ bool CInput::iSetMousePos(const Ivector2& p, bool global /*= false*/) const // but report false } - SDL_WarpMouseInWindow(Device.m_sdlWnd, p.x, p.y); + SDL_WarpMouseInWindow(Device.m_sdlWnd, static_cast(p.x), static_cast(p.y)); return !global; } @@ -632,12 +662,12 @@ void CInput::GrabInput(const bool grab) ShowCursor(!grab); // Clip cursor to the current window - // If SDL_HINT_GRAB_KEYBOARD is set then the keyboard will be grabbed too - SDL_SetWindowGrab(Device.m_sdlWnd, grab ? SDL_TRUE : SDL_FALSE); + SDL_SetWindowMouseGrab(Device.m_sdlWnd, grab); + SDL_SetWindowKeyboardGrab(Device.m_sdlWnd, grab); // Grab the mouse if (exclusiveInput) - SDL_SetRelativeMouseMode(grab ? SDL_TRUE : SDL_FALSE); + SDL_SetWindowRelativeMouseMode(Device.m_sdlWnd, grab); // We're done here. inputGrabbed = grab; @@ -650,7 +680,10 @@ bool CInput::InputIsGrabbed() const void CInput::ShowCursor(const bool show) { - SDL_ShowCursor(show ? SDL_TRUE : SDL_FALSE); + if (show) + SDL_ShowCursor(); + else + SDL_HideCursor(); } void CInput::SetCursor(const SDL_SystemCursor cursor) @@ -668,10 +701,10 @@ void CInput::EnableTextInput() ++textInputCounter; if (textInputCounter == 1) - SDL_StartTextInput(); + SDL_StartTextInput(Device.m_sdlWnd); SDL_PumpEvents(); - SDL_FlushEvents(SDL_TEXTEDITING, SDL_TEXTINPUT); + SDL_FlushEvents(SDL_EVENT_TEXT_EDITING, SDL_EVENT_TEXT_INPUT); } void CInput::DisableTextInput() @@ -681,10 +714,10 @@ void CInput::DisableTextInput() textInputCounter = 0; if (textInputCounter == 0) - SDL_StopTextInput(); + SDL_StopTextInput(Device.m_sdlWnd); SDL_PumpEvents(); - SDL_FlushEvents(SDL_TEXTEDITING, SDL_TEXTINPUT); + SDL_FlushEvents(SDL_EVENT_TEXT_EDITING, SDL_EVENT_TEXT_INPUT); } bool CInput::IsTextInputEnabled() const @@ -813,8 +846,9 @@ void CInput::Feedback(FeedbackType type, float s1, float s2, float duration) { if (controllerState.id != -1) { - const auto controller = SDL_GameControllerFromInstanceID(controllerState.id); - SDL_GameControllerRumble(controller, s1_rumble, s2_rumble, duration_ms); + const auto controller = SDL_GetGamepadFromID(controllerState.id); + if (controller) + SDL_RumbleGamepad(controller, s1_rumble, s2_rumble, duration_ms); } break; } @@ -823,8 +857,9 @@ void CInput::Feedback(FeedbackType type, float s1, float s2, float duration) { if (controllerState.id != -1) { - const auto controller = SDL_GameControllerFromInstanceID(controllerState.id); - SDL_GameControllerRumbleTriggers(controller, s1_rumble, s2_rumble, duration_ms); + const auto controller = SDL_GetGamepadFromID(controllerState.id); + if (controller) + SDL_RumbleGamepadTriggers(controller, s1_rumble, s2_rumble, duration_ms); } break; } diff --git a/src/xrEngine/xr_input.h b/src/xrEngine/xr_input.h index 1f63228fd8d..32b053ddb87 100644 --- a/src/xrEngine/xr_input.h +++ b/src/xrEngine/xr_input.h @@ -2,7 +2,7 @@ #include -#include +#include #include "xrCore/_vector2.h" @@ -16,7 +16,7 @@ DECLARE_MESSAGE(KeyMapChanged); enum EMouseButton { - MOUSE_INVALID = SDL_NUM_SCANCODES, + MOUSE_INVALID = SDL_SCANCODE_COUNT, MOUSE_1, // Left MOUSE_2, // Right MOUSE_3, // Middle @@ -66,8 +66,8 @@ enum EControllerAxis XR_CONTROLLER_AXIS_COUNT = XR_CONTROLLER_AXIS_MAX - XR_CONTROLLER_AXIS_INVALID - 1 }; -static_assert(SDL_CONTROLLER_AXIS_MAX == 6, - "EControllerAxis needs to be updated to match changes in SDL_GameControllerAxis."); +static_assert(SDL_GAMEPAD_AXIS_COUNT == 6, + "EControllerAxis needs to be updated to match changes in SDL_GamepadAxis."); struct ControllerAxisState { @@ -166,7 +166,7 @@ class ENGINE_API CInput { COUNT_MOUSE_BUTTONS = MOUSE_COUNT, COUNT_MOUSE_AXIS = 4, - COUNT_KB_BUTTONS = SDL_NUM_SCANCODES, + COUNT_KB_BUTTONS = SDL_SCANCODE_COUNT, }; struct InputStatistics @@ -187,7 +187,7 @@ class ENGINE_API CInput xr_vector cbStack; - xr_vector controllers; + xr_vector controllers; void SetCurrentInputType(InputType type); @@ -195,7 +195,7 @@ class ENGINE_API CInput void KeyUpdate(); void ControllerUpdate(); - void OpenController(int idx); + void OpenController(SDL_JoystickID instance_id); MessageRegistry seqKeyMapChanged; @@ -206,7 +206,7 @@ class ENGINE_API CInput bool exclusiveInput; bool inputGrabbed; - SDL_Cursor* mouseCursors[SDL_NUM_SYSTEM_CURSORS]{}; + SDL_Cursor* mouseCursors[SDL_SYSTEM_CURSOR_COUNT]{}; SDL_Cursor* lastCursor{}; public: diff --git a/src/xrEngine/xr_level_controller.cpp b/src/xrEngine/xr_level_controller.cpp index f3f2444661d..8f5f66e9d53 100644 --- a/src/xrEngine/xr_level_controller.cpp +++ b/src/xrEngine/xr_level_controller.cpp @@ -463,17 +463,18 @@ keyboard_key keyboards[] = { "kMODE", SDL_SCANCODE_MODE, "Mode" }, - { "kAUDIONEXT", SDL_SCANCODE_AUDIONEXT, "Audio Next" }, - { "kAUDIOPREV", SDL_SCANCODE_AUDIOPREV, "Audio Prev" }, - { "kAUDIOSTOP", SDL_SCANCODE_AUDIOSTOP, "Audio Stop" }, - { "kAUDIOPLAY", SDL_SCANCODE_AUDIOPLAY, "Audio Play" }, - { "kAUDIOMUTE", SDL_SCANCODE_AUDIOMUTE, "Audio Mute" }, - - { "kMEDIASELECT", SDL_SCANCODE_MEDIASELECT, "Media Select" }, - { "kWWW", SDL_SCANCODE_WWW, "WWW" }, - { "kMAIL", SDL_SCANCODE_MAIL, "Mail" }, - { "kCALCULATOR", SDL_SCANCODE_CALCULATOR, "Calculator" }, - { "kCOMPUTER", SDL_SCANCODE_COMPUTER, "My Computer" }, + { "kAUDIONEXT", SDL_SCANCODE_MEDIA_NEXT_TRACK, "Audio Next" }, + { "kAUDIOPREV", SDL_SCANCODE_MEDIA_PREVIOUS_TRACK, "Audio Prev" }, + { "kAUDIOSTOP", SDL_SCANCODE_MEDIA_STOP, "Audio Stop" }, + { "kAUDIOPLAY", SDL_SCANCODE_MEDIA_PLAY, "Audio Play" }, + { "kAUDIOMUTE", SDL_SCANCODE_MUTE, "Audio Mute" }, + + { "kMEDIASELECT", SDL_SCANCODE_MEDIA_SELECT, "Media Select" }, + // Removed in SDL3: + //{ "kWWW", SDL_SCANCODE_WWW, "WWW" }, + //{ "kMAIL", SDL_SCANCODE_MAIL, "Mail" }, + //{ "kCALCULATOR", SDL_SCANCODE_CALCULATOR, "Calculator" }, + //{ "kCOMPUTER", SDL_SCANCODE_COMPUTER, "My Computer" }, { "kNUMPAD_AC_SEARCH", SDL_SCANCODE_AC_SEARCH, "AC Search" }, { "kNUMPAD_AC_HOME", SDL_SCANCODE_AC_HOME, "AC Home" }, @@ -483,19 +484,20 @@ keyboard_key keyboards[] = { "kNUMPAD_AC_REFRESH", SDL_SCANCODE_AC_REFRESH, "AC Refresh" }, { "kNUMPAD_AC_BOOKMARKS", SDL_SCANCODE_AC_BOOKMARKS, "AC Bookmarks" }, - { "kBRIGHTNESSDOWN", SDL_SCANCODE_BRIGHTNESSDOWN, "Brightness Down" }, - { "kBRIGHTNESSUP", SDL_SCANCODE_BRIGHTNESSUP, "Brightness Up" }, - { "kDISPLAYSWITCH", SDL_SCANCODE_DISPLAYSWITCH, "Display Switch" }, + // Removed in SDL3: + //{ "kBRIGHTNESSDOWN", SDL_SCANCODE_BRIGHTNESSDOWN, "Brightness Down" }, + //{ "kBRIGHTNESSUP", SDL_SCANCODE_BRIGHTNESSUP, "Brightness Up" }, + //{ "kDISPLAYSWITCH", SDL_SCANCODE_DISPLAYSWITCH, "Display Switch" }, - { "kKBDILLUMTOGGLE", SDL_SCANCODE_KBDILLUMTOGGLE, "Illum Toogle" }, - { "kKBDILLUMDOWN", SDL_SCANCODE_KBDILLUMDOWN, "Illum Down" }, - { "kKBDILLUMUP", SDL_SCANCODE_KBDILLUMUP, "Illum Up" }, + //{ "kKBDILLUMTOGGLE", SDL_SCANCODE_KBDILLUMTOGGLE, "Illum Toogle" }, + //{ "kKBDILLUMDOWN", SDL_SCANCODE_KBDILLUMDOWN, "Illum Down" }, + //{ "kKBDILLUMUP", SDL_SCANCODE_KBDILLUMUP, "Illum Up" }, - { "kEJECT", SDL_SCANCODE_EJECT, "Eject" }, + { "kEJECT", SDL_SCANCODE_MEDIA_EJECT, "Eject" }, { "kSLEEP", SDL_SCANCODE_SLEEP, "Sleep" }, - { "kAPP1", SDL_SCANCODE_APP1, "App 1" }, - { "kAPP2", SDL_SCANCODE_APP2, "App 2" }, + { "kAPP1", SDL_SCANCODE_APPLICATION, "App 1" }, + { "kAPP2", SDL_SCANCODE_APPLICATION, "App 2" }, { "mouse1", MOUSE_1, "Left mouse button" }, { "mouse2", MOUSE_2, "Right mouse button" }, diff --git a/src/xrGame/MainMenu.cpp b/src/xrGame/MainMenu.cpp index 220287563a8..c24f61ed65b 100644 --- a/src/xrGame/MainMenu.cpp +++ b/src/xrGame/MainMenu.cpp @@ -8,7 +8,7 @@ #include "xrEngine/xr_level_controller.h" #include "xrUICore/XML/UITextureMaster.h" #include "ui/UIXmlInit.h" -#include +#include #include "xrUICore/Buttons/UIBtnHint.h" #include "xrUICore/Cursor/UICursor.h" #include "xrGameSpy/GameSpy_Full.h" diff --git a/src/xrGame/UIDialogHolder.h b/src/xrGame/UIDialogHolder.h index 31b2a321865..dab032af5db 100644 --- a/src/xrGame/UIDialogHolder.h +++ b/src/xrGame/UIDialogHolder.h @@ -5,7 +5,7 @@ #include "xrEngine/pure.h" #include "xrUICore/ui_debug.h" -#include +#include class CUIDialogWnd; class CUIWindow; diff --git a/src/xrUICore/Buttons/UIButton.h b/src/xrUICore/Buttons/UIButton.h index 171b055c184..5ade9954182 100644 --- a/src/xrUICore/Buttons/UIButton.h +++ b/src/xrUICore/Buttons/UIButton.h @@ -40,7 +40,7 @@ class XRUICORE_API CUIButton : public CUIStatic // Поведение кнопки как переключателя реализовано пока только в режиме NORMAL_PRESS void SetButtonAsSwitch(bool bAsSwitch) { m_bIsSwitch = bAsSwitch; } // Работа с акселератором - // Код акселератора берётся из файла SDL_scancode.h, из SDL2. + // Код акселератора берётся из файла SDL_scancode.h, из SDL. // Например: кнопка A - код 4 (SDL_SCANCODE_A) void SetAccelerator(int iAccel, bool isKey, size_t idx); int GetAccelerator(size_t idx) const; diff --git a/src/xrUICore/Cursor/UICursor.cpp b/src/xrUICore/Cursor/UICursor.cpp index 6c5cf5c863d..7d4c0ba5c6a 100644 --- a/src/xrUICore/Cursor/UICursor.cpp +++ b/src/xrUICore/Cursor/UICursor.cpp @@ -29,7 +29,8 @@ void CUICursor::OnDeviceReset() correction.y = UI_BASE_HEIGHT / (float)Device.m_rcWindowClient.h; SDL_Rect display; - if (0 == SDL_GetDisplayBounds(0, &display)) + const SDL_DisplayID displayId = SDL_GetPrimaryDisplay(); + if (displayId != 0 && SDL_GetDisplayBounds(displayId, &display)) { const u32 screen_size_x = display.w - display.x; const u32 screen_size_y = display.h - display.y; From 4754ca91f70fc5a1007cf07ef548215d7402c5c7 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 29 Jan 2026 04:18:35 -0500 Subject: [PATCH 2/3] ci: Update cibuild.yml to use SDL3 --- .github/workflows/cibuild.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml index de48121a37b..cb02c7a5966 100644 --- a/.github/workflows/cibuild.yml +++ b/.github/workflows/cibuild.yml @@ -110,7 +110,7 @@ jobs: with: arch: ${{ matrix.platform.arch }} branch: 'latest-stable' - packages: build-base cmake git mold sdl2-dev lzo-dev libjpeg-turbo-dev openal-soft-dev libogg-dev libtheora-dev libvorbis-dev + packages: build-base cmake git mold sdl3-dev lzo-dev libjpeg-turbo-dev openal-soft-dev libogg-dev libtheora-dev libvorbis-dev - name: Install Ubuntu packages if: ${{ matrix.platform.name == 'Ubuntu' }} @@ -118,7 +118,7 @@ jobs: sudo dpkg --add-architecture ${{ matrix.platform.arch }} sudo apt-get update -qq sudo apt-get install -qq -y \ - libsdl2-dev:${{ matrix.platform.arch }} \ + libsdl3-dev:${{ matrix.platform.arch }} \ liblzo2-dev:${{ matrix.platform.arch }} \ libjpeg-dev:${{ matrix.platform.arch }} \ libopenal-dev:${{ matrix.platform.arch }} \ @@ -134,11 +134,11 @@ jobs: if: ${{ startsWith(matrix.platform.name, 'macOS') }} run: | brew update - brew install sdl2 lzo libogg libvorbis theora + brew install sdl3 lzo libogg libvorbis theora - name: Install Fedora packages if: ${{ matrix.platform.name == 'Fedora' }} - run: dnf install -y git gcc gcc-c++ rpmdevtools cmake SDL2-devel lzo-devel libjpeg-turbo-devel openal-soft-devel libogg-devel libtheora-devel libvorbis-devel + run: dnf install -y git gcc gcc-c++ rpmdevtools cmake SDL3-devel lzo-devel libjpeg-turbo-devel openal-soft-devel libogg-devel libtheora-devel libvorbis-devel - name: Set environment variables if: ${{ matrix.platform.cc != '' && matrix.platform.cxx != '' }} @@ -185,13 +185,13 @@ jobs: matrix: platform: - { name: FreeBSD, os: freebsd, os-version: '14.3', arch: x86_64, - install-cmd: "sudo pkg update && sudo pkg install -y cmake sdl2 lzo2 jpeg-turbo openal-soft libogg libtheora libvorbis" + install-cmd: "sudo pkg update && sudo pkg install -y cmake sdl3 lzo2 jpeg-turbo openal-soft libogg libtheora libvorbis" } - { name: OpenBSD, os: openbsd, os-version: '7.6', arch: x86_64, - install-cmd: "sudo pkg_add cmake SDL2 lzo2 jpeg openal libogg libtheora libvorbis", + install-cmd: "sudo pkg_add cmake SDL3 lzo2 jpeg openal libogg libtheora libvorbis", } - { name: NetBSD, os: netbsd, os-version: '10.1', arch: x86_64, - install-cmd: "sudo pkgin -y install cmake SDL2 lzo libjpeg-turbo openal-soft libogg libtheora libvorbis", + install-cmd: "sudo pkgin -y install cmake SDL3 lzo libjpeg-turbo openal-soft libogg libtheora libvorbis", } #- { name: Haiku, os: haiku, os-version: 'r1beta5', arch: x86_64, # install-cmd: "sudo pkgman install -y cmake libsdl2_devel lzo_devel libjpeg_turbo_devel openal_devel libogg_devel libtheora_devel libvorbis_devel", From c93bd520d74af4a47bf4e92231e3cff2f0de32e1 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 29 Jan 2026 19:34:19 -0500 Subject: [PATCH 3/3] sdl3 ciupdate --- .github/workflows/cibuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml index cb02c7a5966..2a2d374eef1 100644 --- a/.github/workflows/cibuild.yml +++ b/.github/workflows/cibuild.yml @@ -194,7 +194,7 @@ jobs: install-cmd: "sudo pkgin -y install cmake SDL3 lzo libjpeg-turbo openal-soft libogg libtheora libvorbis", } #- { name: Haiku, os: haiku, os-version: 'r1beta5', arch: x86_64, - # install-cmd: "sudo pkgman install -y cmake libsdl2_devel lzo_devel libjpeg_turbo_devel openal_devel libogg_devel libtheora_devel libvorbis_devel", + # install-cmd: "sudo pkgman install -y cmake libsdl3_devel lzo_devel libjpeg_turbo_devel openal_devel libogg_devel libtheora_devel libvorbis_devel", # } configuration: [Debug, Release]