History

can set strength to 0

SamGondelman committed 10 years ago

Commit ff240541 parent 7a3cba82 files · +32 −12Browse files

Showing the changes to plugins/oculus/src/OculusControllerManager.cpp (1 of 2 files). Show all

Unified · Split

plugins/oculus/src/OculusControllerManager.cpp+18−8
@@ -253,18 +253,28 @@ bool OculusControllerManager::TouchDevice::triggerHapticPulse(float strength, fl · 252 unmodified lines
253253 Locker locker(_lock);
254254 bool toReturn = true;
255255 if (hand == controller::BOTH || hand == controller::LEFT) {
256− _leftHapticStrength = (duration > _leftHapticDuration) ? strength : _leftHapticStrength;
257− if (ovr_SetControllerVibration(_parent._session, ovrControllerType_LTouch, 1.0f, _leftHapticStrength) != ovrSuccess) {
258− toReturn = false;
256+ if (strength == 0.0f) {
257+ _leftHapticStrength = 0.0f;
258+ _leftHapticDuration = 0.0f;
259+ } else {
260+ _leftHapticStrength = (duration > _leftHapticDuration) ? strength : _leftHapticStrength;
261+ if (ovr_SetControllerVibration(_parent._session, ovrControllerType_LTouch, 1.0f, _leftHapticStrength) != ovrSuccess) {
262+ toReturn = false;
263+ }
264+ _leftHapticDuration = std::max(duration, _leftHapticDuration);
259265 }
260− _leftHapticDuration = std::max(duration, _leftHapticDuration);
261266 }
262267 if (hand == controller::BOTH || hand == controller::RIGHT) {
263− _rightHapticStrength = (duration > _rightHapticDuration) ? strength : _rightHapticStrength;
264− if (ovr_SetControllerVibration(_parent._session, ovrControllerType_RTouch, 1.0f, _rightHapticStrength) != ovrSuccess) {
265− toReturn = false;
268+ if (strength == 0.0f) {
269+ _rightHapticStrength = 0.0f;
270+ _rightHapticDuration = 0.0f;
271+ } else {
272+ _rightHapticStrength = (duration > _rightHapticDuration) ? strength : _rightHapticStrength;
273+ if (ovr_SetControllerVibration(_parent._session, ovrControllerType_RTouch, 1.0f, _rightHapticStrength) != ovrSuccess) {
274+ toReturn = false;
275+ }
276+ _rightHapticDuration = std::max(duration, _rightHapticDuration);
266277 }
267− _rightHapticDuration = std::max(duration, _rightHapticDuration);
268278 }
269279 return toReturn;
270280 }