OIS  1.5
Object-oriented Input System
OISEffect.h
Go to the documentation of this file.
1 /*
2 The zlib/libpng License
3 
4 Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
5 
6 This software is provided 'as-is', without any express or implied warranty. In no event will
7 the authors be held liable for any damages arising from the use of this software.
8 
9 Permission is granted to anyone to use this software for any purpose, including commercial
10 applications, and to alter it and redistribute it freely, subject to the following
11 restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not claim that
14  you wrote the original software. If you use this software in a product,
15  an acknowledgment in the product documentation would be appreciated but is
16  not required.
17 
18  2. Altered source versions must be plainly marked as such, and must not be
19  misrepresented as being the original software.
20 
21  3. This notice may not be removed or altered from any source distribution.
22 */
23 #ifndef OIS_Effect_H
24 #define OIS_Effect_H
25 
26 #include "OISPrereqs.h"
27 
28 namespace OIS
29 {
30  //Predeclare some Effect Property structs
31  class ForceEffect;
32  class ConstantEffect;
33  class RampEffect;
34  class PeriodicEffect;
35  class ConditionalEffect;
36 
48  {
49  public:
51  enum EForce {
52  UnknownForce = 0,
58  _ForcesNumber // Always keep in last position.
59  };
60 
61  static const char* getForceTypeName(EForce eValue);
62 
64  enum EType {
65  //Type ----- Pairs with force:
66  Unknown = 0, //UnknownForce
67  Constant, //ConstantForce
68  Ramp, //RampForce
69  Square, //PeriodicForce
70  Triangle, //PeriodicForce
71  Sine, //PeriodicForce
72  SawToothUp, //PeriodicForce
73  SawToothDown, //PeriodicForce
74  Friction, //ConditionalForce
75  Damper, //ConditionalForce
76  Inertia, //ConditionalForce
77  Spring, //ConditionalForce
78  Custom, //CustomForce
79  _TypesNumber // Always keep in last position.
80  };
81 
82  static const char* getEffectTypeName(EType eValue);
83 
85  enum EDirection {
94  _DirectionsNumber // Always keep in last position.
95  };
96 
97  static const char* getDirectionName(EDirection eValue);
98 
102  Effect(EForce ef, EType et);
103  virtual ~Effect();
104 
105  const EForce force;
106  const EType type;
107 
108  //Infinite Time
109  static const unsigned int OIS_INFINITE = 0xFFFFFFFF;
110 
111  //-------------------------------------------------------------------//
112  //--- Set these variables before uploading or modifying an effect ---//
113 
114  //Direction to apply to the force - affects two axes+ effects
116 
117  //Number of button triggering an effect (-1 means no trigger)
119 
120  //Time to wait before an effect can be re-triggered (microseconds)
121  unsigned int trigger_interval;
122 
123  //Duration of an effect (microseconds)
124  unsigned int replay_length;
125 
126  //Time to wait before to start playing an effect (microseconds)
127  unsigned int replay_delay;
128 
129  //Get the specific Force Effect. This should be cast depending on the EForce
130  ForceEffect* getForceEffect() const;
131 
138  void setNumAxes(short nAxes);
139 
144  short getNumAxes() const;
145 
146  //------------- Library Internal -------------------------------------//
152  mutable int _handle;
153 
154  protected:
155  // Prevent copying.
156  Effect(const Effect&);
157  Effect& operator=(Effect);
158 
159  ForceEffect* effect; //Properties depend on EForce
160  short axes; //Number of axes to use in effect
161  };
162 
163  //-----------------------------------------------------------------------------//
168  {
169  public:
170  virtual ~ForceEffect() {}
171  };
172 
173  //-----------------------------------------------------------------------------//
180  {
181  public:
183  attackLength(0), attackLevel(0), fadeLength(0), fadeLevel(0) {}
184 #if defined(OIS_MSVC_COMPILER)
185 #pragma warning(push)
186 #pragma warning(disable : 4800)
187 #endif
188  bool isUsed() const
189  {
190  return attackLength | attackLevel | fadeLength | fadeLevel;
191  }
192 #if defined(OIS_MSVC_COMPILER)
193 #pragma warning(pop)
194 #endif
195 
196  // Duration of the attack (microseconds)
197  unsigned int attackLength;
198 
199  // Absolute level at the beginning of the attack (0 to 10K)
200  // (automatically signed when necessary by FF core according to effect level sign)
201  unsigned short attackLevel;
202 
203  // Duration of fade (microseconds)
204  unsigned int fadeLength;
205 
206  // Absolute level at the end of fade (0 to 10K)
207  // (automatically signed when necessary by FF core according to effect level sign)
208  unsigned short fadeLevel;
209  };
210 
211  //-----------------------------------------------------------------------------//
216  {
217  public:
219  level(5000) {}
220 
221  Envelope envelope; //Optional envolope
222  signed short level; //-10K to +10k
223  };
224 
225  //-----------------------------------------------------------------------------//
230  {
231  public:
233  startLevel(0), endLevel(0) {}
234 
235  Envelope envelope; //Optional envelope
236  signed short startLevel; //-10K to +10k
237  signed short endLevel; //-10K to +10k
238  };
239 
240  //-----------------------------------------------------------------------------//
245  {
246  public:
248  magnitude(0), offset(0), phase(0), period(0) {}
249 
250  Envelope envelope; //Optional Envelope
251 
252  unsigned short magnitude; //0 to 10,0000
253  signed short offset;
254  unsigned short phase; //Position at which playback begins 0 to 35,999
255  unsigned int period; //Period of effect (microseconds)
256  };
257 
258  //-----------------------------------------------------------------------------//
263  {
264  public:
266  rightCoeff(0), leftCoeff(0), rightSaturation(0), leftSaturation(0),
267  deadband(0), center(0) {}
268 
269  signed short rightCoeff; //-10k to +10k (Positive Coeff)
270  signed short leftCoeff; //-10k to +10k (Negative Coeff)
271 
272  unsigned short rightSaturation; //0 to 10k (Pos Saturation)
273  unsigned short leftSaturation; //0 to 10k (Neg Saturation)
274 
275  //Region around center in which the condition is not active, in the range
276  //from 0 through 10,000
277  unsigned short deadband;
278 
279  //(Offset in DX) -10k and 10k
280  signed short center;
281  };
282 }
283 #endif //OIS_Effect_H
Definition: OISEffect.h:70
EDirection
Direction of the Force.
Definition: OISEffect.h:85
Definition: OISEffect.h:72
Definition: OISEffect.h:75
EDirection direction
Definition: OISEffect.h:115
Envelope envelope
Definition: OISEffect.h:235
unsigned int attackLength
Definition: OISEffect.h:197
Envelope()
Definition: OISEffect.h:182
unsigned short magnitude
Definition: OISEffect.h:252
Definition: OISEffect.h:69
const EForce force
Definition: OISEffect.h:105
#define _OISExport
Definition: OISPrereqs.h:40
Definition: OISEffect.h:78
EType
Type of effect.
Definition: OISEffect.h:64
unsigned short rightSaturation
Definition: OISEffect.h:272
Definition: OISEffect.h:71
short trigger_button
Definition: OISEffect.h:118
unsigned short fadeLevel
Definition: OISEffect.h:208
Definition: OISEffect.h:47
signed short level
Definition: OISEffect.h:222
unsigned int fadeLength
Definition: OISEffect.h:204
unsigned short leftSaturation
Definition: OISEffect.h:273
Definition: OISEffect.h:167
Definition: OISEffect.h:244
unsigned short deadband
Definition: OISEffect.h:277
Definition: OISEffect.h:76
Definition: OISEffect.h:93
short axes
Definition: OISEffect.h:160
unsigned int replay_length
Definition: OISEffect.h:124
Definition: OISEffect.h:179
const EType type
Definition: OISEffect.h:106
unsigned int trigger_interval
Definition: OISEffect.h:121
signed short startLevel
Definition: OISEffect.h:236
Definition: OISEffect.h:57
Definition: OISEffect.h:53
Definition: OISEffect.h:262
Definition: OISEffect.h:74
signed short center
Definition: OISEffect.h:280
Definition: OISEffect.h:73
unsigned short attackLevel
Definition: OISEffect.h:201
PeriodicEffect()
Definition: OISEffect.h:247
ConstantEffect()
Definition: OISEffect.h:218
signed short rightCoeff
Definition: OISEffect.h:269
Definition: OISEffect.h:86
EForce
Type of force.
Definition: OISEffect.h:51
Definition: OISEffect.h:56
Definition: OISEffect.h:92
Definition: OISEffect.h:88
Definition: OISEffect.h:87
bool isUsed() const
Definition: OISEffect.h:188
Definition: OISEffect.h:68
unsigned int replay_delay
Definition: OISEffect.h:127
Definition: OISEffect.h:215
signed short endLevel
Definition: OISEffect.h:237
RampEffect()
Definition: OISEffect.h:232
Definition: OISEffect.h:89
unsigned short phase
Definition: OISEffect.h:254
Definition: OISEffect.h:67
Definition: OISEffect.h:90
ForceEffect * effect
Definition: OISEffect.h:159
int _handle
Definition: OISEffect.h:152
Definition: OISEffect.h:55
signed short offset
Definition: OISEffect.h:253
Envelope envelope
Definition: OISEffect.h:221
ConditionalEffect()
Definition: OISEffect.h:265
virtual ~ForceEffect()
Definition: OISEffect.h:170
Definition: OISEffect.h:54
Definition: OISEffect.h:91
Definition: OISEffect.h:229
Definition: OISEffect.h:28
Envelope envelope
Definition: OISEffect.h:250
signed short leftCoeff
Definition: OISEffect.h:270
Definition: OISEffect.h:77
unsigned int period
Definition: OISEffect.h:255