#pragma once #include #include #include #include #include namespace sauna { /** * @brief Wrapper for the lighthouse driver * * This class loads and communicates with the existing lighthouse driver, * forwarding calls to it while adding our custom functionality. */ class LighthouseDriverWrapper { public: LighthouseDriverWrapper(); ~LighthouseDriverWrapper(); /** * @brief Initialize the lighthouse driver wrapper * * @return true if initialization was successful * @return false if initialization failed */ bool Initialize(); /** * @brief Shutdown the lighthouse driver wrapper */ void Shutdown(); /** * @brief Forward RunFrame call to the lighthouse driver */ void RunFrame(); /** * @brief Forward EnterStandby call to the lighthouse driver */ void EnterStandby(); /** * @brief Forward LeaveStandby call to the lighthouse driver */ void LeaveStandby(); /** * @brief Get the lighthouse driver provider * * @return vr::IServerTrackedDeviceProvider* Pointer to the lighthouse driver provider */ vr::IServerTrackedDeviceProvider* GetDriverProvider() { // Create a debug log file FILE* logFile = fopen("lighthouse_provider_debug.log", "a"); if (logFile) { fprintf(logFile, "GetDriverProvider called at %lld\n", (long long)time(nullptr)); if (m_pLighthouseProvider) { fprintf(logFile, "Returning valid provider\n"); } else { fprintf(logFile, "Provider is null\n"); } fclose(logFile); } return m_pLighthouseProvider; } /** * @brief Get the path to the lighthouse driver that was last attempted to be loaded * * @return std::string The path to the lighthouse driver */ std::string GetDriverPath() const { return m_strDriverPath; } private: /** * @brief Load the lighthouse driver library * * @return true if loading was successful * @return false if loading failed */ bool LoadLighthouseDriver(); /** * @brief Unload the lighthouse driver library */ void UnloadLighthouseDriver(); void* m_pLighthouseDriverLib; vr::IServerTrackedDeviceProvider* m_pLighthouseProvider; std::string m_strDriverPath; // Function pointer types for the driver factory functions typedef void* (*CreateInterfaceFn)(const char* pInterfaceName, vr::EVRInitError* peError); typedef uint32_t (*GetDriverCountFn)(); typedef const char* (*GetDriverNameFn)(vr::DriverId_t nDriver); // Function pointers to the driver factory functions CreateInterfaceFn m_fnCreateInterface; GetDriverCountFn m_fnGetDriverCount; GetDriverNameFn m_fnGetDriverName; }; } // namespace sauna