Home | History | Annotate | Download | only in WiiMote
      1 #include "OISConfig.h"
      2 #ifdef OIS_WIN32_WIIMOTE_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_WiiMote_H
     26 #define OIS_WiiMote_H
     27 #include "OISJoyStick.h"
     28 #include "OISWiiMoteRingBuffer.h"
     29 #include "wiimote.h"
     30 
     31 namespace OIS
     32 {
     33 	class WiiMoteFactoryCreator;
     34 	class WiiMoteForceFeedback;
     35 
     36 	//Number of ring buffer events. should be nice sized (the structure is not very big)
     37 	//Will be rounded up to power of two automatically
     38 	#define OIS_WII_EVENT_BUFFER 32
     39 
     40 	/**	Specialty joystick - WiiMote controller */
     41 	class _OISExport WiiMote : public JoyStick
     42 	{
     43 	public:
     44 		WiiMote(InputManager* creator, int id, bool buffered, WiiMoteFactoryCreator* local_creator);
     45 		~WiiMote();
     46 
     47 		//Overrides of Object
     48 		void setBuffered(bool buffered);
     49 
     50 		void capture();
     51 
     52 		Interface* queryInterface(Interface::IType type);
     53 
     54 		void _initialize();
     55 
     56 		void _threadUpdate();
     57 
     58 	protected:
     59 		void _doButtonCheck(bool new_state, int ois_button, unsigned int &pushed, unsigned int &released);
     60 		bool _doPOVCheck(const cWiiMote::tButtonStatus &bState, unsigned int &newPosition);
     61 
     62 		//! The creator who created us
     63 		WiiMoteFactoryCreator *mWiiCreator;
     64 
     65 		//! Actual WiiMote HID device
     66 		cWiiMote mWiiMote;
     67 
     68 		//! Used to signal thread that remote is ready
     69 		volatile bool mtInitialized;
     70 
     71 		//! Ringbuffer is used to store events from thread and be read from capture
     72 		WiiMoteRingBuffer mRingBuffer;
     73 
     74 		//Following variables are used entirely within threaded context
     75 		int mtLastButtonStates;
     76 		unsigned int mtLastPOVState;
     77 		float mtLastX, mtLastY, mtLastZ;
     78 		float mtLastNunChuckX, mtLastNunChuckY, mtLastNunChuckZ;
     79 		int mLastNunChuckXAxis, mLastNunChuckYAxis;
     80 
     81 		//Small workaround for slow calibration of wiimote data
     82 		int _mWiiMoteMotionDelay;
     83 
     84 		//Simple rumble force
     85 		WiiMoteForceFeedback *mRumble;
     86 	};
     87 }
     88 #endif //OIS_WiiMote_H
     89 #endif
     90