void Log::FormatLog(char* buffer, unsigned bufferSize, LogMessageType messageType, const char* fmt, va_list argList) { bool addNewline = true; switch(messageType) { case Log_Error: OVR_strcpy(buffer, bufferSize, "Error: "); break; case Log_Debug: OVR_strcpy(buffer, bufferSize, "Debug: "); break; case Log_Assert: OVR_strcpy(buffer, bufferSize, "Assert: "); break; case Log_Text: buffer[0] = 0; addNewline = false; break; case Log_DebugText: buffer[0] = 0; addNewline = false; break; default: buffer[0] = 0; addNewline = false; break; } size_t prefixLength = OVR_strlen(buffer); char *buffer2 = buffer + prefixLength; OVR_vsprintf(buffer2, bufferSize - prefixLength, fmt, argList); if (addNewline) OVR_strcat(buffer, bufferSize, "\n"); }
bool HMDDeviceCreateDesc::GetDeviceInfo(DeviceInfo* info) const { if ((info->InfoClassType != Device_HMD) && (info->InfoClassType != Device_None)) return false; bool is7Inch = Is7Inch(); OVR_strcpy(info->ProductName, DeviceInfo::MaxNameLength, is7Inch ? "Oculus Rift DK1" : "Oculus Rift DK1-Prototype"); OVR_strcpy(info->Manufacturer, DeviceInfo::MaxNameLength, "Oculus VR"); info->Type = Device_HMD; info->Version = 0; // Display detection. if (info->InfoClassType == Device_HMD) { HMDInfo* hmdInfo = static_cast<HMDInfo*>(info); hmdInfo->DesktopX = DesktopX; hmdInfo->DesktopY = DesktopY; hmdInfo->HResolution = HResolution; hmdInfo->VResolution = VResolution; hmdInfo->HScreenSize = HScreenSize; hmdInfo->VScreenSize = VScreenSize; hmdInfo->VScreenCenter = VScreenSize * 0.5f; hmdInfo->InterpupillaryDistance = 0.064f; // Default IPD; should be configurable. hmdInfo->LensSeparationDistance = 0.064f; if (Contents & Contents_Distortion) { memcpy(hmdInfo->DistortionK, DistortionK, sizeof(float)*4); } else { if (is7Inch) { // 7" screen. hmdInfo->DistortionK[0] = 1.0f; hmdInfo->DistortionK[1] = 0.22f; hmdInfo->DistortionK[2] = 0.24f; hmdInfo->EyeToScreenDistance = 0.041f; } else { hmdInfo->DistortionK[0] = 1.0f; hmdInfo->DistortionK[1] = 0.18f; hmdInfo->DistortionK[2] = 0.115f; hmdInfo->EyeToScreenDistance = 0.0387f; } } OVR_strcpy(hmdInfo->DisplayDeviceName, sizeof(hmdInfo->DisplayDeviceName), DisplayDeviceName.ToCStr()); } return true; }
Profile::Profile(ProfileType device, const char* name) { Type = device; Gender = Gender_Unspecified; PlayerHeight = 1.778f; // 5'10" inch man IPD = 0.064f; NeckEyeHori = 0.12f; NeckEyeVert = 0.12f; OVR_strcpy(Name, MaxNameLen, name); OVR_strcpy(CloudUser, MaxNameLen, name); }
static void StripPath( char const * path, char * outName, size_t const outSize ) { if ( path[0] == '\0' ) { outName[0] = '\0'; return; } size_t n = OVR_strlen( path ); char const * fnameStart = NULL; for ( int i = n - 1; i >= 0; --i ) { if ( path[i] == PATH_SEPARATOR ) { fnameStart = &path[i]; break; } } if ( fnameStart != NULL ) { // this will copy 0 characters if the path separator was the last character OVR_strncpy( outName, outSize, fnameStart + 1, n - ( fnameStart - path ) ); } else { OVR_strcpy( outName, outSize, path ); } }
void FormatLatencyReading(char* buff, UPInt size, float val) { if (val < 0.000001f) OVR_strcpy(buff, size, "N/A "); else OVR_sprintf(buff, size, "%4.2fms", val * 1000.0f); }
bool Profile::ParseProperty(const char* prop, const char* sval) { if (OVR_strcmp(prop, "Name") == 0) { OVR_strcpy(Name, MaxNameLen, sval); return true; } else if (OVR_strcmp(prop, "Gender") == 0) { if (OVR_strcmp(sval, "Male") == 0) Gender = Gender_Male; else if (OVR_strcmp(sval, "Female") == 0) Gender = Gender_Female; else Gender = Gender_Unspecified; return true; } else if (OVR_strcmp(prop, "PlayerHeight") == 0) { PlayerHeight = (float)atof(sval); return true; } else if (OVR_strcmp(prop, "IPD") == 0) { IPD = (float)atof(sval); return true; } return false; }
void ExecuteConsoleFunction( long appPtr, char const * commandStr ) const { DROIDLOG( "OvrConsole", "Received console command \"%s\"", commandStr ); char cmdName[128]; char const * parms = ""; int cmdLen = (int)strlen( commandStr ); char const * spacePtr = strstr( commandStr, " " ); if ( spacePtr != NULL && spacePtr - commandStr < cmdLen ) { parms = spacePtr + 1; OVR_strncpy( cmdName, sizeof( cmdName ), commandStr, spacePtr - commandStr ); } else { OVR_strcpy( cmdName, sizeof( cmdName ), commandStr ); } LOG( "ExecuteConsoleFunction( %s, %s )", cmdName, parms ); for ( int i = 0 ; i < ConsoleFunctions.GetSizeI(); ++i ) { LOG( "Checking console function '%s'", ConsoleFunctions[i].GetName() ); if ( OVR_stricmp( ConsoleFunctions[i].GetName(), cmdName ) == 0 ) { LOG( "Executing console function '%s'", cmdName ); ConsoleFunctions[i].Execute( reinterpret_cast< void* >( appPtr ), parms ); return; } } DROIDLOG( "OvrConsole", "ERROR: unknown console command '%s'", cmdName ); }
ovrJobThread( ovrJobManagerImpl * jobManager, char const * threadName ) : JobManager( jobManager ) , MyThread( nullptr ) , Jni( nullptr ) { OVR_strcpy( ThreadName, sizeof( ThreadName ), threadName ); }
// Return behavior is the same as ISO C vsnprintf: returns the required strlen of buffer (which will // be >= bufferSize if bufferSize is insufficient) or returns a negative value because the input was bad. int Log::FormatLog(char* buffer, size_t bufferSize, LogMessageType messageType, const char* fmt, va_list argList) { OVR_ASSERT(buffer && (bufferSize >= 10)); // Need to be able to at least print "Assert: \n" to it. if(!buffer || (bufferSize < 10)) return -1; int addNewline = 1; int prefixLength = 0; switch(messageType) { case Log_Error: OVR_strcpy(buffer, bufferSize, "Error: "); prefixLength = 7; break; case Log_Debug: OVR_strcpy(buffer, bufferSize, "Debug: "); prefixLength = 7; break; case Log_Assert: OVR_strcpy(buffer, bufferSize, "Assert: "); prefixLength = 8; break; case Log_Text: buffer[0] = 0; addNewline = 0; break; case Log_DebugText: buffer[0] = 0; addNewline = 0; break; default: buffer[0] = 0; addNewline = 0; break; } char* buffer2 = buffer + prefixLength; size_t size2 = bufferSize - (size_t)prefixLength; int messageLength = OVR_vsnprintf(buffer2, size2, fmt, argList); if (addNewline) { if (messageLength < 0) // If there was a format error... { // To consider: append <format error> to the buffer here. buffer2[0] = '\n'; // We are guaranteed to have capacity for this. buffer2[1] = '\0'; } else { // If the printed string used all of the capacity or required more than the capacity, // Chop the output by one character so we can append the \n safely. int messageEnd = (messageLength >= (int)(size2 - 1)) ? (int)(size2 - 2) : messageLength; buffer2[messageEnd + 0] = '\n'; buffer2[messageEnd + 1] = '\0'; } } if (messageLength >= 0) // If the format was OK... return prefixLength + messageLength + addNewline; // Return the required strlen of buffer. return messageLength; // Else we cannot know what the required strlen is and return the error to the caller. }
static void AppendPath( char * path, size_t pathsize, char const * append ) { char appendCanonical[512]; OVR_strcpy( appendCanonical, sizeof( appendCanonical ), append ); MakePathCanonical( path ); int n = OVR_strlen( path ); if ( n > 0 && path[n - 1] != PATH_SEPARATOR && appendCanonical[0] != PATH_SEPARATOR ) { OVR_strcat( path, pathsize, PATH_SEPARATOR_STR ); } OVR_strcat( path, pathsize, appendCanonical ); }
bool MySensorDeviceDesc::GetDeviceInfo(DeviceInfo* info) const { SSSA_LOG_FUNCALL(1); if ((info->InfoClassType != Device_Sensor) && (info->InfoClassType != Device_None)) return false; OVR_strcpy(info->ProductName, DeviceInfo::MaxNameLength, "My Test"); OVR_strcpy(info->Manufacturer, DeviceInfo::MaxNameLength, "My Test"); info->Type = Device_Sensor; if (info->InfoClassType == Device_Sensor) { SensorInfo* sinfo = (SensorInfo*)info; sinfo->VendorId = MyDevice_VendorId; sinfo->ProductId = MyDevice_ProductId; sinfo->Version = MyDevice_VersionNumber; //sinfo->MaxRanges = SensorRangeImpl::GetMaxSensorRange(); OVR_strcpy(sinfo->SerialNumber, sizeof(sinfo->SerialNumber), MyDevice_SerialNumber); } return true; }
// Returns the name of the profile that is marked as the current default user. const char* ProfileManager::GetDefaultProfileName(ProfileType device) { Lock::Locker lockScope(&ProfileLock); if (CacheDevice == Profile_Unknown) LoadCache(device); if (ProfileCache.GetSize() > 0) { OVR_strcpy(NameBuff, Profile::MaxNameLen, DefaultProfile); return NameBuff; } else { return NULL; } }
// Returns the profile name of a specific profile in the list. The returned // memory is locally allocated and should not be stored or deleted. Returns NULL // if the index is invalid const char* ProfileManager::GetProfileName(ProfileType device, unsigned int index) { Lock::Locker lockScope(&ProfileLock); if (CacheDevice == Profile_Unknown) LoadCache(device); if (index < ProfileCache.GetSize()) { Profile* profile = ProfileCache[index]; OVR_strcpy(NameBuff, Profile::MaxNameLen, profile->Name); return NameBuff; } else { return NULL; } }
//============================== // ovrLexer::CopyResult void ovrLexer::CopyResult( char const * buffer, char * token, size_t const maxTokenSize ) { // NOTE: if any multi-byte characters are ever treated as quotes, this code must change if ( IsQuote( *buffer ) ) { size_t len = UTF8Util::GetLength( buffer ); const uint32_t lastChar = UTF8Util::GetCharAt( len - 1, buffer ); if ( IsQuote( lastChar ) ) { // The first char and last char are single-byte quotes, we can now just step past the first and not copy the last. char const * start = buffer + 1; len = OVR_strlen( start ); // We do not care about UTF length here since we know the quotes are a single bytes OVR_strncpy( token, maxTokenSize, start, len - 1 ); return; } } OVR_strcpy( token, maxTokenSize, buffer ); }
static void StripFileName( char const * path, char * outPath, size_t const outSize ) { size_t n = OVR_strlen( path ); char const * fnameStart = NULL; for ( int i = n - 1; i >= 0; --i ) { if ( path[i] == PATH_SEPARATOR ) { fnameStart = &path[i]; break; } } if ( fnameStart != NULL ) { OVR_strncpy( outPath, outSize, path, ( fnameStart - path ) + 1 ); } else { OVR_strcpy( outPath, outSize, path ); } }
//----------------------------------------------------------------------------- bool Profile::LoadDeviceProfile(const ProfileDeviceKey& deviceKey) { bool success = false; if (!deviceKey.Valid) return false; #if 0 int dev_major = BCDByte((sinfo.Version >> 8) & 0x00ff); OVR_UNUSED(dev_major); //int dev_minor = BCDByte(sinfo.Version & 0xff); //if (dev_minor > 18) //{ // If the firmware supports hardware stored profiles then grab the device profile // from the sensor // TBD: Implement this //} //else { #endif // Grab the model and serial number from the device and use it to access the device // profile file stored on the local machine success = LoadDeviceFile(deviceKey.ProductId, deviceKey.PrintedSerial); //} return success; } //----------------------------------------------------------------------------- bool Profile::LoadUser(JSON* root, const char* user, const char* model_name, const char* device_serial) { if (user == NULL) return false; // For legacy files, convert to old style names //if (model_name && OVR_strcmp(model_name, "Oculus Rift DK1") == 0) // model_name = "RiftDK1"; bool user_found = false; JSON* data = root->GetItemByName("TaggedData"); if (data) { const char* tag_names[3]; const char* tags[3]; tag_names[0] = "User"; tags[0] = user; int num_tags = 1; if (model_name) { tag_names[num_tags] = "Product"; tags[num_tags] = model_name; num_tags++; } if (device_serial) { tag_names[num_tags] = "Serial"; tags[num_tags] = device_serial; num_tags++; } // Retrieve all tag permutations for (int combos=1; combos<=num_tags; combos++) { for (int i=0; i<(num_tags - combos + 1); i++) { JSON* vals = FindTaggedData(data, tag_names+i, tags+i, combos); if (vals) { if (i==0) // This tag-combination contains a user match user_found = true; // Add the values to the Profile. More specialized multi-tag values // will take precedence over and overwrite generalized ones // For example: ("Me","RiftDK1").IPD would overwrite ("Me").IPD JSON* item = vals->GetFirstItem(); while (item) { //printf("Add %s, %s\n", item->Name.ToCStr(), item->Value.ToCStr()); //Settings.Set(item->Name, item->Value); SetValue(item); item = vals->GetNextItem(item); } } } } } if (user_found) SetValue(OVR_KEY_USER, user); return user_found; } //----------------------------------------------------------------------------- bool Profile::LoadProfile(JSON* root, const char* user, const char* device_model, const char* device_serial) { if (!LoadUser(root, user, device_model, device_serial)) return false; return true; } //----------------------------------------------------------------------------- char* Profile::GetValue(const char* key, char* val, int val_length) const { JSON* value = NULL; if (ValMap.Get(key, &value)) { OVR_strcpy(val, val_length, value->Value.ToCStr()); return val; } else { val[0] = 0; return NULL; } }
//----------------------------------------------------------------------------- // Render an object to text. The returned string must be freed char* JSON::PrintObject(int depth, bool fmt) { char** entries = 0, **names = 0; char* out = 0; char* ptr, *ret, *str; intptr_t len = 7, i = 0, j; bool fail = false; // Count the number of entries. int numentries = GetItemCount(); // Explicitly handle empty object case if (numentries == 0) { out=(char*)OVR_ALLOC(fmt?depth+4:4); if (!out) return 0; ptr=out; *ptr++='{'; if (fmt) { *ptr++='\n'; for (i=0;i<depth-1;i++) *ptr++='\t'; } *ptr++='}'; *ptr++=0; return out; } // Allocate space for the names and the objects entries=(char**)OVR_ALLOC(numentries*sizeof(char*)); if (!entries) return 0; names=(char**)OVR_ALLOC(numentries*sizeof(char*)); if (!names) { OVR_FREE(entries); return 0; } memset(entries,0,sizeof(char*)*numentries); memset(names,0,sizeof(char*)*numentries); // Collect all the results into our arrays: depth++; if (fmt) len+=depth; JSON* child = Children.GetFirst(); while (!Children.IsNull(child)) { names[i] = str = PrintString(child->Name); entries[i++] = ret = child->PrintValue(depth, fmt); if (str && ret) { len += OVR_strlen(ret)+OVR_strlen(str)+2+(fmt?3+depth:0); } else { fail = true; break; } child = Children.GetNext(child); } // Try to allocate the output string if (!fail) out=(char*)OVR_ALLOC(len); if (!out) fail=true; // Handle failure if (fail) { for (i=0;i<numentries;i++) { if (names[i]) OVR_FREE(names[i]); if (entries[i]) OVR_FREE(entries[i]);} OVR_FREE(names); OVR_FREE(entries); return 0; } // Compose the output: *out = '{'; ptr = out+1; if (fmt) { #ifdef OVR_OS_WIN32 *ptr++ = '\r'; #endif *ptr++ = '\n'; } *ptr = 0; for (i=0; i<numentries; i++) { if (fmt) { for (j = 0; j < depth; j++) { *ptr++ = '\t'; } } OVR_strcpy(ptr, len - (ptr-out), names[i]); ptr += OVR_strlen(names[i]); *ptr++ =':'; if (fmt) { *ptr++ = '\t'; } OVR_strcpy(ptr, len - (ptr-out), entries[i]); ptr+=OVR_strlen(entries[i]); if (i != numentries - 1) { *ptr++ = ','; } if (fmt) { #ifdef OVR_OS_WIN32 *ptr++ = '\r'; #endif *ptr++ = '\n'; } *ptr = 0; OVR_FREE(names[i]); OVR_FREE(entries[i]); } OVR_FREE(names); OVR_FREE(entries); if (fmt) { for (i = 0; i < depth - 1; i++) { *ptr++ = '\t'; } } *ptr++='}'; *ptr++=0; return out; }
//----------------------------------------------------------------------------- // Render an array to text. The returned text must be freed char* JSON::PrintArray(int depth, bool fmt) { char ** entries; char * out = 0, *ptr,*ret; intptr_t len = 5; bool fail = false; // How many entries in the array? int numentries = GetItemCount(); if (!numentries) { out=(char*)OVR_ALLOC(3); if (out) OVR_strcpy(out, 3, "[]"); return out; } // Allocate an array to hold the values for each entries=(char**)OVR_ALLOC(numentries*sizeof(char*)); if (!entries) return 0; memset(entries,0,numentries*sizeof(char*)); //// Retrieve all the results: JSON* child = Children.GetFirst(); for (int i=0; i<numentries; i++) { //JSON* child = Children[i]; ret=child->PrintValue(depth+1, fmt); entries[i]=ret; if (ret) len+=OVR_strlen(ret)+2+(fmt?1:0); else { fail = true; break; } child = Children.GetNext(child); } // If we didn't fail, try to malloc the output string if (!fail) out=(char*)OVR_ALLOC(len); // If that fails, we fail. if (!out) fail = true; // Handle failure. if (fail) { for (int i=0; i<numentries; i++) { if (entries[i]) OVR_FREE(entries[i]); } OVR_FREE(entries); return 0; } // Compose the output array. *out='['; ptr=out+1; *ptr=0; for (int i=0; i<numentries; i++) { OVR_strcpy(ptr, len - (ptr-out), entries[i]); ptr+=OVR_strlen(entries[i]); if (i!=numentries-1) { *ptr++=','; if (fmt) *ptr++=' '; *ptr=0; } OVR_FREE(entries[i]); } OVR_FREE(entries); *ptr++=']'; *ptr++=0; return out; }
bool HMDDeviceCreateDesc::GetDeviceInfo(DeviceInfo* info) const { if ((info->InfoClassType != Device_HMD) && (info->InfoClassType != Device_None)) return false; #if defined(OVR_OS_ANDROID) // LDC - Use zero data for now. info->Version = 0; info->ProductName[0] = 0; info->Manufacturer[0] = 0; if (info->InfoClassType == Device_HMD) { HMDInfo* hmdInfo = static_cast<HMDInfo*>(info); *hmdInfo = HMDInfo(); } #else HmdTypeEnum hmdType = HmdType_DKProto; char const *deviceName = "Oculus Rift DK1-Prototype"; if ( Is7Inch() ) { hmdType = HmdType_DK1; deviceName = "Oculus Rift DK1"; } else if ( ResolutionInPixels.Width == 1920 ) { // DKHD protoypes, all 1920x1080 if ( ScreenSizeInMeters.Width < 0.121f ) { // Screen size 0.12096 x 0.06804 hmdType = HmdType_DKHDProto; deviceName = "Oculus Rift DK HD"; } else if ( ScreenSizeInMeters.Width < 0.126f ) { // Screen size 0.125 x 0.071 hmdType = HmdType_DKHDProto566Mi; deviceName = "Oculus Rift DK HD 566 Mi"; } else { // Screen size 0.1296 x 0.0729 hmdType = HmdType_DKHDProto585; deviceName = "Oculus Rift DK HD 585"; } } else { OVR_ASSERT ( "Unknown HMD" ); } OVR_strcpy(info->ProductName, DeviceInfo::MaxNameLength, deviceName ); OVR_strcpy(info->Manufacturer, DeviceInfo::MaxNameLength, "Oculus VR"); info->Type = Device_HMD; info->Version = 0; // Display detection. if (info->InfoClassType == Device_HMD) { HMDInfo* hmdInfo = static_cast<HMDInfo*>(info); hmdInfo->HmdType = hmdType; hmdInfo->DesktopX = Desktop.X; hmdInfo->DesktopY = Desktop.Y; hmdInfo->ResolutionInPixels = ResolutionInPixels; hmdInfo->ScreenSizeInMeters = ScreenSizeInMeters; // Includes ScreenGapSizeInMeters hmdInfo->ScreenGapSizeInMeters = 0.0f; hmdInfo->CenterFromTopInMeters = ScreenSizeInMeters.Height * 0.5f; hmdInfo->LensSeparationInMeters = 0.0635f; // TODO: any other information we get from the hardware itself should be added to this list switch ( hmdInfo->HmdType ) { case HmdType_DKProto: // WARNING - estimated. hmdInfo->Shutter.Type = HmdShutter_RollingTopToBottom; hmdInfo->Shutter.VsyncToNextVsync = ( 1.0f / 60.0f ); hmdInfo->Shutter.VsyncToFirstScanline = 0.000052f; hmdInfo->Shutter.FirstScanlineToLastScanline = 0.016580f; hmdInfo->Shutter.PixelSettleTime = 0.015f; // estimated. hmdInfo->Shutter.PixelPersistence = hmdInfo->Shutter.VsyncToNextVsync; // Full persistence break; case HmdType_DK1: // Data from specs. hmdInfo->Shutter.Type = HmdShutter_RollingTopToBottom; hmdInfo->Shutter.VsyncToNextVsync = ( 1.0f / 60.0f ); hmdInfo->Shutter.VsyncToFirstScanline = 0.00018226f; hmdInfo->Shutter.FirstScanlineToLastScanline = 0.01620089f; hmdInfo->Shutter.PixelSettleTime = 0.017f; // estimated. hmdInfo->Shutter.PixelPersistence = hmdInfo->Shutter.VsyncToNextVsync; // Full persistence break; case HmdType_DKHDProto: // Data from specs. hmdInfo->Shutter.Type = HmdShutter_RollingLeftToRight; hmdInfo->Shutter.VsyncToNextVsync = ( 1.0f / 60.0f ); hmdInfo->Shutter.VsyncToFirstScanline = 0.0000859f; hmdInfo->Shutter.FirstScanlineToLastScanline = 0.0164948f; hmdInfo->Shutter.PixelSettleTime = 0.012f; // estimated. hmdInfo->Shutter.PixelPersistence = hmdInfo->Shutter.VsyncToNextVsync; // Full persistence break; case HmdType_DKHDProto585: // Data from specs. hmdInfo->Shutter.Type = HmdShutter_RollingLeftToRight; hmdInfo->Shutter.VsyncToNextVsync = ( 1.0f / 60.0f ); hmdInfo->Shutter.VsyncToFirstScanline = 0.000052f; hmdInfo->Shutter.FirstScanlineToLastScanline = 0.016580f; hmdInfo->Shutter.PixelSettleTime = 0.015f; // estimated. hmdInfo->Shutter.PixelPersistence = hmdInfo->Shutter.VsyncToNextVsync; // Full persistence break; case HmdType_DKHDProto566Mi: #if 0 // Low-persistence global shutter hmdInfo->Shutter.Type = HmdShutter_Global; hmdInfo->Shutter.VsyncToNextVsync = ( 1.0f / 76.0f ); hmdInfo->Shutter.VsyncToFirstScanline = 0.0000273f + 0.0131033f; // Global shutter - first visible scan line is actually the last! hmdInfo->Shutter.FirstScanlineToLastScanline = 0.000f; // Global shutter - all visible at once. hmdInfo->Shutter.PixelSettleTime = 0.0f; // <100us hmdInfo->Shutter.PixelPersistence = 0.18f * hmdInfo->Shutter.VsyncToNextVsync; // Confgurable - currently set to 18% of total frame. #else // Low-persistence rolling shutter hmdInfo->Shutter.Type = HmdShutter_RollingLeftToRight; hmdInfo->Shutter.VsyncToNextVsync = ( 1.0f / 76.0f ); hmdInfo->Shutter.VsyncToFirstScanline = 0.0000273f; hmdInfo->Shutter.FirstScanlineToLastScanline = 0.0131033f; hmdInfo->Shutter.PixelSettleTime = 0.0f; // <100us hmdInfo->Shutter.PixelPersistence = 0.18f * hmdInfo->Shutter.VsyncToNextVsync; // Confgurable - currently set to 18% of total frame. #endif break; default: OVR_ASSERT ( false ); break; } OVR_strcpy(hmdInfo->DisplayDeviceName, sizeof(hmdInfo->DisplayDeviceName), DisplayDeviceName.ToCStr()); #if defined(OVR_OS_WIN32) // Nothing special for Win32. #elif defined(OVR_OS_MAC) hmdInfo->DisplayId = DisplayId; #elif defined(OVR_OS_LINUX) hmdInfo->DisplayId = DisplayId; #elif defined(OVR_OS_ANDROID) #else #error Unknown platform #endif } #endif return true; }
//============================================================================================== // ovrJob //============================================================================================== ovrJob::ovrJob( char const * name ) { OVR_strcpy( Name, sizeof( Name ), name ); }
bool HMDDeviceCreateDesc::GetDeviceInfo(DeviceInfo* info) const { if ((info->InfoClassType != Device_HMD) && (info->InfoClassType != Device_None)) return false; bool is7Inch = Is7Inch(); OVR_strcpy(info->ProductName, DeviceInfo::MaxNameLength, is7Inch ? "Oculus Rift DK1" : ((HResolution >= 1920) ? "Oculus Rift DK HD" : "Oculus Rift DK1-Prototype") ); OVR_strcpy(info->Manufacturer, DeviceInfo::MaxNameLength, "Oculus VR"); info->Type = Device_HMD; info->Version = 0; // Display detection. if (info->InfoClassType == Device_HMD) { HMDInfo* hmdInfo = static_cast<HMDInfo*>(info); hmdInfo->DesktopX = DesktopX; hmdInfo->DesktopY = DesktopY; hmdInfo->HResolution = HResolution; hmdInfo->VResolution = VResolution; hmdInfo->HScreenSize = HScreenSize; hmdInfo->VScreenSize = VScreenSize; hmdInfo->VScreenCenter = VScreenSize * 0.5f; hmdInfo->InterpupillaryDistance = 0.064f; // Default IPD; should be configurable. hmdInfo->LensSeparationDistance = 0.0635f; // Obtain IPD from profile. Ptr<Profile> profile = *GetProfileAddRef(); if (profile) { hmdInfo->InterpupillaryDistance = profile->GetIPD(); // TBD: Switch on EyeCup type. } if (Contents & Contents_Distortion) { memcpy(hmdInfo->DistortionK, DistortionK, sizeof(float)*4); } else { if (is7Inch) { // 7" screen. hmdInfo->DistortionK[0] = 1.0f; hmdInfo->DistortionK[1] = 0.22f; hmdInfo->DistortionK[2] = 0.24f; hmdInfo->EyeToScreenDistance = 0.041f; } else { hmdInfo->DistortionK[0] = 1.0f; hmdInfo->DistortionK[1] = 0.18f; hmdInfo->DistortionK[2] = 0.115f; if (HResolution == 1920) hmdInfo->EyeToScreenDistance = 0.040f; else hmdInfo->EyeToScreenDistance = 0.0387f; } hmdInfo->ChromaAbCorrection[0] = 0.996f; hmdInfo->ChromaAbCorrection[1] = -0.004f; hmdInfo->ChromaAbCorrection[2] = 1.014f; hmdInfo->ChromaAbCorrection[3] = 0.0f; } OVR_strcpy(hmdInfo->DisplayDeviceName, sizeof(hmdInfo->DisplayDeviceName), DisplayDeviceName.ToCStr()); } return true; }
ovrHmdDesc HMDRenderState::GetDesc() const { ovrHmdDesc d; memset(&d, 0, sizeof(d)); d.Type = ovrHmd_Other; d.ProductName = OurHMDInfo.ProductName; d.Manufacturer = OurHMDInfo.Manufacturer; d.Resolution.w = OurHMDInfo.ResolutionInPixels.w; d.Resolution.h = OurHMDInfo.ResolutionInPixels.h; d.WindowsPos.x = OurHMDInfo.DesktopX; d.WindowsPos.y = OurHMDInfo.DesktopY; d.DisplayDeviceName = OurHMDInfo.DisplayDeviceName; d.DisplayId = OurHMDInfo.DisplayId; d.VendorId = (short)OurHMDInfo.VendorId; d.ProductId = (short)OurHMDInfo.ProductId; d.FirmwareMajor = (short)OurHMDInfo.FirmwareMajor; d.FirmwareMinor = (short)OurHMDInfo.FirmwareMinor; d.CameraFrustumFarZInMeters = OurHMDInfo.CameraFrustumFarZInMeters; d.CameraFrustumHFovInRadians = OurHMDInfo.CameraFrustumHFovInRadians; d.CameraFrustumNearZInMeters = OurHMDInfo.CameraFrustumNearZInMeters; d.CameraFrustumVFovInRadians = OurHMDInfo.CameraFrustumVFovInRadians; OVR_strcpy(d.SerialNumber, sizeof(d.SerialNumber), OurHMDInfo.PrintedSerial.ToCStr()); d.HmdCaps = ovrHmdCap_Present | ovrHmdCap_NoVSync; d.TrackingCaps = ovrTrackingCap_MagYawCorrection | ovrTrackingCap_Orientation; d.DistortionCaps = ovrDistortionCap_Chromatic | ovrDistortionCap_TimeWarp | ovrDistortionCap_Vignette | ovrDistortionCap_SRGB | ovrDistortionCap_FlipInput | ovrDistortionCap_ProfileNoTimewarpSpinWaits | ovrDistortionCap_HqDistortion | ovrDistortionCap_LinuxDevFullscreen; if( OurHMDInfo.InCompatibilityMode ) d.HmdCaps |= ovrHmdCap_ExtendDesktop; if (strstr(OurHMDInfo.ProductName, "DK1")) { d.Type = ovrHmd_DK1; } else if (strstr(OurHMDInfo.ProductName, "DK2")) { d.Type = ovrHmd_DK2; d.HmdCaps |= ovrHmdCap_LowPersistence | ovrHmdCap_DynamicPrediction; d.TrackingCaps |= ovrTrackingCap_Position; d.DistortionCaps |= ovrDistortionCap_Overdrive; } const DistortionRenderDesc& leftDistortion = Distortion[0]; const DistortionRenderDesc& rightDistortion = Distortion[1]; // The suggested FOV (assuming eye rotation) d.DefaultEyeFov[0] = CalculateFovFromHmdInfo(StereoEye_Left, leftDistortion, RenderInfo, OVR_DEFAULT_EXTRA_EYE_ROTATION); d.DefaultEyeFov[1] = CalculateFovFromHmdInfo(StereoEye_Right, rightDistortion, RenderInfo, OVR_DEFAULT_EXTRA_EYE_ROTATION); // FOV extended across the entire screen d.MaxEyeFov[0] = GetPhysicalScreenFov(StereoEye_Left, leftDistortion); d.MaxEyeFov[1] = GetPhysicalScreenFov(StereoEye_Right, rightDistortion); if (OurHMDInfo.Shutter.Type == HmdShutter_RollingRightToLeft) { d.EyeRenderOrder[0] = ovrEye_Right; d.EyeRenderOrder[1] = ovrEye_Left; } else { d.EyeRenderOrder[0] = ovrEye_Left; d.EyeRenderOrder[1] = ovrEye_Right; } // MA: Taking this out on purpose. // Important information for those that are required to do their own timing, // because of shortfalls in timing code. //d.VsyncToNextVsync = OurHMDInfo.Shutter.VsyncToNextVsync; //d.PixelPersistence = OurHMDInfo.Shutter.PixelPersistence; return d; }