handle steamvr quitting cleanly

This commit is contained in:
Crispy 2023-11-22 18:35:52 +01:00
parent f9735a9946
commit d4f567d577
3 changed files with 10 additions and 2 deletions

View file

@ -1,4 +1,4 @@
VERSION := 1.0.0
VERSION := 1.0.1
CXX := g++
TARGET := ./vr_status
LFLAGS := -Wl,-rpath,'$$ORIGIN' -L. -lopenvr_api

View file

@ -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`.

View file

@ -1,5 +1,4 @@
#include "../lib/openvr.h"
#include <cstdio>
#include <fstream>
#include <signal.h>
#include <string>
@ -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);