From c6cb5451ee0d5ab6bfa38783f0eacac488c08575 Mon Sep 17 00:00:00 2001 From: bjorn Date: Mon, 31 Jul 2023 17:21:05 -0700 Subject: [PATCH] Set XR_LOADER_DEBUG environment variable to none; LOVR doesn't require OpenXR to run. When the headset module is enabled and the openxr headset driver is enabled, LOVR tries to initialize OpenXR, and if it fails then it will try the next driver. The OpenXR loader will print error messages to stderr by default. This is undesirable because someone who is unfamiliar with OpenXR will see a bunch of messages in their console that say "ERROR" and think something is wrong, even though the messages are innocuous and don't indicate an actual problem. The only way to silence these messages from the OpenXR loader, to my knowledge, is to set the XR_LOADER_DEBUG environment variable to 'none'. This is only done when the environment variable isn't set, so it's still possible to set XR_LOADER_DEBUG to see the logs. --- src/modules/headset/headset_openxr.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/headset/headset_openxr.c b/src/modules/headset/headset_openxr.c index 662a159d..00d42b71 100644 --- a/src/modules/headset/headset_openxr.c +++ b/src/modules/headset/headset_openxr.c @@ -438,7 +438,8 @@ static void openxr_destroy(); static bool openxr_init(HeadsetConfig* config) { state.config = *config; -#ifdef __ANDROID__ + // Loader +#if defined(__ANDROID__) static PFN_xrInitializeLoaderKHR xrInitializeLoaderKHR; XR_LOAD(xrInitializeLoaderKHR); if (!xrInitializeLoaderKHR) { @@ -454,6 +455,12 @@ static bool openxr_init(HeadsetConfig* config) { if (XR_FAILED(xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*) &loaderInfo))) { return false; } +#elif defined(__linux__) || defined(__APPLE__) + setenv("XR_LOADER_DEBUG", "none", 0); +#elif defined(_WIN32) + if (GetEnvironmentVariable("XR_LOADER_DEBUG", NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) { + SetEnvironmentVariable("XR_LOADER_DEBUG", "none"); + } #endif { // Instance