mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-12 02:52:10 +02:00
if overlapping calls, haptics take on strength and duration of call that will finish last
This commit is contained in:
parent
cea0d74c35
commit
b59d597780
3 changed files with 12 additions and 8 deletions
|
@ -253,16 +253,18 @@ bool OculusControllerManager::TouchDevice::triggerHapticPulse(float strength, fl
|
|||
Locker locker(_lock);
|
||||
bool toReturn = true;
|
||||
if (hand == controller::BOTH || hand == controller::LEFT) {
|
||||
if (ovr_SetControllerVibration(_parent._session, ovrControllerType_LTouch, 1.0f, strength) != ovrSuccess) {
|
||||
_leftHapticStrength = (duration > _leftHapticDuration) ? strength : _leftHapticStrength;
|
||||
if (ovr_SetControllerVibration(_parent._session, ovrControllerType_LTouch, 1.0f, _leftHapticStrength) != ovrSuccess) {
|
||||
toReturn = false;
|
||||
}
|
||||
_leftHapticDuration = duration;
|
||||
_leftHapticDuration = std::max(duration, _leftHapticDuration);
|
||||
}
|
||||
if (hand == controller::BOTH || hand == controller::RIGHT) {
|
||||
if (ovr_SetControllerVibration(_parent._session, ovrControllerType_RTouch, 1.0f, strength) != ovrSuccess) {
|
||||
_rightHapticStrength = (duration > _rightHapticDuration) ? strength : _rightHapticStrength;
|
||||
if (ovr_SetControllerVibration(_parent._session, ovrControllerType_RTouch, 1.0f, _rightHapticStrength) != ovrSuccess) {
|
||||
toReturn = false;
|
||||
}
|
||||
_rightHapticDuration = duration;
|
||||
_rightHapticDuration = std::max(duration, _rightHapticDuration);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,9 @@ private:
|
|||
void withLock(F&& f) { Locker locker(_lock); f(); }
|
||||
|
||||
float _leftHapticDuration { 0.0f };
|
||||
float _leftHapticStrength { 0.0f };
|
||||
float _rightHapticDuration { 0.0f };
|
||||
float _rightHapticStrength { 0.0f };
|
||||
mutable std::recursive_mutex _lock;
|
||||
|
||||
friend class OculusControllerManager;
|
||||
|
|
|
@ -455,12 +455,12 @@ void ViveControllerManager::InputDevice::handlePoseEvent(float deltaTime, const
|
|||
bool ViveControllerManager::InputDevice::triggerHapticPulse(float strength, float duration, controller::Hand hand) {
|
||||
Locker locker(_lock);
|
||||
if (hand == controller::BOTH || hand == controller::LEFT) {
|
||||
_leftHapticStrength = strength;
|
||||
_leftHapticDuration = duration;
|
||||
_leftHapticStrength = (duration > _leftHapticDuration) ? strength : _leftHapticStrength;
|
||||
_leftHapticDuration = std::max(duration, _leftHapticDuration);
|
||||
}
|
||||
if (hand == controller::BOTH || hand == controller::RIGHT) {
|
||||
_rightHapticStrength = strength;
|
||||
_rightHapticDuration = duration;
|
||||
_rightHapticStrength = (duration > _rightHapticDuration) ? strength : _rightHapticStrength;
|
||||
_rightHapticDuration = std::max(duration, _rightHapticDuration);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue