00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef OIS_Effect_H
00024 #define OIS_Effect_H
00025
00026 #include "OISPrereqs.h"
00027
00028 namespace OIS
00029 {
00030
00031 struct ForceEffect;
00032 struct ConstantEffect;
00033 struct RampEffect;
00034 struct PeriodicEffect;
00035 struct ConditionalEffect;
00036
00047 class _OISExport Effect
00048 {
00052 Effect();
00053 public:
00055 enum EForce
00056 {
00057 UnknownForce = 0,
00058 ConstantForce,
00059 RampForce,
00060 PeriodicForce,
00061 ConditionalForce,
00062 CustomForce
00063 };
00064
00066 enum EType
00067 {
00068
00069 Unknown = 0,
00070 Constant,
00071 Ramp,
00072 Square,
00073 Triangle,
00074 Sine,
00075 SawToothUp,
00076 SawToothDown,
00077 Friction,
00078 Damper,
00079 Inertia,
00080 Spring,
00081 Custom
00082 };
00083
00085 enum EDirection
00086 {
00087 NorthWest,
00088 North,
00089 NorthEast,
00090 East,
00091 SouthEast,
00092 South,
00093 SouthWest,
00094 West
00095 };
00096
00100 Effect(EForce ef, EType et);
00101 virtual ~Effect();
00102
00103 const EForce force;
00104 const EType type;
00105
00106
00107 static const unsigned int OIS_INFINITE = 0xFFFFFFFF;
00108
00109
00110
00111
00112
00113 EDirection direction;
00114
00115
00116 short trigger_button;
00117
00118
00119 unsigned int trigger_interval;
00120
00121
00122 unsigned int replay_length;
00123
00124
00125 unsigned int replay_delay;
00126
00127
00128 ForceEffect* getForceEffect() const;
00129
00136 void setNumAxes(short nAxes);
00137
00142 short getNumAxes() const;
00143
00144
00150 mutable int _handle;
00151 protected:
00152 ForceEffect* effect;
00153 short axes;
00154 };
00155
00156
00160 struct _OISExport ForceEffect
00161 {
00162 virtual ~ForceEffect() {}
00163 };
00164
00165
00171 struct _OISExport Envelope : public ForceEffect
00172 {
00173 Envelope() : attackLength(0), attackLevel(0), fadeLength(0), fadeLevel(0) {}
00174 #if defined(OIS_MSVC_COMPILER)
00175 #pragma warning (push)
00176 #pragma warning (disable : 4800)
00177 #endif
00178 bool isUsed() { return attackLength | attackLevel | fadeLength | fadeLevel; }
00179 #if defined(OIS_MSVC_COMPILER)
00180 #pragma warning (pop)
00181 #endif
00182
00183 unsigned short attackLength;
00184 unsigned short attackLevel;
00185 unsigned short fadeLength;
00186 unsigned short fadeLevel;
00187 };
00188
00189
00193 struct _OISExport ConstantEffect : public ForceEffect
00194 {
00195 ConstantEffect() : level(5000) {}
00196
00197 struct Envelope envelope;
00198 signed short level;
00199 };
00200
00201
00205 struct _OISExport RampEffect : public ForceEffect
00206 {
00207 RampEffect() : startLevel(0), endLevel(0) {}
00208
00209 struct Envelope envelope;
00210 signed short startLevel;
00211 signed short endLevel;
00212 };
00213
00214
00218 struct _OISExport PeriodicEffect : public ForceEffect
00219 {
00220 PeriodicEffect() : magnitude(0), offset(0), phase(0), period(0) {}
00221
00222 struct Envelope envelope;
00223
00224 unsigned short magnitude;
00225 signed short offset;
00226 unsigned short phase;
00227 unsigned int period;
00228 };
00229
00230
00234 struct _OISExport ConditionalEffect : public ForceEffect
00235 {
00236 ConditionalEffect() :
00237 rightCoeff(0), leftCoeff(0), rightSaturation(0), leftSaturation(0),
00238 deadband(0), center(0) {}
00239
00240 signed short rightCoeff;
00241 signed short leftCoeff;
00242
00243 unsigned short rightSaturation;
00244 unsigned short leftSaturation;
00245
00246
00247
00248 unsigned short deadband;
00249
00250
00251 signed short center;
00252 };
00253 }
00254 #endif //OIS_Effect_H