nuclear@1: /************************************************************************************ nuclear@1: nuclear@1: PublicHeader: OVR.h nuclear@1: Filename : OVR_Profile.h nuclear@1: Content : Structs and functions for loading and storing device profile settings nuclear@1: Created : February 14, 2013 nuclear@1: Notes : nuclear@1: Profiles are used to store per-user settings that can be transferred and used nuclear@1: across multiple applications. For example, player IPD can be configured once nuclear@1: and reused for a unified experience across games. Configuration and saving of profiles nuclear@1: can be accomplished in game via the Profile API or by the official Oculus Configuration nuclear@1: Utility. nuclear@1: nuclear@1: Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved. nuclear@1: nuclear@1: Use of this software is subject to the terms of the Oculus license nuclear@1: agreement provided at the time of installation or download, or which nuclear@1: otherwise accompanies this software in either electronic or hard copy form. nuclear@1: nuclear@1: ************************************************************************************/ nuclear@1: nuclear@1: #ifndef OVR_Profile_h nuclear@1: #define OVR_Profile_h nuclear@1: nuclear@1: #include "Kernel/OVR_String.h" nuclear@1: #include "Kernel/OVR_RefCount.h" nuclear@1: #include "Kernel/OVR_Array.h" nuclear@1: nuclear@1: namespace OVR { nuclear@1: nuclear@1: // Defines the profile object for each device type nuclear@1: enum ProfileType nuclear@1: { nuclear@1: Profile_Unknown = 0, nuclear@1: Profile_RiftDK1 = 1, nuclear@1: Profile_RiftDKHD = 2, nuclear@1: }; nuclear@1: nuclear@1: class Profile; nuclear@1: nuclear@1: // ----------------------------------------------------------------------------- nuclear@1: // ***** ProfileManager nuclear@1: nuclear@1: // Profiles are interfaced through a ProfileManager object. Applications should nuclear@1: // create a ProfileManager each time they intend to read or write user profile data. nuclear@1: // The scope of the ProfileManager object defines when disk I/O is performed. Disk nuclear@1: // reads are performed on the first profile access and disk writes are performed when nuclear@1: // the ProfileManager goes out of scope. All profile interactions between these times nuclear@1: // are performed in local memory and are fast. A typical profile interaction might nuclear@1: // look like this: nuclear@1: // nuclear@1: // { nuclear@1: // Ptr pm = *ProfileManager::Create(); nuclear@1: // Ptr profile = pm->LoadProfile(Profile_RiftDK1, nuclear@1: // pm->GetDefaultProfileName(Profile_RiftDK1)); nuclear@1: // if (profile) nuclear@1: // { // Retrieve the current profile settings nuclear@1: // } nuclear@1: // } // Profile will be destroyed and any disk I/O completed when going out of scope nuclear@1: nuclear@1: class ProfileManager : public RefCountBase nuclear@1: { nuclear@1: protected: nuclear@1: // Synchronize ProfileManager access since it may be accessed from multiple threads, nuclear@1: // as it's shared through DeviceManager. nuclear@1: Lock ProfileLock; nuclear@1: Array > ProfileCache; nuclear@1: ProfileType CacheDevice; nuclear@1: String DefaultProfile; nuclear@1: bool Changed; nuclear@1: char NameBuff[32]; nuclear@1: nuclear@1: public: nuclear@1: static ProfileManager* Create(); nuclear@1: nuclear@1: // Static interface functions nuclear@1: int GetProfileCount(ProfileType device); nuclear@1: const char* GetProfileName(ProfileType device, unsigned int index); nuclear@1: bool HasProfile(ProfileType device, const char* name); nuclear@1: Profile* LoadProfile(ProfileType device, unsigned int index); nuclear@1: Profile* LoadProfile(ProfileType device, const char* name); nuclear@1: Profile* GetDeviceDefaultProfile(ProfileType device); nuclear@1: const char* GetDefaultProfileName(ProfileType device); nuclear@1: bool SetDefaultProfileName(ProfileType device, const char* name); nuclear@1: bool Save(const Profile* profile); nuclear@1: bool Delete(const Profile* profile); nuclear@1: nuclear@1: protected: nuclear@1: ProfileManager(); nuclear@1: ~ProfileManager(); nuclear@1: void LoadCache(ProfileType device); nuclear@1: void SaveCache(); nuclear@1: void ClearCache(); nuclear@1: Profile* CreateProfileObject(const char* user, nuclear@1: ProfileType device, nuclear@1: const char** device_name); nuclear@1: }; nuclear@1: nuclear@1: //------------------------------------------------------------------- nuclear@1: // ***** Profile nuclear@1: nuclear@1: // The base profile for all HMD devices. This object is never created directly. nuclear@1: // Instead derived objects provide specific data implementations. Some settings nuclear@1: // such as IPD will be tied to a specific user and be consistent between , nuclear@1: // implementations but other settings like optical distortion may vary between devices. nuclear@1: nuclear@1: class Profile : public RefCountBase nuclear@1: { nuclear@1: public: nuclear@1: enum { MaxNameLen = 32 }; nuclear@1: nuclear@1: enum GenderType nuclear@1: { nuclear@1: Gender_Unspecified = 0, nuclear@1: Gender_Male = 1, nuclear@1: Gender_Female = 2 nuclear@1: }; nuclear@1: nuclear@1: ProfileType Type; // The type of device profile nuclear@1: char Name[MaxNameLen]; // The name given to this profile nuclear@1: nuclear@1: protected: nuclear@1: GenderType Gender; // The gender of the user nuclear@1: float PlayerHeight; // The height of the user in meters nuclear@1: float IPD; // Distance between eyes in meters nuclear@1: nuclear@1: public: nuclear@1: // These are properties which are intrinsic to the user and affect scene setup nuclear@1: GenderType GetGender() { return Gender; }; nuclear@1: float GetPlayerHeight() { return PlayerHeight; }; nuclear@1: float GetIPD() { return IPD; }; nuclear@1: float GetEyeHeight(); nuclear@1: nuclear@1: void SetGender(GenderType gender) { Gender = gender; }; nuclear@1: void SetPlayerHeight(float height) { PlayerHeight = height; }; nuclear@1: void SetIPD(float ipd) { IPD = ipd; }; nuclear@1: nuclear@1: nuclear@1: protected: nuclear@1: Profile(ProfileType type, const char* name); nuclear@1: nuclear@1: virtual Profile* Clone() const = 0; nuclear@1: virtual bool ParseProperty(const char* prop, const char* sval); nuclear@1: nuclear@1: friend class ProfileManager; nuclear@1: }; nuclear@1: nuclear@1: nuclear@1: //----------------------------------------------------------------------------- nuclear@1: // ***** RiftDK1Profile nuclear@1: nuclear@1: // This profile is specific to the Rift Dev Kit 1 and contains overrides specific nuclear@1: // to that device and lens cup settings. nuclear@1: class RiftDK1Profile : public Profile nuclear@1: { nuclear@1: public: nuclear@1: enum EyeCupType nuclear@1: { nuclear@1: EyeCup_A = 0, nuclear@1: EyeCup_B = 1, nuclear@1: EyeCup_C = 2 nuclear@1: }; nuclear@1: nuclear@1: protected: nuclear@1: EyeCupType EyeCups; // Which eye cup does the player use nuclear@1: int LL; // Configuration Utility IPD setting nuclear@1: int LR; // Configuration Utility IPD setting nuclear@1: int RL; // Configuration Utility IPD setting nuclear@1: int RR; // Configuration Utility IPD setting nuclear@1: nuclear@1: public: nuclear@1: EyeCupType GetEyeCup() { return EyeCups; }; nuclear@1: void SetEyeCup(EyeCupType cup) { EyeCups = cup; }; nuclear@1: nuclear@1: protected: nuclear@1: RiftDK1Profile(const char* name); nuclear@1: nuclear@1: virtual Profile* Clone() const; nuclear@1: virtual bool ParseProperty(const char* prop, const char* sval); nuclear@1: nuclear@1: friend class ProfileManager; nuclear@1: }; nuclear@1: nuclear@1: nuclear@1: String GetBaseOVRPath(bool create_dir); nuclear@1: nuclear@1: } nuclear@1: nuclear@1: #endif // OVR_Profile_h