vr::EVRInitError ServerDriver_OSVR::Init(vr::IVRDriverContext* driver_context) { VR_INIT_SERVER_DRIVER_CONTEXT(driver_context); Logging::instance().setDriverLog(vr::VRDriverLog()); OSVR_LOG(notice) << "SteamVR-OSVR version " << STEAMVR_OSVR_VERSION; settings_ = std::make_unique<Settings>(); // Verbose logging const auto verbose = settings_->getSetting<bool>("verbose", false); Logging::instance().setLogLevel(verbose ? trace : info); OSVR_LOG(info) << "Verbose logging " << (verbose ? "enabled" : "disabled") << "."; // Client loop update rate standbyWaitPeriod_ = settings_->getSetting<int>("standbyWaitPeriod", 100); activeWaitPeriod_ = settings_->getSetting<int>("activeWaitPeriod", 1); OSVR_LOG(debug) << "Standby wait period is " << standbyWaitPeriod_ << " ms."; OSVR_LOG(debug) << "Active wait period is " << activeWaitPeriod_ << " ms."; context_ = std::make_unique<osvr::clientkit::ClientContext>("org.osvr.SteamVR"); trackedDevices_.emplace_back(std::make_unique<OSVRTrackedHMD>(*(context_.get()))); trackedDevices_.emplace_back(std::make_unique<OSVRTrackingReference>(*(context_.get()))); for (auto& tracked_device : trackedDevices_) { vr::VRServerDriverHost()->TrackedDeviceAdded(tracked_device->getId(), tracked_device->getDeviceClass(), tracked_device.get()); } client_update_thread_quit.store(false); client_update_thread_ms_wait.store(activeWaitPeriod_); client_update_thread = std::thread(client_update_thread_work, std::ref(*context_)); return vr::VRInitError_None; }
vr::EVRInitError ServerDriver::Init(vr::IVRDriverContext *pDriverContext) { LOG(TRACE) << "CServerDriver::Init()"; // Initialize Hooking InterfaceHooks::setServerDriver(this); auto mhError = MH_Initialize(); if (mhError == MH_OK) { _driverContextHooks = InterfaceHooks::hookInterface(pDriverContext, "IVRDriverContext"); } else { LOG(ERROR) << "Error while initialising minHook: " << MH_StatusToString(mhError); } LOG(DEBUG) << "Initialize driver context."; VR_INIT_SERVER_DRIVER_CONTEXT(pDriverContext); // Read installation directory vr::ETrackedPropertyError tpeError; installDir = vr::VRProperties()->GetStringProperty(pDriverContext->GetDriverHandle(), vr::Prop_InstallPath_String, &tpeError); if (tpeError == vr::TrackedProp_Success) { LOG(INFO) << "Install Dir:" << installDir; } else { LOG(INFO) << "Could not get Install Dir: " << vr::VRPropertiesRaw()->GetPropErrorNameFromEnum(tpeError); } // Read vrsettings char buffer[vr::k_unMaxPropertyStringSize]; vr::EVRSettingsError peError; vr::VRSettings()->GetString(vrsettings_SectionName, vrsettings_overrideHmdManufacturer_string, buffer, vr::k_unMaxPropertyStringSize, &peError); if (peError == vr::VRSettingsError_None) { _propertiesOverrideHmdManufacturer = buffer; LOG(INFO) << vrsettings_SectionName << "::" << vrsettings_overrideHmdManufacturer_string << " = " << _propertiesOverrideHmdManufacturer; } vr::VRSettings()->GetString(vrsettings_SectionName, vrsettings_overrideHmdModel_string, buffer, vr::k_unMaxPropertyStringSize, &peError); if (peError == vr::VRSettingsError_None) { _propertiesOverrideHmdModel = buffer; LOG(INFO) << vrsettings_SectionName << "::" << vrsettings_overrideHmdModel_string << " = " << _propertiesOverrideHmdModel; } vr::VRSettings()->GetString(vrsettings_SectionName, vrsettings_overrideHmdTrackingSystem_string, buffer, vr::k_unMaxPropertyStringSize, &peError); if (peError == vr::VRSettingsError_None) { _propertiesOverrideHmdTrackingSystem = buffer; LOG(INFO) << vrsettings_SectionName << "::" << vrsettings_overrideHmdTrackingSystem_string << " = " << _propertiesOverrideHmdTrackingSystem; } auto boolVal = vr::VRSettings()->GetBool(vrsettings_SectionName, vrsettings_genericTrackerFakeController_bool, &peError); if (peError == vr::VRSettingsError_None) { _propertiesOverrideGenericTrackerFakeController = boolVal; LOG(INFO) << vrsettings_SectionName << "::" << vrsettings_genericTrackerFakeController_bool << " = " << boolVal; } // Start IPC thread shmCommunicator.init(this); return vr::VRInitError_None; }