ovr_sdk

view LibOVR/Src/Service/Service_NetClient.h @ 0:1b39a1b46319

initial 0.4.4
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 14 Jan 2015 06:51:16 +0200
parents
children
line source
1 /************************************************************************************
3 Filename : Service_NetClient.h
4 Content : Client for service interface
5 Created : June 12, 2014
6 Authors : Michael Antonov, Kevin Jenkins, Chris Taylor
8 Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
10 Licensed under the Oculus VR Rift SDK License Version 3.2 (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.
15 You may obtain a copy of the License at
17 http://www.oculusvr.com/licenses/LICENSE-3.2
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.
25 ************************************************************************************/
27 #ifndef OVR_Service_NetClient_h
28 #define OVR_Service_NetClient_h
30 #include "../Net/OVR_NetworkTypes.h"
31 #include "Service_NetSessionCommon.h"
32 #include "../Kernel/OVR_System.h"
33 #include "../OVR_CAPI.h"
34 #include "../Util/Util_Render_Stereo.h"
36 namespace OVR { namespace Service {
38 using namespace OVR::Net;
41 //-------------------------------------------------------------------------------------
42 // NetClient
44 class NetClient : public NetSessionCommon,
45 public Net::Plugins::NetworkPlugin,
46 public SystemSingletonBase<NetClient>
47 {
48 OVR_DECLARE_SINGLETON(NetClient);
49 virtual void OnThreadDestroy();
51 // Status
52 bool LatencyTesterAvailable;
53 int HMDCount;
54 bool EdgeTriggeredHMDCount;
56 virtual void OnReceive(Net::ReceivePayload* pPayload, Net::ListenerReceiveResult* lrrOut);
57 virtual void OnDisconnected(Net::Connection* conn);
58 virtual void OnConnected(Net::Connection* conn);
60 virtual int Run();
62 public:
63 bool Connect(bool blocking);
64 bool IsConnected(bool attemptReconnect, bool blockOnReconnect);
65 void Disconnect();
67 void GetLocalProtocolVersion(int& major, int& minor, int& patch);
68 // This function may fail if it is not connected
69 bool GetRemoteProtocolVersion(int& major, int& minor, int& patch);
71 void SetLastError(String str);
73 public:
74 // Persistent key-value storage
75 const char* GetStringValue(VirtualHmdId hmd, const char* key, const char* default_val);
76 bool GetBoolValue(VirtualHmdId hmd, const char* key, bool default_val);
77 int GetIntValue(VirtualHmdId hmd, const char* key, int default_val);
78 double GetNumberValue(VirtualHmdId hmd, const char* key, double default_val);
79 int GetNumberValues(VirtualHmdId hmd, const char* key, double* values, int num_vals);
81 bool SetStringValue(VirtualHmdId hmd, const char* key, const char* val);
82 bool SetBoolValue(VirtualHmdId hmd, const char* key, bool val);
83 bool SetIntValue(VirtualHmdId hmd, const char* key, int val);
84 bool SetNumberValue(VirtualHmdId hmd, const char* key, double val);
85 bool SetNumberValues(VirtualHmdId hmd, const char* key, const double* vals, int num_vals);
87 bool GetDriverMode(bool& driverInstalled, bool& compatMode, bool& hideDK1Mode);
88 bool SetDriverMode(bool compatMode, bool hideDK1Mode);
90 int Hmd_Detect();
91 bool Hmd_Create(int index, HMDNetworkInfo* netInfo);
92 void Hmd_Release(VirtualHmdId hmd);
94 // Last string is cached locally.
95 const char* Hmd_GetLastError(VirtualHmdId hmd);
97 // TBD: Replace with a function to return internal, original HMDInfo?
99 // Fills in description about HMD; this is the same as filled in by ovrHmd_Create.
100 // The actual descriptor is a par
101 bool Hmd_GetHmdInfo(VirtualHmdId hmd, HMDInfo* hmdInfo);
103 //-------------------------------------------------------------------------------------
104 unsigned int Hmd_GetEnabledCaps(VirtualHmdId hmd);
105 // Returns new caps after modification
106 unsigned int Hmd_SetEnabledCaps(VirtualHmdId hmd, unsigned int hmdCaps);
108 // Updates driver render target
109 bool Hmd_AttachToWindow(VirtualHmdId hmd, void* hWindow);
111 //-------------------------------------------------------------------------------------
112 // *** Tracking Setup
114 bool Hmd_ConfigureTracking(VirtualHmdId hmd, unsigned supportedCaps, unsigned requiredCaps);
115 void Hmd_ResetTracking(VirtualHmdId hmd);
117 // TBD: Camera frames
118 bool LatencyUtil_ProcessInputs(double startTestSeconds, unsigned char rgbColorOut[3]);
119 const char* LatencyUtil_GetResultsString();
121 bool ShutdownServer();
123 protected:
124 String Hmd_GetLastError_Str;
125 String LatencyUtil_GetResultsString_Str;
126 String ProfileGetValue1_Str, ProfileGetValue3_Str;
128 protected:
129 //// Push Notifications:
131 void registerRPC();
133 ObserverScope<Net::Plugins::RPCSlot> InitialServerStateScope;
134 void InitialServerState_1(BitStream* userData, ReceivePayload* pPayload);
136 ObserverScope<Net::Plugins::RPCSlot> LatencyTesterAvailableScope;
137 void LatencyTesterAvailable_1(BitStream* userData, ReceivePayload* pPayload);
139 ObserverScope<Net::Plugins::RPCSlot> DefaultLogOutputScope;
140 void DefaultLogOutput_1(BitStream* userData, ReceivePayload* pPayload);
142 ObserverScope<Net::Plugins::RPCSlot> HMDCountUpdateScope;
143 void HMDCountUpdate_1(BitStream* userData, ReceivePayload* pPayload);
144 };
147 }} // namespace OVR::Service
149 #endif // OVR_Service_NetClient_h