void Sensor2DeviceImpl::openDevice() { // Read the currently configured range from sensor. SensorRangeImpl sr(SensorRange(), 0); if (GetInternalDevice()->GetFeatureReport(sr.Buffer, SensorRangeImpl::PacketSize)) { sr.Unpack(); sr.GetSensorRange(&CurrentRange); } // Read the currently configured calibration from sensor. SensorFactoryCalibrationImpl sc; if (GetInternalDevice()->GetFeatureReport(sc.Buffer, SensorFactoryCalibrationImpl::PacketSize)) { sc.Unpack(); AccelCalibrationOffset = sc.AccelOffset; GyroCalibrationOffset = sc.GyroOffset; AccelCalibrationMatrix = sc.AccelMatrix; GyroCalibrationMatrix = sc.GyroMatrix; CalibrationTemperature = sc.Temperature; } // If the sensor has "DisplayInfo" data, use HMD coordinate frame by default. SensorDisplayInfoImpl displayInfo; if (GetInternalDevice()->GetFeatureReport(displayInfo.Buffer, SensorDisplayInfoImpl::PacketSize)) { displayInfo.Unpack(); Coordinates = (displayInfo.DistortionType & SensorDisplayInfoImpl::Mask_BaseFmt) ? Coord_HMD : Coord_Sensor; } Coordinates = Coord_HMD; // TODO temporary to force it behave // Read/Apply sensor config. setCoordinateFrame(Coordinates); setReportRate(Sensor2_DefaultReportRate); setOnboardCalibrationEnabled(false); // Must send DK2 keep-alive. Set Keep-alive at 10 seconds. KeepAliveMuxReport keepAlive; keepAlive.CommandId = 0; keepAlive.INReport = 11; keepAlive.Interval = 10 * 1000; // Device creation is done from background thread so we don't need to add this to the command queue. KeepAliveMuxImpl keepAliveImpl(keepAlive); GetInternalDevice()->SetFeatureReport(keepAliveImpl.Buffer, KeepAliveMuxImpl::PacketSize); // Read the temperature data from the device pCalibration->Initialize(); }
HMDDevice* HMDDevice::Disconnect(SensorDevice* psensor) { if (!psensor) return NULL; OVR::DeviceManager* manager = GetManager(); if (manager) { //DeviceManagerImpl* mgrImpl = static_cast<DeviceManagerImpl*>(manager); Ptr<DeviceCreateDesc> desc = getDeviceCommon()->pCreateDesc; if (desc) { class Visitor : public DeviceFactory::EnumerateVisitor { Ptr<DeviceCreateDesc> Desc; public: Visitor(DeviceCreateDesc* desc) : Desc(desc) {} virtual void Visit(const DeviceCreateDesc& createDesc) { Lock::Locker lock(Desc->GetLock()); Desc->UpdateMatchedCandidate(createDesc); } } visitor(desc); //SensorDeviceImpl* sImpl = static_cast<SensorDeviceImpl*>(psensor); SensorDisplayInfoImpl displayInfo; if (psensor->GetFeatureReport(displayInfo.Buffer, SensorDisplayInfoImpl::PacketSize)) { displayInfo.Unpack(); // If we got display info, try to match / create HMDDevice as well // so that sensor settings give preference. if (displayInfo.DistortionType & SensorDisplayInfoImpl::Mask_BaseFmt) { SensorDeviceImpl::EnumerateHMDFromSensorDisplayInfo(displayInfo, visitor); } } } } return this; }