Home | History | Annotate | Download | only in LIRC
      1 #include "OISConfig.h"
      2 #ifdef OIS_LIRC_SUPPORT
      3 /*
      4 The zlib/libpng License
      5 
      6 Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
      7 
      8 This software is provided 'as-is', without any express or implied warranty. In no event will
      9 the authors be held liable for any damages arising from the use of this software.
     10 
     11 Permission is granted to anyone to use this software for any purpose, including commercial
     12 applications, and to alter it and redistribute it freely, subject to the following
     13 restrictions:
     14 
     15     1. The origin of this software must not be misrepresented; you must not claim that
     16 		you wrote the original software. If you use this software in a product,
     17 		an acknowledgment in the product documentation would be appreciated but is
     18 		not required.
     19 
     20     2. Altered source versions must be plainly marked as such, and must not be
     21 		misrepresented as being the original software.
     22 
     23     3. This notice may not be removed or altered from any source distribution.
     24 */
     25 #ifndef OIS_LIRC_H
     26 #define OIS_LIRC_H
     27 #include "OISJoyStick.h"
     28 #include "OISLIRCRingBuffer.h"
     29 
     30 namespace OIS
     31 {
     32 	class LIRCFactoryCreator;
     33 
     34 	struct RemoteInfo
     35 	{
     36 		RemoteInfo() : buttons(0) {}
     37 
     38 		RemoteInfo( const RemoteInfo &other )
     39 		{
     40 			buttons = other.buttons;
     41 			buttonMap = other.buttonMap;
     42 		}
     43 
     44 		int buttons;
     45 		std::map<std::string, int> buttonMap;
     46 	};
     47 
     48 	//Number of ring buffer events. should be nice sized (the structure is not very big)
     49 	//Will be rounded up to power of two automatically
     50 	#define OIS_LIRC_EVENT_BUFFER 16
     51 
     52 	/**	Specialty joystick - Linux Infrared Remote Support */
     53 	class _OISExport LIRCControl : public JoyStick
     54 	{
     55 		friend class LIRCFactoryCreator;
     56 	public:
     57 		LIRCControl(InputManager* creator, int id, bool buffered, LIRCFactoryCreator* local_creator, RemoteInfo &info);
     58 		~LIRCControl();
     59 
     60 		//Overrides of Object
     61 		/** copydoc Object::setBuffered */
     62 		void setBuffered(bool buffered);
     63 
     64 		/** copydoc Object::capture */
     65 		void capture();
     66 
     67 		/** copydoc Object::queryInterface */
     68 		Interface* queryInterface(Interface::IType type);
     69 
     70 		/** copydoc Object::_intialize */
     71 		void _initialize();
     72 
     73 	protected:
     74 		//! Internal method used to add a button press to the queue (called from thread)
     75 		void queueButtonPressed(const std::string &id);
     76 
     77 		//! The creator who created us
     78 		LIRCFactoryCreator *mLIRCCreator;
     79 
     80 		//! Ringbuffer is used to store events from thread and be read from capture
     81 		LIRCRingBuffer mRingBuffer;
     82 
     83 		//! Information about remote
     84 		RemoteInfo mInfo;
     85 	};
     86 }
     87 #endif //OIS_LIRC_H
     88 #endif
     89