2022-02-24 18:51:36 +08:00
|
|
|
/****************************************************************************
|
2020-10-17 16:32:16 +08:00
|
|
|
Copyright (c) 2013-2017 Chukong Technologies Inc.
|
2013-06-04 17:38:43 +08:00
|
|
|
|
2022-07-09 22:23:34 +08:00
|
|
|
https://axis-project.github.io/
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#ifndef __AX_EXTENTIONS_CCINPUTDELEGATE_H__
|
|
|
|
#define __AX_EXTENTIONS_CCINPUTDELEGATE_H__
|
2013-06-04 17:38:43 +08:00
|
|
|
|
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"
|
2020-10-21 10:12:00 +08:00
|
|
|
#include "CocosStudioExport.h"
|
2014-04-10 00:52:41 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2021-12-25 10:04:45 +08:00
|
|
|
class __Set;
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|
2013-06-04 17:38:43 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
namespace cocostudio
|
|
|
|
{
|
2013-06-04 17:38:43 +08:00
|
|
|
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2020-10-17 16:32:16 +08:00
|
|
|
class CCS_DLL InputDelegate
|
2013-06-04 17:38:43 +08:00
|
|
|
{
|
2022-03-18 21:46:07 +08:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
|
|
|
InputDelegate(void);
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2020-10-17 16:32:16 +08:00
|
|
|
virtual ~InputDelegate(void);
|
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);
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void setTouchMode(axis::Touch::DispatchMode mode);
|
|
|
|
virtual axis::Touch::DispatchMode getTouchMode() const;
|
2013-11-20 12:04:47 +08:00
|
|
|
virtual void setTouchPriority(int priority);
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual int getTouchPriority() const;
|
|
|
|
/** @deprecated Please override onAcceleration */
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE virtual void didAccelerate(axis::Acceleration* accelerationValue) final;
|
2013-11-20 12:04:47 +08:00
|
|
|
// Deprecated touch callbacks.
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE virtual bool ccTouchBegan(axis::Touch* touch, axis::Event* event) final;
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE virtual void ccTouchMoved(axis::Touch* touch, axis::Event* event) final;
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE virtual void ccTouchEnded(axis::Touch* touch, axis::Event* event) final;
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE virtual void ccTouchCancelled(axis::Touch* touch, axis::Event* event) final;
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE virtual void ccTouchesBegan(axis::__Set* touches, axis::Event* event) final;
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE virtual void ccTouchesMoved(axis::__Set* touches, axis::Event* event) final;
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE virtual void ccTouchesEnded(axis::__Set* touches, axis::Event* event) final;
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE virtual void ccTouchesCancelled(axis::__Set* touches, axis::Event* event) final;
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onAcceleration(axis::Acceleration* acc, axis::Event* event);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onKeyPressed(axis::EventKeyboard::KeyCode keyCode, axis::Event* event);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onKeyReleased(axis::EventKeyboard::KeyCode keyCode, axis::Event* event);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual bool onTouchBegan(axis::Touch* touch, axis::Event* event);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onTouchMoved(axis::Touch* touch, axis::Event* event);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onTouchEnded(axis::Touch* touch, axis::Event* event);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onTouchCancelled(axis::Touch* touch, axis::Event* event);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onTouchesBegan(const std::vector<axis::Touch*>& touches, axis::Event* event);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onTouchesMoved(const std::vector<axis::Touch*>& touches, axis::Event* event);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onTouchesEnded(const std::vector<axis::Touch*>& touches, axis::Event* event);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onTouchesCancelled(const std::vector<axis::Touch*>& touches, axis::Event* event);
|
2013-07-26 07:27:24 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _touchEnabled;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListener* _touchListener;
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _accelerometerEnabled;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListener* _accelerometerListener;
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _keypadEnabled;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListener* _keyboardListener;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-06-04 17:38:43 +08:00
|
|
|
private:
|
2021-12-25 10:04:45 +08:00
|
|
|
int _touchPriority;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Touch::DispatchMode _touchMode;
|
2013-06-04 17:38:43 +08:00
|
|
|
};
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
} // namespace cocostudio
|
2013-06-04 17:38:43 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#endif // __AX_EXTENTIONS_CCINPUTDELEGATE_H__
|