From 2acdfcc95c317f30e725e17f0d372fce050830ef Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 6 Oct 2016 02:43:47 +0300 Subject: [PATCH] Receive events from OpenVR --- source/openvr/openvrsystem.cpp | 16 ++++++++++++++++ source/openvr/openvrsystem.h | 2 ++ source/system.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/source/openvr/openvrsystem.cpp b/source/openvr/openvrsystem.cpp index 8c3188c..d631f48 100644 --- a/source/openvr/openvrsystem.cpp +++ b/source/openvr/openvrsystem.cpp @@ -101,6 +101,22 @@ OpenVRCombiner *OpenVRSystem::create_combiner(GL::View &v) return new OpenVRCombiner(*this, v); } +void OpenVRSystem::tick() +{ + vr::IVRSystem *vr_sys = vr::VRSystem(); + + vr::VREvent_t event; + while(vr_sys->PollNextEvent(&event, sizeof(event))) + { + if(event.eventType==vr::VREvent_TrackedDeviceActivated) + if(event.trackedDeviceIndex>=n_tracked_devices) + { + n_tracked_devices = event.trackedDeviceIndex+1; + tracking_matrices.resize(n_tracked_devices); + } + } +} + void OpenVRSystem::update_pose_matrices() { vector poses; diff --git a/source/openvr/openvrsystem.h b/source/openvr/openvrsystem.h index ca5411e..119eb16 100644 --- a/source/openvr/openvrsystem.h +++ b/source/openvr/openvrsystem.h @@ -31,6 +31,8 @@ public: virtual OpenVRCamera *create_camera(const GL::Camera &); virtual OpenVRCombiner *create_combiner(GL::View &); + virtual void tick(); + void update_pose_matrices(); const GL::Matrix &get_tracking_matrix(unsigned) const; const GL::Matrix &get_hmd_matrix() const; diff --git a/source/system.h b/source/system.h index 69b93a1..b7187b9 100644 --- a/source/system.h +++ b/source/system.h @@ -29,6 +29,8 @@ public: virtual bool get_absolute_tracking() const { return false; } virtual HeadTrackingCamera *create_camera(const GL::Camera &) = 0; virtual StereoCombiner *create_combiner(GL::View &) = 0; + + virtual void tick() { } }; } // namespace VR -- 2.45.2