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; }
// returns the MessageHandler's lock Lock* DeviceBase::GetHandlerLock() const { return getDeviceCommon()->HandlerRef.GetLock(); }
DeviceType DeviceBase::GetType() const { return getDeviceCommon()->pCreateDesc->Type; }
bool DeviceBase::GetDeviceInfo(DeviceInfo* info) const { return getDeviceCommon()->pCreateDesc->GetDeviceInfo(info); //info->Name[0] = 0; //return false; }
void DeviceBase::SetMessageHandler(MessageHandler* handler) { getDeviceCommon()->HandlerRef.SetHandler(handler); }
MessageHandler* DeviceBase::GetMessageHandler() const { return getDeviceCommon()->HandlerRef.GetHandler(); }
DeviceManager* DeviceBase::GetManager() const { return getDeviceCommon()->pCreateDesc->GetManagerImpl(); }
DeviceBase* DeviceBase::GetParent() const { return getDeviceCommon()->pParent.GetPtr(); }
void DeviceBase::Release() { getDeviceCommon()->DeviceRelease(); }
// Delegate relevant implementation to DeviceRectord to avoid re-implementation in // every derived Device. void DeviceBase::AddRef() { getDeviceCommon()->DeviceAddRef(); }
// Returns true if device is connected and usable bool DeviceBase::IsConnected() { return getDeviceCommon()->ConnectedFlag; }