oculus1
diff libovr/Src/OVR_Profile.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/OVR_Profile.h Sat Sep 14 16:14:59 2013 +0300 1.3 @@ -0,0 +1,189 @@ 1.4 +/************************************************************************************ 1.5 + 1.6 +PublicHeader: OVR.h 1.7 +Filename : OVR_Profile.h 1.8 +Content : Structs and functions for loading and storing device profile settings 1.9 +Created : February 14, 2013 1.10 +Notes : 1.11 + Profiles are used to store per-user settings that can be transferred and used 1.12 + across multiple applications. For example, player IPD can be configured once 1.13 + and reused for a unified experience across games. Configuration and saving of profiles 1.14 + can be accomplished in game via the Profile API or by the official Oculus Configuration 1.15 + Utility. 1.16 + 1.17 +Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved. 1.18 + 1.19 +Use of this software is subject to the terms of the Oculus license 1.20 +agreement provided at the time of installation or download, or which 1.21 +otherwise accompanies this software in either electronic or hard copy form. 1.22 + 1.23 +************************************************************************************/ 1.24 + 1.25 +#ifndef OVR_Profile_h 1.26 +#define OVR_Profile_h 1.27 + 1.28 +#include "Kernel/OVR_String.h" 1.29 +#include "Kernel/OVR_RefCount.h" 1.30 +#include "Kernel/OVR_Array.h" 1.31 + 1.32 +namespace OVR { 1.33 + 1.34 +// Defines the profile object for each device type 1.35 +enum ProfileType 1.36 +{ 1.37 + Profile_Unknown = 0, 1.38 + Profile_RiftDK1 = 1, 1.39 + Profile_RiftDKHD = 2, 1.40 +}; 1.41 + 1.42 +class Profile; 1.43 + 1.44 +// ----------------------------------------------------------------------------- 1.45 +// ***** ProfileManager 1.46 + 1.47 +// Profiles are interfaced through a ProfileManager object. Applications should 1.48 +// create a ProfileManager each time they intend to read or write user profile data. 1.49 +// The scope of the ProfileManager object defines when disk I/O is performed. Disk 1.50 +// reads are performed on the first profile access and disk writes are performed when 1.51 +// the ProfileManager goes out of scope. All profile interactions between these times 1.52 +// are performed in local memory and are fast. A typical profile interaction might 1.53 +// look like this: 1.54 +// 1.55 +// { 1.56 +// Ptr<ProfileManager> pm = *ProfileManager::Create(); 1.57 +// Ptr<Profile> profile = pm->LoadProfile(Profile_RiftDK1, 1.58 +// pm->GetDefaultProfileName(Profile_RiftDK1)); 1.59 +// if (profile) 1.60 +// { // Retrieve the current profile settings 1.61 +// } 1.62 +// } // Profile will be destroyed and any disk I/O completed when going out of scope 1.63 + 1.64 +class ProfileManager : public RefCountBase<ProfileManager> 1.65 +{ 1.66 +protected: 1.67 + // Synchronize ProfileManager access since it may be accessed from multiple threads, 1.68 + // as it's shared through DeviceManager. 1.69 + Lock ProfileLock; 1.70 + Array<Ptr<Profile> > ProfileCache; 1.71 + ProfileType CacheDevice; 1.72 + String DefaultProfile; 1.73 + bool Changed; 1.74 + char NameBuff[32]; 1.75 + 1.76 +public: 1.77 + static ProfileManager* Create(); 1.78 + 1.79 + // Static interface functions 1.80 + int GetProfileCount(ProfileType device); 1.81 + const char* GetProfileName(ProfileType device, unsigned int index); 1.82 + bool HasProfile(ProfileType device, const char* name); 1.83 + Profile* LoadProfile(ProfileType device, unsigned int index); 1.84 + Profile* LoadProfile(ProfileType device, const char* name); 1.85 + Profile* GetDeviceDefaultProfile(ProfileType device); 1.86 + const char* GetDefaultProfileName(ProfileType device); 1.87 + bool SetDefaultProfileName(ProfileType device, const char* name); 1.88 + bool Save(const Profile* profile); 1.89 + bool Delete(const Profile* profile); 1.90 + 1.91 +protected: 1.92 + ProfileManager(); 1.93 + ~ProfileManager(); 1.94 + void LoadCache(ProfileType device); 1.95 + void SaveCache(); 1.96 + void ClearCache(); 1.97 + Profile* CreateProfileObject(const char* user, 1.98 + ProfileType device, 1.99 + const char** device_name); 1.100 +}; 1.101 + 1.102 +//------------------------------------------------------------------- 1.103 +// ***** Profile 1.104 + 1.105 +// The base profile for all HMD devices. This object is never created directly. 1.106 +// Instead derived objects provide specific data implementations. Some settings 1.107 +// such as IPD will be tied to a specific user and be consistent between , 1.108 +// implementations but other settings like optical distortion may vary between devices. 1.109 + 1.110 +class Profile : public RefCountBase<Profile> 1.111 +{ 1.112 +public: 1.113 + enum { MaxNameLen = 32 }; 1.114 + 1.115 + enum GenderType 1.116 + { 1.117 + Gender_Unspecified = 0, 1.118 + Gender_Male = 1, 1.119 + Gender_Female = 2 1.120 + }; 1.121 + 1.122 + ProfileType Type; // The type of device profile 1.123 + char Name[MaxNameLen]; // The name given to this profile 1.124 + 1.125 +protected: 1.126 + GenderType Gender; // The gender of the user 1.127 + float PlayerHeight; // The height of the user in meters 1.128 + float IPD; // Distance between eyes in meters 1.129 + 1.130 +public: 1.131 + // These are properties which are intrinsic to the user and affect scene setup 1.132 + GenderType GetGender() { return Gender; }; 1.133 + float GetPlayerHeight() { return PlayerHeight; }; 1.134 + float GetIPD() { return IPD; }; 1.135 + float GetEyeHeight(); 1.136 + 1.137 + void SetGender(GenderType gender) { Gender = gender; }; 1.138 + void SetPlayerHeight(float height) { PlayerHeight = height; }; 1.139 + void SetIPD(float ipd) { IPD = ipd; }; 1.140 + 1.141 + 1.142 +protected: 1.143 + Profile(ProfileType type, const char* name); 1.144 + 1.145 + virtual Profile* Clone() const = 0; 1.146 + virtual bool ParseProperty(const char* prop, const char* sval); 1.147 + 1.148 + friend class ProfileManager; 1.149 +}; 1.150 + 1.151 + 1.152 +//----------------------------------------------------------------------------- 1.153 +// ***** RiftDK1Profile 1.154 + 1.155 +// This profile is specific to the Rift Dev Kit 1 and contains overrides specific 1.156 +// to that device and lens cup settings. 1.157 +class RiftDK1Profile : public Profile 1.158 +{ 1.159 +public: 1.160 + enum EyeCupType 1.161 + { 1.162 + EyeCup_A = 0, 1.163 + EyeCup_B = 1, 1.164 + EyeCup_C = 2 1.165 + }; 1.166 + 1.167 +protected: 1.168 + EyeCupType EyeCups; // Which eye cup does the player use 1.169 + int LL; // Configuration Utility IPD setting 1.170 + int LR; // Configuration Utility IPD setting 1.171 + int RL; // Configuration Utility IPD setting 1.172 + int RR; // Configuration Utility IPD setting 1.173 + 1.174 +public: 1.175 + EyeCupType GetEyeCup() { return EyeCups; }; 1.176 + void SetEyeCup(EyeCupType cup) { EyeCups = cup; }; 1.177 + 1.178 +protected: 1.179 + RiftDK1Profile(const char* name); 1.180 + 1.181 + virtual Profile* Clone() const; 1.182 + virtual bool ParseProperty(const char* prop, const char* sval); 1.183 + 1.184 + friend class ProfileManager; 1.185 +}; 1.186 + 1.187 + 1.188 +String GetBaseOVRPath(bool create_dir); 1.189 + 1.190 +} 1.191 + 1.192 +#endif // OVR_Profile_h 1.193 \ No newline at end of file