From d4f567d5778d1034999d2a540803061e1bcbb6f1 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Wed, 22 Nov 2023 18:35:52 +0100 Subject: [PATCH] handle steamvr quitting cleanly --- Makefile | 2 +- README.md | 2 ++ src/main.cpp | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 111aa1b..cef6308 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := 1.0.0 +VERSION := 1.0.1 CXX := g++ TARGET := ./vr_status LFLAGS := -Wl,-rpath,'$$ORIGIN' -L. -lopenvr_api 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);