Home | History | Annotate | Download | only in iphone
      1 #ifndef OIS_iPhoneAccelerometer_H
      2 #define OIS_iPhoneAccelerometer_H
      3 
      4 #include "OISJoystick.h"
      5 #include "iphone/iPhonePrereqs.h"
      6 
      7 #import <UIKit/UIKit.h>
      8 @class iPhoneAccelerometerDelegate;
      9 
     10 class JoyStickState;
     11 
     12 namespace OIS
     13 {
     14 	class iPhoneAccelerometer : public JoyStick
     15     {
     16 	public:
     17 		iPhoneAccelerometer(InputManager* creator, bool buffered);
     18 		virtual ~iPhoneAccelerometer();
     19 
     20 		/** @copydoc Object::setBuffered */
     21 		virtual void setBuffered(bool buffered);
     22 
     23         void setUpdateInterval(float interval) {
     24             mUpdateInterval = interval;
     25             [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0f / mUpdateInterval)];
     26         }
     27 
     28         Vector3 getAccelerometerVector3(void) { return mState.mVectors[0]; }
     29 		/** @copydoc Object::capture */
     30 		virtual void capture();
     31 
     32 		/** @copydoc Object::queryInterface */
     33 		virtual Interface* queryInterface(Interface::IType type) {return 0;}
     34 
     35 		/** @copydoc Object::_initialize */
     36 		virtual void _initialize();
     37 
     38         void didAccelerate(UIAcceleration *acceleration);
     39 
     40     protected:
     41         iPhoneAccelerometerDelegate *accelerometerDelegate;
     42 
     43         /** The update frequency of the accelerometer.  Represented in times per second. */
     44         float mUpdateInterval;
     45         Vector3 mTempState;
     46 	};
     47 }
     48 
     49 
     50 #endif // OIS_iPhoneAccelerometer_H
     51