From: Mikko Rasa Date: Wed, 5 Oct 2016 23:43:47 +0000 (+0300) Subject: Receive events from OpenVR X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=2acdfcc95c317f30e725e17f0d372fce050830ef;p=libs%2Fvr.git Receive events from OpenVR --- 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