diff options
author | Brad Davis <[email protected]> | 2013-07-03 09:16:03 -0700 |
---|---|---|
committer | Brad Davis <[email protected]> | 2013-07-03 09:16:03 -0700 |
commit | d46694c91c2bec4eb1e282c0c0101e6dab26e082 (patch) | |
tree | eb5fba71edf1aedc0d6af9406881004289433b20 /LibOVR/Src/OVR_OSX_DeviceManager.h | |
parent | 7fa8be4bc565adc9911c95c814480cc48bf2d13c (diff) |
SDK 0.2.3
Diffstat (limited to 'LibOVR/Src/OVR_OSX_DeviceManager.h')
-rw-r--r-- | LibOVR/Src/OVR_OSX_DeviceManager.h | 238 |
1 files changed, 119 insertions, 119 deletions
diff --git a/LibOVR/Src/OVR_OSX_DeviceManager.h b/LibOVR/Src/OVR_OSX_DeviceManager.h index 02ba661..f272a35 100644 --- a/LibOVR/Src/OVR_OSX_DeviceManager.h +++ b/LibOVR/Src/OVR_OSX_DeviceManager.h @@ -1,119 +1,119 @@ -/************************************************************************************
-
-Filename : OVR_OSX_DeviceManager.h
-Content : OSX specific DeviceManager header.
-Created : March 14, 2013
-Authors : Lee Cooper
-
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
-
-Use of this software is subject to the terms of the Oculus license
-agreement provided at the time of installation or download, or which
-otherwise accompanies this software in either electronic or hard copy form.
-
-*************************************************************************************/
-
-#ifndef OVR_OSX_DeviceManager_h
-#define OVR_OSX_DeviceManager_h
-
-#include "OVR_DeviceImpl.h"
-
-#include "Kernel/OVR_Timer.h"
-
-#include <IOKit/hid/IOHIDManager.h>
-#include <CoreGraphics/CGDirectDisplay.h>
-#include <CoreGraphics/CGDisplayConfiguration.h>
-
-
-namespace OVR { namespace OSX {
-
-class DeviceManagerThread;
-
-//-------------------------------------------------------------------------------------
-// ***** OSX DeviceManager
-
-class DeviceManager : public DeviceManagerImpl
-{
-public:
- DeviceManager();
- ~DeviceManager();
-
- // Initialize/Shutdown manager thread.
- virtual bool Initialize(DeviceBase* parent);
- virtual void Shutdown();
-
- virtual ThreadCommandQueue* GetThreadQueue();
- virtual ThreadId GetThreadId() const;
-
- virtual DeviceEnumerator<> EnumerateDevicesEx(const DeviceEnumerationArgs& args);
-
- virtual bool GetDeviceInfo(DeviceInfo* info) const;
-
-protected:
- static void displayReconfigurationCallBack (CGDirectDisplayID display,
- CGDisplayChangeSummaryFlags flags,
- void *userInfo);
-
-public: // data
- Ptr<DeviceManagerThread> pThread;
-};
-
-//-------------------------------------------------------------------------------------
-// ***** Device Manager Background Thread
-
-class DeviceManagerThread : public Thread, public ThreadCommandQueue
-{
- friend class DeviceManager;
- enum { ThreadStackSize = 32 * 1024 };
-public:
- DeviceManagerThread();
- ~DeviceManagerThread();
-
- virtual int Run();
-
- // ThreadCommandQueue notifications for CommandEvent handling.
- virtual void OnPushNonEmpty_Locked()
- {
- CFRunLoopSourceSignal(CommandQueueSource);
- CFRunLoopWakeUp(RunLoop);
- }
-
- virtual void OnPopEmpty_Locked() {}
-
-
- // Notifier used for different updates (EVENT or regular timing or messages).
- class Notifier
- {
- public:
-
- // Called when timing ticks are updated. // Returns the largest number of microseconds
- // this function can wait till next call.
- virtual UInt64 OnTicks(UInt64 ticksMks)
- { OVR_UNUSED1(ticksMks); return Timer::MksPerSecond * 1000; }
- };
-
- // Add notifier that will be called at regular intervals.
- bool AddTicksNotifier(Notifier* notify);
- bool RemoveTicksNotifier(Notifier* notify);
-
- CFRunLoopRef GetRunLoop()
- { return RunLoop; }
-
- void Shutdown();
-private:
- CFRunLoopRef RunLoop;
-
- CFRunLoopSourceRef CommandQueueSource;
-
- static void staticCommandQueueSourceCallback(void* pContext);
- void commandQueueSourceCallback();
-
- Event StartupEvent;
-
- // Ticks notifiers. Used for time-dependent events such as keep-alive.
- Array<Notifier*> TicksNotifiers;
-};
-
-}} // namespace OSX::OVR
-
-#endif // OVR_OSX_DeviceManager_h
+/************************************************************************************ + +Filename : OVR_OSX_DeviceManager.h +Content : OSX specific DeviceManager header. +Created : March 14, 2013 +Authors : Lee Cooper + +Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved. + +Use of this software is subject to the terms of the Oculus license +agreement provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +*************************************************************************************/ + +#ifndef OVR_OSX_DeviceManager_h +#define OVR_OSX_DeviceManager_h + +#include "OVR_DeviceImpl.h" + +#include "Kernel/OVR_Timer.h" + +#include <IOKit/hid/IOHIDManager.h> +#include <CoreGraphics/CGDirectDisplay.h> +#include <CoreGraphics/CGDisplayConfiguration.h> + + +namespace OVR { namespace OSX { + +class DeviceManagerThread; + +//------------------------------------------------------------------------------------- +// ***** OSX DeviceManager + +class DeviceManager : public DeviceManagerImpl +{ +public: + DeviceManager(); + ~DeviceManager(); + + // Initialize/Shutdown manager thread. + virtual bool Initialize(DeviceBase* parent); + virtual void Shutdown(); + + virtual ThreadCommandQueue* GetThreadQueue(); + virtual ThreadId GetThreadId() const; + + virtual DeviceEnumerator<> EnumerateDevicesEx(const DeviceEnumerationArgs& args); + + virtual bool GetDeviceInfo(DeviceInfo* info) const; + +protected: + static void displayReconfigurationCallBack (CGDirectDisplayID display, + CGDisplayChangeSummaryFlags flags, + void *userInfo); + +public: // data + Ptr<DeviceManagerThread> pThread; +}; + +//------------------------------------------------------------------------------------- +// ***** Device Manager Background Thread + +class DeviceManagerThread : public Thread, public ThreadCommandQueue +{ + friend class DeviceManager; + enum { ThreadStackSize = 32 * 1024 }; +public: + DeviceManagerThread(); + ~DeviceManagerThread(); + + virtual int Run(); + + // ThreadCommandQueue notifications for CommandEvent handling. + virtual void OnPushNonEmpty_Locked() + { + CFRunLoopSourceSignal(CommandQueueSource); + CFRunLoopWakeUp(RunLoop); + } + + virtual void OnPopEmpty_Locked() {} + + + // Notifier used for different updates (EVENT or regular timing or messages). + class Notifier + { + public: + + // Called when timing ticks are updated. // Returns the largest number of microseconds + // this function can wait till next call. + virtual UInt64 OnTicks(UInt64 ticksMks) + { OVR_UNUSED1(ticksMks); return Timer::MksPerSecond * 1000; } + }; + + // Add notifier that will be called at regular intervals. + bool AddTicksNotifier(Notifier* notify); + bool RemoveTicksNotifier(Notifier* notify); + + CFRunLoopRef GetRunLoop() + { return RunLoop; } + + void Shutdown(); +private: + CFRunLoopRef RunLoop; + + CFRunLoopSourceRef CommandQueueSource; + + static void staticCommandQueueSourceCallback(void* pContext); + void commandQueueSourceCallback(); + + Event StartupEvent; + + // Ticks notifiers. Used for time-dependent events such as keep-alive. + Array<Notifier*> TicksNotifiers; +}; + +}} // namespace OSX::OVR + +#endif // OVR_OSX_DeviceManager_h |