ovr_sdk

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/LibOVR/Src/Service/Service_NetClient.h	Wed Jan 14 06:51:16 2015 +0200
     1.3 @@ -0,0 +1,149 @@
     1.4 +/************************************************************************************
     1.5 +
     1.6 +Filename    :   Service_NetClient.h
     1.7 +Content     :   Client for service interface
     1.8 +Created     :   June 12, 2014
     1.9 +Authors     :   Michael Antonov, Kevin Jenkins, Chris Taylor
    1.10 +
    1.11 +Copyright   :   Copyright 2014 Oculus VR, LLC All Rights reserved.
    1.12 +
    1.13 +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); 
    1.14 +you may not use the Oculus VR Rift SDK except in compliance with the License, 
    1.15 +which is provided at the time of installation or download, or which 
    1.16 +otherwise accompanies this software in either electronic or hard copy form.
    1.17 +
    1.18 +You may obtain a copy of the License at
    1.19 +
    1.20 +http://www.oculusvr.com/licenses/LICENSE-3.2 
    1.21 +
    1.22 +Unless required by applicable law or agreed to in writing, the Oculus VR SDK 
    1.23 +distributed under the License is distributed on an "AS IS" BASIS,
    1.24 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.25 +See the License for the specific language governing permissions and
    1.26 +limitations under the License.
    1.27 +
    1.28 +************************************************************************************/
    1.29 +
    1.30 +#ifndef OVR_Service_NetClient_h
    1.31 +#define OVR_Service_NetClient_h
    1.32 +
    1.33 +#include "../Net/OVR_NetworkTypes.h"
    1.34 +#include "Service_NetSessionCommon.h"
    1.35 +#include "../Kernel/OVR_System.h"
    1.36 +#include "../OVR_CAPI.h"
    1.37 +#include "../Util/Util_Render_Stereo.h"
    1.38 +
    1.39 +namespace OVR { namespace Service {
    1.40 +
    1.41 +using namespace OVR::Net;
    1.42 +
    1.43 +
    1.44 +//-------------------------------------------------------------------------------------
    1.45 +// NetClient
    1.46 +
    1.47 +class NetClient : public NetSessionCommon,
    1.48 +                  public Net::Plugins::NetworkPlugin,
    1.49 +                  public SystemSingletonBase<NetClient>
    1.50 +{
    1.51 +    OVR_DECLARE_SINGLETON(NetClient);
    1.52 +    virtual void OnThreadDestroy();
    1.53 +
    1.54 +    // Status
    1.55 +    bool          LatencyTesterAvailable;
    1.56 +    int           HMDCount;
    1.57 +    bool          EdgeTriggeredHMDCount;
    1.58 +
    1.59 +    virtual void OnReceive(Net::ReceivePayload* pPayload, Net::ListenerReceiveResult* lrrOut);
    1.60 +    virtual void OnDisconnected(Net::Connection* conn);
    1.61 +    virtual void OnConnected(Net::Connection* conn);
    1.62 +
    1.63 +    virtual int  Run();
    1.64 +
    1.65 +public:
    1.66 +    bool         Connect(bool blocking);
    1.67 +    bool         IsConnected(bool attemptReconnect, bool blockOnReconnect);
    1.68 +    void         Disconnect();
    1.69 +
    1.70 +    void         GetLocalProtocolVersion(int& major, int& minor, int& patch);
    1.71 +    // This function may fail if it is not connected
    1.72 +    bool         GetRemoteProtocolVersion(int& major, int& minor, int& patch);
    1.73 +
    1.74 +    void         SetLastError(String str);
    1.75 +
    1.76 +public:
    1.77 +    // Persistent key-value storage
    1.78 +    const char*  GetStringValue(VirtualHmdId hmd, const char* key, const char* default_val);
    1.79 +    bool         GetBoolValue(VirtualHmdId hmd, const char* key, bool default_val);
    1.80 +    int          GetIntValue(VirtualHmdId hmd, const char* key, int default_val);
    1.81 +    double       GetNumberValue(VirtualHmdId hmd, const char* key, double default_val);
    1.82 +    int          GetNumberValues(VirtualHmdId hmd, const char* key, double* values, int num_vals);
    1.83 +
    1.84 +    bool         SetStringValue(VirtualHmdId hmd, const char* key, const char* val);
    1.85 +    bool         SetBoolValue(VirtualHmdId hmd, const char* key, bool val);
    1.86 +    bool         SetIntValue(VirtualHmdId hmd, const char* key, int val);
    1.87 +    bool         SetNumberValue(VirtualHmdId hmd, const char* key, double val);
    1.88 +    bool         SetNumberValues(VirtualHmdId hmd, const char* key, const double* vals, int num_vals);
    1.89 +
    1.90 +    bool         GetDriverMode(bool& driverInstalled, bool& compatMode, bool& hideDK1Mode);
    1.91 +    bool         SetDriverMode(bool compatMode, bool hideDK1Mode);
    1.92 +
    1.93 +	int          Hmd_Detect();
    1.94 +	bool         Hmd_Create(int index, HMDNetworkInfo* netInfo);
    1.95 +	void         Hmd_Release(VirtualHmdId hmd);
    1.96 +
    1.97 +	// Last string is cached locally.
    1.98 +	const char*  Hmd_GetLastError(VirtualHmdId hmd);
    1.99 +
   1.100 +	// TBD: Replace with a function to return internal, original HMDInfo?
   1.101 +
   1.102 +	// Fills in description about HMD; this is the same as filled in by ovrHmd_Create.
   1.103 +	// The actual descriptor is a par
   1.104 +	bool         Hmd_GetHmdInfo(VirtualHmdId hmd, HMDInfo* hmdInfo);
   1.105 +
   1.106 +	//-------------------------------------------------------------------------------------
   1.107 +	unsigned int Hmd_GetEnabledCaps(VirtualHmdId hmd);
   1.108 +	// Returns new caps after modification
   1.109 +	unsigned int Hmd_SetEnabledCaps(VirtualHmdId hmd, unsigned int hmdCaps);
   1.110 +
   1.111 +    // Updates driver render target
   1.112 +    bool         Hmd_AttachToWindow(VirtualHmdId hmd, void* hWindow);
   1.113 +
   1.114 +	//-------------------------------------------------------------------------------------
   1.115 +	// *** Tracking Setup
   1.116 +
   1.117 +	bool         Hmd_ConfigureTracking(VirtualHmdId hmd, unsigned supportedCaps, unsigned requiredCaps);	
   1.118 +	void         Hmd_ResetTracking(VirtualHmdId hmd);
   1.119 +
   1.120 +	// TBD: Camera frames
   1.121 +    bool         LatencyUtil_ProcessInputs(double startTestSeconds, unsigned char rgbColorOut[3]);
   1.122 +    const char*  LatencyUtil_GetResultsString();
   1.123 +
   1.124 +    bool         ShutdownServer();
   1.125 +
   1.126 +protected:
   1.127 +    String       Hmd_GetLastError_Str;
   1.128 +    String       LatencyUtil_GetResultsString_Str;
   1.129 +    String       ProfileGetValue1_Str, ProfileGetValue3_Str;
   1.130 +
   1.131 +protected:
   1.132 +    //// Push Notifications:
   1.133 +
   1.134 +    void registerRPC();
   1.135 +
   1.136 +    ObserverScope<Net::Plugins::RPCSlot> InitialServerStateScope;
   1.137 +    void InitialServerState_1(BitStream* userData, ReceivePayload* pPayload);
   1.138 +
   1.139 +    ObserverScope<Net::Plugins::RPCSlot> LatencyTesterAvailableScope;
   1.140 +    void LatencyTesterAvailable_1(BitStream* userData, ReceivePayload* pPayload);
   1.141 +
   1.142 +    ObserverScope<Net::Plugins::RPCSlot> DefaultLogOutputScope;
   1.143 +    void DefaultLogOutput_1(BitStream* userData, ReceivePayload* pPayload);
   1.144 +
   1.145 +    ObserverScope<Net::Plugins::RPCSlot> HMDCountUpdateScope;
   1.146 +    void HMDCountUpdate_1(BitStream* userData, ReceivePayload* pPayload);
   1.147 +};
   1.148 +
   1.149 +
   1.150 +}} // namespace OVR::Service
   1.151 +
   1.152 +#endif // OVR_Service_NetClient_h