2013-05-31 20:29:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
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 __CCKEYBOARD_DISPATCHER_H__
|
|
|
|
#define __CCKEYBOARD_DISPATCHER_H__
|
|
|
|
|
2013-06-03 22:06:33 +08:00
|
|
|
#include <vector>
|
|
|
|
#include <functional>
|
2013-05-31 20:29:32 +08:00
|
|
|
#include "cocoa/CCArray.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup input
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
typedef std::function<void(int)> KeyboardDelegate;
|
2013-06-03 22:06:33 +08:00
|
|
|
|
2013-05-31 20:29:32 +08:00
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@class KeyboardDispatcher
|
2013-05-31 20:29:32 +08:00
|
|
|
@brief Dispatch the keypad message from the phone
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL KeyboardDispatcher : public Object
|
2013-05-31 20:29:32 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:13:12 +08:00
|
|
|
KeyboardDispatcher();
|
|
|
|
~KeyboardDispatcher();
|
2013-05-31 20:29:32 +08:00
|
|
|
|
|
|
|
/**
|
2013-06-03 22:06:33 +08:00
|
|
|
@brief set delagate to key press event
|
2013-05-31 20:29:32 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void setKeyPressDelegate(KeyboardDelegate delegate);
|
2013-05-31 20:29:32 +08:00
|
|
|
/**
|
2013-06-03 22:06:33 +08:00
|
|
|
@brief set delagate to key release event
|
2013-05-31 20:29:32 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void setKeyReleaseDelegate(KeyboardDelegate delegate);
|
2013-05-31 20:29:32 +08:00
|
|
|
|
|
|
|
/**
|
2013-06-03 22:06:33 +08:00
|
|
|
@brief dispatch the key stroke event
|
2013-05-31 20:29:32 +08:00
|
|
|
*/
|
|
|
|
bool dispatchKeyboardEvent(int keyCode, bool pressed);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
KeyboardDelegate _keyPressDelegate;
|
|
|
|
KeyboardDelegate _keyReleaseDelegate;
|
2013-05-31 20:29:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// end of input group
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif //__CCKEYBOARD_DISPATCHER_H__
|