#pragma once #include #include "imu_data_provider.h" namespace sauna { /** * @brief Custom interface for IMU component * * This interface allows applications to access raw IMU data * even when optical tracking is lost. */ class IVRIMUComponent { public: /** * @brief Get the latest IMU sample * * @param pSample Pointer to store the IMU sample * @return true if IMU data was available * @return false if no IMU data was available */ virtual bool GetLatestIMUSample(vr::ImuSample_t *pSample) = 0; /** * @brief Check if IMU data is available * * @return true if IMU data is available * @return false if no IMU data is available */ virtual bool IsIMUDataAvailable() = 0; /** * @brief Get IMU data even when optical tracking is lost * * @param pSample Pointer to store the IMU sample * @return true if IMU data was available * @return false if no IMU data was available */ virtual bool GetIMUDataInFallbackMode(vr::ImuSample_t *pSample) = 0; }; // Version string for the IMU component interface static const char *IVRIMUComponent_Version = "IVRIMUComponent_001"; /** * @brief Custom device driver that wraps the existing device driver * * This class wraps the existing device driver and adds our custom * functionality to access raw IMU data when optical tracking is lost. */ class SaunaDeviceDriver : public vr::ITrackedDeviceServerDriver, public IVRIMUComponent { public: SaunaDeviceDriver(vr::ITrackedDeviceServerDriver *pWrappedDriver, IMUDataProvider *pIMUDataProvider); virtual ~SaunaDeviceDriver(); // ITrackedDeviceServerDriver interface virtual vr::EVRInitError Activate(uint32_t unObjectId) override; virtual void Deactivate() override; virtual void EnterStandby() override; virtual void *GetComponent(const char *pchComponentNameAndVersion) override; virtual void DebugRequest(const char *pchRequest, char *pchResponseBuffer, uint32_t unResponseBufferSize) override; virtual vr::DriverPose_t GetPose() override; // IVRIMUComponent interface virtual bool GetLatestIMUSample(vr::ImuSample_t *pSample) override; virtual bool IsIMUDataAvailable() override; virtual bool GetIMUDataInFallbackMode(vr::ImuSample_t *pSample) override; private: vr::ITrackedDeviceServerDriver *m_pWrappedDriver; IMUDataProvider *m_pIMUDataProvider; uint32_t m_unDeviceId; bool m_bActivated; }; } // namespace sauna