]> git.tdb.fi Git - libs/vr.git/commitdiff
Receive events from OpenVR
authorMikko Rasa <tdb@tdb.fi>
Wed, 5 Oct 2016 23:43:47 +0000 (02:43 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 5 Oct 2016 23:43:47 +0000 (02:43 +0300)
source/openvr/openvrsystem.cpp
source/openvr/openvrsystem.h
source/system.h

index 8c3188c370006edf0e5f38c3da713afe37d0a938..d631f48f8dece03c7a27c074924eafc0ded64b86 100644 (file)
@@ -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<vr::TrackedDevicePose_t> poses;
index ca5411e287181e08b1cfd7875e67d5f3e1b98671..119eb16e7e7948d211cea8b7804360c7d40b4a89 100644 (file)
@@ -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;
index 69b93a15d3220a02abcaf38d52440ffcea7eaaab..b7187b9e00a95670ddfe974690afc0fc70b090cb 100644 (file)
@@ -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