From 766c3e2056911b01f54b6d59c5838139e4f80fd8 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Tue, 4 Apr 2023 21:04:18 +0200 Subject: [PATCH] early exit if steamvr is not already running --- src/main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c4b2c96..ea9a747 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -60,9 +60,21 @@ void init_glfw() void init_vr() { vr::EVRInitError init_err; + ovr_sys = vr::VR_Init(&init_err, vr::EVRApplicationType::VRApplication_Background); + if (init_err == vr::EVRInitError::VRInitError_Init_NoServerForBackgroundApp) + { + printf("SteamVR is not running\n"); + exit(1); + } + else if (init_err != 0) + { + printf("Could not initialize OpenVR session. Error code: %d\n", init_err); + exit(1); + } + vr::VR_ShutdownInternal(); ovr_sys = vr::VR_Init(&init_err, vr::EVRApplicationType::VRApplication_Overlay); assert(init_err == 0); - printf("Initialized openvr\n"); + printf("Initialized OpenVR\n"); ovr_overlay = vr::VROverlay(); } @@ -201,9 +213,9 @@ int main() { signal(SIGINT, interrupted); + init_vr(); init_x11(); init_glfw(); - init_vr(); init_overlay(); while (!should_exit)