Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OVR_DeviceImpl.cpp
Go to the documentation of this file.
1 /************************************************************************************
2 
3 Filename : OVR_DeviceImpl.h
4 Content : Partial back-end independent implementation of Device interfaces
5 Created : October 10, 2012
6 Authors : Michael Antonov
7 
8 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 
10 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 you may not use the Oculus VR Rift SDK except in compliance with the License,
12 which is provided at the time of installation or download, or which
13 otherwise accompanies this software in either electronic or hard copy form.
14 
15 You may obtain a copy of the License at
16 
17 http://www.oculusvr.com/licenses/LICENSE-3.1
18 
19 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 distributed under the License is distributed on an "AS IS" BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 See the License for the specific language governing permissions and
23 limitations under the License.
24 
25 *************************************************************************************/
26 
27 #include "OVR_DeviceImpl.h"
28 #include "Kernel/OVR_Atomic.h"
29 #include "Kernel/OVR_Log.h"
30 #include "Kernel/OVR_System.h"
31 
32 #include "OVR_DeviceImpl.h"
33 #include "OVR_SensorImpl.h"
34 #include "OVR_Profile.h"
35 
36 namespace OVR {
37 
38 
39 //-------------------------------------------------------------------------------------
40 // ***** MessageHandler
41 
42 // Threading notes:
43 // The OnMessage() handler and SetMessageHandler are currently synchronized
44 // through a separately stored shared Lock object to avoid calling the handler
45 // from background thread while it's being removed.
46 
48 
49 
51 {
52 public:
53  enum
54  {
56  };
57 
59  : pLock(MessageHandlerSharedLock.GetLockAddRef()), HandlerRefsCount(0)
60  {
61  }
63  {
65  pLock = 0;
66  }
67 
69  { return (MessageHandlerImpl*)&handler->Internal; }
70  static const MessageHandlerImpl* FromHandler(const MessageHandler* handler)
71  { return (const MessageHandlerImpl*)&handler->Internal; }
72 
73  // This lock is held while calling a handler and when we are applied/
74  // removed from a device.
76  // List of devices we are applied to.
79 };
80 
81 
83  : pLock(MessageHandlerSharedLock.GetLockAddRef()), pDevice(device), HandlersCount(0)
84 {
85 }
86 
88 {
89  {
90  Lock::Locker lockScope(pLock);
91 
92  while (HandlersCount > 0)
93  removeHandler(0);
94  }
96  pLock = 0;
97 }
98 
100 {
101  Lock::Locker lockScope(pLock);
102 
103  for (int i = 0; i < HandlersCount; i++)
104  pHandlers[i]->OnMessage(msg);
105 }
106 
108 {
109  OVR_ASSERT(!handler ||
111  Lock::Locker lockScope(pLock);
112  AddHandler_NTS(handler);
113 }
114 
116 {
117  OVR_ASSERT(handler != NULL);
118 
120  for (int i = 0; i < HandlersCount; i++)
121  if (pHandlers[i] == handler)
122  // handler already installed - do nothing
123  return;
124  pHandlers[HandlersCount] = handler;
125  HandlersCount++;
126 
127  MessageHandlerImpl* handlerImpl = MessageHandlerImpl::FromHandler(handler);
129  handlerImpl->pHandlerRefs[handlerImpl->HandlerRefsCount] = this;
130  handlerImpl->HandlerRefsCount++;
131 
132  // TBD: Call notifier on device?
133 }
134 
136 {
137  Lock::Locker lockScope(pLock);
138 
139  for (int i = 0; i < HandlersCount; i++)
140  {
141  if (pHandlers[i] == handler)
142  return removeHandler(i);
143  }
144  return false;
145 }
146 
148 {
149  OVR_ASSERT(idx < HandlersCount);
150 
152  for (int i = 0; i < handlerImpl->HandlerRefsCount; i++)
153  if (handlerImpl->pHandlerRefs[i] == this)
154  {
155  handlerImpl->pHandlerRefs[i] = handlerImpl->pHandlerRefs[handlerImpl->HandlerRefsCount - 1];
156  handlerImpl->HandlerRefsCount--;
157 
158  pHandlers[idx] = pHandlers[HandlersCount - 1];
159  HandlersCount--;
160 
161  return true;
162  }
163 
164  // couldn't find a link in the opposite direction, assert in Debug
165  OVR_ASSERT(0);
166 
167  pHandlers[idx] = pHandlers[HandlersCount - 1];
168  HandlersCount--;
169 
170  return true;
171 }
172 
174 {
176  Construct<MessageHandlerImpl>(Internal);
177 }
178 
180 {
182  {
183  Lock::Locker lockedScope(handlerImpl->pLock);
184  OVR_ASSERT_LOG(handlerImpl->HandlerRefsCount == 0,
185  ("~MessageHandler %p - Handler still active; call RemoveHandlerFromDevices", this));
186  }
187 
188  Destruct<MessageHandlerImpl>(handlerImpl);
189 }
190 
192 {
193  const MessageHandlerImpl* handlerImpl = MessageHandlerImpl::FromHandler(this);
194  Lock::Locker lockedScope(handlerImpl->pLock);
195 
196  return handlerImpl->HandlerRefsCount > 0;
197 }
198 
200 {
202  Lock::Locker lockedScope(handlerImpl->pLock);
203 
204  while (handlerImpl->HandlerRefsCount > 0)
205  {
206  MessageHandlerRef* use = handlerImpl->pHandlerRefs[0];
207  use->RemoveHandler(this);
208  }
209 }
210 
212 {
213  const MessageHandlerImpl* handlerImpl = MessageHandlerImpl::FromHandler(this);
214  return handlerImpl->pLock;
215 }
216 
217 
218 //-------------------------------------------------------------------------------------
219 // ***** DeviceBase
220 
221 
222 // Delegate relevant implementation to DeviceRectord to avoid re-implementation in
223 // every derived Device.
225 {
227 }
229 {
231 }
233 {
234  return getDeviceCommon()->pParent.GetPtr();
235 }
237 {
238  return getDeviceCommon()->pCreateDesc->GetManagerImpl();
239 }
240 
242 {
244 }
245 
247 {
248  return getDeviceCommon()->pCreateDesc->Type;
249 }
250 
252 {
253  return getDeviceCommon()->pCreateDesc->GetDeviceInfo(info);
254  //info->Name[0] = 0;
255  //return false;
256 }
257 
258 // Returns true if device is connected and usable
260 {
261  return getDeviceCommon()->ConnectedFlag;
262 }
263 
264 // returns the MessageHandler's lock
266 {
267  return getDeviceCommon()->HandlerRef.GetLock();
268 }
269 
270 // Derive DeviceManagerCreateDesc to provide abstract function implementation.
272 {
273 public:
275  : DeviceCreateDesc(factory, Device_Manager) { }
276 
277  // We don't need there on Manager since it isn't assigned to DeviceHandle.
278  virtual DeviceCreateDesc* Clone() const { return 0; }
280  DeviceCreateDesc**) const { return Match_None; }
281  virtual DeviceBase* NewDeviceInstance() { return 0; }
282  virtual bool GetDeviceInfo(DeviceInfo*) const { return false; }
283 };
284 
285 //-------------------------------------------------------------------------------------
286 // ***** DeviceManagerImpl
287 
289  : DeviceImpl<OVR::DeviceManager>(CreateManagerDesc(), 0)
290  //,DeviceCreateDescList(pCreateDesc ? pCreateDesc->pLock : 0)
291 {
292  if (pCreateDesc)
293  {
294  pCreateDesc->pLock->pManager = this;
295  }
296 }
297 
299 {
300  // Shutdown must've been called.
301  OVR_ASSERT(!pCreateDesc->pDevice);
302 
303  // Remove all factories
304  while(!Factories.IsEmpty())
305  {
306  DeviceFactory* factory = Factories.GetFirst();
307  factory->RemovedFromManager();
308  factory->RemoveNode();
309  }
310 }
311 
313 {
314  DeviceCreateDesc* managerDesc = new DeviceManagerCreateDesc(0);
315  if (managerDesc)
316  {
317  managerDesc->pLock = *new DeviceManagerLock;
318  }
319  return managerDesc;
320 }
321 
323 {
324  OVR_UNUSED(parent);
325  if (!pCreateDesc || !pCreateDesc->pLock)
326  return false;
327 
329 
330  return true;
331 }
332 
334 {
335  // Remove all device descriptors from list while the lock is held.
336  // Some descriptors may survive longer due to handles.
337  while(!Devices.IsEmpty())
338  {
339  DeviceCreateDesc* devDesc = Devices.GetFirst();
340  OVR_ASSERT(!devDesc->pDevice); // Manager shouldn't be dying while Device exists.
341  devDesc->Enumerated = false;
342  devDesc->RemoveNode();
343  devDesc->pNext = devDesc->pPrev = 0;
344 
345  if (devDesc->HandleCount == 0)
346  {
347  delete devDesc;
348  }
349  }
350  Devices.Clear();
351 
352  // These must've been cleared by caller.
353  OVR_ASSERT(pCreateDesc->pDevice == 0);
354  OVR_ASSERT(pCreateDesc->pLock->pManager == 0);
355 
356  pProfileManager.Clear();
357 }
358 
359 
360 // Callbacks for DeviceCreation/Release
362 {
363  // Calls to DeviceManagerImpl::CreateDevice are enqueued with wait while holding pManager,
364  // so 'this' must remain valid.
365  OVR_ASSERT(createDesc->pLock->pManager);
366 
367  Lock::Locker devicesLock(GetLock());
368 
369  // If device already exists, just AddRef to it.
370  if (createDesc->pDevice)
371  {
372  createDesc->pDevice->AddRef();
373  return createDesc->pDevice;
374  }
375 
376  if (!parent)
377  parent = this;
378 
379  DeviceBase* device = createDesc->NewDeviceInstance();
380 
381  if (device)
382  {
383  if (device->getDeviceCommon()->Initialize(parent))
384  {
385  createDesc->pDevice = device;
386  }
387  else
388  {
389  // Don't go through Release() to avoid PushCall behaviour,
390  // as it is not needed here.
391  delete device;
392  device = 0;
393  }
394  }
395 
396  return device;
397 }
398 
400 {
401  // descKeepAlive will keep ManagerLock object alive as well,
402  // allowing us to exit gracefully.
403  Ptr<DeviceCreateDesc> descKeepAlive;
404  Lock::Locker devicesLock(GetLock());
405  DeviceCommon* devCommon = device->getDeviceCommon();
406 
407  while(1)
408  {
409  UInt32 refCount = devCommon->RefCount;
410 
411  if (refCount > 1)
412  {
413  if (devCommon->RefCount.CompareAndSet_NoSync(refCount, refCount-1))
414  {
415  // We decreented from initial count higher then 1;
416  // nothing else to do.
417  return 0;
418  }
419  }
420  else if (devCommon->RefCount.CompareAndSet_NoSync(1, 0))
421  {
422  // { 1 -> 0 } decrement succeded. Destroy this device.
423  break;
424  }
425  }
426 
427  // At this point, may be releasing the device manager itself.
428  // This does not matter, however, since shutdown logic is the same
429  // in both cases. DeviceManager::Shutdown with begin shutdown process for
430  // the internal manager thread, which will eventually destroy itself.
431  // TBD: Clean thread shutdown.
432  descKeepAlive = devCommon->pCreateDesc;
433  descKeepAlive->pDevice = 0;
434  devCommon->Shutdown();
435  delete device;
436  return 0;
437 }
438 
439 
440 
442 {
443  // 1. Mark matching devices as NOT enumerated.
444  // 2. Call factory to enumerate all HW devices, adding any device that
445  // was not matched.
446  // 3. Remove non-matching devices.
447 
448  Lock::Locker deviceLock(GetLock());
449 
450  DeviceCreateDesc* devDesc, *nextdevDesc;
451 
452  // 1.
453  for(devDesc = Devices.GetFirst();
454  !Devices.IsNull(devDesc); devDesc = devDesc->pNext)
455  {
456  //if (devDesc->pFactory == factory)
457  devDesc->Enumerated = false;
458  }
459 
460  // 2.
461  DeviceFactory* factory = Factories.GetFirst();
462  while(!Factories.IsNull(factory))
463  {
464  EnumerateFactoryDevices(factory);
465  factory = factory->pNext;
466  }
467 
468 
469  // 3.
470  for(devDesc = Devices.GetFirst();
471  !Devices.IsNull(devDesc); devDesc = nextdevDesc)
472  {
473  // In case 'devDesc' gets removed.
474  nextdevDesc = devDesc->pNext;
475 
476  // Note, device might be not enumerated since it is opened and
477  // in use! Do NOT notify 'device removed' in this case (!AB)
478  if (!devDesc->Enumerated)
479  {
480  // This deletes the devDesc for HandleCount == 0 due to Release in DeviceHandle.
481  CallOnDeviceRemoved(devDesc);
482 
483  /*
484  if (devDesc->HandleCount == 0)
485  {
486  // Device must be dead if it ever existed, since it AddRefs to us.
487  // ~DeviceCreateDesc removes its node from list.
488  OVR_ASSERT(!devDesc->pDevice);
489  delete devDesc;
490  }
491  */
492  }
493  }
494 
495  return 0;
496 }
497 
499  const DeviceCreateDesc& createDesc)
500 {
501  // If found, mark as enumerated and we are done.
502  DeviceCreateDesc* descCandidate = 0;
503 
504  for(DeviceCreateDesc* devDesc = Devices.GetFirst();
505  !Devices.IsNull(devDesc); devDesc = devDesc->pNext)
506  {
507  DeviceCreateDesc::MatchResult mr = devDesc->MatchDevice(createDesc, &descCandidate);
509  {
510  devDesc->Enumerated = true;
511  if (!devDesc->pDevice)
512  CallOnDeviceAdded(devDesc);
513  return devDesc;
514  }
515  }
516 
517  // Update candidate (this may involve writing fields to HMDDevice createDesc).
518  if (descCandidate)
519  {
520  bool newDevice = false;
521  if (descCandidate->UpdateMatchedCandidate(createDesc, &newDevice))
522  {
523  descCandidate->Enumerated = true;
524  if (!descCandidate->pDevice || newDevice)
525  CallOnDeviceAdded(descCandidate);
526  return descCandidate;
527  }
528  }
529 
530  // If not found, add new device.
531  // - This stores a new descriptor with
532  // {pDevice = 0, HandleCount = 1, Enumerated = true}
533  DeviceCreateDesc* desc = createDesc.Clone();
534  desc->pLock = pCreateDesc->pLock;
535  Devices.PushBack(desc);
536  desc->Enumerated = true;
537 
538  CallOnDeviceAdded(desc);
539 
540  return desc;
541 }
542 
544  const String& path,
546 {
547  Lock::Locker deviceLock(GetLock());
548  DeviceCreateDesc* devDesc;
549 
550  for (devDesc = Devices.GetFirst();
551  !Devices.IsNull(devDesc); devDesc = devDesc->pNext)
552  {
553  if ((deviceType == Device_None || deviceType == devDesc->Type) &&
554  devDesc->MatchDevice(path))
555  return devDesc;
556  }
557  return NULL;
558 }
559 
561 {
562  Lock::Locker deviceLock(GetLock());
563  DeviceCreateDesc* devDesc;
564 
565  for (devDesc = Devices.GetFirst();
566  !Devices.IsNull(devDesc); devDesc = devDesc->pNext)
567  {
568  if (created)
569  { // Search for matching device that is created
570  if (devDesc->MatchHIDDevice(hidDevDesc) && devDesc->pDevice)
571  return devDesc;
572  }
573  else
574  { // Search for any matching device
575  if (devDesc->MatchHIDDevice(hidDevDesc))
576  return devDesc;
577  }
578  }
579  return NULL;
580 }
581 
583 {
584  Lock::Locker deviceLock(GetLock());
585  DeviceFactory* factory = Factories.GetFirst();
586  while(!Factories.IsNull(factory))
587  {
588  if (factory->DetectHIDDevice(this, hidDevDesc))
589  break;
590  factory = factory->pNext;
591  }
592 
593 }
594 
595 // Enumerates devices for a particular factory.
597 {
598 
599  class FactoryEnumerateVisitor : public DeviceFactory::EnumerateVisitor
600  {
601  DeviceManagerImpl* pManager;
602  DeviceFactory* pFactory;
603  public:
604  FactoryEnumerateVisitor(DeviceManagerImpl* manager, DeviceFactory* factory)
605  : pManager(manager), pFactory(factory) { }
606 
607  virtual void Visit(const DeviceCreateDesc& createDesc)
608  {
609  pManager->AddDevice_NeedsLock(createDesc);
610  }
611  };
612 
613  FactoryEnumerateVisitor newDeviceVisitor(this, factory);
614  factory->EnumerateDevices(newDeviceVisitor);
615 
616 
617  return 0;
618 }
619 
620 
622 {
623  Lock::Locker deviceLock(GetLock());
624 
625  if (Devices.IsEmpty())
626  return DeviceEnumerator<>();
627 
628  DeviceCreateDesc* firstDeviceDesc = Devices.GetFirst();
629  DeviceEnumerator<> e = enumeratorFromHandle(DeviceHandle(firstDeviceDesc), args);
630 
631  if (!args.MatchRule(firstDeviceDesc->Type, firstDeviceDesc->Enumerated))
632  {
633  e.Next();
634  }
635 
636  return e;
637 }
638 
639 //-------------------------------------------------------------------------------------
640 // ***** DeviceCommon
641 
643 {
644  RefCount++;
645 }
646 
648 {
649  while(1)
650  {
651  UInt32 refCount = RefCount;
652  OVR_ASSERT(refCount > 0);
653 
654  if (refCount == 1)
655  {
656  DeviceManagerImpl* manager = pCreateDesc->GetManagerImpl();
657  ThreadCommandQueue* queue = manager->GetThreadQueue();
658 
659  // Enqueue ReleaseDevice for {1 -> 0} transition with no wait.
660  // We pass our reference ownership into the queue to destroy.
661  // It's in theory possible for another thread to re-steal our device reference,
662  // but that is checked for atomically in DeviceManagerImpl::ReleaseDevice.
664  pCreateDesc->pDevice))
665  {
666  // PushCall shouldn't fail because background thread runs while manager is
667  // alive and we are holding Manager alive through pParent chain.
668  OVR_ASSERT(false);
669  }
670 
671  // Warning! At his point everything, including manager, may be dead.
672  break;
673  }
674  else if (RefCount.CompareAndSet_NoSync(refCount, refCount-1))
675  {
676  break;
677  }
678  }
679 }
680 
681 
682 
683 //-------------------------------------------------------------------------------------
684 // ***** DeviceCreateDesc
685 
686 
688 {
689  // Technically, HandleCount { 0 -> 1 } transition can only happen during Lock,
690  // but we leave this to caller to worry about (happens during enumeration).
691  HandleCount++;
692 }
693 
695 {
696  while(1)
697  {
698  UInt32 handleCount = HandleCount;
699  // HandleCount must obviously be >= 1, since we are releasing it.
700  OVR_ASSERT(handleCount > 0);
701 
702  // {1 -> 0} transition may cause us to be destroyed, so require a lock.
703  if (handleCount == 1)
704  {
705  Ptr<DeviceManagerLock> lockKeepAlive;
706  Lock::Locker deviceLockScope(GetLock());
707 
708  if (!HandleCount.CompareAndSet_NoSync(handleCount, 0))
709  continue;
710 
711  OVR_ASSERT(pDevice == 0);
712 
713  // Destroy *this if the manager was destroyed already, or Enumerated
714  // is false (device no longer available).
715  if (!GetManagerImpl() || !Enumerated)
716  {
717  lockKeepAlive = pLock;
718 
719  // Remove from manager list (only matters for !Enumerated).
720  if (pNext)
721  {
722  RemoveNode();
723  pNext = pPrev = 0;
724  }
725 
726  delete this;
727  }
728 
729  // Available DeviceCreateDesc may survive with { HandleCount == 0 },
730  // in case it might be enumerated again later.
731  break;
732  }
733  else if (HandleCount.CompareAndSet_NoSync(handleCount, handleCount-1))
734  {
735  break;
736  }
737  }
738 }
739 
741 {
742  if (!psensor)
743  return NULL;
744 
745  OVR::DeviceManager* manager = GetManager();
746  if (manager)
747  {
748  //DeviceManagerImpl* mgrImpl = static_cast<DeviceManagerImpl*>(manager);
750  if (desc)
751  {
752  class Visitor : public DeviceFactory::EnumerateVisitor
753  {
755  public:
756  Visitor(DeviceCreateDesc* desc) : Desc(desc) {}
757  virtual void Visit(const DeviceCreateDesc& createDesc)
758  {
759  Lock::Locker lock(Desc->GetLock());
760  Desc->UpdateMatchedCandidate(createDesc);
761  }
762  } visitor(desc);
763  //SensorDeviceImpl* sImpl = static_cast<SensorDeviceImpl*>(psensor);
764 
765  SensorDisplayInfoImpl displayInfo;
766 
767  if (psensor->GetFeatureReport(displayInfo.Buffer, SensorDisplayInfoImpl::PacketSize))
768  {
769  displayInfo.Unpack();
770 
771  // If we got display info, try to match / create HMDDevice as well
772  // so that sensor settings give preference.
774  {
776  }
777  }
778  }
779  }
780  return this;
781 }
782 
784 {
785  OVR::HMDInfo info;
786  GetDeviceInfo(&info);
787  // if strlen(info.DisplayDeviceName) == 0 then
788  // this HMD is 'fake' (created using sensor).
789  return (strlen(info.DisplayDeviceName) == 0);
790 }
791 
792 
793 } // namespace OVR
794 
void ReleaseLock(Lock *plock)
Definition: OVR_Atomic.cpp:131
virtual bool GetDeviceInfo(DeviceInfo *info) const
Lock * GetLock() const
virtual bool MatchHIDDevice(const HIDDeviceDesc &) const
virtual bool GetFeatureReport(UByte *data, UInt32 length)=0
virtual DeviceCreateDesc * Clone() const
void CallOnDeviceRemoved(DeviceCreateDesc *desc)
bool PushCall(R(C::*fn)(), bool wait=false)
bool RemoveHandler(MessageHandler *handler)
bool CompareAndSet_NoSync(T c, T val)
Definition: OVR_Atomic.h:620
Void ReleaseDevice_MgrThread(DeviceBase *device)
#define OVR_ASSERT_LOG(c, args)
Definition: OVR_Log.h:198
virtual bool Initialize(DeviceBase *parent)=0
virtual DeviceManager * GetManager() const
virtual Ptr< DeviceCreateDesc > AddDevice_NeedsLock(const DeviceCreateDesc &createDesc)
#define NULL
virtual void AddRef()
virtual ThreadCommandQueue * GetThreadQueue()=0
MessageHandler * pHandlers[MaxHandlersCount]
Ptr< DeviceCreateDesc > pCreateDesc
Ptr< DeviceCreateDesc > FindDevice(const String &path, DeviceType=Device_None)
static ProfileManager * Create()
Lock * GetHandlerLock() const
Ptr< DeviceBase > pParent
uint32_t UInt32
Definition: OVR_Types.h:253
Ptr< DeviceManagerLock > pLock
__END_NAMESPACE_STD char char __BEGIN_NAMESPACE_STD size_t strlen(const char *__s) __THROW __attribute_pure__ __nonnull((1))
Lock * GetLock() const
void CallOnDeviceAdded(DeviceCreateDesc *desc)
virtual DeviceType GetType() const
#define OVR_UNUSED(a)
virtual MatchResult MatchDevice(const DeviceCreateDesc &other, DeviceCreateDesc **pcandidate) const =0
void AddHandler_NTS(MessageHandler *handler)
virtual MatchResult MatchDevice(const DeviceCreateDesc &, DeviceCreateDesc **) const
MessageHandlerRef * pHandlerRefs[MaxHandlerRefsCount]
static void EnumerateHMDFromSensorDisplayInfo(const SensorDisplayInfoImpl &displayInfo, DeviceFactory::EnumerateVisitor &visitor)
virtual bool UpdateMatchedCandidate(const DeviceCreateDesc &desc, bool *newDeviceFlag=NULL)
DeviceManagerCreateDesc(DeviceFactory *factory)
virtual DeviceEnumerator EnumerateDevicesEx(const DeviceEnumerationArgs &args)
virtual void Release()
Ptr< ProfileManager > pProfileManager
DeviceManagerImpl * GetManagerImpl() const
void AddHandler(MessageHandler *handler)
bool IsDisconnected() const
char DisplayDeviceName[32]
Definition: OVR_Device.h:347
enum _deviceType deviceType
const DeviceType Type
virtual bool DetectHIDDevice(DeviceManager *pdevMgr, const HIDDeviceDesc &desc)
void RemoveNode()
Definition: OVR_List.h:58
virtual DeviceBase * NewDeviceInstance()=0
Ptr< DeviceCreateDesc > FindHIDDevice(const HIDDeviceDesc &, bool created)
Lock * GetLock() const
#define OVR_ASSERT(p)
MessageHandlerRef(DeviceBase *device)
static const MessageHandlerImpl * FromHandler(const MessageHandler *handler)
virtual Void EnumerateFactoryDevices(DeviceFactory *factory)
static MessageHandlerImpl * FromHandler(MessageHandler *handler)
virtual DeviceBase * NewDeviceInstance()
static SharedLock MessageHandlerSharedLock
List< DeviceFactory > Factories
MessageHandlerRef HandlerRef
List< DeviceCreateDesc > Devices
virtual void Shutdown()=0
AtomicInt< UInt32 > HandleCount
virtual DeviceBase * GetParent() const
Lock * GetHandlerLock() const
DeviceEnumerator enumeratorFromHandle(const DeviceHandle &h, const DeviceEnumerationArgs &args)
Definition: OVR_Device.h:290
virtual bool GetDeviceInfo(DeviceInfo *) const
bool IsHandlerInstalled() const
friend class DeviceHandle
Definition: OVR_Device.h:102
virtual DeviceCreateDesc * Clone() const =0
virtual DeviceCommon * getDeviceCommon() const =0
virtual void AddMessageHandler(MessageHandler *handler)
bool MatchRule(DeviceType type, bool available) const
Definition: OVR_Device.h:175
void DetectHIDDevice(const HIDDeviceDesc &)
virtual Void EnumerateAllFactoryDevices()
virtual void RemovedFromManager()
void Call(const Message &msg)
virtual bool IsConnected()
virtual void EnumerateDevices(EnumerateVisitor &visitor)=0
HMDDevice * Disconnect(SensorDevice *)
DeviceBase * CreateDevice_MgrThread(DeviceCreateDesc *createDesc, DeviceBase *parent=0)
static DeviceCreateDesc * CreateManagerDesc()
volatile bool ConnectedFlag
#define OVR_COMPILER_ASSERT(x)
AtomicInt< UInt32 > RefCount
virtual bool Initialize(DeviceBase *parent)
UByte Buffer[PacketSize]