mozaSdk
Effect.h
1 #pragma once
2 #include <cstdint>
3 #include <string>
4 #include <dinput.h>
5 #include <memory>
6 #include <map>
7 namespace RS21::direct_input{
8 class Device;
9 extern unsigned int DI_MSECONDS;
21 class Effect
22 {
23 public:
31  void start();
39  void stop();
40 
50  void setAttackLevel(const unsigned long newAttackLevel = 0);
60  unsigned long attackLevel() const;
61 
71  unsigned long attackTime() const;
81  void setAttackTime(const unsigned long newAttackTime = 500);//单位:s
82 
92  unsigned long fadeLevel() const;
102  void setFadeLevel(const unsigned long newFadeLevel = 0);
103 
113  unsigned long fadeTime()const;
123  void setFadeTime(const unsigned long newFadeTime = 1000 );//
124 
134  unsigned long duration() const;
144  void setDuration(const unsigned long newDuration = 2000);
145 
155  unsigned long samplePeriod() const;
165  void setSamplePeriod(const unsigned long newSamplePeriod = 0);
166 
176  unsigned long gain() const;
185  void setGain(const unsigned long newGain = DI_FFNOMINALMAX);
186 
196  unsigned long triggerButton() const;
206  void setTriggerButton(const unsigned long newButtonIndex = DIEB_NOTRIGGER);
207 
217  unsigned long triggerRepeatInterval() const;
227  void setTriggerRepeatInterval(const unsigned long newRepeatInterval = 0);
228 
229 // void setCAxes(const unsigned long newCAxes = 2);
239  unsigned long rgdAxesCount();
249  unsigned long* rgdAxes();
261  void setRgdAxes(unsigned long* axes, unsigned long size);//设置轴,运行时不能修改,不建议修改,使用默认
262 
272  long xDirection();
282  void setXDirection(long newDegree = 1 );//设置x轴方向,单位:度
283 // void setEnvelope();//设置封装
284 // void virtual setCbTypeSpecificParams() = 0;//设置特殊参数长度
285 // void virtual setTypeSpecificParams() = 0;//设置特殊参数长度
286 
296  std::string effectName() const;
297 
307  void setEffectName(const std::string &newEffectName);
308 
309 
319  int index() const;
320 
330  void setIndex( unsigned int newIndex);
331 
332  bool m_isRunning = false;
333 protected:
334  Effect(Device* device);//抽象类,但是没有虚函数
335  ~Effect();//生命周期由device管理
336  virtual void downloadToDevice(LPDIRECTINPUTDEVICE8 device) = 0;
337  std::map<std::string, std::string> allGeneralEffectInfo();
338 protected:
339  uint16_t m_effectId;
340  std::string m_effectName;
341  LPDIRECTINPUTEFFECT m_effect = NULL;
342  DIEFFECT m_diEffect; //effect_info
343  DIENVELOPE m_diEnvelope; //effect_instance
344  LONG* m_lDirection = nullptr;
345  DWORD *m_dwAxes = nullptr;
346  Device* m_device = nullptr;//parent
347  unsigned int m_index = 0;
348 };
349 }//RS21::directInput
void stop()
stop Force effect
void start()
start Force effect
void setDuration(const unsigned long newDuration=2000)
set attenuation duration
void setFadeLevel(const unsigned long newFadeLevel=0)
Set attenuation level
void setXDirection(long newDegree=1)
Set the angle of the effect in the x-axis
void setSamplePeriod(const unsigned long newSamplePeriod=0)
set sampling period
unsigned long triggerRepeatInterval() const
Obtain trigger effect repetition interval
std::string m_effectName
Definition: Effect.h:340
Device * m_device
Definition: Effect.h:346
void setTriggerRepeatInterval(const unsigned long newRepeatInterval=0)
Set trigger effect repetition interval
unsigned long fadeTime() const
Obtain attenuation time
void setEffectName(const std::string &newEffectName)
set the name of the current effect
std::map< std::string, std::string > allGeneralEffectInfo()
DWORD * m_dwAxes
Definition: Effect.h:345
LONG * m_lDirection
Definition: Effect.h:344
Effect Abstract Class
Definition: Effect.h:21
unsigned long rgdAxesCount()
Number of effect related axes
DIEFFECT m_diEffect
Definition: Effect.h:342
long xDirection()
Obtain the angle of the effect in the x-axis
unsigned int m_index
Definition: Effect.h:347
unsigned long attackLevel() const
Obtain Power Level
void setGain(const unsigned long newGain=DI_FFNOMINALMAX)
set Gain
DIENVELOPE m_diEnvelope
Definition: Effect.h:343
unsigned long samplePeriod() const
Obtain sampling period
uint16_t m_effectId
Definition: Effect.h:339
bool m_isRunning
Definition: Effect.h:332
void setAttackLevel(const unsigned long newAttackLevel=0)
Set the power level
void setAttackTime(const unsigned long newAttackTime=500)
set Power time
unsigned long triggerButton() const
Obtain departure effect button
unsigned long attackTime() const
Obtain Power time
unsigned int DI_MSECONDS
unsigned long gain() const
Obtain Gain
unsigned long duration() const
Obtain attenuation duration
unsigned long * rgdAxes()
Obtain relevant axis array
unsigned long fadeLevel() const
Obtain attenuation level
void setFadeTime(const unsigned long newFadeTime=1000)
Set attenuation time
Definition: DeviceException.h:7
void setTriggerButton(const unsigned long newButtonIndex=DIEB_NOTRIGGER)
set departure effect button
void setRgdAxes(unsigned long *axes, unsigned long size)
Set related axes
void setIndex(unsigned int newIndex)
set the index of the current effect
std::string effectName() const
Obtain the name of the current effect
virtual void downloadToDevice(LPDIRECTINPUTDEVICE8 device)=0
LPDIRECTINPUTEFFECT m_effect
Definition: Effect.h:341
int index() const
Obtain the index of the current effect