aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/OVR_DeviceImpl.h
diff options
context:
space:
mode:
authorBrad Davis <[email protected]>2014-04-14 21:25:09 -0700
committerBrad Davis <[email protected]>2014-04-14 21:25:09 -0700
commit07d0f4d0bbf3477ac6a9584f726e8ec6ab285707 (patch)
tree1854d0c690eff32e77b137567c88a52d56d8b660 /LibOVR/Src/OVR_DeviceImpl.h
parentf28388ff2af14b56ef2d973b2f4f9da021716d4c (diff)
Adding windows 0.3.1 SDK
Diffstat (limited to 'LibOVR/Src/OVR_DeviceImpl.h')
-rw-r--r--LibOVR/Src/OVR_DeviceImpl.h72
1 files changed, 29 insertions, 43 deletions
diff --git a/LibOVR/Src/OVR_DeviceImpl.h b/LibOVR/Src/OVR_DeviceImpl.h
index 7f85c78..80b227b 100644
--- a/LibOVR/Src/OVR_DeviceImpl.h
+++ b/LibOVR/Src/OVR_DeviceImpl.h
@@ -5,16 +5,16 @@ Content : Partial back-end independent implementation of Device interfaces
Created : October 10, 2012
Authors : Michael Antonov
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
-Licensed under the Oculus VR SDK License Version 2.0 (the "License");
-you may not use the Oculus VR SDK except in compliance with the License,
+Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-2.0
+http://www.oculusvr.com/licenses/LICENSE-3.1
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
@@ -43,61 +43,44 @@ class DeviceFactory;
enum
{
- Oculus_VendorId = 0x2833
-};
-
-//-------------------------------------------------------------------------------------
-// Globally shared Lock implementation used for MessageHandlers.
-
-class SharedLock
-{
-public:
- SharedLock() : UseCount(0) {}
-
- Lock* GetLockAddRef();
- void ReleaseLock(Lock* plock);
-
-private:
- Lock* toLock() { return (Lock*)Buffer; }
-
- // UseCount and max alignment.
- volatile int UseCount;
- UInt64 Buffer[(sizeof(Lock)+sizeof(UInt64)-1)/sizeof(UInt64)];
+ Oculus_VendorId = 0x2833,
+ Device_Tracker_ProductId = 0x0001,
+ Device_Tracker2_ProductId = 0x0021,
+ Device_KTracker_ProductId = 0x0010,
};
// Wrapper for MessageHandler that includes synchronization logic.
-// References to MessageHandlers are organized in a list to allow for them to
-// easily removed with MessageHandler::RemoveAllHandlers.
-class MessageHandlerRef : public ListNode<MessageHandlerRef>
-{
+class MessageHandlerRef
+{
+ enum
+ {
+ MaxHandlersCount = 4
+ };
public:
MessageHandlerRef(DeviceBase* device);
~MessageHandlerRef();
- void SetHandler(MessageHandler* hander);
-
+ bool HasHandlers() const { return HandlersCount > 0; };
+ void AddHandler(MessageHandler* handler);
+ // returns false if the handler is not found
+ bool RemoveHandler(MessageHandler* handler);
// Not-thread-safe version
- void SetHandler_NTS(MessageHandler* hander);
+ void AddHandler_NTS(MessageHandler* handler);
- void Call(const Message& msg)
- {
- Lock::Locker lockScope(pLock);
- if (pHandler)
- pHandler->OnMessage(msg);
- }
+ void Call(const Message& msg);
Lock* GetLock() const { return pLock; }
-
- // GetHandler() is not thread safe if used out of order across threads; nothing can be done
- // about that.
- MessageHandler* GetHandler() const { return pHandler; }
DeviceBase* GetDevice() const { return pDevice; }
private:
Lock* pLock; // Cached global handler lock.
DeviceBase* pDevice;
- MessageHandler* pHandler;
+
+ int HandlersCount;
+ MessageHandler* pHandlers[MaxHandlersCount];
+
+ bool removeHandler(int idx);
};
@@ -221,12 +204,15 @@ public:
AtomicInt<UInt32> RefCount;
Ptr<DeviceCreateDesc> pCreateDesc;
Ptr<DeviceBase> pParent;
+ volatile bool ConnectedFlag;
MessageHandlerRef HandlerRef;
DeviceCommon(DeviceCreateDesc* createDesc, DeviceBase* device, DeviceBase* parent)
- : RefCount(1), pCreateDesc(createDesc), pParent(parent), HandlerRef(device)
+ : RefCount(1), pCreateDesc(createDesc), pParent(parent),
+ ConnectedFlag(true), HandlerRef(device)
{
}
+ virtual ~DeviceCommon() {}
// Device reference counting delegates to Manager thread to actually kill devices.
void DeviceAddRef();