1 /* 2 The zlib/libpng License 3 4 Copyright (c) 2006 Chris Snyder 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_iPhoneInputManager_H 24 #define OIS_iPhoneInputManager_H 25 26 #include "OISInputManager.h" 27 #include "OISFactoryCreator.h" 28 #include "iphone/iPhonePrereqs.h" 29 30 #import <UIKit/UIKit.h> 31 namespace OIS { 32 class iPhoneAccelerometer; 33 class iPhoneMultiTouch; 34 } 35 36 @interface InputDelegate : UIView <UIAccelerometerDelegate> { 37 OIS::iPhoneAccelerometer *accelerometerObject; 38 OIS::iPhoneMultiTouch *touchObject; 39 } 40 41 @property (assign) OIS::iPhoneAccelerometer *accelerometerObject; 42 @property (assign) OIS::iPhoneMultiTouch *touchObject; 43 44 @end 45 46 namespace OIS 47 { 48 49 class iPhoneInputManager : public InputManager, public FactoryCreator 50 { 51 public: 52 iPhoneInputManager(); 53 virtual ~iPhoneInputManager(); 54 55 //InputManager Overrides 56 /** @copydoc InputManager::_initialize */ 57 void _initialize( ParamList ¶mList ); 58 59 //FactoryCreator Overrides 60 /** @copydoc FactoryCreator::deviceList */ 61 DeviceList freeDeviceList(); 62 63 /** @copydoc FactoryCreator::totalDevices */ 64 int totalDevices(Type iType); 65 66 /** @copydoc FactoryCreator::freeDevices */ 67 int freeDevices(Type iType); 68 69 /** @copydoc FactoryCreator::vendorExist */ 70 bool vendorExist(Type iType, const std::string & vendor); 71 72 /** @copydoc FactoryCreator::createObject */ 73 Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = ""); 74 75 /** @copydoc FactoryCreator::destroyObject */ 76 void destroyObject(Object* obj); 77 78 //Internal Items 79 80 //! Internal method, used for flagging multi-touch as available/unavailable for creation 81 void _setMultiTouchUsed(bool used) { bMultiTouchUsed = used; } 82 83 //! Internal method, used for flagging accelerometer as available/unavailable for creation 84 void _setAccelerometerUsed(bool used) { bAccelerometerUsed = used; } 85 86 //! methodfor getting the delegate 87 InputDelegate * _getDelegate() { return mDelegate; } 88 89 //! method for getting window 90 UIWindow * _getWindow() { return mWindow; } 91 92 protected: 93 void _parseConfigSettings( ParamList& paramList ); 94 95 // iPhone stuff 96 UIWindow *mWindow; 97 InputDelegate *mDelegate; 98 99 // settings 100 bool mHideMouse; 101 102 //! Used to know if we used up multi-touch device 103 bool bMultiTouchUsed; 104 105 //! Used to know if we used up accelerometer 106 bool bAccelerometerUsed; 107 }; 108 } 109 110 #endif 111