Orxonox  0.0.5 Codename: Arcturus
LinuxForceFeedback.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_LinuxForceFeedBack_H
24 #define OIS_LinuxForceFeedBack_H
25 
26 #include "linux/LinuxPrereqs.h"
27 #include "OISForceFeedback.h"
28 #include <linux/input.h>
29 
30 namespace OIS
31 {
33  {
34  public:
35  LinuxForceFeedback(int deviceID);
37 
39  void setMasterGain(float);
40 
42  void setAutoCenterMode(bool);
43 
45  void upload( const Effect* effect );
46 
48  void modify( const Effect* effect );
49 
51  void remove( const Effect* effect );
52 
54  short int getFFAxesNumber() { return -1; }
55 
57  unsigned short getFFMemoryLoad();
58 
59  protected:
60 
61  //Sets the common properties to all effects
62  void _setCommonProperties(struct ff_effect *event, struct ff_envelope *ffenvelope,
63  const Effect* effect, const Envelope *envelope );
64 
65  //Specific Effect Settings
66  void _updateConstantEffect( const Effect* effect );
67  void _updateRampEffect( const Effect* effect );
68  void _updatePeriodicEffect( const Effect* effect );
69  void _updateConditionalEffect( const Effect* effect );
70  //void _updateCustomEffect( const Effect* effect );
71 
72  void _upload( struct ff_effect* ffeffect, const Effect* effect);
73  void _stop( int handle);
74  void _start( int handle);
75  void _unload( int handle);
76 
77  // Map of currently uploaded effects (handle => effect)
78  typedef std::map<int, struct ff_effect *> EffectList;
79  EffectList mEffectList;
80 
81  // Joystick device (file) descriptor.
82  int mJoyStick;
83  };
84 }
85 #endif //OIS_LinuxForceFeedBack_H
void _unload(int handle)
Definition: LinuxForceFeedback.cpp:550
Interface class for dealing with Force Feedback devices.
Definition: OISForceFeedback.h:35
unsigned short getFFMemoryLoad()
Definition: LinuxForceFeedback.cpp:62
void _setCommonProperties(struct ff_effect *event, struct ff_envelope *ffenvelope, const Effect *effect, const Envelope *envelope)
Definition: LinuxForceFeedback.cpp:224
void _start(int handle)
Definition: LinuxForceFeedback.cpp:532
Force Feedback is a relatively complex set of properties to upload to a device.
Definition: OISEffect.h:47
short int getFFAxesNumber()
FF is not yet implemented fully on Linux.
Definition: LinuxForceFeedback.h:54
void _updatePeriodicEffect(const Effect *effect)
Definition: LinuxForceFeedback.cpp:332
An optional envelope to be applied to the start/end of an effect.
Definition: OISEffect.h:181
void setAutoCenterMode(bool)
Definition: LinuxForceFeedback.cpp:109
EffectList mEffectList
Definition: LinuxForceFeedback.h:79
void _updateRampEffect(const Effect *effect)
Definition: LinuxForceFeedback.cpp:307
void upload(const Effect *effect)
Definition: LinuxForceFeedback.cpp:138
void setMasterGain(float)
Definition: LinuxForceFeedback.cpp:76
void _stop(int handle)
Definition: LinuxForceFeedback.cpp:514
void _updateConditionalEffect(const Effect *effect)
Definition: LinuxForceFeedback.cpp:393
void modify(const Effect *effect)
Definition: LinuxForceFeedback.cpp:164
int mJoyStick
Definition: LinuxForceFeedback.h:82
LinuxForceFeedback(int deviceID)
Definition: LinuxForceFeedback.cpp:42
std::map< int, struct ff_effect * > EffectList
Definition: LinuxForceFeedback.h:78
~LinuxForceFeedback()
Definition: LinuxForceFeedback.cpp:48
void _updateConstantEffect(const Effect *effect)
Definition: LinuxForceFeedback.cpp:285
Definition: EventHelpers.h:31
void _upload(struct ff_effect *ffeffect, const Effect *effect)
Definition: LinuxForceFeedback.cpp:452
Definition: LinuxForceFeedback.h:32