uint32_t OSVRTrackedDeviceController::GetStringTrackedDeviceProperty(vr::ETrackedDeviceProperty prop, char *pchValue, uint32_t unBufferSize, vr::ETrackedPropertyError *pError) { uint32_t default_value = 0; if (isWrongDataType(prop, pchValue)) { if (pError) *pError = vr::TrackedProp_WrongDataType; return default_value; } if (isWrongDeviceClass(prop, deviceClass_)) { if (pError) *pError = vr::TrackedProp_WrongDeviceClass; return default_value; } if (vr::TrackedDeviceClass_Invalid == deviceClass_) { if (pError) *pError = vr::TrackedProp_InvalidDevice; return default_value; } std::string sValue = GetStringTrackedDeviceProperty(prop, pError); if (*pError == vr::TrackedProp_Success) { if (sValue.size() + 1 > unBufferSize) { *pError = vr::TrackedProp_BufferTooSmall; } else { valveStrCpy(sValue, pchValue, unBufferSize); } return static_cast<uint32_t>(sValue.size()) + 1; } return 0; }
uint32_t OSVRTrackedDeviceHandR::GetStringTrackedDeviceProperty(vr::ETrackedDeviceProperty prop, char *pchValue, uint32_t unBufferSize, vr::ETrackedPropertyError *pError) { uint32_t default_value = 0; if (isWrongDataType(prop, pchValue)) { if (pError) *pError = vr::TrackedProp_WrongDataType; return default_value; } if (isWrongDeviceClass(prop, deviceClass_)) { if (pError) *pError = vr::TrackedProp_WrongDeviceClass; return default_value; } if (vr::TrackedDeviceClass_Invalid == deviceClass_) { if (pError) *pError = vr::TrackedProp_InvalidDevice; return default_value; } if (logDebugProps) { const std::string msg = "OSVRTrackedDeviceHandR::GetFloatTrackedDeviceProperty(): Requested property: " + std::to_string(prop) + "\n"; logger_->Log(msg.c_str()); } std::string sValue = GetStringTrackedDeviceProperty(prop, pError); if (*pError == vr::TrackedProp_Success) { if (sValue.size() + 1 > unBufferSize) { *pError = vr::TrackedProp_BufferTooSmall; } else { valveStrCpy(sValue, pchValue, unBufferSize); } return static_cast<uint32_t>(sValue.size()) + 1; } return 0; }