handle steamvr quitting cleanly

This commit is contained in:
Crispy 2023-11-22 18:35:52 +01:00
parent f9735a9946
commit 4c36ec7bc8
2 changed files with 9 additions and 1 deletions

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);