oculus1

diff libovr/Src/osx/OVR_OSX_DeviceManager.h @ 1:e2f9e4603129

added LibOVR and started a simple vr wrapper.
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 14 Sep 2013 16:14:59 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libovr/Src/osx/OVR_OSX_DeviceManager.h	Sat Sep 14 16:14:59 2013 +0300
     1.3 @@ -0,0 +1,119 @@
     1.4 +/************************************************************************************
     1.5 +
     1.6 +Filename    :   OVR_OSX_DeviceManager.h
     1.7 +Content     :   OSX specific DeviceManager header.
     1.8 +Created     :   March 14, 2013
     1.9 +Authors     :   Lee Cooper
    1.10 +
    1.11 +Copyright   :   Copyright 2013 Oculus VR, Inc. All Rights reserved.
    1.12 +
    1.13 +Use of this software is subject to the terms of the Oculus license
    1.14 +agreement provided at the time of installation or download, or which
    1.15 +otherwise accompanies this software in either electronic or hard copy form.
    1.16 +
    1.17 +*************************************************************************************/
    1.18 +
    1.19 +#ifndef OVR_OSX_DeviceManager_h
    1.20 +#define OVR_OSX_DeviceManager_h
    1.21 +
    1.22 +#include "OVR_DeviceImpl.h"
    1.23 +
    1.24 +#include "Kernel/OVR_Timer.h"
    1.25 +
    1.26 +#include <IOKit/hid/IOHIDManager.h>
    1.27 +#include <CoreGraphics/CGDirectDisplay.h>
    1.28 +#include <CoreGraphics/CGDisplayConfiguration.h>
    1.29 +
    1.30 +
    1.31 +namespace OVR { namespace OSX {
    1.32 +
    1.33 +class DeviceManagerThread;
    1.34 +
    1.35 +//-------------------------------------------------------------------------------------
    1.36 +// ***** OSX DeviceManager
    1.37 +
    1.38 +class DeviceManager : public DeviceManagerImpl
    1.39 +{
    1.40 +public:
    1.41 +    DeviceManager();
    1.42 +    ~DeviceManager();
    1.43 +
    1.44 +    // Initialize/Shutdown manager thread.
    1.45 +    virtual bool Initialize(DeviceBase* parent);
    1.46 +    virtual void Shutdown();
    1.47 +
    1.48 +    virtual ThreadCommandQueue* GetThreadQueue();
    1.49 +    virtual ThreadId GetThreadId() const;
    1.50 +    
    1.51 +    virtual DeviceEnumerator<> EnumerateDevicesEx(const DeviceEnumerationArgs& args);
    1.52 +
    1.53 +    virtual bool  GetDeviceInfo(DeviceInfo* info) const;
    1.54 +
    1.55 +protected:
    1.56 +    static void displayReconfigurationCallBack (CGDirectDisplayID display,
    1.57 +                                                CGDisplayChangeSummaryFlags flags,
    1.58 +                                                void *userInfo);
    1.59 +  
    1.60 +public: // data
    1.61 +    Ptr<DeviceManagerThread> pThread;
    1.62 +};
    1.63 +
    1.64 +//-------------------------------------------------------------------------------------
    1.65 +// ***** Device Manager Background Thread
    1.66 +
    1.67 +class DeviceManagerThread : public Thread, public ThreadCommandQueue
    1.68 +{
    1.69 +    friend class DeviceManager;
    1.70 +    enum { ThreadStackSize = 32 * 1024 };
    1.71 +public:
    1.72 +    DeviceManagerThread();
    1.73 +    ~DeviceManagerThread();
    1.74 +
    1.75 +    virtual int Run();
    1.76 +
    1.77 +    // ThreadCommandQueue notifications for CommandEvent handling.
    1.78 +    virtual void OnPushNonEmpty_Locked()
    1.79 +    {
    1.80 +        CFRunLoopSourceSignal(CommandQueueSource);
    1.81 +        CFRunLoopWakeUp(RunLoop);
    1.82 +    }
    1.83 +    
    1.84 +    virtual void OnPopEmpty_Locked()     {}
    1.85 +
    1.86 +
    1.87 +    // Notifier used for different updates (EVENT or regular timing or messages).
    1.88 +    class Notifier  
    1.89 +    {
    1.90 +    public:
    1.91 +
    1.92 +        // Called when timing ticks are updated. // Returns the largest number of microseconds
    1.93 +        // this function can wait till next call.
    1.94 +        virtual UInt64  OnTicks(UInt64 ticksMks)
    1.95 +        { OVR_UNUSED1(ticksMks);  return Timer::MksPerSecond * 1000; }
    1.96 +    };
    1.97 + 
    1.98 +    // Add notifier that will be called at regular intervals. 
    1.99 +    bool AddTicksNotifier(Notifier* notify);
   1.100 +    bool RemoveTicksNotifier(Notifier* notify);
   1.101 +
   1.102 +    CFRunLoopRef        GetRunLoop()
   1.103 +    { return RunLoop; }
   1.104 +    
   1.105 +    void                Shutdown();
   1.106 +private:
   1.107 +    CFRunLoopRef        RunLoop;
   1.108 +
   1.109 +    CFRunLoopSourceRef  CommandQueueSource;
   1.110 +    
   1.111 +    static void staticCommandQueueSourceCallback(void* pContext);
   1.112 +    void commandQueueSourceCallback();
   1.113 +
   1.114 +    Event               StartupEvent;
   1.115 +    
   1.116 +    // Ticks notifiers. Used for time-dependent events such as keep-alive.
   1.117 +    Array<Notifier*>    TicksNotifiers;
   1.118 +};
   1.119 +
   1.120 +}} // namespace OSX::OVR
   1.121 +
   1.122 +#endif // OVR_OSX_DeviceManager_h