summaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/OVR_Profile.h
diff options
context:
space:
mode:
Diffstat (limited to 'LibOVR/Src/OVR_Profile.h')
-rw-r--r--LibOVR/Src/OVR_Profile.h104
1 files changed, 77 insertions, 27 deletions
diff --git a/LibOVR/Src/OVR_Profile.h b/LibOVR/Src/OVR_Profile.h
index e34820a..a11e9c4 100644
--- a/LibOVR/Src/OVR_Profile.h
+++ b/LibOVR/Src/OVR_Profile.h
@@ -1,6 +1,5 @@
/************************************************************************************
-PublicHeader: OVR.h
Filename : OVR_Profile.h
Content : Structs and functions for loading and storing device profile settings
Created : February 14, 2013
@@ -33,18 +32,45 @@ limitations under the License.
#ifndef OVR_Profile_h
#define OVR_Profile_h
-#include "OVR_DeviceConstants.h"
+#include "Sensors/OVR_DeviceConstants.h"
#include "Kernel/OVR_String.h"
#include "Kernel/OVR_RefCount.h"
#include "Kernel/OVR_Array.h"
#include "Kernel/OVR_StringHash.h"
+#include "Kernel/OVR_System.h"
namespace OVR {
+class HMDInfo; // Opaque forward declaration
class Profile;
-class DeviceBase;
class JSON;
+
+// Device key for looking up profiles
+struct ProfileDeviceKey
+{
+ ProfileDeviceKey(const HMDInfo* info);
+
+ // Initialized properly?
+ bool Valid;
+
+ // The HMD type
+ HmdTypeEnum HmdType;
+
+ // This is the 12 character serial number printed on the HMD
+ String PrintedSerial;
+
+ // This is the product name string of the USB sensor device
+ // Note: It has been modified from the original to remove spaces and strip off "Oculus"
+ String ProductName;
+
+ // This is the product id from the HID info of the USB sensor device
+ unsigned ProductId;
+
+ static String SanitizeProductName(String productName);
+};
+
+
// -----------------------------------------------------------------------------
// ***** ProfileManager
@@ -64,8 +90,15 @@ class JSON;
// { // 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>
+class ProfileManager : public NewOverrideBase, public SystemSingletonBase<ProfileManager>
{
+ friend class OVR::SystemSingletonBase<ProfileManager>;
+
+protected:
+ ProfileManager(bool sys_register);
+ ~ProfileManager();
+ virtual void OnSystemDestroy();
+
protected:
// Synchronize ProfileManager access since it may be accessed from multiple threads,
// as it's shared through DeviceManager.
@@ -73,34 +106,38 @@ protected:
Ptr<JSON> ProfileCache;
bool Changed;
String TempBuff;
+ String BasePath;
public:
- static ProfileManager* Create();
+ // In the service process it is important to set the base path because this cannot be detected automatically
+ void SetBasePath(String basePath);
int GetUserCount();
const char* GetUser(unsigned int index);
bool CreateUser(const char* user, const char* name);
bool RemoveUser(const char* user);
- const char* GetDefaultUser(const DeviceBase* device);
- bool SetDefaultUser(const DeviceBase* device, const char* user);
+ const char* GetDefaultUser(const ProfileDeviceKey& deviceKey);
+ bool SetDefaultUser(const ProfileDeviceKey& deviceKey, const char* user);
virtual Profile* CreateProfile();
- Profile* GetProfile(const DeviceBase* device, const char* user);
- Profile* GetDefaultProfile(const DeviceBase* device);
+ Profile* GetProfile(const ProfileDeviceKey& deviceKey, const char* user);
+ Profile* GetDefaultUserProfile(const ProfileDeviceKey& deviceKey);
+ Profile* GetDefaultProfile(HmdTypeEnum device);
Profile* GetTaggedProfile(const char** key_names, const char** keys, int num_keys);
bool SetTaggedProfile(const char** key_names, const char** keys, int num_keys, Profile* profile);
- bool GetDeviceTags(const DeviceBase* device, String& product, String& serial);
-
+ // Force re-reading the settings
+ void Read();
+
protected:
- ProfileManager();
- ~ProfileManager();
- String GetProfilePath(bool create_dir);
+ // Force writing the settings
+ void ClearProfileData();
+ void Save();
+
+ String GetProfilePath();
void LoadCache(bool create);
- void ClearCache();
void LoadV1Profiles(JSON* v1);
-
-
+ const char* GetDefaultUser(const char* product, const char* serial);
};
@@ -116,6 +153,8 @@ protected:
OVR::Hash<String, JSON*, String::HashFunctor> ValMap;
OVR::Array<JSON*> Values;
OVR::String TempVal;
+ String BasePath;
+ bool IsDefault;
public:
~Profile();
@@ -137,23 +176,26 @@ public:
void SetFloatValues(const char* key, const float* vals, int num_vals);
void SetDoubleValue(const char* key, double val);
void SetDoubleValues(const char* key, const double* vals, int num_vals);
+
+ bool IsDefaultProfile();
bool Close();
protected:
- Profile() {};
-
+ Profile(String basePath) :
+ BasePath(basePath)
+ {
+ }
void SetValue(JSON* val);
-
- static bool LoadProfile(const DeviceBase* device,
+ static bool LoadProfile(const ProfileDeviceKey& deviceKey,
const char* user,
Profile** profile);
void CopyItems(JSON* root, String prefix);
bool LoadDeviceFile(unsigned int device_id, const char* serial);
- bool LoadDeviceProfile(const DeviceBase* device);
+ bool LoadDeviceProfile(const ProfileDeviceKey& deviceKey);
bool LoadProfile(JSON* root,
const char* user,
@@ -165,8 +207,8 @@ protected:
const char* device_name,
const char* device_serial);
-
friend class ProfileManager;
+ friend class WProfileManager;
};
// # defined() check for CAPI compatibility near term that re-defines these
@@ -186,18 +228,26 @@ protected:
#define OVR_KEY_EYE_CUP "EyeCup"
#define OVR_KEY_CUSTOM_EYE_RENDER "CustomEyeRender"
-#define OVR_DEFAULT_GENDER "Male"
+// Default measurements empirically determined at Oculus to make us happy
+// The neck model numbers were derived as an average of the male and female averages from ANSUR-88
+// NECK_TO_EYE_HORIZONTAL = H22 - H43 = INFRAORBITALE_BACK_OF_HEAD - TRAGION_BACK_OF_HEAD
+// NECK_TO_EYE_VERTICAL = H21 - H15 = GONION_TOP_OF_HEAD - ECTOORBITALE_TOP_OF_HEAD
+// These were determined to be the best in a small user study, clearly beating out the previous default values
+#define OVR_DEFAULT_GENDER "Unknown"
#define OVR_DEFAULT_PLAYER_HEIGHT 1.778f
#define OVR_DEFAULT_EYE_HEIGHT 1.675f
#define OVR_DEFAULT_IPD 0.064f
-#define OVR_DEFAULT_NECK_TO_EYE_HORIZONTAL 0.09f
-#define OVR_DEFAULT_NECK_TO_EYE_VERTICAL 0.15f
+#define OVR_DEFAULT_NECK_TO_EYE_HORIZONTAL 0.0805f
+#define OVR_DEFAULT_NECK_TO_EYE_VERTICAL 0.075f
#define OVR_DEFAULT_EYE_RELIEF_DIAL 3
#endif // OVR_KEY_USER
+
+// This path should be passed into the ProfileManager
String GetBaseOVRPath(bool create_dir);
-}
+
+} // namespace OVR
#endif // OVR_Profile_h \ No newline at end of file