2013-09-03 18:22:03 +08:00
|
|
|
/****************************************************************************
|
2017-02-14 14:36:57 +08:00
|
|
|
Copyright (c) 2013-2017 Chukong Technologies Inc.
|
2013-09-03 18:22:03 +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 __cocos2d_libs__CCKeyboardEvent__
|
|
|
|
#define __cocos2d_libs__CCKeyboardEvent__
|
|
|
|
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "base/CCEvent.h"
|
2013-09-03 18:22:03 +08:00
|
|
|
|
2015-03-24 18:22:52 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup base
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** @class EventKeyboard
|
|
|
|
* @brief Keyboard event.
|
|
|
|
*/
|
2014-07-15 12:00:31 +08:00
|
|
|
class CC_DLL EventKeyboard : public Event
|
2013-09-03 18:22:03 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2015-03-23 18:39:27 +08:00
|
|
|
* KeyCode The key (code).
|
2015-03-24 16:37:09 +08:00
|
|
|
* @js NA
|
2013-09-03 18:22:03 +08:00
|
|
|
*/
|
|
|
|
enum class KeyCode
|
|
|
|
{
|
2014-05-04 13:59:26 +08:00
|
|
|
KEY_NONE,
|
|
|
|
KEY_PAUSE,
|
|
|
|
KEY_SCROLL_LOCK,
|
|
|
|
KEY_PRINT,
|
|
|
|
KEY_SYSREQ,
|
|
|
|
KEY_BREAK,
|
|
|
|
KEY_ESCAPE,
|
2014-06-09 09:50:13 +08:00
|
|
|
KEY_BACK = KEY_ESCAPE,
|
2014-05-04 13:59:26 +08:00
|
|
|
KEY_BACKSPACE,
|
|
|
|
KEY_TAB,
|
|
|
|
KEY_BACK_TAB,
|
|
|
|
KEY_RETURN,
|
|
|
|
KEY_CAPS_LOCK,
|
|
|
|
KEY_SHIFT,
|
2014-12-10 18:11:07 +08:00
|
|
|
KEY_LEFT_SHIFT = KEY_SHIFT,
|
|
|
|
KEY_RIGHT_SHIFT,
|
2014-05-04 13:59:26 +08:00
|
|
|
KEY_CTRL,
|
2014-12-10 18:11:07 +08:00
|
|
|
KEY_LEFT_CTRL = KEY_CTRL,
|
|
|
|
KEY_RIGHT_CTRL,
|
2014-05-04 13:59:26 +08:00
|
|
|
KEY_ALT,
|
2014-12-10 18:11:07 +08:00
|
|
|
KEY_LEFT_ALT = KEY_ALT,
|
|
|
|
KEY_RIGHT_ALT,
|
2014-05-04 13:59:26 +08:00
|
|
|
KEY_MENU,
|
|
|
|
KEY_HYPER,
|
|
|
|
KEY_INSERT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Y_GRAVE,
|
|
|
|
KEY_A,
|
|
|
|
KEY_B,
|
|
|
|
KEY_C,
|
|
|
|
KEY_D,
|
|
|
|
KEY_E,
|
|
|
|
KEY_F,
|
|
|
|
KEY_G,
|
|
|
|
KEY_H,
|
|
|
|
KEY_I,
|
|
|
|
KEY_J,
|
|
|
|
KEY_K,
|
|
|
|
KEY_L,
|
|
|
|
KEY_M,
|
|
|
|
KEY_N,
|
|
|
|
KEY_O,
|
|
|
|
KEY_P,
|
|
|
|
KEY_Q,
|
|
|
|
KEY_R,
|
|
|
|
KEY_S,
|
|
|
|
KEY_T,
|
|
|
|
KEY_U,
|
|
|
|
KEY_V,
|
|
|
|
KEY_W,
|
|
|
|
KEY_X,
|
|
|
|
KEY_Y,
|
|
|
|
KEY_Z,
|
|
|
|
KEY_LEFT_BRACE,
|
|
|
|
KEY_BAR,
|
|
|
|
KEY_RIGHT_BRACE,
|
|
|
|
KEY_TILDE,
|
|
|
|
KEY_EURO,
|
|
|
|
KEY_POUND,
|
|
|
|
KEY_YEN,
|
|
|
|
KEY_MIDDLE_DOT,
|
|
|
|
KEY_SEARCH,
|
|
|
|
KEY_DPAD_LEFT,
|
|
|
|
KEY_DPAD_RIGHT,
|
|
|
|
KEY_DPAD_UP,
|
|
|
|
KEY_DPAD_DOWN,
|
|
|
|
KEY_DPAD_CENTER,
|
|
|
|
KEY_ENTER,
|
2014-12-10 18:11:07 +08:00
|
|
|
KEY_PLAY
|
2013-09-03 18:22:03 +08:00
|
|
|
};
|
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Constructor.
|
|
|
|
*
|
|
|
|
* @param keyCode A given keycode.
|
|
|
|
* @param isPressed True if the key is pressed.
|
2015-03-24 16:37:09 +08:00
|
|
|
* @js ctor
|
2015-03-23 18:39:27 +08:00
|
|
|
*/
|
2013-10-28 16:00:01 +08:00
|
|
|
EventKeyboard(KeyCode keyCode, bool isPressed);
|
2013-09-18 18:16:14 +08:00
|
|
|
|
|
|
|
private:
|
2013-09-03 18:22:03 +08:00
|
|
|
KeyCode _keyCode;
|
|
|
|
bool _isPressed;
|
2013-09-18 18:35:42 +08:00
|
|
|
|
2013-09-20 19:19:31 +08:00
|
|
|
friend class EventListenerKeyboard;
|
2013-09-03 18:22:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
2015-03-24 18:22:52 +08:00
|
|
|
// end of base group
|
|
|
|
/// @}
|
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
#endif /* defined(__cocos2d_libs__CCKeyboardEvent__) */
|