Created
October 24, 2016 23:33
-
-
Save jeremyselan/d567b427298d46e1f9882333b6af5a94 to your computer and use it in GitHub Desktop.
OpenVR GetStringTrackedDeviceProperty Wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::string GetStringTrackedDeviceProperty( vr::IVRSystem * pSystem, vr::TrackedDeviceIndex_t unDeviceIndex, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *pError ) | |
{ | |
vr::ETrackedPropertyError err = TrackedProp_Success; | |
std::string sRetVal; | |
char buf[32]; | |
uint32_t unPropLen = pSystem->GetStringTrackedDeviceProperty( unDeviceIndex, prop, buf, sizeof( buf ), &err ); | |
if ( err == vr::TrackedProp_Success ) | |
{ | |
sRetVal = buf; | |
} | |
else if ( err == vr::TrackedProp_BufferTooSmall ) | |
{ | |
char *pchBuffer = new char[unPropLen]; | |
unPropLen = pSystem->GetStringTrackedDeviceProperty( unDeviceIndex, prop, pchBuffer, unPropLen, &err ); | |
if ( err == vr::TrackedProp_Success ) | |
{ | |
sRetVal = pchBuffer; | |
} | |
delete[] pchBuffer; | |
} | |
if ( pError ) | |
{ | |
*pError = err; | |
} | |
return sRetVal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice wrapper, I was about to write one similar!