From 88669e451815f7ee9c7aeac638db8eb897ffffa5 Mon Sep 17 00:00:00 2001 From: BMagnu <6238428+BMagnu@users.noreply.github.com> Date: Thu, 15 Oct 2026 09:48:46 +0900 Subject: [PATCH] Fix VR cursor issues and warn about crash hazard (#7868) * Add warning for OpenXR toolkit * Properly handle mouse position * GCC 9 issue --- code/graphics/openxr.cpp | 20 ++++++++++++++++++++ code/scpui/rocket_ui.cpp | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/code/graphics/openxr.cpp b/code/graphics/openxr.cpp index bca9cc5c53..b45cf71a4a 100644 --- a/code/graphics/openxr.cpp +++ b/code/graphics/openxr.cpp @@ -75,7 +75,27 @@ void openxr_prepare(float hudscale) { openxr_req = true; } +static void openxr_check_api_layers() { + uint32_t layerCount = 0; + if (xrEnumerateApiLayerProperties(0, &layerCount, nullptr) != XR_SUCCESS || layerCount == 0) + return; + + SCP_vector layers(layerCount, XrApiLayerProperties { XR_TYPE_API_LAYER_PROPERTIES, nullptr, "", 0, 0, "" }); + if (xrEnumerateApiLayerProperties(layerCount, &layerCount, layers.data()) != XR_SUCCESS) + return; + + for (const auto& layer : layers) { + mprintf(("OpenXR API layer: %s (version %u)\n", layer.layerName, layer.layerVersion)); + + if (!strcmp(layer.layerName, "XR_APILAYER_NOVENDOR_toolkit")) { + ReleaseWarning(LOCATION, "OpenXR Toolkit is installed and active. There are known compatibility issues with FSO that will likely crash the game.\nPlease disable or uninstall OpenXR Toolkit to use VR with FSO."); + } + } +} + static bool openxr_init_instance() { + openxr_check_api_layers(); + auto extensions = gr_openxr_get_extensions(); const gameversion::version& fso_version = gameversion::get_executable_version(); diff --git a/code/scpui/rocket_ui.cpp b/code/scpui/rocket_ui.cpp index 53a783952d..3e9fdc12e3 100644 --- a/code/scpui/rocket_ui.cpp +++ b/code/scpui/rocket_ui.cpp @@ -173,7 +173,9 @@ bool mouse_motion_handler(const SDL_Event& evt) input_context->ProcessMouseMove((int)evt_pos.x, (int)evt_pos.y, get_modifier_state()); - return true; + // Don't consume motion: the engine's own handler still has to track the cursor position, which + // mouse_get_pos() and thereby e.g. the cursor drawn into the VR headset image depend on. + return false; } bool mouse_button_handler(const SDL_Event& evt)