wavelength 1.0.0
Loading...
Searching...
No Matches
forcefeedbackmgr.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6#include "os/ptr.h"
7
19public:
20 class BeatCmd;
21 class Controller;
22 class MotorEffect;
23
31
33 static constexpr int kMaxPlayers = 2;
34
36 static constexpr int kPadCount = 2;
37
45
53
62
75 void Start(const float *pTickDuration, int nTicksPerBar);
76
85 void StopAll();
86
98 void StartMetronome(int nPeriod, int nTick);
99
109
120 void SetBeatEnabled(int nPad, bool bEnabled);
121
134 void SetVibration(int nController, int nSmallMotor, int nBigMotor);
135
143 void PlayBumpEffect(int nController);
144
152 void PlayCrippleEffect(int nController);
153
161 void PlayAutocatchEffect(int nController);
162
173 void PlayEffect(int nController, int nEffect);
174
183 void Pause();
184
193 void Resume();
194
197 return mBeatCmd.Get();
198 }
199
201 const std::vector<std::unique_ptr<Controller>> &GetControllers() const {
202 return mControllers;
203 }
204
206 int GetEnabled() const {
207 return mEnabled;
208 }
209
210private:
211 Ptr<BeatCmd> mBeatCmd;
213 const float *mTickDuration;
214 std::vector<std::unique_ptr<Controller>> mControllers;
215 int mEnabled;
216 int mPaused;
217};
218
Command that runs the beat pulse once a period.
Definition forcefeedbackmgrbeatcmd.h:14
One player's controller, with its beat pulse and its effects.
Definition forcefeedbackmgrcontroller.h:14
One vibration pattern of a controller, which runs both motors for a duration.
Definition forcefeedbackmgrmotoreffect.h:14
Driver of the controllers' vibration motors during a song.
Definition forcefeedbackmgr.h:18
void SetBeatEnabled(int nPad, bool bEnabled)
Set whether the beat pulse drives one controller.
void Pause()
Stop the motors of both ports while the game is paused.
void Resume()
Read each controller's vibration option again and restore the motors Pause() stopped.
void PlayCrippleEffect(int nController)
Play the crippler effect on a controller while vibration is enabled.
const std::vector< std::unique_ptr< Controller > > & GetControllers() const
Definition forcefeedbackmgr.h:201
void StopMetronome()
Withdraw the beat pulse from the song scheduler.
static ForceFeedbackMgr * shared()
Report the single instance, constructing it on first use.
void PlayBumpEffect(int nController)
Play the bumper effect on a controller while vibration is enabled.
Effect
The effects of a controller, indices into Controller::mEffects.
Definition forcefeedbackmgr.h:25
@ kEffectAutocatch
Definition forcefeedbackmgr.h:28
@ kEffectCripple
Definition forcefeedbackmgr.h:26
@ kEffectCount
Definition forcefeedbackmgr.h:29
@ kEffectBump
Definition forcefeedbackmgr.h:27
void Start(const float *pTickDuration, int nTicksPerBar)
Prepare one controller for each player and enable vibration.
ForceFeedbackMgr()
Construct the manager with no controller and the beat pulse's command.
~ForceFeedbackMgr()
Delete every controller.
BeatCmd * GetBeatCmd()
Definition forcefeedbackmgr.h:196
static constexpr int kMaxPlayers
The most players Start() prepares controllers for.
Definition forcefeedbackmgr.h:33
void PlayAutocatchEffect(int nController)
Play the autocatcher effect on a controller while vibration is enabled.
void SetVibration(int nController, int nSmallMotor, int nBigMotor)
Record a controller's motor levels and pass them to its port.
void PlayEffect(int nController, int nEffect)
Cancel every effect of a controller and start one.
void StopAll()
Withdraw the beat pulse, cancel every effect, and disable vibration.
void StartMetronome(int nPeriod, int nTick)
Schedule the beat pulse at the first multiple of a period from a tick that still lies ahead.
static constexpr int kPadCount
The number of controller ports.
Definition forcefeedbackmgr.h:36
int GetEnabled() const
Definition forcefeedbackmgr.h:206
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.