OSVR_ReturnCode CombinedOrientationReader::update(OSVR_OrientationState* orientation, OSVR_TimeValue* timeValue) { OSVR_OrientationState orientation_x; OSVR_OrientationState orientation_y; OSVR_OrientationState orientation_z; OSVR_ReturnCode xret = osvrGetOrientationState(m_orientations[0], timeValue, &orientation_x); OSVR_ReturnCode yret = osvrGetOrientationState(m_orientations[1], timeValue, &orientation_y); OSVR_ReturnCode zret = osvrGetOrientationState(m_orientations[2], timeValue, &orientation_z); OSVR_Vec3 rpy_x; OSVR_Vec3 rpy_y; OSVR_Vec3 rpy_z; rpyFromQuaternion(&orientation_x, &rpy_x); rpyFromQuaternion(&orientation_y, &rpy_y); rpyFromQuaternion(&orientation_z, &rpy_z); OSVR_Vec3 rpy; osvrVec3SetX(&rpy, osvrVec3GetX(&rpy_x)); osvrVec3SetY(&rpy, osvrVec3GetY(&rpy_y)); osvrVec3SetZ(&rpy, osvrVec3GetZ(&rpy_z)); quaternionFromRPY(&rpy, orientation); return OSVR_RETURN_SUCCESS; }
void OSVRInterface::RefreshCapabilities() { #if OSVR_ENABLED if (OSVRClientInterface == nullptr) return; #if 0 // Detection currently doesn't work (v0.1-261-gb6c8db7) OSVR_TimeValue Time; OSVR_PositionState Position; OSVR_OrientationState Orientation; OSVR_ButtonState Button; OSVR_AnalogState Analog; OSVR_ReturnCode HasPositonState = osvrGetPositionState(OSVRClientInterface, &Time, &Position); Capabilities |= (HasPositonState == OSVR_RETURN_SUCCESS) ? POSITION_STATE_AVAILABLE : 0; OSVR_ReturnCode HasOrientationState = osvrGetOrientationState(OSVRClientInterface, &Time, &Orientation); Capabilities |= (HasOrientationState == OSVR_RETURN_SUCCESS) ? ORIENTATION_STATE_AVAILABLE : 0; OSVR_ReturnCode HasButtonState = osvrGetButtonState(OSVRClientInterface, &Time, &Button); Capabilities |= (HasButtonState == OSVR_RETURN_SUCCESS) ? BUTTON_STATE_AVAILABLE : 0; OSVR_ReturnCode HasAnalogState = osvrGetAnalogState(OSVRClientInterface, &Time, &Analog); Capabilities |= (HasAnalogState == OSVR_RETURN_SUCCESS) ? ANALOG_STATE_AVAILABLE : 0; #else Capabilities = POSITION_STATE_AVAILABLE | ORIENTATION_STATE_AVAILABLE | BUTTON_STATE_AVAILABLE | ANALOG_STATE_AVAILABLE; #endif #endif // OSVR_ENABLED }
// Simple HMD Detection OSVRWRAPPER_API bool OSVR_IsHMDDetected() { // Check Validity Of Context & Interface if(!IsHMDInit || !Context->checkStatus() || !HMD.notEmpty()) return false; // Attempt To Retrieve HMD Rotation OSVR_TimeValue timestamp; OSVR_OrientationState state; auto ret = osvrGetOrientationState(HMD.get(), ×tamp, &state); return (ret == OSVR_RETURN_SUCCESS); }
bool OSVRInterface::GetOrientation(FQuat& Value, bool Latest) const { if (Latest) { #if OSVR_ENABLED OSVR_TimeValue Time; OSVR_OrientationState Orientation; OSVR_ReturnCode ReturnCode = osvrGetOrientationState(OSVRClientInterface, &Time, &Orientation); Value = OSVR2FQuat(Orientation); return ReturnCode == OSVR_RETURN_SUCCESS; #endif // OSVR_ENABLED } else { Value = PoseState.GetRotation(); } return HasOrientationState(); }
OSVR_ReturnCode SingleOrientationReader::update(OSVR_OrientationState* orientation, OSVR_TimeValue* timeValue) { return osvrGetOrientationState(m_orientation, timeValue, orientation); }