MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / UpdateRumble

Function UpdateRumble

TombEngine/Specific/Input/Input.cpp:619–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

617 }
618
619 static void UpdateRumble()
620 {
621 if (!OisRumble || !OisEffect || !RumbleInfo.Power)
622 return;
623
624 RumbleInfo.Power -= RumbleInfo.FadeSpeed;
625
626 // Don't update effect too frequently if its value hasn't changed much.
627 if (RumbleInfo.Power >= 0.2f && (RumbleInfo.LastPower - RumbleInfo.Power) < 0.1f)
628 return;
629
630 if (RumbleInfo.Power <= 0.0f)
631 {
632 StopRumble();
633 return;
634 }
635
636 try
637 {
638 auto& force = *dynamic_cast<OIS::ConstantEffect*>(OisEffect->getForceEffect());
639 force.level = RumbleInfo.Power * 10000;
640
641 switch (RumbleInfo.Mode)
642 {
643 case RumbleMode::Left:
644 OisEffect->direction = OIS::Effect::EDirection::West;
645 break;
646
647 case RumbleMode::Right:
648 OisEffect->direction = OIS::Effect::EDirection::East;
649 break;
650
651 case RumbleMode::Both:
652 OisEffect->direction = OIS::Effect::EDirection::North;
653 break;
654 }
655
656 OisRumble->upload(OisEffect);
657 }
658 catch (OIS::Exception& ex)
659 {
660 TENLog("Error updating vibration effect: " + std::string(ex.eText), LogLevel::Error);
661 }
662
663 RumbleInfo.LastPower = RumbleInfo.Power;
664 }
665
666 void UpdateInputActions(bool allowAsyncUpdate, bool applyQueue)
667 {

Callers 1

UpdateInputActionsFunction · 0.85

Calls 2

StopRumbleFunction · 0.85
TENLogFunction · 0.85

Tested by

no test coverage detected