OVR_OSX_DeviceManager.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 Filename    :   OVR_OSX_DeviceManager.h
00004 Content     :   OSX specific DeviceManager header.
00005 Created     :   March 14, 2013
00006 Authors     :   Lee Cooper
00007 
00008 Copyright   :   Copyright 2013 Oculus VR, Inc. All Rights reserved.
00009 
00010 Use of this software is subject to the terms of the Oculus license
00011 agreement provided at the time of installation or download, or which
00012 otherwise accompanies this software in either electronic or hard copy form.
00013 
00014 *************************************************************************************/
00015 
00016 #ifndef OVR_OSX_DeviceManager_h
00017 #define OVR_OSX_DeviceManager_h
00018 
00019 #include "OVR_DeviceImpl.h"
00020 
00021 #include "Kernel/OVR_Timer.h"
00022 
00023 #include <IOKit/hid/IOHIDManager.h>
00024 #include <CoreGraphics/CGDirectDisplay.h>
00025 #include <CoreGraphics/CGDisplayConfiguration.h>
00026 
00027 
00028 namespace OVR { namespace OSX {
00029 
00030 class DeviceManagerThread;
00031 
00032 //-------------------------------------------------------------------------------------
00033 // ***** OSX DeviceManager
00034 
00035 class DeviceManager : public DeviceManagerImpl
00036 {
00037 public:
00038     DeviceManager();
00039     ~DeviceManager();
00040 
00041     // Initialize/Shutdown manager thread.
00042     virtual bool Initialize(DeviceBase* parent);
00043     virtual void Shutdown();
00044 
00045     virtual ThreadCommandQueue* GetThreadQueue();
00046     virtual ThreadId GetThreadId() const;
00047     
00048     virtual DeviceEnumerator<> EnumerateDevicesEx(const DeviceEnumerationArgs& args);
00049 
00050     virtual bool  GetDeviceInfo(DeviceInfo* info) const;
00051 
00052 protected:
00053     static void displayReconfigurationCallBack (CGDirectDisplayID display,
00054                                                 CGDisplayChangeSummaryFlags flags,
00055                                                 void *userInfo);
00056   
00057 public: // data
00058     Ptr<DeviceManagerThread> pThread;
00059 };
00060 
00061 //-------------------------------------------------------------------------------------
00062 // ***** Device Manager Background Thread
00063 
00064 class DeviceManagerThread : public Thread, public ThreadCommandQueue
00065 {
00066     friend class DeviceManager;
00067     enum { ThreadStackSize = 32 * 1024 };
00068 public:
00069     DeviceManagerThread();
00070     ~DeviceManagerThread();
00071 
00072     virtual int Run();
00073 
00074     // ThreadCommandQueue notifications for CommandEvent handling.
00075     virtual void OnPushNonEmpty_Locked()
00076     {
00077         CFRunLoopSourceSignal(CommandQueueSource);
00078         CFRunLoopWakeUp(RunLoop);
00079     }
00080     
00081     virtual void OnPopEmpty_Locked()     {}
00082 
00083 
00084     // Notifier used for different updates (EVENT or regular timing or messages).
00085     class Notifier  
00086     {
00087     public:
00088 
00089         // Called when timing ticks are updated. // Returns the largest number of microseconds
00090         // this function can wait till next call.
00091         virtual UInt64  OnTicks(UInt64 ticksMks)
00092         { OVR_UNUSED1(ticksMks);  return Timer::MksPerSecond * 1000; }
00093     };
00094  
00095     // Add notifier that will be called at regular intervals. 
00096     bool AddTicksNotifier(Notifier* notify);
00097     bool RemoveTicksNotifier(Notifier* notify);
00098 
00099     CFRunLoopRef        GetRunLoop()
00100     { return RunLoop; }
00101     
00102     void                Shutdown();
00103 private:
00104     CFRunLoopRef        RunLoop;
00105 
00106     CFRunLoopSourceRef  CommandQueueSource;
00107     
00108     static void staticCommandQueueSourceCallback(void* pContext);
00109     void commandQueueSourceCallback();
00110 
00111     Event               StartupEvent;
00112     
00113     // Ticks notifiers. Used for time-dependent events such as keep-alive.
00114     Array<Notifier*>    TicksNotifiers;
00115 };
00116 
00117 }} // namespace OSX::OVR
00118 
00119 #endif // OVR_OSX_DeviceManager_h


oculus_sdk
Author(s):
autogenerated on Fri Aug 28 2015 11:53:11