From 9c210aa22344b88cb8ad4516f60a5276cf6261e1 Mon Sep 17 00:00:00 2001 From: Sepalani Date: Fri, 11 Jul 2025 17:10:47 +0400 Subject: [PATCH] SDL: Fix a XWayland crash when capturing keyboard input --- .../Core/InputCommon/ControllerInterface/SDL/SDL.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp index 8633853b3a..f7e32fb4ef 100644 --- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp +++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp @@ -369,6 +369,17 @@ bool InputBackend::HandleEventAndContinue(const SDL_Event& e) } else if (e.type == Common::KeyboardContext::s_sdl_init_event_type) { + const auto wsi = GetControllerInterface().GetWindowSystemInfo(); + if (wsi.type == WindowSystemType::X11) + { + // Avoid a crash with Xwayland when the wrong driver is picked + if (!SDL_SetHint(SDL_HINT_VIDEO_DRIVER, "x11")) + { + WARN_LOG_FMT(IOS_USB, "SDL failed to pick driver to capture keyboard input: {}", + SDL_GetError()); + } + } + if (!SDL_InitSubSystem(SDL_INIT_VIDEO)) { ERROR_LOG_FMT(IOS_USB, "SDL failed to init subsystem to capture keyboard input: {}",