Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hud3/src/ois/OISEffect.cpp @ 1344

Last change on this file since 1344 was 1219, checked in by rgrieder, 17 years ago

merged input branch back to trunk. Not yet tested on tardis

File size: 2.8 KB
Line 
1/*
2The zlib/libpng License
3
4Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
5
6This software is provided 'as-is', without any express or implied warranty. In no event will
7the authors be held liable for any damages arising from the use of this software.
8
9Permission is granted to anyone to use this software for any purpose, including commercial
10applications, and to alter it and redistribute it freely, subject to the following
11restrictions:
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#include "OISEffect.h"
24#include "OISException.h"
25
26using namespace OIS;
27
28//VC7.1 had a problem with these not getting included..
29//Perhaps a case of a crazy extreme optimizer :/ (moved to header)
30//const unsigned int Effect::OIS_INFINITE = 0xFFFFFFFF;
31
32//------------------------------------------------------------------------------//
33Effect::Effect() : 
34        force(UnknownForce), 
35        type(Unknown),
36        effect(0),
37        axes(1)
38{
39}
40
41//------------------------------------------------------------------------------//
42Effect::Effect(EForce ef, EType et) : 
43        force(ef), 
44        type(et),
45        direction(North), 
46        trigger_button(-1),
47        trigger_interval(0),
48        replay_length(Effect::OIS_INFINITE),
49        replay_delay(0),
50        _handle(-1),
51        axes(1)
52{
53        effect = 0;
54
55        switch( ef )
56        {
57        case ConstantForce:    effect = new ConstantEffect(); break;
58        case RampForce:        effect = new RampEffect(); break;
59        case PeriodicForce:    effect = new PeriodicEffect(); break;
60        case ConditionalForce: effect = new ConditionalEffect(); break;
61        default: break;
62        }
63}
64
65//------------------------------------------------------------------------------//
66Effect::~Effect()
67{
68        delete effect;
69}
70
71//------------------------------------------------------------------------------//
72ForceEffect* Effect::getForceEffect() const
73{
74        //If no effect was created in constructor, then we raise an error here
75        if( effect == 0 )
76                OIS_EXCEPT( E_NotSupported, "Requested ForceEffect is null!" );
77
78        return effect;
79}
80
81//------------------------------------------------------------------------------//
82void Effect::setNumAxes(short nAxes)
83{
84        //Can only be set before a handle was assigned (effect created)
85        if( _handle != -1 )
86        axes = nAxes;
87}
88
89//------------------------------------------------------------------------------//
90short Effect::getNumAxes() const
91{
92        return axes;
93}
Note: See TracBrowser for help on using the repository browser.