| [1505] | 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_ForceFeedBack_H | 
|---|
|  | 24 | #define OIS_ForceFeedBack_H | 
|---|
|  | 25 |  | 
|---|
|  | 26 | #include "OISPrereqs.h" | 
|---|
|  | 27 | #include "OISInterface.h" | 
|---|
|  | 28 | #include "OISEffect.h" | 
|---|
|  | 29 |  | 
|---|
|  | 30 | namespace OIS | 
|---|
|  | 31 | { | 
|---|
|  | 32 | /** | 
|---|
|  | 33 | Interface class for dealing with Force Feedback devices | 
|---|
|  | 34 | */ | 
|---|
|  | 35 | class _OISExport ForceFeedback : public Interface | 
|---|
|  | 36 | { | 
|---|
|  | 37 | public: | 
|---|
| [5695] | 38 | ForceFeedback(); | 
|---|
| [1505] | 39 | virtual ~ForceFeedback() {} | 
|---|
|  | 40 |  | 
|---|
|  | 41 | /** | 
|---|
|  | 42 | @remarks | 
|---|
|  | 43 | This is like setting the master volume of an audio device. | 
|---|
|  | 44 | Individual effects have gain levels; however, this affects all | 
|---|
|  | 45 | effects at once. | 
|---|
| [5695] | 46 | Note: If the device does not support master gain setting, nothing is done | 
|---|
| [1505] | 47 | @param level | 
|---|
|  | 48 | A value between 0.0 and 1.0 represent the percentage of gain. 1.0 | 
|---|
|  | 49 | being the highest possible force level (means no scaling). | 
|---|
|  | 50 | */ | 
|---|
|  | 51 | virtual void setMasterGain( float level ) = 0; | 
|---|
|  | 52 |  | 
|---|
|  | 53 | /** | 
|---|
|  | 54 | @remarks | 
|---|
|  | 55 | If using Force Feedback effects, this should be turned off | 
|---|
|  | 56 | before uploading any effects. Auto centering is the motor moving | 
|---|
|  | 57 | the joystick back to center. DirectInput only has an on/off setting, | 
|---|
|  | 58 | whereas linux has levels.. Though, we go with DI's on/off mode only | 
|---|
| [5695] | 59 | Note: If the device does not support auto-centering, nothing is done | 
|---|
| [1505] | 60 | @param auto_on | 
|---|
|  | 61 | true to turn auto centering on, false to turn off. | 
|---|
|  | 62 | */ | 
|---|
|  | 63 | virtual void setAutoCenterMode( bool auto_on ) = 0; | 
|---|
|  | 64 |  | 
|---|
|  | 65 | /** | 
|---|
|  | 66 | @remarks | 
|---|
|  | 67 | Creates and Plays the effect immediately. If the device is full | 
|---|
|  | 68 | of effects, it will fail to be uploaded. You will know this by | 
|---|
|  | 69 | an invalid Effect Handle | 
|---|
|  | 70 | */ | 
|---|
|  | 71 | virtual void upload( const Effect* effect ) = 0; | 
|---|
|  | 72 |  | 
|---|
|  | 73 | /** | 
|---|
|  | 74 | @remarks | 
|---|
|  | 75 | Modifies an effect that is currently playing | 
|---|
|  | 76 | */ | 
|---|
|  | 77 | virtual void modify( const Effect* effect ) = 0; | 
|---|
|  | 78 |  | 
|---|
|  | 79 | /** | 
|---|
|  | 80 | @remarks | 
|---|
|  | 81 | Remove the effect from the device | 
|---|
|  | 82 | */ | 
|---|
|  | 83 | virtual void remove( const Effect* effect ) = 0; | 
|---|
|  | 84 |  | 
|---|
|  | 85 | /** | 
|---|
|  | 86 | @remarks | 
|---|
|  | 87 | Get the number of supported Axes for FF usage | 
|---|
|  | 88 | */ | 
|---|
|  | 89 | virtual short getFFAxesNumber() = 0; | 
|---|
|  | 90 |  | 
|---|
|  | 91 | /** | 
|---|
|  | 92 | @remarks | 
|---|
| [5695] | 93 | Get the current load (%, in [0, 100] of the FF device memory | 
|---|
|  | 94 | */ | 
|---|
|  | 95 | virtual unsigned short getFFMemoryLoad() = 0; | 
|---|
|  | 96 |  | 
|---|
|  | 97 | typedef std::multimap<Effect::EForce, Effect::EType> SupportedEffectList; | 
|---|
|  | 98 | /** | 
|---|
|  | 99 | @remarks | 
|---|
| [1505] | 100 | Get a list of all supported effects | 
|---|
|  | 101 | */ | 
|---|
|  | 102 | const SupportedEffectList& getSupportedEffects() const; | 
|---|
|  | 103 |  | 
|---|
| [5695] | 104 | /** | 
|---|
|  | 105 | @remarks | 
|---|
|  | 106 | Tell if a given force / effect type pair is supported | 
|---|
|  | 107 | */ | 
|---|
|  | 108 | bool supportsEffect(Effect::EForce force, Effect::EType type) const; | 
|---|
|  | 109 |  | 
|---|
| [1505] | 110 | void _addEffectTypes( Effect::EForce force, Effect::EType type ); | 
|---|
| [5695] | 111 | void _setGainSupport( bool on ); | 
|---|
|  | 112 | void _setAutoCenterSupport( bool on ); | 
|---|
| [1505] | 113 |  | 
|---|
|  | 114 | protected: | 
|---|
|  | 115 | SupportedEffectList mSupportedEffects; | 
|---|
| [5695] | 116 | bool mSetGainSupport; | 
|---|
|  | 117 | bool mSetAutoCenterSupport; | 
|---|
| [1505] | 118 | }; | 
|---|
|  | 119 | } | 
|---|
|  | 120 | #endif //OIS_ForceFeedBack_H | 
|---|