Fix VR cursor issues and warn about crash hazard (#7868)

* Add warning for OpenXR toolkit

* Properly handle mouse position

* GCC 9 issue
This commit is contained in:
BMagnu authored and GitHub committed 2026-10-15 00:48:46 +00:00
1 parent f6f1aac574
commit 88669e4518
2 files changed
+23 -1

No files matched your search

+20
View File
@@ -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<XrApiLayerProperties> 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();
+3 -1
View File
@@ -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)