oculus1

annotate libovr/Src/OVR_Profile.h @ 23:0c76f70fb7e9

merged
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 28 Sep 2013 04:13:33 +0300
parents
children
rev   line source
nuclear@1 1 /************************************************************************************
nuclear@1 2
nuclear@1 3 PublicHeader: OVR.h
nuclear@1 4 Filename : OVR_Profile.h
nuclear@1 5 Content : Structs and functions for loading and storing device profile settings
nuclear@1 6 Created : February 14, 2013
nuclear@1 7 Notes :
nuclear@1 8 Profiles are used to store per-user settings that can be transferred and used
nuclear@1 9 across multiple applications. For example, player IPD can be configured once
nuclear@1 10 and reused for a unified experience across games. Configuration and saving of profiles
nuclear@1 11 can be accomplished in game via the Profile API or by the official Oculus Configuration
nuclear@1 12 Utility.
nuclear@1 13
nuclear@1 14 Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
nuclear@1 15
nuclear@1 16 Use of this software is subject to the terms of the Oculus license
nuclear@1 17 agreement provided at the time of installation or download, or which
nuclear@1 18 otherwise accompanies this software in either electronic or hard copy form.
nuclear@1 19
nuclear@1 20 ************************************************************************************/
nuclear@1 21
nuclear@1 22 #ifndef OVR_Profile_h
nuclear@1 23 #define OVR_Profile_h
nuclear@1 24
nuclear@1 25 #include "Kernel/OVR_String.h"
nuclear@1 26 #include "Kernel/OVR_RefCount.h"
nuclear@1 27 #include "Kernel/OVR_Array.h"
nuclear@1 28
nuclear@1 29 namespace OVR {
nuclear@1 30
nuclear@1 31 // Defines the profile object for each device type
nuclear@1 32 enum ProfileType
nuclear@1 33 {
nuclear@1 34 Profile_Unknown = 0,
nuclear@1 35 Profile_RiftDK1 = 1,
nuclear@1 36 Profile_RiftDKHD = 2,
nuclear@1 37 };
nuclear@1 38
nuclear@1 39 class Profile;
nuclear@1 40
nuclear@1 41 // -----------------------------------------------------------------------------
nuclear@1 42 // ***** ProfileManager
nuclear@1 43
nuclear@1 44 // Profiles are interfaced through a ProfileManager object. Applications should
nuclear@1 45 // create a ProfileManager each time they intend to read or write user profile data.
nuclear@1 46 // The scope of the ProfileManager object defines when disk I/O is performed. Disk
nuclear@1 47 // reads are performed on the first profile access and disk writes are performed when
nuclear@1 48 // the ProfileManager goes out of scope. All profile interactions between these times
nuclear@1 49 // are performed in local memory and are fast. A typical profile interaction might
nuclear@1 50 // look like this:
nuclear@1 51 //
nuclear@1 52 // {
nuclear@1 53 // Ptr<ProfileManager> pm = *ProfileManager::Create();
nuclear@1 54 // Ptr<Profile> profile = pm->LoadProfile(Profile_RiftDK1,
nuclear@1 55 // pm->GetDefaultProfileName(Profile_RiftDK1));
nuclear@1 56 // if (profile)
nuclear@1 57 // { // Retrieve the current profile settings
nuclear@1 58 // }
nuclear@1 59 // } // Profile will be destroyed and any disk I/O completed when going out of scope
nuclear@1 60
nuclear@1 61 class ProfileManager : public RefCountBase<ProfileManager>
nuclear@1 62 {
nuclear@1 63 protected:
nuclear@1 64 // Synchronize ProfileManager access since it may be accessed from multiple threads,
nuclear@1 65 // as it's shared through DeviceManager.
nuclear@1 66 Lock ProfileLock;
nuclear@1 67 Array<Ptr<Profile> > ProfileCache;
nuclear@1 68 ProfileType CacheDevice;
nuclear@1 69 String DefaultProfile;
nuclear@1 70 bool Changed;
nuclear@1 71 char NameBuff[32];
nuclear@1 72
nuclear@1 73 public:
nuclear@1 74 static ProfileManager* Create();
nuclear@1 75
nuclear@1 76 // Static interface functions
nuclear@1 77 int GetProfileCount(ProfileType device);
nuclear@1 78 const char* GetProfileName(ProfileType device, unsigned int index);
nuclear@1 79 bool HasProfile(ProfileType device, const char* name);
nuclear@1 80 Profile* LoadProfile(ProfileType device, unsigned int index);
nuclear@1 81 Profile* LoadProfile(ProfileType device, const char* name);
nuclear@1 82 Profile* GetDeviceDefaultProfile(ProfileType device);
nuclear@1 83 const char* GetDefaultProfileName(ProfileType device);
nuclear@1 84 bool SetDefaultProfileName(ProfileType device, const char* name);
nuclear@1 85 bool Save(const Profile* profile);
nuclear@1 86 bool Delete(const Profile* profile);
nuclear@1 87
nuclear@1 88 protected:
nuclear@1 89 ProfileManager();
nuclear@1 90 ~ProfileManager();
nuclear@1 91 void LoadCache(ProfileType device);
nuclear@1 92 void SaveCache();
nuclear@1 93 void ClearCache();
nuclear@1 94 Profile* CreateProfileObject(const char* user,
nuclear@1 95 ProfileType device,
nuclear@1 96 const char** device_name);
nuclear@1 97 };
nuclear@1 98
nuclear@1 99 //-------------------------------------------------------------------
nuclear@1 100 // ***** Profile
nuclear@1 101
nuclear@1 102 // The base profile for all HMD devices. This object is never created directly.
nuclear@1 103 // Instead derived objects provide specific data implementations. Some settings
nuclear@1 104 // such as IPD will be tied to a specific user and be consistent between ,
nuclear@1 105 // implementations but other settings like optical distortion may vary between devices.
nuclear@1 106
nuclear@1 107 class Profile : public RefCountBase<Profile>
nuclear@1 108 {
nuclear@1 109 public:
nuclear@1 110 enum { MaxNameLen = 32 };
nuclear@1 111
nuclear@1 112 enum GenderType
nuclear@1 113 {
nuclear@1 114 Gender_Unspecified = 0,
nuclear@1 115 Gender_Male = 1,
nuclear@1 116 Gender_Female = 2
nuclear@1 117 };
nuclear@1 118
nuclear@1 119 ProfileType Type; // The type of device profile
nuclear@1 120 char Name[MaxNameLen]; // The name given to this profile
nuclear@1 121
nuclear@1 122 protected:
nuclear@1 123 GenderType Gender; // The gender of the user
nuclear@1 124 float PlayerHeight; // The height of the user in meters
nuclear@1 125 float IPD; // Distance between eyes in meters
nuclear@1 126
nuclear@1 127 public:
nuclear@1 128 // These are properties which are intrinsic to the user and affect scene setup
nuclear@1 129 GenderType GetGender() { return Gender; };
nuclear@1 130 float GetPlayerHeight() { return PlayerHeight; };
nuclear@1 131 float GetIPD() { return IPD; };
nuclear@1 132 float GetEyeHeight();
nuclear@1 133
nuclear@1 134 void SetGender(GenderType gender) { Gender = gender; };
nuclear@1 135 void SetPlayerHeight(float height) { PlayerHeight = height; };
nuclear@1 136 void SetIPD(float ipd) { IPD = ipd; };
nuclear@1 137
nuclear@1 138
nuclear@1 139 protected:
nuclear@1 140 Profile(ProfileType type, const char* name);
nuclear@1 141
nuclear@1 142 virtual Profile* Clone() const = 0;
nuclear@1 143 virtual bool ParseProperty(const char* prop, const char* sval);
nuclear@1 144
nuclear@1 145 friend class ProfileManager;
nuclear@1 146 };
nuclear@1 147
nuclear@1 148
nuclear@1 149 //-----------------------------------------------------------------------------
nuclear@1 150 // ***** RiftDK1Profile
nuclear@1 151
nuclear@1 152 // This profile is specific to the Rift Dev Kit 1 and contains overrides specific
nuclear@1 153 // to that device and lens cup settings.
nuclear@1 154 class RiftDK1Profile : public Profile
nuclear@1 155 {
nuclear@1 156 public:
nuclear@1 157 enum EyeCupType
nuclear@1 158 {
nuclear@1 159 EyeCup_A = 0,
nuclear@1 160 EyeCup_B = 1,
nuclear@1 161 EyeCup_C = 2
nuclear@1 162 };
nuclear@1 163
nuclear@1 164 protected:
nuclear@1 165 EyeCupType EyeCups; // Which eye cup does the player use
nuclear@1 166 int LL; // Configuration Utility IPD setting
nuclear@1 167 int LR; // Configuration Utility IPD setting
nuclear@1 168 int RL; // Configuration Utility IPD setting
nuclear@1 169 int RR; // Configuration Utility IPD setting
nuclear@1 170
nuclear@1 171 public:
nuclear@1 172 EyeCupType GetEyeCup() { return EyeCups; };
nuclear@1 173 void SetEyeCup(EyeCupType cup) { EyeCups = cup; };
nuclear@1 174
nuclear@1 175 protected:
nuclear@1 176 RiftDK1Profile(const char* name);
nuclear@1 177
nuclear@1 178 virtual Profile* Clone() const;
nuclear@1 179 virtual bool ParseProperty(const char* prop, const char* sval);
nuclear@1 180
nuclear@1 181 friend class ProfileManager;
nuclear@1 182 };
nuclear@1 183
nuclear@1 184
nuclear@1 185 String GetBaseOVRPath(bool create_dir);
nuclear@1 186
nuclear@1 187 }
nuclear@1 188
nuclear@1 189 #endif // OVR_Profile_h