wavelength 1.0.0
Loading...
Searching...
No Matches
forcefeedbackmgrmotoreffect.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/command.h"
5#include "os/ptr.h"
6#include "os/scheduler.h"
7
15public:
16 class OffCmd;
17
28 MotorEffect(int nController, int nSmallMotor, int nBigMotor, int nDuration);
29
32 Cancel();
33 }
34
43 void Cancel() {
44 if (mActive) {
45 mActive = 0;
46 TheForceFeedbackMgr->SetVibration(mController, 0, 0);
47 TheSongScheduler.Cancel(mOffCmd.Get());
48 }
49 }
50
56 void Start() {
57 if (mActive) {
58 Cancel();
59 }
60 mActive = 1;
61 TheForceFeedbackMgr->SetVibration(mController, mSmallMotor, mBigMotor);
62 TheSongScheduler.PostIn(mOffCmd.Get(), mDuration, false);
63 }
64
76 void SetMotors(int nController, int nSmallMotor, int nBigMotor) {
77 TheForceFeedbackMgr->SetVibration(nController, nSmallMotor, nBigMotor);
78 }
79
81 int GetController() const {
82 return mController;
83 }
84
86 int GetActive() const {
87 return mActive;
88 }
89
95 void SetActive(int nActive) {
96 mActive = nActive;
97 }
98
99private:
100 int mController;
101 int mSmallMotor;
102 int mBigMotor;
103 int mDuration;
104 Ptr<Command> mOffCmd;
105 int mActive;
106};
Command that ends a MotorEffect once its duration has passed.
Definition forcefeedbackmgrmotoreffectoffcmd.h:11
One vibration pattern of a controller, which runs both motors for a duration.
Definition forcefeedbackmgrmotoreffect.h:14
void Start()
Start the effect again from its beginning.
Definition forcefeedbackmgrmotoreffect.h:56
~MotorEffect()
Cancel the effect.
Definition forcefeedbackmgrmotoreffect.h:31
MotorEffect(int nController, int nSmallMotor, int nBigMotor, int nDuration)
Construct an effect that is not running, with the command that ends it.
int GetController() const
Definition forcefeedbackmgrmotoreffect.h:81
int GetActive() const
Definition forcefeedbackmgrmotoreffect.h:86
void SetActive(int nActive)
Set whether the effect runs.
Definition forcefeedbackmgrmotoreffect.h:95
void Cancel()
Stop the motors and withdraw the command that ends the effect, when the effect runs.
Definition forcefeedbackmgrmotoreffect.h:43
void SetMotors(int nController, int nSmallMotor, int nBigMotor)
Pass motor levels to the manager.
Definition forcefeedbackmgrmotoreffect.h:76
Owner of one reference to an Attachment.
Definition ptr.h:16
ForceFeedbackMgr * TheForceFeedbackMgr
The vibration manager, ForceFeedbackMgr::shared() as the unit's static initialiser stored it.
Scheduler TheSongScheduler
The scheduler of the song clock.