2015-06-17 13:16:06 +08:00
|
|
|
|
/****************************************************************************
|
2016-08-05 09:42:15 +08:00
|
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
THE SOFTWARE.
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef __CC_EXTENTIONS_CCINPUTDELEGATE_H__
|
|
|
|
|
#define __CC_EXTENTIONS_CCINPUTDELEGATE_H__
|
|
|
|
|
|
2014-09-10 08:17:07 +08:00
|
|
|
|
#include "platform/CCPlatformMacros.h"
|
2014-04-30 08:37:36 +08:00
|
|
|
|
#include "base/CCTouch.h"
|
|
|
|
|
#include "base/CCEvent.h"
|
|
|
|
|
#include "base/ccTypes.h"
|
|
|
|
|
#include "base/CCEventKeyboard.h"
|
|
|
|
|
#include "base/CCEventListener.h"
|
2016-03-20 21:53:44 +08:00
|
|
|
|
#include "editor-support/cocostudio/CocosStudioExport.h"
|
2014-04-10 00:52:41 +08:00
|
|
|
|
|
|
|
|
|
namespace cocos2d {
|
|
|
|
|
class __Set;
|
|
|
|
|
}
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
|
namespace cocostudio {
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
2013-11-20 12:04:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @lua NA
|
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
|
class CC_STUDIO_DLL InputDelegate
|
2013-06-04 17:38:43 +08:00
|
|
|
|
{
|
2014-08-21 15:40:22 +08:00
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
2013-11-20 12:04:47 +08:00
|
|
|
|
* @js ctor
|
2013-09-13 11:41:20 +08:00
|
|
|
|
*/
|
2013-06-20 14:15:53 +08:00
|
|
|
|
InputDelegate(void);
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-06-20 14:15:53 +08:00
|
|
|
|
virtual ~InputDelegate(void);
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
|
|
|
|
public:
|
2013-11-20 12:04:47 +08:00
|
|
|
|
virtual bool isTouchEnabled() const;
|
|
|
|
|
virtual void setTouchEnabled(bool value);
|
|
|
|
|
virtual bool isAccelerometerEnabled() const;
|
|
|
|
|
virtual void setAccelerometerEnabled(bool value);
|
|
|
|
|
virtual bool isKeypadEnabled() const;
|
|
|
|
|
virtual void setKeypadEnabled(bool value);
|
|
|
|
|
virtual void setTouchMode(cocos2d::Touch::DispatchMode mode);
|
|
|
|
|
virtual cocos2d::Touch::DispatchMode getTouchMode() const;
|
|
|
|
|
virtual void setTouchPriority(int priority);
|
|
|
|
|
virtual int getTouchPriority() const;
|
|
|
|
|
/** @deprecated Please override onAcceleration */
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-11-20 12:04:47 +08:00
|
|
|
|
CC_DEPRECATED_ATTRIBUTE virtual void didAccelerate(cocos2d::Acceleration* accelerationValue) final { CC_UNUSED_PARAM(accelerationValue); };
|
|
|
|
|
// Deprecated touch callbacks.
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-11-20 12:04:47 +08:00
|
|
|
|
CC_DEPRECATED_ATTRIBUTE virtual bool ccTouchBegan(cocos2d::Touch *pTouch, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent); return false;};
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-11-20 12:04:47 +08:00
|
|
|
|
CC_DEPRECATED_ATTRIBUTE virtual void ccTouchMoved(cocos2d::Touch *pTouch, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-11-20 12:04:47 +08:00
|
|
|
|
CC_DEPRECATED_ATTRIBUTE virtual void ccTouchEnded(cocos2d::Touch *pTouch, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-11-20 12:04:47 +08:00
|
|
|
|
CC_DEPRECATED_ATTRIBUTE virtual void ccTouchCancelled(cocos2d::Touch *pTouch, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2014-01-04 09:17:37 +08:00
|
|
|
|
CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesBegan(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2014-01-04 09:17:37 +08:00
|
|
|
|
CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesMoved(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2014-01-04 09:17:37 +08:00
|
|
|
|
CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesEnded(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2014-01-04 09:17:37 +08:00
|
|
|
|
CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesCancelled(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
|
2013-09-13 11:41:20 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
|
virtual void onAcceleration(cocos2d::Acceleration* acc, cocos2d::Event* event) {};
|
2013-11-20 12:04:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
|
virtual void onKeyPressed(cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event* event) {};
|
2013-11-20 12:04:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
|
virtual void onKeyReleased(cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event* event) {};
|
2013-11-20 12:04:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
|
virtual bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event);
|
2013-11-20 12:04:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
|
virtual void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event);
|
2013-11-20 12:04:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
|
virtual void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event);
|
2013-11-20 12:04:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
|
virtual void onTouchCancelled(cocos2d::Touch *touch, cocos2d::Event *event);
|
2013-11-20 12:04:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
|
virtual void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
|
2013-11-20 12:04:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
|
virtual void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
|
2013-11-20 12:04:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
|
virtual void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
|
2013-11-20 12:04:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* @js NA
|
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
|
virtual void onTouchesCancelled(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
|
2013-07-26 07:27:24 +08:00
|
|
|
|
|
2013-06-04 17:38:43 +08:00
|
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
|
bool _touchEnabled;
|
2013-10-15 18:00:03 +08:00
|
|
|
|
cocos2d::EventListener* _touchListener;
|
2013-06-15 14:03:30 +08:00
|
|
|
|
bool _accelerometerEnabled;
|
2013-10-15 18:00:03 +08:00
|
|
|
|
cocos2d::EventListener* _accelerometerListener;
|
2013-06-15 14:03:30 +08:00
|
|
|
|
bool _keypadEnabled;
|
2013-10-15 18:00:03 +08:00
|
|
|
|
cocos2d::EventListener* _keyboardListener;
|
2013-06-04 17:38:43 +08:00
|
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
|
int _touchPriority;
|
2013-10-15 18:00:03 +08:00
|
|
|
|
cocos2d::Touch::DispatchMode _touchMode;
|
2013-06-04 17:38:43 +08:00
|
|
|
|
};
|
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
|
}
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
2015-11-18 00:39:43 +08:00
|
|
|
|
#endif // __CC_EXTENTIONS_CCINPUTDELEGATE_H__
|