From 4c36ec7bc8ebb9316d40c3d3d7d745a4bba46c54 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Wed, 22 Nov 2023 18:35:52 +0100 Subject: [PATCH] handle steamvr quitting cleanly --- README.md | 2 ++ src/main.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f787c1e..e422a88 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # SteamVR-status A very simple program that prints the battery levels of connected VR devices to `/tmp/steamvr_battery_status` if SteamVR is running. + +You can set it to auto-launch with SteamVR by adding it to the launch options in Steam: `%command% & sleep 4 && ~/bin/steamvr-status/vr_status`. diff --git a/src/main.cpp b/src/main.cpp index 01b4e02..5a2b3a3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,4 @@ #include "../lib/openvr.h" -#include #include #include #include @@ -35,6 +34,13 @@ int main() { while (!should_exit) { update(); sleep(1); + + vr::VREvent_t event; + while (vr_sys->PollNextEvent(&event, sizeof(vr::VREvent_t))) { + if (event.eventType == vr::VREvent_Quit) { + should_exit = true; + } + } } std::remove(OUT_PATH);