mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 02:48:12 +02:00
can set strength to 0
This commit is contained in:
parent
7a3cba8580
commit
ff2405437b
2 changed files with 32 additions and 12 deletions
|
@ -253,18 +253,28 @@ bool OculusControllerManager::TouchDevice::triggerHapticPulse(float strength, fl
|
||||||
Locker locker(_lock);
|
Locker locker(_lock);
|
||||||
bool toReturn = true;
|
bool toReturn = true;
|
||||||
if (hand == controller::BOTH || hand == controller::LEFT) {
|
if (hand == controller::BOTH || hand == controller::LEFT) {
|
||||||
_leftHapticStrength = (duration > _leftHapticDuration) ? strength : _leftHapticStrength;
|
if (strength == 0.0f) {
|
||||||
if (ovr_SetControllerVibration(_parent._session, ovrControllerType_LTouch, 1.0f, _leftHapticStrength) != ovrSuccess) {
|
_leftHapticStrength = 0.0f;
|
||||||
toReturn = false;
|
_leftHapticDuration = 0.0f;
|
||||||
|
} else {
|
||||||
|
_leftHapticStrength = (duration > _leftHapticDuration) ? strength : _leftHapticStrength;
|
||||||
|
if (ovr_SetControllerVibration(_parent._session, ovrControllerType_LTouch, 1.0f, _leftHapticStrength) != ovrSuccess) {
|
||||||
|
toReturn = false;
|
||||||
|
}
|
||||||
|
_leftHapticDuration = std::max(duration, _leftHapticDuration);
|
||||||
}
|
}
|
||||||
_leftHapticDuration = std::max(duration, _leftHapticDuration);
|
|
||||||
}
|
}
|
||||||
if (hand == controller::BOTH || hand == controller::RIGHT) {
|
if (hand == controller::BOTH || hand == controller::RIGHT) {
|
||||||
_rightHapticStrength = (duration > _rightHapticDuration) ? strength : _rightHapticStrength;
|
if (strength == 0.0f) {
|
||||||
if (ovr_SetControllerVibration(_parent._session, ovrControllerType_RTouch, 1.0f, _rightHapticStrength) != ovrSuccess) {
|
_rightHapticStrength = 0.0f;
|
||||||
toReturn = false;
|
_rightHapticDuration = 0.0f;
|
||||||
|
} else {
|
||||||
|
_rightHapticStrength = (duration > _rightHapticDuration) ? strength : _rightHapticStrength;
|
||||||
|
if (ovr_SetControllerVibration(_parent._session, ovrControllerType_RTouch, 1.0f, _rightHapticStrength) != ovrSuccess) {
|
||||||
|
toReturn = false;
|
||||||
|
}
|
||||||
|
_rightHapticDuration = std::max(duration, _rightHapticDuration);
|
||||||
}
|
}
|
||||||
_rightHapticDuration = std::max(duration, _rightHapticDuration);
|
|
||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
|
@ -455,12 +455,22 @@ void ViveControllerManager::InputDevice::handlePoseEvent(float deltaTime, const
|
||||||
bool ViveControllerManager::InputDevice::triggerHapticPulse(float strength, float duration, controller::Hand hand) {
|
bool ViveControllerManager::InputDevice::triggerHapticPulse(float strength, float duration, controller::Hand hand) {
|
||||||
Locker locker(_lock);
|
Locker locker(_lock);
|
||||||
if (hand == controller::BOTH || hand == controller::LEFT) {
|
if (hand == controller::BOTH || hand == controller::LEFT) {
|
||||||
_leftHapticStrength = (duration > _leftHapticDuration) ? strength : _leftHapticStrength;
|
if (strength == 0.0f) {
|
||||||
_leftHapticDuration = std::max(duration, _leftHapticDuration);
|
_leftHapticStrength = 0.0f;
|
||||||
|
_leftHapticDuration = 0.0f;
|
||||||
|
} else {
|
||||||
|
_leftHapticStrength = (duration > _leftHapticDuration) ? strength : _leftHapticStrength;
|
||||||
|
_leftHapticDuration = std::max(duration, _leftHapticDuration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (hand == controller::BOTH || hand == controller::RIGHT) {
|
if (hand == controller::BOTH || hand == controller::RIGHT) {
|
||||||
_rightHapticStrength = (duration > _rightHapticDuration) ? strength : _rightHapticStrength;
|
if (strength == 0.0f) {
|
||||||
_rightHapticDuration = std::max(duration, _rightHapticDuration);
|
_rightHapticStrength = 0.0f;
|
||||||
|
_rightHapticDuration = 0.0f;
|
||||||
|
} else {
|
||||||
|
_rightHapticStrength = (duration > _rightHapticDuration) ? strength : _rightHapticStrength;
|
||||||
|
_rightHapticDuration = std::max(duration, _rightHapticDuration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue