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