PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/src/ois/includes/linux/LinuxForceFeedback.h

https://bitbucket.org/cabalistic/ogredeps/
C++ Header | 85 lines | 36 code | 15 blank | 34 comment | 0 complexity | d1b66eb7cc05fc9b72a063384fff53da MD5 | raw file
 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#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
30namespace OIS
31{
32	class LinuxForceFeedback : public ForceFeedback
33	{
34	public:
35		LinuxForceFeedback(int deviceID);
36		~LinuxForceFeedback();
37
38		/** @copydoc ForceFeedback::setMasterGain */
39		void setMasterGain(float);
40		
41		/** @copydoc ForceFeedback::setAutoCenterMode */
42		void setAutoCenterMode(bool);
43
44		/** @copydoc ForceFeedback::upload */
45		void upload( const Effect* effect );
46
47		/** @copydoc ForceFeedback::modify */
48		void modify( const Effect* effect );
49
50		/** @copydoc ForceFeedback::remove */
51		void remove( const Effect* effect );
52
53		/** FF is not yet implemented fully on Linux.. just return -1 for now. todo, xxx */
54		short int getFFAxesNumber() { return -1; }
55
56		/** @copydoc ForceFeedback::getFFMemoryLoad */
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