Add a getter and signal to indicate if a controller is tracked
authorMikko Rasa <tdb@tdb.fi>
Thu, 6 Oct 2016 17:08:51 +0000 (20:08 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 6 Oct 2016 17:09:13 +0000 (20:09 +0300)
Build
source/motioncontroller.h
source/openvr/openvrcontroller.cpp
source/openvr/openvrcontroller.h

diff --git a/Build b/Build
index fa837ec0cf19603f5426076b998b388631281009..43581debe5acdfa40aa720c30ed35667b8edb6d6 100644 (file)
--- a/Build
+++ b/Build
@@ -3,6 +3,7 @@ package "mspvr"
        description "OpenGL-based virtual reality library";
        version "0.1";
 
+       require "sigc++-2.0";
        require "mspcore";
        require "mspgl";
        require "mspgui";
index 9cdd6221318bbf84b6c9c75f1e61f25c593d1a14..959e056cd8c6c1b537951bb8161d7f0d6c1dfd83 100644 (file)
@@ -11,6 +11,9 @@ class StereoView;
 
 class MotionController: public Input::Device
 {
+public:
+       sigc::signal<void, bool> signal_tracking_state_changed;
+
 protected:
        StereoView *view;
        Msp::GL::Matrix matrix;
@@ -21,6 +24,7 @@ public:
 
        void attach_to_view(StereoView &);
        void detach_from_view();
+       virtual bool is_tracked() const = 0;
        const GL::Matrix &get_matrix() const { return matrix; }
        virtual void update() = 0;
 protected:
index 9ab957de11c5d5fe41031902548fed66c503253c..405cd2f837a429b2aaf9408bca55b3e8b20d0524 100644 (file)
@@ -58,9 +58,11 @@ void OpenVRController::event(const Event &ev)
        {
        case vr::VREvent_TrackedDeviceActivated:
                index = ev.trackedDeviceIndex;
+               signal_tracking_state_changed.emit(true);
                break;
        case vr::VREvent_TrackedDeviceDeactivated:
                index = -1;
+               signal_tracking_state_changed.emit(false);
                break;
        case vr::VREvent_ButtonPress:
                set_button_state(ev.data.controller.button, true, true);
index 18c5774817e729977e63ad3b0066808ec569c8e0..00ae1c09d5c83ba1018665d2479ddf04abb818ec 100644 (file)
@@ -26,6 +26,7 @@ public:
        virtual std::string get_axis_name(unsigned) const;
 
        int get_index() const { return index; }
+       virtual bool is_tracked() const { return index>=0; }
 
        void event(const Event &);
        virtual void update();