rename some class names to obey cocos2d-x coding style

This commit is contained in:
minggo 2013-09-20 19:19:31 +08:00
parent 7471a1224c
commit 4c9771ba3c
45 changed files with 555 additions and 555 deletions

View File

@ -26,9 +26,9 @@
NS_CC_BEGIN NS_CC_BEGIN
const char* AccelerationEvent::EVENT_TYPE = "AccelerometerEvent"; const char* EventAcceleration::EVENT_TYPE = "AccelerometerEvent";
AccelerationEvent::AccelerationEvent(Acceleration acc) EventAcceleration::EventAcceleration(Acceleration acc)
: Event(EVENT_TYPE) : Event(EVENT_TYPE)
, _acc(acc) , _acc(acc)
{ {

View File

@ -30,16 +30,16 @@
NS_CC_BEGIN NS_CC_BEGIN
class AccelerationEvent : public Event class EventAcceleration : public Event
{ {
public: public:
static const char* EVENT_TYPE; static const char* EVENT_TYPE;
AccelerationEvent(Acceleration acc); EventAcceleration(Acceleration acc);
private: private:
Acceleration _acc; Acceleration _acc;
friend class AccelerationEventListener; friend class EventListenerAcceleration;
}; };
NS_CC_END NS_CC_END

View File

@ -27,19 +27,19 @@
NS_CC_BEGIN NS_CC_BEGIN
AccelerationEventListener::AccelerationEventListener() EventListenerAcceleration::EventListenerAcceleration()
{ {
} }
AccelerationEventListener::~AccelerationEventListener() EventListenerAcceleration::~EventListenerAcceleration()
{ {
CCLOGINFO("In the destructor of AccelerationEventListener. %p", this); CCLOGINFO("In the destructor of AccelerationEventListener. %p", this);
} }
AccelerationEventListener* AccelerationEventListener::create(std::function<void(Acceleration*, Event* event)> callback) EventListenerAcceleration* EventListenerAcceleration::create(std::function<void(Acceleration*, Event* event)> callback)
{ {
AccelerationEventListener* ret = new AccelerationEventListener(); EventListenerAcceleration* ret = new EventListenerAcceleration();
if (ret && ret->init(callback)) if (ret && ret->init(callback))
{ {
ret->autorelease(); ret->autorelease();
@ -52,14 +52,14 @@ AccelerationEventListener* AccelerationEventListener::create(std::function<void(
return ret; return ret;
} }
bool AccelerationEventListener::init(std::function<void(Acceleration*, Event* event)> callback) bool EventListenerAcceleration::init(std::function<void(Acceleration*, Event* event)> callback)
{ {
auto listener = [this](Event* event){ auto listener = [this](Event* event){
auto accEvent = static_cast<AccelerationEvent*>(event); auto accEvent = static_cast<EventAcceleration*>(event);
this->onAccelerationEvent(&accEvent->_acc, event); this->onAccelerationEvent(&accEvent->_acc, event);
}; };
if (EventListener::init(AccelerationEvent::EVENT_TYPE, listener)) if (EventListener::init(EventAcceleration::EVENT_TYPE, listener))
{ {
onAccelerationEvent = callback; onAccelerationEvent = callback;
return true; return true;
@ -68,9 +68,9 @@ bool AccelerationEventListener::init(std::function<void(Acceleration*, Event* ev
return false; return false;
} }
AccelerationEventListener* AccelerationEventListener::clone() EventListenerAcceleration* EventListenerAcceleration::clone()
{ {
auto ret = new AccelerationEventListener(); auto ret = new EventListenerAcceleration();
if (ret && ret->init(onAccelerationEvent)) if (ret && ret->init(onAccelerationEvent))
{ {
@ -84,7 +84,7 @@ AccelerationEventListener* AccelerationEventListener::clone()
return ret; return ret;
} }
bool AccelerationEventListener::checkAvaiable() bool EventListenerAcceleration::checkAvaiable()
{ {
CCASSERT(onAccelerationEvent, ""); CCASSERT(onAccelerationEvent, "");

View File

@ -30,17 +30,17 @@
NS_CC_BEGIN NS_CC_BEGIN
class AccelerationEventListener : public EventListener class EventListenerAcceleration : public EventListener
{ {
public: public:
static AccelerationEventListener* create(std::function<void(Acceleration*, Event* event)> callback); static EventListenerAcceleration* create(std::function<void(Acceleration*, Event* event)> callback);
~AccelerationEventListener(); virtual ~EventListenerAcceleration();
/// Overrides /// Overrides
virtual AccelerationEventListener* clone() override; virtual EventListenerAcceleration* clone() override;
virtual bool checkAvaiable() override; virtual bool checkAvaiable() override;
private: private:
AccelerationEventListener(); EventListenerAcceleration();
bool init(std::function<void(Acceleration*, Event* event)> callback); bool init(std::function<void(Acceleration*, Event* event)> callback);
std::function<void(Acceleration*, Event*)> onAccelerationEvent; std::function<void(Acceleration*, Event*)> onAccelerationEvent;

View File

@ -26,7 +26,7 @@
NS_CC_BEGIN NS_CC_BEGIN
CustomEvent::CustomEvent(const std::string& eventName) EventCustom::EventCustom(const std::string& eventName)
: Event(eventName) : Event(eventName)
, _userData(nullptr) , _userData(nullptr)
{ {

View File

@ -29,11 +29,11 @@
NS_CC_BEGIN NS_CC_BEGIN
class CustomEvent : public Event class EventCustom : public Event
{ {
public: public:
/** Constructor */ /** Constructor */
CustomEvent(const std::string& eventName); EventCustom(const std::string& eventName);
/** Set user data */ /** Set user data */
inline void setUserData(void* data) { _userData = data; }; inline void setUserData(void* data) { _userData = data; };

View File

@ -27,14 +27,14 @@
NS_CC_BEGIN NS_CC_BEGIN
CustomEventListener::CustomEventListener() EventListenerCustom::EventListenerCustom()
: _onCustomEvent(nullptr) : _onCustomEvent(nullptr)
{ {
} }
CustomEventListener* CustomEventListener::create(const std::string& eventName, std::function<void(CustomEvent*)> callback) EventListenerCustom* EventListenerCustom::create(const std::string& eventName, std::function<void(EventCustom*)> callback)
{ {
CustomEventListener* ret = new CustomEventListener(); EventListenerCustom* ret = new EventListenerCustom();
if (ret && ret->init(eventName, callback)) if (ret && ret->init(eventName, callback))
{ {
ret->autorelease(); ret->autorelease();
@ -46,7 +46,7 @@ CustomEventListener* CustomEventListener::create(const std::string& eventName, s
return ret; return ret;
} }
bool CustomEventListener::init(const std::string& eventName, std::function<void(CustomEvent*)>callback) bool EventListenerCustom::init(const std::string& eventName, std::function<void(EventCustom*)>callback)
{ {
bool ret = false; bool ret = false;
@ -55,7 +55,7 @@ bool CustomEventListener::init(const std::string& eventName, std::function<void(
auto listener = [this](Event* event){ auto listener = [this](Event* event){
if (_onCustomEvent != nullptr) if (_onCustomEvent != nullptr)
{ {
_onCustomEvent(static_cast<CustomEvent*>(event)); _onCustomEvent(static_cast<EventCustom*>(event));
} }
}; };
@ -66,9 +66,9 @@ bool CustomEventListener::init(const std::string& eventName, std::function<void(
return ret; return ret;
} }
CustomEventListener* CustomEventListener::clone() EventListenerCustom* EventListenerCustom::clone()
{ {
CustomEventListener* ret = new CustomEventListener(); EventListenerCustom* ret = new EventListenerCustom();
if (ret && ret->init(_type, _onCustomEvent)) if (ret && ret->init(_type, _onCustomEvent))
{ {
ret->autorelease(); ret->autorelease();
@ -80,7 +80,7 @@ CustomEventListener* CustomEventListener::clone()
return ret; return ret;
} }
bool CustomEventListener::checkAvaiable() bool EventListenerCustom::checkAvaiable()
{ {
bool ret = false; bool ret = false;
if (EventListener::checkAvaiable() && _onCustomEvent != nullptr) if (EventListener::checkAvaiable() && _onCustomEvent != nullptr)

View File

@ -29,7 +29,7 @@
NS_CC_BEGIN NS_CC_BEGIN
class CustomEvent; class EventCustom;
/** /**
* Usage: * Usage:
@ -49,27 +49,27 @@ class CustomEvent;
* *
* dispatcher->removeListener(listener); * dispatcher->removeListener(listener);
*/ */
class CustomEventListener : public EventListener class EventListenerCustom : public EventListener
{ {
public: public:
/** Creates an event listener with type and callback. /** Creates an event listener with type and callback.
* @param eventType The type of the event. * @param eventType The type of the event.
* @param callback The callback function when the specified event was emitted. * @param callback The callback function when the specified event was emitted.
*/ */
static CustomEventListener* create(const std::string& eventName, std::function<void(CustomEvent*)> callback); static EventListenerCustom* create(const std::string& eventName, std::function<void(EventCustom*)> callback);
/// Overrides /// Overrides
virtual bool checkAvaiable() override; virtual bool checkAvaiable() override;
virtual CustomEventListener* clone() override; virtual EventListenerCustom* clone() override;
protected: protected:
/** Constructor */ /** Constructor */
CustomEventListener(); EventListenerCustom();
/** Initializes event with type and callback function */ /** Initializes event with type and callback function */
bool init(const std::string& eventName, std::function<void(CustomEvent*)> callback); bool init(const std::string& eventName, std::function<void(EventCustom*)> callback);
std::function<void(CustomEvent*)> _onCustomEvent; std::function<void(EventCustom*)> _onCustomEvent;
}; };
NS_CC_END NS_CC_END

View File

@ -267,9 +267,9 @@ void EventDispatcher::dispatchEvent(Event* event, bool forceSortListeners)
DispatchGuard guard(_inDispatch); DispatchGuard guard(_inDispatch);
if (event->_type == TouchEvent::EVENT_TYPE) if (event->_type == EventTouch::EVENT_TYPE)
{ {
dispatchTouchEvent(static_cast<TouchEvent*>(event)); dispatchTouchEvent(static_cast<EventTouch*>(event));
return; return;
} }
@ -292,9 +292,9 @@ void EventDispatcher::dispatchEvent(Event* event, bool forceSortListeners)
updateListenerItems(); updateListenerItems();
} }
void EventDispatcher::dispatchTouchEvent(TouchEvent* event) void EventDispatcher::dispatchTouchEvent(EventTouch* event)
{ {
auto touchListeners = getListenerItemsForType(TouchEvent::EVENT_TYPE); auto touchListeners = getListenerItemsForType(EventTouch::EVENT_TYPE);
if (touchListeners == nullptr) if (touchListeners == nullptr)
return; return;
@ -304,11 +304,11 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event)
std::vector<EventDispatcher::EventListenerItem*> allInOnelisteners; std::vector<EventDispatcher::EventListenerItem*> allInOnelisteners;
allInOnelisteners.reserve(touchListeners->size()); allInOnelisteners.reserve(touchListeners->size());
TouchEventListener* touchEventListener = nullptr; EventListenerTouch* touchEventListener = nullptr;
std::for_each(touchListeners->begin(), touchListeners->end(), [&](EventListenerItem*& item){ std::for_each(touchListeners->begin(), touchListeners->end(), [&](EventListenerItem*& item){
touchEventListener = static_cast<TouchEventListener*>(item->listener); touchEventListener = static_cast<EventListenerTouch*>(item->listener);
if (touchEventListener->_dispatchMode == Touch::DispatchMode::ONE_BY_ONE) if (touchEventListener->_dispatchMode == Touch::DispatchMode::ONE_BY_ONE)
{ {
@ -353,10 +353,10 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event)
bool isClaimed = false; bool isClaimed = false;
std::vector<Touch*>::iterator removedIter; std::vector<Touch*>::iterator removedIter;
auto touchEventListener = static_cast<TouchEventListener*>(item->listener); auto touchEventListenerTouch = static_cast<EventListener*>(item->listener);
TouchEvent::EventCode eventCode = event->getEventCode(); EventTouch::EventCode eventCode = event->getEventCode();
if (eventCode == TouchEvent::EventCode::BEGAN) if (eventCode == EventTouch::EventCode::BEGAN)
{ {
if (touchEventListener->onTouchBegan) if (touchEventListener->onTouchBegan)
{ {
@ -374,13 +374,13 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event)
switch (eventCode) switch (eventCode)
{ {
case TouchEvent::EventCode::MOVED: case EventTouch::EventCode::MOVED:
if (touchEventListener->onTouchMoved) if (touchEventListener->onTouchMoved)
{ {
touchEventListener->onTouchMoved(*touchesIter, event); touchEventListener->onTouchMoved(*touchesIter, event);
} }
break; break;
case TouchEvent::EventCode::ENDED: case EventTouch::EventCode::ENDED:
if (touchEventListener->onTouchEnded) if (touchEventListener->onTouchEnded)
{ {
touchEventListener->onTouchEnded(*touchesIter, event); touchEventListener->onTouchEnded(*touchesIter, event);
@ -390,7 +390,7 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event)
touchEventListener->_claimedTouches.erase(removedIter); touchEventListener->_claimedTouches.erase(removedIter);
} }
break; break;
case TouchEvent::EventCode::CANCELLED: case EventTouch::EventCode::CANCELLED:
if (touchEventListener->onTouchCancelled) if (touchEventListener->onTouchCancelled)
{ {
touchEventListener->onTouchCancelled(*touchesIter, event); touchEventListener->onTouchCancelled(*touchesIter, event);
@ -444,29 +444,29 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event)
event->setCurrentTarget(item->node); event->setCurrentTarget(item->node);
auto touchEventListener = static_cast<TouchEventListener*>(item->listener); auto touchEventListener = static_cast<EventListenerTouch*>(item->listener);
switch (event->getEventCode()) switch (event->getEventCode())
{ {
case TouchEvent::EventCode::BEGAN: case EventTouch::EventCode::BEGAN:
if (touchEventListener->onTouchesBegan) if (touchEventListener->onTouchesBegan)
{ {
touchEventListener->onTouchesBegan(mutableTouches, event); touchEventListener->onTouchesBegan(mutableTouches, event);
} }
break; break;
case TouchEvent::EventCode::MOVED: case EventTouch::EventCode::MOVED:
if (touchEventListener->onTouchesMoved) if (touchEventListener->onTouchesMoved)
{ {
touchEventListener->onTouchesMoved(mutableTouches, event); touchEventListener->onTouchesMoved(mutableTouches, event);
} }
break; break;
case TouchEvent::EventCode::ENDED: case EventTouch::EventCode::ENDED:
if (touchEventListener->onTouchesEnded) if (touchEventListener->onTouchesEnded)
{ {
touchEventListener->onTouchesEnded(mutableTouches, event); touchEventListener->onTouchesEnded(mutableTouches, event);
} }
break; break;
case TouchEvent::EventCode::CANCELLED: case EventTouch::EventCode::CANCELLED:
if (touchEventListener->onTouchesCancelled) if (touchEventListener->onTouchesCancelled)
{ {
touchEventListener->onTouchesCancelled(mutableTouches, event); touchEventListener->onTouchesCancelled(mutableTouches, event);

View File

@ -37,7 +37,7 @@
NS_CC_BEGIN NS_CC_BEGIN
class Event; class Event;
class TouchEvent; class EventTouch;
class Node; class Node;
/** /**
@ -124,7 +124,7 @@ private:
void addEventListenerWithItem(EventListenerItem* item); void addEventListenerWithItem(EventListenerItem* item);
/** Touch event needs to be processed different with other events since it needs support ALL_AT_ONCE and ONE_BY_NONE mode. */ /** Touch event needs to be processed different with other events since it needs support ALL_AT_ONCE and ONE_BY_NONE mode. */
void dispatchTouchEvent(TouchEvent* event); void dispatchTouchEvent(EventTouch* event);
/** Gets event the listener list for the event type. */ /** Gets event the listener list for the event type. */
std::vector<EventListenerItem*>* getListenerItemsForType(const std::string& eventType); std::vector<EventListenerItem*>* getListenerItemsForType(const std::string& eventType);

View File

@ -27,6 +27,6 @@
NS_CC_BEGIN NS_CC_BEGIN
const char* KeyboardEvent::EVENT_TYPE = "KeyboardEvent"; const char* EventKeyboard::EVENT_TYPE = "KeyboardEvent";
NS_CC_END NS_CC_END

View File

@ -30,7 +30,7 @@
NS_CC_BEGIN NS_CC_BEGIN
class KeyboardEvent : public Event class EventKeyboard : public Event
{ {
public: public:
/** /**
@ -198,7 +198,7 @@ public:
static const char* EVENT_TYPE; static const char* EVENT_TYPE;
KeyboardEvent(KeyCode keyCode, bool isPressed) EventKeyboard(KeyCode keyCode, bool isPressed)
: Event(EVENT_TYPE) : Event(EVENT_TYPE)
, _keyCode(keyCode) , _keyCode(keyCode)
, _isPressed(isPressed) , _isPressed(isPressed)
@ -208,7 +208,7 @@ private:
KeyCode _keyCode; KeyCode _keyCode;
bool _isPressed; bool _isPressed;
friend class KeyboardEventListener; friend class EventListenerKeyboard;
}; };
NS_CC_END NS_CC_END

View File

@ -29,16 +29,16 @@
NS_CC_BEGIN NS_CC_BEGIN
bool KeyboardEventListener::checkAvaiable() bool EventListenerKeyboard::checkAvaiable()
{ {
CCASSERT(onKeyPressed && onKeyReleased, ""); CCASSERT(onKeyPressed && onKeyReleased, "");
return true; return true;
} }
KeyboardEventListener* KeyboardEventListener::create() EventListenerKeyboard* EventListenerKeyboard::create()
{ {
auto ret = new KeyboardEventListener(); auto ret = new EventListenerKeyboard();
if (ret && ret->init()) if (ret && ret->init())
{ {
ret->autorelease(); ret->autorelease();
@ -50,9 +50,9 @@ KeyboardEventListener* KeyboardEventListener::create()
return ret; return ret;
} }
KeyboardEventListener* KeyboardEventListener::clone() EventListenerKeyboard* EventListenerKeyboard::clone()
{ {
auto ret = new KeyboardEventListener(); auto ret = new EventListenerKeyboard();
if (ret && ret->init()) if (ret && ret->init())
{ {
ret->autorelease(); ret->autorelease();
@ -66,16 +66,16 @@ KeyboardEventListener* KeyboardEventListener::clone()
return ret; return ret;
} }
KeyboardEventListener::KeyboardEventListener() EventListenerKeyboard::EventListenerKeyboard()
: onKeyPressed(nullptr) : onKeyPressed(nullptr)
, onKeyReleased(nullptr) , onKeyReleased(nullptr)
{ {
} }
bool KeyboardEventListener::init() bool EventListenerKeyboard::init()
{ {
auto listener = [this](Event* event){ auto listener = [this](Event* event){
auto keyboardEvent = static_cast<KeyboardEvent*>(event); auto keyboardEvent = static_cast<EventKeyboard*>(event);
if (keyboardEvent->_isPressed) if (keyboardEvent->_isPressed)
{ {
if (onKeyPressed != nullptr) if (onKeyPressed != nullptr)
@ -88,7 +88,7 @@ bool KeyboardEventListener::init()
} }
}; };
if (EventListener::init(KeyboardEvent::EVENT_TYPE, listener)) if (EventListener::init(EventKeyboard::EVENT_TYPE, listener))
{ {
return true; return true;
} }

View File

@ -33,19 +33,19 @@ NS_CC_BEGIN
class Event; class Event;
class KeyboardEventListener : public EventListener class EventListenerKeyboard : public EventListener
{ {
public: public:
static KeyboardEventListener* create(); static EventListenerKeyboard* create();
/// Overrides /// Overrides
virtual KeyboardEventListener* clone() override; virtual EventListenerKeyboard* clone() override;
virtual bool checkAvaiable() override; virtual bool checkAvaiable() override;
std::function<void(KeyboardEvent::KeyCode, Event* event)> onKeyPressed; std::function<void(EventKeyboard::KeyCode, Event* event)> onKeyPressed;
std::function<void(KeyboardEvent::KeyCode, Event* event)> onKeyReleased; std::function<void(EventKeyboard::KeyCode, Event* event)> onKeyReleased;
private: private:
KeyboardEventListener(); EventListenerKeyboard();
bool init(); bool init();
}; };

View File

@ -26,6 +26,6 @@
NS_CC_BEGIN NS_CC_BEGIN
const char* TouchEvent::EVENT_TYPE = "TouchEvent"; const char* EventTouch::EVENT_TYPE = "TouchEvent";
NS_CC_END NS_CC_END

View File

@ -33,7 +33,7 @@ NS_CC_BEGIN
#define TOUCH_PERF_DEBUG 1 #define TOUCH_PERF_DEBUG 1
class TouchEvent : public Event class EventTouch : public Event
{ {
public: public:
static const char* EVENT_TYPE; static const char* EVENT_TYPE;
@ -47,7 +47,7 @@ public:
CANCELLED CANCELLED
}; };
TouchEvent() EventTouch()
: Event(EVENT_TYPE) : Event(EVENT_TYPE)
{ {
_touches.reserve(MAX_TOUCHES); _touches.reserve(MAX_TOUCHES);

View File

@ -30,7 +30,7 @@
NS_CC_BEGIN NS_CC_BEGIN
TouchEventListener::TouchEventListener() EventListenerTouch::EventListenerTouch()
: onTouchBegan(nullptr) : onTouchBegan(nullptr)
, onTouchMoved(nullptr) , onTouchMoved(nullptr)
, onTouchEnded(nullptr) , onTouchEnded(nullptr)
@ -44,14 +44,14 @@ TouchEventListener::TouchEventListener()
{ {
} }
TouchEventListener::~TouchEventListener() EventListenerTouch::~EventListenerTouch()
{ {
CCLOGINFO("In the destructor of TouchEventListener, %p", this); CCLOGINFO("In the destructor of TouchEventListener, %p", this);
} }
bool TouchEventListener::init(Touch::DispatchMode mode) bool EventListenerTouch::init(Touch::DispatchMode mode)
{ {
if (EventListener::init(TouchEvent::EVENT_TYPE, nullptr)) if (EventListener::init(EventTouch::EVENT_TYPE, nullptr))
{ {
_dispatchMode = mode; _dispatchMode = mode;
return true; return true;
@ -60,15 +60,15 @@ bool TouchEventListener::init(Touch::DispatchMode mode)
return false; return false;
} }
void TouchEventListener::setSwallowTouches(bool needSwallow) void EventListenerTouch::setSwallowTouches(bool needSwallow)
{ {
CCASSERT(_dispatchMode == Touch::DispatchMode::ONE_BY_ONE, "Swallow touches only available in OneByOne mode."); CCASSERT(_dispatchMode == Touch::DispatchMode::ONE_BY_ONE, "Swallow touches only available in OneByOne mode.");
_needSwallow = needSwallow; _needSwallow = needSwallow;
} }
TouchEventListener* TouchEventListener::create(Touch::DispatchMode mode) EventListenerTouch* EventListenerTouch::create(Touch::DispatchMode mode)
{ {
auto ret = new TouchEventListener(); auto ret = new EventListenerTouch();
if (ret && ret->init(mode)) if (ret && ret->init(mode))
{ {
ret->autorelease(); ret->autorelease();
@ -80,7 +80,7 @@ TouchEventListener* TouchEventListener::create(Touch::DispatchMode mode)
return ret; return ret;
} }
bool TouchEventListener::checkAvaiable() bool EventListenerTouch::checkAvaiable()
{ {
if (_dispatchMode == Touch::DispatchMode::ALL_AT_ONCE) if (_dispatchMode == Touch::DispatchMode::ALL_AT_ONCE)
{ {
@ -108,9 +108,9 @@ bool TouchEventListener::checkAvaiable()
return true; return true;
} }
TouchEventListener* TouchEventListener::clone() EventListenerTouch* EventListenerTouch::clone()
{ {
auto ret = new TouchEventListener(); auto ret = new EventListenerTouch();
if (ret && ret->init(_dispatchMode)) if (ret && ret->init(_dispatchMode))
{ {
ret->autorelease(); ret->autorelease();

View File

@ -33,19 +33,19 @@
NS_CC_BEGIN NS_CC_BEGIN
class TouchEventListener : public EventListener class EventListenerTouch : public EventListener
{ {
public: public:
static TouchEventListener* create(Touch::DispatchMode mode); static EventListenerTouch* create(Touch::DispatchMode mode);
/// Overrides /// Overrides
virtual TouchEventListener* clone() override; virtual EventListenerTouch* clone() override;
virtual bool checkAvaiable() override; virtual bool checkAvaiable() override;
virtual ~TouchEventListener(); virtual ~EventListenerTouch();
private: private:
TouchEventListener(); EventListenerTouch();
bool init(Touch::DispatchMode mode); bool init(Touch::DispatchMode mode);
public: public:

View File

@ -109,7 +109,7 @@ void Layer::addTouchListener()
if( _touchMode == Touch::DispatchMode::ALL_AT_ONCE ) if( _touchMode == Touch::DispatchMode::ALL_AT_ONCE )
{ {
// Register Touch Event // Register Touch Event
auto listener = TouchEventListener::create(Touch::DispatchMode::ALL_AT_ONCE); auto listener = EventListenerTouch::create(Touch::DispatchMode::ALL_AT_ONCE);
listener->onTouchesBegan = CC_CALLBACK_2(Layer::onTouchesBegan, this); listener->onTouchesBegan = CC_CALLBACK_2(Layer::onTouchesBegan, this);
listener->onTouchesMoved = CC_CALLBACK_2(Layer::onTouchesMoved, this); listener->onTouchesMoved = CC_CALLBACK_2(Layer::onTouchesMoved, this);
@ -122,7 +122,7 @@ void Layer::addTouchListener()
else else
{ {
// Register Touch Event // Register Touch Event
auto listener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->setSwallowTouches(_swallowsTouches); listener->setSwallowTouches(_swallowsTouches);
listener->onTouchBegan = CC_CALLBACK_2(Layer::onTouchBegan, this); listener->onTouchBegan = CC_CALLBACK_2(Layer::onTouchBegan, this);
@ -135,7 +135,7 @@ void Layer::addTouchListener()
} }
} }
int Layer::executeScriptTouchHandler(TouchEvent::EventCode eventType, Touch* touch) int Layer::executeScriptTouchHandler(EventTouch::EventCode eventType, Touch* touch)
{ {
if (kScriptTypeNone != _scriptType) if (kScriptTypeNone != _scriptType)
{ {
@ -148,7 +148,7 @@ int Layer::executeScriptTouchHandler(TouchEvent::EventCode eventType, Touch* tou
return 0; return 0;
} }
int Layer::executeScriptTouchesHandler(TouchEvent::EventCode eventType, const std::vector<Touch*>& touches) int Layer::executeScriptTouchesHandler(EventTouch::EventCode eventType, const std::vector<Touch*>& touches)
{ {
if (kScriptTypeNone != _scriptType) if (kScriptTypeNone != _scriptType)
{ {
@ -249,7 +249,7 @@ void Layer::setAccelerometerEnabled(bool enabled)
if (enabled) if (enabled)
{ {
_accelerationListener = AccelerationEventListener::create(CC_CALLBACK_2(Layer::onAcceleration, this)); _accelerationListener = EventListenerAcceleration::create(CC_CALLBACK_2(Layer::onAcceleration, this));
dispatcher->addEventListenerWithSceneGraphPriority(_accelerationListener, this); dispatcher->addEventListenerWithSceneGraphPriority(_accelerationListener, this);
} }
} }
@ -280,13 +280,13 @@ void Layer::onAcceleration(Acceleration* pAccelerationValue, Event* event)
} }
} }
void Layer::onKeyPressed(KeyboardEvent::KeyCode keyCode, Event* event) void Layer::onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event)
{ {
CC_UNUSED_PARAM(keyCode); CC_UNUSED_PARAM(keyCode);
CC_UNUSED_PARAM(event); CC_UNUSED_PARAM(event);
} }
void Layer::onKeyReleased(KeyboardEvent::KeyCode keyCode, Event* event) void Layer::onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event)
{ {
CC_UNUSED_PARAM(event); CC_UNUSED_PARAM(event);
if(kScriptTypeNone != _scriptType) if(kScriptTypeNone != _scriptType)
@ -315,7 +315,7 @@ void Layer::setKeyboardEnabled(bool enabled)
if (enabled) if (enabled)
{ {
auto listener = KeyboardEventListener::create(); auto listener = EventListenerKeyboard::create();
listener->onKeyPressed = CC_CALLBACK_2(Layer::onKeyPressed, this); listener->onKeyPressed = CC_CALLBACK_2(Layer::onKeyPressed, this);
listener->onKeyReleased = CC_CALLBACK_2(Layer::onKeyReleased, this); listener->onKeyReleased = CC_CALLBACK_2(Layer::onKeyReleased, this);
@ -343,7 +343,7 @@ void Layer::onEnter()
{ {
auto dispatcher = EventDispatcher::getInstance(); auto dispatcher = EventDispatcher::getInstance();
dispatcher->removeEventListener(_accelerationListener); dispatcher->removeEventListener(_accelerationListener);
_accelerationListener = AccelerationEventListener::create(CC_CALLBACK_2(Layer::onAcceleration, this)); _accelerationListener = EventListenerAcceleration::create(CC_CALLBACK_2(Layer::onAcceleration, this));
dispatcher->addEventListenerWithSceneGraphPriority(_accelerationListener, this); dispatcher->addEventListenerWithSceneGraphPriority(_accelerationListener, this);
} }
} }
@ -372,7 +372,7 @@ void Layer::onEnterTransitionDidFinish()
{ {
auto dispatcher = EventDispatcher::getInstance(); auto dispatcher = EventDispatcher::getInstance();
dispatcher->removeEventListener(_accelerationListener); dispatcher->removeEventListener(_accelerationListener);
_accelerationListener = AccelerationEventListener::create(CC_CALLBACK_2(Layer::onAcceleration, this)); _accelerationListener = EventListenerAcceleration::create(CC_CALLBACK_2(Layer::onAcceleration, this));
dispatcher->addEventListenerWithSceneGraphPriority(_accelerationListener, this); dispatcher->addEventListenerWithSceneGraphPriority(_accelerationListener, this);
} }
@ -383,7 +383,7 @@ bool Layer::onTouchBegan(Touch *pTouch, Event *pEvent)
{ {
if (kScriptTypeNone != _scriptType) if (kScriptTypeNone != _scriptType)
{ {
return executeScriptTouchHandler(TouchEvent::EventCode::BEGAN, pTouch) == 0 ? false : true; return executeScriptTouchHandler(EventTouch::EventCode::BEGAN, pTouch) == 0 ? false : true;
} }
CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pTouch);
@ -396,7 +396,7 @@ void Layer::onTouchMoved(Touch *pTouch, Event *pEvent)
{ {
if (kScriptTypeNone != _scriptType) if (kScriptTypeNone != _scriptType)
{ {
executeScriptTouchHandler(TouchEvent::EventCode::MOVED, pTouch); executeScriptTouchHandler(EventTouch::EventCode::MOVED, pTouch);
return; return;
} }
@ -408,7 +408,7 @@ void Layer::onTouchEnded(Touch *pTouch, Event *pEvent)
{ {
if (kScriptTypeNone != _scriptType) if (kScriptTypeNone != _scriptType)
{ {
executeScriptTouchHandler(TouchEvent::EventCode::ENDED, pTouch); executeScriptTouchHandler(EventTouch::EventCode::ENDED, pTouch);
return; return;
} }
@ -420,7 +420,7 @@ void Layer::onTouchCancelled(Touch *pTouch, Event *pEvent)
{ {
if (kScriptTypeNone != _scriptType) if (kScriptTypeNone != _scriptType)
{ {
executeScriptTouchHandler(TouchEvent::EventCode::CANCELLED, pTouch); executeScriptTouchHandler(EventTouch::EventCode::CANCELLED, pTouch);
return; return;
} }
@ -432,7 +432,7 @@ void Layer::onTouchesBegan(const std::vector<Touch*>& pTouches, Event *pEvent)
{ {
if (kScriptTypeNone != _scriptType) if (kScriptTypeNone != _scriptType)
{ {
executeScriptTouchesHandler(TouchEvent::EventCode::BEGAN, pTouches); executeScriptTouchesHandler(EventTouch::EventCode::BEGAN, pTouches);
return; return;
} }
@ -444,7 +444,7 @@ void Layer::onTouchesMoved(const std::vector<Touch*>& pTouches, Event *pEvent)
{ {
if (kScriptTypeNone != _scriptType) if (kScriptTypeNone != _scriptType)
{ {
executeScriptTouchesHandler(TouchEvent::EventCode::MOVED, pTouches); executeScriptTouchesHandler(EventTouch::EventCode::MOVED, pTouches);
return; return;
} }
@ -456,7 +456,7 @@ void Layer::onTouchesEnded(const std::vector<Touch*>& pTouches, Event *pEvent)
{ {
if (kScriptTypeNone != _scriptType) if (kScriptTypeNone != _scriptType)
{ {
executeScriptTouchesHandler(TouchEvent::EventCode::ENDED, pTouches); executeScriptTouchesHandler(EventTouch::EventCode::ENDED, pTouches);
return; return;
} }
@ -468,7 +468,7 @@ void Layer::onTouchesCancelled(const std::vector<Touch*>& pTouches, Event *pEven
{ {
if (kScriptTypeNone != _scriptType) if (kScriptTypeNone != _scriptType)
{ {
executeScriptTouchesHandler(TouchEvent::EventCode::CANCELLED, pTouches); executeScriptTouchesHandler(EventTouch::EventCode::CANCELLED, pTouches);
return; return;
} }

View File

@ -46,9 +46,9 @@ NS_CC_BEGIN
class TouchScriptHandlerEntry; class TouchScriptHandlerEntry;
class TouchEventListener; class EventListenerTouch;
class KeyboardEventListener; class EventListenerKeyboard;
class AccelerationEventListener; class EventListenerAcceleration;
// //
// Layer // Layer
@ -152,8 +152,8 @@ public:
/** Please use onKeyReleased instead. */ /** Please use onKeyReleased instead. */
virtual void keyReleased(int keyCode) final {}; virtual void keyReleased(int keyCode) final {};
virtual void onKeyPressed(KeyboardEvent::KeyCode keyCode, Event* event); virtual void onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event);
virtual void onKeyReleased(KeyboardEvent::KeyCode keyCode, Event* event); virtual void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event);
CC_DEPRECATED_ATTRIBUTE virtual bool isKeypadEnabled() const final { return isKeyboardEnabled(); }; CC_DEPRECATED_ATTRIBUTE virtual bool isKeypadEnabled() const final { return isKeyboardEnabled(); };
CC_DEPRECATED_ATTRIBUTE virtual void setKeypadEnabled(bool value) { setKeyboardEnabled(value); }; CC_DEPRECATED_ATTRIBUTE virtual void setKeypadEnabled(bool value) { setKeyboardEnabled(value); };
@ -192,15 +192,15 @@ protected:
bool _touchEnabled; bool _touchEnabled;
bool _accelerometerEnabled; bool _accelerometerEnabled;
bool _keyboardEnabled; bool _keyboardEnabled;
TouchEventListener* _touchListener; EventListenerTouch* _touchListener;
KeyboardEventListener* _keyboardListener; EventListenerKeyboard* _keyboardListener;
AccelerationEventListener* _accelerationListener; EventListenerAcceleration* _accelerationListener;
private: private:
Touch::DispatchMode _touchMode; Touch::DispatchMode _touchMode;
bool _swallowsTouches; bool _swallowsTouches;
int executeScriptTouchHandler(TouchEvent::EventCode eventType, Touch* touch); int executeScriptTouchHandler(EventTouch::EventCode eventType, Touch* touch);
int executeScriptTouchesHandler(TouchEvent::EventCode eventType, const std::vector<Touch*>& touches); int executeScriptTouchesHandler(EventTouch::EventCode eventType, const std::vector<Touch*>& touches);
}; };
#ifdef __apple__ #ifdef __apple__

View File

@ -9,7 +9,7 @@ NS_CC_BEGIN
namespace { namespace {
static Touch* g_touches[TouchEvent::MAX_TOUCHES] = { NULL }; static Touch* g_touches[EventTouch::MAX_TOUCHES] = { NULL };
static unsigned int g_indexBitsUsed = 0; static unsigned int g_indexBitsUsed = 0;
// System touch pointer ID (It may not be ascending order number) <-> Ascending order number from 0 // System touch pointer ID (It may not be ascending order number) <-> Ascending order number from 0
static std::map<int, int> g_touchIdReorderMap; static std::map<int, int> g_touchIdReorderMap;
@ -19,7 +19,7 @@ namespace {
int i; int i;
int temp = g_indexBitsUsed; int temp = g_indexBitsUsed;
for (i = 0; i < TouchEvent::MAX_TOUCHES; i++) { for (i = 0; i < EventTouch::MAX_TOUCHES; i++) {
if (! (temp & 0x00000001)) { if (! (temp & 0x00000001)) {
g_indexBitsUsed |= (1 << i); g_indexBitsUsed |= (1 << i);
return i; return i;
@ -34,7 +34,7 @@ namespace {
static void removeUsedIndexBit(int index) static void removeUsedIndexBit(int index)
{ {
if (index < 0 || index >= TouchEvent::MAX_TOUCHES) if (index < 0 || index >= EventTouch::MAX_TOUCHES)
{ {
return; return;
} }
@ -207,7 +207,7 @@ void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float y
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
int nUnusedIndex = 0; int nUnusedIndex = 0;
TouchEvent touchEvent; EventTouch touchEvent;
for (int i = 0; i < num; ++i) for (int i = 0; i < num; ++i)
{ {
@ -246,7 +246,7 @@ void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float y
return; return;
} }
touchEvent._eventCode = TouchEvent::EventCode::BEGAN; touchEvent._eventCode = EventTouch::EventCode::BEGAN;
EventDispatcher::getInstance()->dispatchEvent(&touchEvent); EventDispatcher::getInstance()->dispatchEvent(&touchEvent);
} }
@ -255,7 +255,7 @@ void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys
int id = 0; int id = 0;
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
TouchEvent touchEvent; EventTouch touchEvent;
for (int i = 0; i < num; ++i) for (int i = 0; i < num; ++i)
{ {
@ -293,16 +293,16 @@ void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys
return; return;
} }
touchEvent._eventCode = TouchEvent::EventCode::MOVED; touchEvent._eventCode = EventTouch::EventCode::MOVED;
EventDispatcher::getInstance()->dispatchEvent(&touchEvent); EventDispatcher::getInstance()->dispatchEvent(&touchEvent);
} }
void EGLViewProtocol::handleTouchesOfEndOrCancel(TouchEvent::EventCode eventCode, int num, int ids[], float xs[], float ys[]) void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[])
{ {
int id = 0; int id = 0;
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
TouchEvent touchEvent; EventTouch touchEvent;
for (int i = 0; i < num; ++i) for (int i = 0; i < num; ++i)
{ {
@ -358,12 +358,12 @@ void EGLViewProtocol::handleTouchesOfEndOrCancel(TouchEvent::EventCode eventCode
void EGLViewProtocol::handleTouchesEnd(int num, int ids[], float xs[], float ys[]) void EGLViewProtocol::handleTouchesEnd(int num, int ids[], float xs[], float ys[])
{ {
handleTouchesOfEndOrCancel(TouchEvent::EventCode::ENDED, num, ids, xs, ys); handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys);
} }
void EGLViewProtocol::handleTouchesCancel(int num, int ids[], float xs[], float ys[]) void EGLViewProtocol::handleTouchesCancel(int num, int ids[], float xs[], float ys[])
{ {
handleTouchesOfEndOrCancel(TouchEvent::EventCode::CANCELLED, num, ids, xs, ys); handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys);
} }
const Rect& EGLViewProtocol::getViewPortRect() const const Rect& EGLViewProtocol::getViewPortRect() const

View File

@ -156,7 +156,7 @@ public:
*/ */
float getScaleY() const; float getScaleY() const;
private: private:
void handleTouchesOfEndOrCancel(TouchEvent::EventCode eventCode, int num, int ids[], float xs[], float ys[]); void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]);
protected: protected:
EGLTouchDelegate* _delegate; EGLTouchDelegate* _delegate;

View File

@ -400,13 +400,13 @@ static int32_t handle_key_input(AInputEvent *event)
{ {
case AKEYCODE_BACK: case AKEYCODE_BACK:
{ {
cocos2d::KeyboardEvent event(cocos2d::KeyboardEvent::KeyCode::KEY_BACKSPACE, false); cocos2d::EventKeyboard event(cocos2d::EventKeyboard::KeyCode::KEY_BACKSPACE, false);
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event); cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event);
} }
return 1; return 1;
case AKEYCODE_MENU: case AKEYCODE_MENU:
{ {
cocos2d::KeyboardEvent event(cocos2d::KeyboardEvent::KeyCode::KEY_MENU, false); cocos2d::EventKeyboard event(cocos2d::EventKeyboard::KeyCode::KEY_MENU, false);
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event); cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event);
} }
return 1; return 1;
@ -602,7 +602,7 @@ void android_main(struct android_app* state) {
acc.y = -event.acceleration.y/10; acc.y = -event.acceleration.y/10;
acc.z = event.acceleration.z/10; acc.z = event.acceleration.z/10;
acc.timestamp = 0; acc.timestamp = 0;
cocos2d::AccelerationEvent accEvent(acc); cocos2d::EventAcceleration accEvent(acc);
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&accEvent); cocos2d::EventDispatcher::getInstance()->dispatchEvent(&accEvent);
} else { } else {
@ -613,7 +613,7 @@ void android_main(struct android_app* state) {
acc.y = -event.acceleration.x/10; acc.y = -event.acceleration.x/10;
acc.z = event.acceleration.z/10; acc.z = event.acceleration.z/10;
acc.timestamp = 0; acc.timestamp = 0;
cocos2d::AccelerationEvent accEvent(acc); cocos2d::EventAcceleration accEvent(acc);
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&accEvent); cocos2d::EventDispatcher::getInstance()->dispatchEvent(&accEvent);
} }

View File

@ -95,7 +95,7 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher;
break; break;
} }
cocos2d::AccelerationEvent event(*_acceleration); cocos2d::EventAcceleration event(*_acceleration);
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event); cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event);
} }

View File

@ -18,134 +18,134 @@
NS_CC_BEGIN NS_CC_BEGIN
static std::map<int, KeyboardEvent::KeyCode> g_keyCodeMap = { static std::map<int, EventKeyboard::KeyCode> g_keyCodeMap = {
/* The unknown key */ /* The unknown key */
{ GLFW_KEY_UNKNOWN , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_UNKNOWN , EventKeyboard::KeyCode::KEY_NONE },
/* Printable keys */ /* Printable keys */
{ GLFW_KEY_SPACE , KeyboardEvent::KeyCode::KEY_SPACE }, { GLFW_KEY_SPACE , EventKeyboard::KeyCode::KEY_SPACE },
{ GLFW_KEY_APOSTROPHE , KeyboardEvent::KeyCode::KEY_APOSTROPHE }, { GLFW_KEY_APOSTROPHE , EventKeyboard::KeyCode::KEY_APOSTROPHE },
{ GLFW_KEY_COMMA , KeyboardEvent::KeyCode::KEY_COMMA }, { GLFW_KEY_COMMA , EventKeyboard::KeyCode::KEY_COMMA },
{ GLFW_KEY_MINUS , KeyboardEvent::KeyCode::KEY_MINUS }, { GLFW_KEY_MINUS , EventKeyboard::KeyCode::KEY_MINUS },
{ GLFW_KEY_PERIOD , KeyboardEvent::KeyCode::KEY_PERIOD }, { GLFW_KEY_PERIOD , EventKeyboard::KeyCode::KEY_PERIOD },
{ GLFW_KEY_SLASH , KeyboardEvent::KeyCode::KEY_SLASH }, { GLFW_KEY_SLASH , EventKeyboard::KeyCode::KEY_SLASH },
{ GLFW_KEY_0 , KeyboardEvent::KeyCode::KEY_0 }, { GLFW_KEY_0 , EventKeyboard::KeyCode::KEY_0 },
{ GLFW_KEY_1 , KeyboardEvent::KeyCode::KEY_1 }, { GLFW_KEY_1 , EventKeyboard::KeyCode::KEY_1 },
{ GLFW_KEY_2 , KeyboardEvent::KeyCode::KEY_2 }, { GLFW_KEY_2 , EventKeyboard::KeyCode::KEY_2 },
{ GLFW_KEY_3 , KeyboardEvent::KeyCode::KEY_3 }, { GLFW_KEY_3 , EventKeyboard::KeyCode::KEY_3 },
{ GLFW_KEY_4 , KeyboardEvent::KeyCode::KEY_4 }, { GLFW_KEY_4 , EventKeyboard::KeyCode::KEY_4 },
{ GLFW_KEY_5 , KeyboardEvent::KeyCode::KEY_5 }, { GLFW_KEY_5 , EventKeyboard::KeyCode::KEY_5 },
{ GLFW_KEY_6 , KeyboardEvent::KeyCode::KEY_6 }, { GLFW_KEY_6 , EventKeyboard::KeyCode::KEY_6 },
{ GLFW_KEY_7 , KeyboardEvent::KeyCode::KEY_7 }, { GLFW_KEY_7 , EventKeyboard::KeyCode::KEY_7 },
{ GLFW_KEY_8 , KeyboardEvent::KeyCode::KEY_8 }, { GLFW_KEY_8 , EventKeyboard::KeyCode::KEY_8 },
{ GLFW_KEY_9 , KeyboardEvent::KeyCode::KEY_9 }, { GLFW_KEY_9 , EventKeyboard::KeyCode::KEY_9 },
{ GLFW_KEY_SEMICOLON , KeyboardEvent::KeyCode::KEY_SEMICOLON }, { GLFW_KEY_SEMICOLON , EventKeyboard::KeyCode::KEY_SEMICOLON },
{ GLFW_KEY_EQUAL , KeyboardEvent::KeyCode::KEY_EQUAL }, { GLFW_KEY_EQUAL , EventKeyboard::KeyCode::KEY_EQUAL },
{ GLFW_KEY_A , KeyboardEvent::KeyCode::KEY_A }, { GLFW_KEY_A , EventKeyboard::KeyCode::KEY_A },
{ GLFW_KEY_B , KeyboardEvent::KeyCode::KEY_B }, { GLFW_KEY_B , EventKeyboard::KeyCode::KEY_B },
{ GLFW_KEY_C , KeyboardEvent::KeyCode::KEY_C }, { GLFW_KEY_C , EventKeyboard::KeyCode::KEY_C },
{ GLFW_KEY_D , KeyboardEvent::KeyCode::KEY_D }, { GLFW_KEY_D , EventKeyboard::KeyCode::KEY_D },
{ GLFW_KEY_E , KeyboardEvent::KeyCode::KEY_E }, { GLFW_KEY_E , EventKeyboard::KeyCode::KEY_E },
{ GLFW_KEY_F , KeyboardEvent::KeyCode::KEY_F }, { GLFW_KEY_F , EventKeyboard::KeyCode::KEY_F },
{ GLFW_KEY_G , KeyboardEvent::KeyCode::KEY_G }, { GLFW_KEY_G , EventKeyboard::KeyCode::KEY_G },
{ GLFW_KEY_H , KeyboardEvent::KeyCode::KEY_H }, { GLFW_KEY_H , EventKeyboard::KeyCode::KEY_H },
{ GLFW_KEY_I , KeyboardEvent::KeyCode::KEY_I }, { GLFW_KEY_I , EventKeyboard::KeyCode::KEY_I },
{ GLFW_KEY_J , KeyboardEvent::KeyCode::KEY_J }, { GLFW_KEY_J , EventKeyboard::KeyCode::KEY_J },
{ GLFW_KEY_K , KeyboardEvent::KeyCode::KEY_K }, { GLFW_KEY_K , EventKeyboard::KeyCode::KEY_K },
{ GLFW_KEY_L , KeyboardEvent::KeyCode::KEY_L }, { GLFW_KEY_L , EventKeyboard::KeyCode::KEY_L },
{ GLFW_KEY_M , KeyboardEvent::KeyCode::KEY_M }, { GLFW_KEY_M , EventKeyboard::KeyCode::KEY_M },
{ GLFW_KEY_N , KeyboardEvent::KeyCode::KEY_N }, { GLFW_KEY_N , EventKeyboard::KeyCode::KEY_N },
{ GLFW_KEY_O , KeyboardEvent::KeyCode::KEY_O }, { GLFW_KEY_O , EventKeyboard::KeyCode::KEY_O },
{ GLFW_KEY_P , KeyboardEvent::KeyCode::KEY_P }, { GLFW_KEY_P , EventKeyboard::KeyCode::KEY_P },
{ GLFW_KEY_Q , KeyboardEvent::KeyCode::KEY_Q }, { GLFW_KEY_Q , EventKeyboard::KeyCode::KEY_Q },
{ GLFW_KEY_R , KeyboardEvent::KeyCode::KEY_R }, { GLFW_KEY_R , EventKeyboard::KeyCode::KEY_R },
{ GLFW_KEY_S , KeyboardEvent::KeyCode::KEY_S }, { GLFW_KEY_S , EventKeyboard::KeyCode::KEY_S },
{ GLFW_KEY_T , KeyboardEvent::KeyCode::KEY_T }, { GLFW_KEY_T , EventKeyboard::KeyCode::KEY_T },
{ GLFW_KEY_U , KeyboardEvent::KeyCode::KEY_U }, { GLFW_KEY_U , EventKeyboard::KeyCode::KEY_U },
{ GLFW_KEY_V , KeyboardEvent::KeyCode::KEY_V }, { GLFW_KEY_V , EventKeyboard::KeyCode::KEY_V },
{ GLFW_KEY_W , KeyboardEvent::KeyCode::KEY_W }, { GLFW_KEY_W , EventKeyboard::KeyCode::KEY_W },
{ GLFW_KEY_X , KeyboardEvent::KeyCode::KEY_X }, { GLFW_KEY_X , EventKeyboard::KeyCode::KEY_X },
{ GLFW_KEY_Y , KeyboardEvent::KeyCode::KEY_Y }, { GLFW_KEY_Y , EventKeyboard::KeyCode::KEY_Y },
{ GLFW_KEY_Z , KeyboardEvent::KeyCode::KEY_Z }, { GLFW_KEY_Z , EventKeyboard::KeyCode::KEY_Z },
{ GLFW_KEY_LEFT_BRACKET , KeyboardEvent::KeyCode::KEY_LEFT_BRACKET }, { GLFW_KEY_LEFT_BRACKET , EventKeyboard::KeyCode::KEY_LEFT_BRACKET },
{ GLFW_KEY_BACKSLASH , KeyboardEvent::KeyCode::KEY_BACK_SLASH }, { GLFW_KEY_BACKSLASH , EventKeyboard::KeyCode::KEY_BACK_SLASH },
{ GLFW_KEY_RIGHT_BRACKET , KeyboardEvent::KeyCode::KEY_RIGHT_BRACKET }, { GLFW_KEY_RIGHT_BRACKET , EventKeyboard::KeyCode::KEY_RIGHT_BRACKET },
{ GLFW_KEY_GRAVE_ACCENT , KeyboardEvent::KeyCode::KEY_GRAVE }, { GLFW_KEY_GRAVE_ACCENT , EventKeyboard::KeyCode::KEY_GRAVE },
{ GLFW_KEY_WORLD_1 , KeyboardEvent::KeyCode::KEY_GRAVE }, { GLFW_KEY_WORLD_1 , EventKeyboard::KeyCode::KEY_GRAVE },
{ GLFW_KEY_WORLD_2 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_WORLD_2 , EventKeyboard::KeyCode::KEY_NONE },
/* Function keys */ /* Function keys */
{ GLFW_KEY_ESCAPE , KeyboardEvent::KeyCode::KEY_ESCAPE }, { GLFW_KEY_ESCAPE , EventKeyboard::KeyCode::KEY_ESCAPE },
{ GLFW_KEY_ENTER , KeyboardEvent::KeyCode::KEY_KP_ENTER }, { GLFW_KEY_ENTER , EventKeyboard::KeyCode::KEY_KP_ENTER },
{ GLFW_KEY_TAB , KeyboardEvent::KeyCode::KEY_TAB }, { GLFW_KEY_TAB , EventKeyboard::KeyCode::KEY_TAB },
{ GLFW_KEY_BACKSPACE , KeyboardEvent::KeyCode::KEY_BACKSPACE }, { GLFW_KEY_BACKSPACE , EventKeyboard::KeyCode::KEY_BACKSPACE },
{ GLFW_KEY_INSERT , KeyboardEvent::KeyCode::KEY_INSERT }, { GLFW_KEY_INSERT , EventKeyboard::KeyCode::KEY_INSERT },
{ GLFW_KEY_DELETE , KeyboardEvent::KeyCode::KEY_DELETE }, { GLFW_KEY_DELETE , EventKeyboard::KeyCode::KEY_DELETE },
{ GLFW_KEY_RIGHT , KeyboardEvent::KeyCode::KEY_RIGHT_ARROW }, { GLFW_KEY_RIGHT , EventKeyboard::KeyCode::KEY_RIGHT_ARROW },
{ GLFW_KEY_LEFT , KeyboardEvent::KeyCode::KEY_LEFT_ARROW }, { GLFW_KEY_LEFT , EventKeyboard::KeyCode::KEY_LEFT_ARROW },
{ GLFW_KEY_DOWN , KeyboardEvent::KeyCode::KEY_DOWN_ARROW }, { GLFW_KEY_DOWN , EventKeyboard::KeyCode::KEY_DOWN_ARROW },
{ GLFW_KEY_UP , KeyboardEvent::KeyCode::KEY_UP_ARROW }, { GLFW_KEY_UP , EventKeyboard::KeyCode::KEY_UP_ARROW },
{ GLFW_KEY_PAGE_UP , KeyboardEvent::KeyCode::KEY_KP_PG_UP }, { GLFW_KEY_PAGE_UP , EventKeyboard::KeyCode::KEY_KP_PG_UP },
{ GLFW_KEY_PAGE_DOWN , KeyboardEvent::KeyCode::KEY_KP_PG_DOWN }, { GLFW_KEY_PAGE_DOWN , EventKeyboard::KeyCode::KEY_KP_PG_DOWN },
{ GLFW_KEY_HOME , KeyboardEvent::KeyCode::KEY_KP_HOME }, { GLFW_KEY_HOME , EventKeyboard::KeyCode::KEY_KP_HOME },
{ GLFW_KEY_END , KeyboardEvent::KeyCode::KEY_END }, { GLFW_KEY_END , EventKeyboard::KeyCode::KEY_END },
{ GLFW_KEY_CAPS_LOCK , KeyboardEvent::KeyCode::KEY_CAPS_LOCK }, { GLFW_KEY_CAPS_LOCK , EventKeyboard::KeyCode::KEY_CAPS_LOCK },
{ GLFW_KEY_SCROLL_LOCK , KeyboardEvent::KeyCode::KEY_SCROLL_LOCK }, { GLFW_KEY_SCROLL_LOCK , EventKeyboard::KeyCode::KEY_SCROLL_LOCK },
{ GLFW_KEY_NUM_LOCK , KeyboardEvent::KeyCode::KEY_NUM_LOCK }, { GLFW_KEY_NUM_LOCK , EventKeyboard::KeyCode::KEY_NUM_LOCK },
{ GLFW_KEY_PRINT_SCREEN , KeyboardEvent::KeyCode::KEY_PRINT }, { GLFW_KEY_PRINT_SCREEN , EventKeyboard::KeyCode::KEY_PRINT },
{ GLFW_KEY_PAUSE , KeyboardEvent::KeyCode::KEY_PAUSE }, { GLFW_KEY_PAUSE , EventKeyboard::KeyCode::KEY_PAUSE },
{ GLFW_KEY_F1 , KeyboardEvent::KeyCode::KEY_F1 }, { GLFW_KEY_F1 , EventKeyboard::KeyCode::KEY_F1 },
{ GLFW_KEY_F2 , KeyboardEvent::KeyCode::KEY_F2 }, { GLFW_KEY_F2 , EventKeyboard::KeyCode::KEY_F2 },
{ GLFW_KEY_F3 , KeyboardEvent::KeyCode::KEY_F3 }, { GLFW_KEY_F3 , EventKeyboard::KeyCode::KEY_F3 },
{ GLFW_KEY_F4 , KeyboardEvent::KeyCode::KEY_F4 }, { GLFW_KEY_F4 , EventKeyboard::KeyCode::KEY_F4 },
{ GLFW_KEY_F5 , KeyboardEvent::KeyCode::KEY_F5 }, { GLFW_KEY_F5 , EventKeyboard::KeyCode::KEY_F5 },
{ GLFW_KEY_F6 , KeyboardEvent::KeyCode::KEY_F6 }, { GLFW_KEY_F6 , EventKeyboard::KeyCode::KEY_F6 },
{ GLFW_KEY_F7 , KeyboardEvent::KeyCode::KEY_F7 }, { GLFW_KEY_F7 , EventKeyboard::KeyCode::KEY_F7 },
{ GLFW_KEY_F8 , KeyboardEvent::KeyCode::KEY_F8 }, { GLFW_KEY_F8 , EventKeyboard::KeyCode::KEY_F8 },
{ GLFW_KEY_F9 , KeyboardEvent::KeyCode::KEY_F9 }, { GLFW_KEY_F9 , EventKeyboard::KeyCode::KEY_F9 },
{ GLFW_KEY_F10 , KeyboardEvent::KeyCode::KEY_F10 }, { GLFW_KEY_F10 , EventKeyboard::KeyCode::KEY_F10 },
{ GLFW_KEY_F11 , KeyboardEvent::KeyCode::KEY_F11 }, { GLFW_KEY_F11 , EventKeyboard::KeyCode::KEY_F11 },
{ GLFW_KEY_F12 , KeyboardEvent::KeyCode::KEY_F12 }, { GLFW_KEY_F12 , EventKeyboard::KeyCode::KEY_F12 },
{ GLFW_KEY_F13 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F13 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F14 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F14 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F15 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F15 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F16 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F16 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F17 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F17 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F18 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F18 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F19 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F19 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F20 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F20 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F21 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F21 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F22 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F22 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F23 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F23 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F24 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F24 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F25 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F25 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_KP_0 , KeyboardEvent::KeyCode::KEY_0 }, { GLFW_KEY_KP_0 , EventKeyboard::KeyCode::KEY_0 },
{ GLFW_KEY_KP_1 , KeyboardEvent::KeyCode::KEY_1 }, { GLFW_KEY_KP_1 , EventKeyboard::KeyCode::KEY_1 },
{ GLFW_KEY_KP_2 , KeyboardEvent::KeyCode::KEY_2 }, { GLFW_KEY_KP_2 , EventKeyboard::KeyCode::KEY_2 },
{ GLFW_KEY_KP_3 , KeyboardEvent::KeyCode::KEY_3 }, { GLFW_KEY_KP_3 , EventKeyboard::KeyCode::KEY_3 },
{ GLFW_KEY_KP_4 , KeyboardEvent::KeyCode::KEY_4 }, { GLFW_KEY_KP_4 , EventKeyboard::KeyCode::KEY_4 },
{ GLFW_KEY_KP_5 , KeyboardEvent::KeyCode::KEY_5 }, { GLFW_KEY_KP_5 , EventKeyboard::KeyCode::KEY_5 },
{ GLFW_KEY_KP_6 , KeyboardEvent::KeyCode::KEY_6 }, { GLFW_KEY_KP_6 , EventKeyboard::KeyCode::KEY_6 },
{ GLFW_KEY_KP_7 , KeyboardEvent::KeyCode::KEY_7 }, { GLFW_KEY_KP_7 , EventKeyboard::KeyCode::KEY_7 },
{ GLFW_KEY_KP_8 , KeyboardEvent::KeyCode::KEY_8 }, { GLFW_KEY_KP_8 , EventKeyboard::KeyCode::KEY_8 },
{ GLFW_KEY_KP_9 , KeyboardEvent::KeyCode::KEY_9 }, { GLFW_KEY_KP_9 , EventKeyboard::KeyCode::KEY_9 },
{ GLFW_KEY_KP_DECIMAL , KeyboardEvent::KeyCode::KEY_PERIOD }, { GLFW_KEY_KP_DECIMAL , EventKeyboard::KeyCode::KEY_PERIOD },
{ GLFW_KEY_KP_DIVIDE , KeyboardEvent::KeyCode::KEY_KP_DIVIDE }, { GLFW_KEY_KP_DIVIDE , EventKeyboard::KeyCode::KEY_KP_DIVIDE },
{ GLFW_KEY_KP_MULTIPLY , KeyboardEvent::KeyCode::KEY_KP_MULTIPLY }, { GLFW_KEY_KP_MULTIPLY , EventKeyboard::KeyCode::KEY_KP_MULTIPLY },
{ GLFW_KEY_KP_SUBTRACT , KeyboardEvent::KeyCode::KEY_KP_MINUS }, { GLFW_KEY_KP_SUBTRACT , EventKeyboard::KeyCode::KEY_KP_MINUS },
{ GLFW_KEY_KP_ADD , KeyboardEvent::KeyCode::KEY_KP_PLUS }, { GLFW_KEY_KP_ADD , EventKeyboard::KeyCode::KEY_KP_PLUS },
{ GLFW_KEY_KP_ENTER , KeyboardEvent::KeyCode::KEY_KP_ENTER }, { GLFW_KEY_KP_ENTER , EventKeyboard::KeyCode::KEY_KP_ENTER },
{ GLFW_KEY_KP_EQUAL , KeyboardEvent::KeyCode::KEY_EQUAL }, { GLFW_KEY_KP_EQUAL , EventKeyboard::KeyCode::KEY_EQUAL },
{ GLFW_KEY_LEFT_SHIFT , KeyboardEvent::KeyCode::KEY_SHIFT }, { GLFW_KEY_LEFT_SHIFT , EventKeyboard::KeyCode::KEY_SHIFT },
{ GLFW_KEY_LEFT_CONTROL , KeyboardEvent::KeyCode::KEY_CTRL }, { GLFW_KEY_LEFT_CONTROL , EventKeyboard::KeyCode::KEY_CTRL },
{ GLFW_KEY_LEFT_ALT , KeyboardEvent::KeyCode::KEY_ALT }, { GLFW_KEY_LEFT_ALT , EventKeyboard::KeyCode::KEY_ALT },
{ GLFW_KEY_LEFT_SUPER , KeyboardEvent::KeyCode::KEY_HYPER }, { GLFW_KEY_LEFT_SUPER , EventKeyboard::KeyCode::KEY_HYPER },
{ GLFW_KEY_RIGHT_SHIFT , KeyboardEvent::KeyCode::KEY_SHIFT }, { GLFW_KEY_RIGHT_SHIFT , EventKeyboard::KeyCode::KEY_SHIFT },
{ GLFW_KEY_RIGHT_CONTROL , KeyboardEvent::KeyCode::KEY_CTRL }, { GLFW_KEY_RIGHT_CONTROL , EventKeyboard::KeyCode::KEY_CTRL },
{ GLFW_KEY_RIGHT_ALT , KeyboardEvent::KeyCode::KEY_ALT }, { GLFW_KEY_RIGHT_ALT , EventKeyboard::KeyCode::KEY_ALT },
{ GLFW_KEY_RIGHT_SUPER , KeyboardEvent::KeyCode::KEY_HYPER }, { GLFW_KEY_RIGHT_SUPER , EventKeyboard::KeyCode::KEY_HYPER },
{ GLFW_KEY_MENU , KeyboardEvent::KeyCode::KEY_MENU }, { GLFW_KEY_MENU , EventKeyboard::KeyCode::KEY_MENU },
{ GLFW_KEY_LAST , KeyboardEvent::KeyCode::KEY_NONE } { GLFW_KEY_LAST , EventKeyboard::KeyCode::KEY_NONE }
}; };
//begin EGLViewEventHandler //begin EGLViewEventHandler
@ -222,7 +222,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
{ {
KeyboardEvent event(g_keyCodeMap[key], GLFW_PRESS == action); EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action);
EventDispatcher::getInstance()->dispatchEvent(&event); EventDispatcher::getInstance()->dispatchEvent(&event);
} }

View File

@ -33,134 +33,134 @@
NS_CC_BEGIN NS_CC_BEGIN
static std::map<int, KeyboardEvent::KeyCode> g_keyCodeMap = { static std::map<int, EventKeyboard::KeyCode> g_keyCodeMap = {
/* The unknown key */ /* The unknown key */
{ GLFW_KEY_UNKNOWN , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_UNKNOWN , EventKeyboard::KeyCode::KEY_NONE },
/* Printable keys */ /* Printable keys */
{ GLFW_KEY_SPACE , KeyboardEvent::KeyCode::KEY_SPACE }, { GLFW_KEY_SPACE , EventKeyboard::KeyCode::KEY_SPACE },
{ GLFW_KEY_APOSTROPHE , KeyboardEvent::KeyCode::KEY_APOSTROPHE }, { GLFW_KEY_APOSTROPHE , EventKeyboard::KeyCode::KEY_APOSTROPHE },
{ GLFW_KEY_COMMA , KeyboardEvent::KeyCode::KEY_COMMA }, { GLFW_KEY_COMMA , EventKeyboard::KeyCode::KEY_COMMA },
{ GLFW_KEY_MINUS , KeyboardEvent::KeyCode::KEY_MINUS }, { GLFW_KEY_MINUS , EventKeyboard::KeyCode::KEY_MINUS },
{ GLFW_KEY_PERIOD , KeyboardEvent::KeyCode::KEY_PERIOD }, { GLFW_KEY_PERIOD , EventKeyboard::KeyCode::KEY_PERIOD },
{ GLFW_KEY_SLASH , KeyboardEvent::KeyCode::KEY_SLASH }, { GLFW_KEY_SLASH , EventKeyboard::KeyCode::KEY_SLASH },
{ GLFW_KEY_0 , KeyboardEvent::KeyCode::KEY_0 }, { GLFW_KEY_0 , EventKeyboard::KeyCode::KEY_0 },
{ GLFW_KEY_1 , KeyboardEvent::KeyCode::KEY_1 }, { GLFW_KEY_1 , EventKeyboard::KeyCode::KEY_1 },
{ GLFW_KEY_2 , KeyboardEvent::KeyCode::KEY_2 }, { GLFW_KEY_2 , EventKeyboard::KeyCode::KEY_2 },
{ GLFW_KEY_3 , KeyboardEvent::KeyCode::KEY_3 }, { GLFW_KEY_3 , EventKeyboard::KeyCode::KEY_3 },
{ GLFW_KEY_4 , KeyboardEvent::KeyCode::KEY_4 }, { GLFW_KEY_4 , EventKeyboard::KeyCode::KEY_4 },
{ GLFW_KEY_5 , KeyboardEvent::KeyCode::KEY_5 }, { GLFW_KEY_5 , EventKeyboard::KeyCode::KEY_5 },
{ GLFW_KEY_6 , KeyboardEvent::KeyCode::KEY_6 }, { GLFW_KEY_6 , EventKeyboard::KeyCode::KEY_6 },
{ GLFW_KEY_7 , KeyboardEvent::KeyCode::KEY_7 }, { GLFW_KEY_7 , EventKeyboard::KeyCode::KEY_7 },
{ GLFW_KEY_8 , KeyboardEvent::KeyCode::KEY_8 }, { GLFW_KEY_8 , EventKeyboard::KeyCode::KEY_8 },
{ GLFW_KEY_9 , KeyboardEvent::KeyCode::KEY_9 }, { GLFW_KEY_9 , EventKeyboard::KeyCode::KEY_9 },
{ GLFW_KEY_SEMICOLON , KeyboardEvent::KeyCode::KEY_SEMICOLON }, { GLFW_KEY_SEMICOLON , EventKeyboard::KeyCode::KEY_SEMICOLON },
{ GLFW_KEY_EQUAL , KeyboardEvent::KeyCode::KEY_EQUAL }, { GLFW_KEY_EQUAL , EventKeyboard::KeyCode::KEY_EQUAL },
{ GLFW_KEY_A , KeyboardEvent::KeyCode::KEY_A }, { GLFW_KEY_A , EventKeyboard::KeyCode::KEY_A },
{ GLFW_KEY_B , KeyboardEvent::KeyCode::KEY_B }, { GLFW_KEY_B , EventKeyboard::KeyCode::KEY_B },
{ GLFW_KEY_C , KeyboardEvent::KeyCode::KEY_C }, { GLFW_KEY_C , EventKeyboard::KeyCode::KEY_C },
{ GLFW_KEY_D , KeyboardEvent::KeyCode::KEY_D }, { GLFW_KEY_D , EventKeyboard::KeyCode::KEY_D },
{ GLFW_KEY_E , KeyboardEvent::KeyCode::KEY_E }, { GLFW_KEY_E , EventKeyboard::KeyCode::KEY_E },
{ GLFW_KEY_F , KeyboardEvent::KeyCode::KEY_F }, { GLFW_KEY_F , EventKeyboard::KeyCode::KEY_F },
{ GLFW_KEY_G , KeyboardEvent::KeyCode::KEY_G }, { GLFW_KEY_G , EventKeyboard::KeyCode::KEY_G },
{ GLFW_KEY_H , KeyboardEvent::KeyCode::KEY_H }, { GLFW_KEY_H , EventKeyboard::KeyCode::KEY_H },
{ GLFW_KEY_I , KeyboardEvent::KeyCode::KEY_I }, { GLFW_KEY_I , EventKeyboard::KeyCode::KEY_I },
{ GLFW_KEY_J , KeyboardEvent::KeyCode::KEY_J }, { GLFW_KEY_J , EventKeyboard::KeyCode::KEY_J },
{ GLFW_KEY_K , KeyboardEvent::KeyCode::KEY_K }, { GLFW_KEY_K , EventKeyboard::KeyCode::KEY_K },
{ GLFW_KEY_L , KeyboardEvent::KeyCode::KEY_L }, { GLFW_KEY_L , EventKeyboard::KeyCode::KEY_L },
{ GLFW_KEY_M , KeyboardEvent::KeyCode::KEY_M }, { GLFW_KEY_M , EventKeyboard::KeyCode::KEY_M },
{ GLFW_KEY_N , KeyboardEvent::KeyCode::KEY_N }, { GLFW_KEY_N , EventKeyboard::KeyCode::KEY_N },
{ GLFW_KEY_O , KeyboardEvent::KeyCode::KEY_O }, { GLFW_KEY_O , EventKeyboard::KeyCode::KEY_O },
{ GLFW_KEY_P , KeyboardEvent::KeyCode::KEY_P }, { GLFW_KEY_P , EventKeyboard::KeyCode::KEY_P },
{ GLFW_KEY_Q , KeyboardEvent::KeyCode::KEY_Q }, { GLFW_KEY_Q , EventKeyboard::KeyCode::KEY_Q },
{ GLFW_KEY_R , KeyboardEvent::KeyCode::KEY_R }, { GLFW_KEY_R , EventKeyboard::KeyCode::KEY_R },
{ GLFW_KEY_S , KeyboardEvent::KeyCode::KEY_S }, { GLFW_KEY_S , EventKeyboard::KeyCode::KEY_S },
{ GLFW_KEY_T , KeyboardEvent::KeyCode::KEY_T }, { GLFW_KEY_T , EventKeyboard::KeyCode::KEY_T },
{ GLFW_KEY_U , KeyboardEvent::KeyCode::KEY_U }, { GLFW_KEY_U , EventKeyboard::KeyCode::KEY_U },
{ GLFW_KEY_V , KeyboardEvent::KeyCode::KEY_V }, { GLFW_KEY_V , EventKeyboard::KeyCode::KEY_V },
{ GLFW_KEY_W , KeyboardEvent::KeyCode::KEY_W }, { GLFW_KEY_W , EventKeyboard::KeyCode::KEY_W },
{ GLFW_KEY_X , KeyboardEvent::KeyCode::KEY_X }, { GLFW_KEY_X , EventKeyboard::KeyCode::KEY_X },
{ GLFW_KEY_Y , KeyboardEvent::KeyCode::KEY_Y }, { GLFW_KEY_Y , EventKeyboard::KeyCode::KEY_Y },
{ GLFW_KEY_Z , KeyboardEvent::KeyCode::KEY_Z }, { GLFW_KEY_Z , EventKeyboard::KeyCode::KEY_Z },
{ GLFW_KEY_LEFT_BRACKET , KeyboardEvent::KeyCode::KEY_LEFT_BRACKET }, { GLFW_KEY_LEFT_BRACKET , EventKeyboard::KeyCode::KEY_LEFT_BRACKET },
{ GLFW_KEY_BACKSLASH , KeyboardEvent::KeyCode::KEY_BACK_SLASH }, { GLFW_KEY_BACKSLASH , EventKeyboard::KeyCode::KEY_BACK_SLASH },
{ GLFW_KEY_RIGHT_BRACKET , KeyboardEvent::KeyCode::KEY_RIGHT_BRACKET }, { GLFW_KEY_RIGHT_BRACKET , EventKeyboard::KeyCode::KEY_RIGHT_BRACKET },
{ GLFW_KEY_GRAVE_ACCENT , KeyboardEvent::KeyCode::KEY_GRAVE }, { GLFW_KEY_GRAVE_ACCENT , EventKeyboard::KeyCode::KEY_GRAVE },
{ GLFW_KEY_WORLD_1 , KeyboardEvent::KeyCode::KEY_GRAVE }, { GLFW_KEY_WORLD_1 , EventKeyboard::KeyCode::KEY_GRAVE },
{ GLFW_KEY_WORLD_2 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_WORLD_2 , EventKeyboard::KeyCode::KEY_NONE },
/* Function keys */ /* Function keys */
{ GLFW_KEY_ESCAPE , KeyboardEvent::KeyCode::KEY_ESCAPE }, { GLFW_KEY_ESCAPE , EventKeyboard::KeyCode::KEY_ESCAPE },
{ GLFW_KEY_ENTER , KeyboardEvent::KeyCode::KEY_KP_ENTER }, { GLFW_KEY_ENTER , EventKeyboard::KeyCode::KEY_KP_ENTER },
{ GLFW_KEY_TAB , KeyboardEvent::KeyCode::KEY_TAB }, { GLFW_KEY_TAB , EventKeyboard::KeyCode::KEY_TAB },
{ GLFW_KEY_BACKSPACE , KeyboardEvent::KeyCode::KEY_BACKSPACE }, { GLFW_KEY_BACKSPACE , EventKeyboard::KeyCode::KEY_BACKSPACE },
{ GLFW_KEY_INSERT , KeyboardEvent::KeyCode::KEY_INSERT }, { GLFW_KEY_INSERT , EventKeyboard::KeyCode::KEY_INSERT },
{ GLFW_KEY_DELETE , KeyboardEvent::KeyCode::KEY_DELETE }, { GLFW_KEY_DELETE , EventKeyboard::KeyCode::KEY_DELETE },
{ GLFW_KEY_RIGHT , KeyboardEvent::KeyCode::KEY_RIGHT_ARROW }, { GLFW_KEY_RIGHT , EventKeyboard::KeyCode::KEY_RIGHT_ARROW },
{ GLFW_KEY_LEFT , KeyboardEvent::KeyCode::KEY_LEFT_ARROW }, { GLFW_KEY_LEFT , EventKeyboard::KeyCode::KEY_LEFT_ARROW },
{ GLFW_KEY_DOWN , KeyboardEvent::KeyCode::KEY_DOWN_ARROW }, { GLFW_KEY_DOWN , EventKeyboard::KeyCode::KEY_DOWN_ARROW },
{ GLFW_KEY_UP , KeyboardEvent::KeyCode::KEY_UP_ARROW }, { GLFW_KEY_UP , EventKeyboard::KeyCode::KEY_UP_ARROW },
{ GLFW_KEY_PAGE_UP , KeyboardEvent::KeyCode::KEY_KP_PG_UP }, { GLFW_KEY_PAGE_UP , EventKeyboard::KeyCode::KEY_KP_PG_UP },
{ GLFW_KEY_PAGE_DOWN , KeyboardEvent::KeyCode::KEY_KP_PG_DOWN }, { GLFW_KEY_PAGE_DOWN , EventKeyboard::KeyCode::KEY_KP_PG_DOWN },
{ GLFW_KEY_HOME , KeyboardEvent::KeyCode::KEY_KP_HOME }, { GLFW_KEY_HOME , EventKeyboard::KeyCode::KEY_KP_HOME },
{ GLFW_KEY_END , KeyboardEvent::KeyCode::KEY_END }, { GLFW_KEY_END , EventKeyboard::KeyCode::KEY_END },
{ GLFW_KEY_CAPS_LOCK , KeyboardEvent::KeyCode::KEY_CAPS_LOCK }, { GLFW_KEY_CAPS_LOCK , EventKeyboard::KeyCode::KEY_CAPS_LOCK },
{ GLFW_KEY_SCROLL_LOCK , KeyboardEvent::KeyCode::KEY_SCROLL_LOCK }, { GLFW_KEY_SCROLL_LOCK , EventKeyboard::KeyCode::KEY_SCROLL_LOCK },
{ GLFW_KEY_NUM_LOCK , KeyboardEvent::KeyCode::KEY_NUM_LOCK }, { GLFW_KEY_NUM_LOCK , EventKeyboard::KeyCode::KEY_NUM_LOCK },
{ GLFW_KEY_PRINT_SCREEN , KeyboardEvent::KeyCode::KEY_PRINT }, { GLFW_KEY_PRINT_SCREEN , EventKeyboard::KeyCode::KEY_PRINT },
{ GLFW_KEY_PAUSE , KeyboardEvent::KeyCode::KEY_PAUSE }, { GLFW_KEY_PAUSE , EventKeyboard::KeyCode::KEY_PAUSE },
{ GLFW_KEY_F1 , KeyboardEvent::KeyCode::KEY_F1 }, { GLFW_KEY_F1 , EventKeyboard::KeyCode::KEY_F1 },
{ GLFW_KEY_F2 , KeyboardEvent::KeyCode::KEY_F2 }, { GLFW_KEY_F2 , EventKeyboard::KeyCode::KEY_F2 },
{ GLFW_KEY_F3 , KeyboardEvent::KeyCode::KEY_F3 }, { GLFW_KEY_F3 , EventKeyboard::KeyCode::KEY_F3 },
{ GLFW_KEY_F4 , KeyboardEvent::KeyCode::KEY_F4 }, { GLFW_KEY_F4 , EventKeyboard::KeyCode::KEY_F4 },
{ GLFW_KEY_F5 , KeyboardEvent::KeyCode::KEY_F5 }, { GLFW_KEY_F5 , EventKeyboard::KeyCode::KEY_F5 },
{ GLFW_KEY_F6 , KeyboardEvent::KeyCode::KEY_F6 }, { GLFW_KEY_F6 , EventKeyboard::KeyCode::KEY_F6 },
{ GLFW_KEY_F7 , KeyboardEvent::KeyCode::KEY_F7 }, { GLFW_KEY_F7 , EventKeyboard::KeyCode::KEY_F7 },
{ GLFW_KEY_F8 , KeyboardEvent::KeyCode::KEY_F8 }, { GLFW_KEY_F8 , EventKeyboard::KeyCode::KEY_F8 },
{ GLFW_KEY_F9 , KeyboardEvent::KeyCode::KEY_F9 }, { GLFW_KEY_F9 , EventKeyboard::KeyCode::KEY_F9 },
{ GLFW_KEY_F10 , KeyboardEvent::KeyCode::KEY_F10 }, { GLFW_KEY_F10 , EventKeyboard::KeyCode::KEY_F10 },
{ GLFW_KEY_F11 , KeyboardEvent::KeyCode::KEY_F11 }, { GLFW_KEY_F11 , EventKeyboard::KeyCode::KEY_F11 },
{ GLFW_KEY_F12 , KeyboardEvent::KeyCode::KEY_F12 }, { GLFW_KEY_F12 , EventKeyboard::KeyCode::KEY_F12 },
{ GLFW_KEY_F13 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F13 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F14 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F14 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F15 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F15 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F16 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F16 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F17 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F17 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F18 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F18 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F19 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F19 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F20 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F20 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F21 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F21 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F22 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F22 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F23 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F23 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F24 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F24 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F25 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F25 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_KP_0 , KeyboardEvent::KeyCode::KEY_0 }, { GLFW_KEY_KP_0 , EventKeyboard::KeyCode::KEY_0 },
{ GLFW_KEY_KP_1 , KeyboardEvent::KeyCode::KEY_1 }, { GLFW_KEY_KP_1 , EventKeyboard::KeyCode::KEY_1 },
{ GLFW_KEY_KP_2 , KeyboardEvent::KeyCode::KEY_2 }, { GLFW_KEY_KP_2 , EventKeyboard::KeyCode::KEY_2 },
{ GLFW_KEY_KP_3 , KeyboardEvent::KeyCode::KEY_3 }, { GLFW_KEY_KP_3 , EventKeyboard::KeyCode::KEY_3 },
{ GLFW_KEY_KP_4 , KeyboardEvent::KeyCode::KEY_4 }, { GLFW_KEY_KP_4 , EventKeyboard::KeyCode::KEY_4 },
{ GLFW_KEY_KP_5 , KeyboardEvent::KeyCode::KEY_5 }, { GLFW_KEY_KP_5 , EventKeyboard::KeyCode::KEY_5 },
{ GLFW_KEY_KP_6 , KeyboardEvent::KeyCode::KEY_6 }, { GLFW_KEY_KP_6 , EventKeyboard::KeyCode::KEY_6 },
{ GLFW_KEY_KP_7 , KeyboardEvent::KeyCode::KEY_7 }, { GLFW_KEY_KP_7 , EventKeyboard::KeyCode::KEY_7 },
{ GLFW_KEY_KP_8 , KeyboardEvent::KeyCode::KEY_8 }, { GLFW_KEY_KP_8 , EventKeyboard::KeyCode::KEY_8 },
{ GLFW_KEY_KP_9 , KeyboardEvent::KeyCode::KEY_9 }, { GLFW_KEY_KP_9 , EventKeyboard::KeyCode::KEY_9 },
{ GLFW_KEY_KP_DECIMAL , KeyboardEvent::KeyCode::KEY_PERIOD }, { GLFW_KEY_KP_DECIMAL , EventKeyboard::KeyCode::KEY_PERIOD },
{ GLFW_KEY_KP_DIVIDE , KeyboardEvent::KeyCode::KEY_KP_DIVIDE }, { GLFW_KEY_KP_DIVIDE , EventKeyboard::KeyCode::KEY_KP_DIVIDE },
{ GLFW_KEY_KP_MULTIPLY , KeyboardEvent::KeyCode::KEY_KP_MULTIPLY }, { GLFW_KEY_KP_MULTIPLY , EventKeyboard::KeyCode::KEY_KP_MULTIPLY },
{ GLFW_KEY_KP_SUBTRACT , KeyboardEvent::KeyCode::KEY_KP_MINUS }, { GLFW_KEY_KP_SUBTRACT , EventKeyboard::KeyCode::KEY_KP_MINUS },
{ GLFW_KEY_KP_ADD , KeyboardEvent::KeyCode::KEY_KP_PLUS }, { GLFW_KEY_KP_ADD , EventKeyboard::KeyCode::KEY_KP_PLUS },
{ GLFW_KEY_KP_ENTER , KeyboardEvent::KeyCode::KEY_KP_ENTER }, { GLFW_KEY_KP_ENTER , EventKeyboard::KeyCode::KEY_KP_ENTER },
{ GLFW_KEY_KP_EQUAL , KeyboardEvent::KeyCode::KEY_EQUAL }, { GLFW_KEY_KP_EQUAL , EventKeyboard::KeyCode::KEY_EQUAL },
{ GLFW_KEY_LEFT_SHIFT , KeyboardEvent::KeyCode::KEY_SHIFT }, { GLFW_KEY_LEFT_SHIFT , EventKeyboard::KeyCode::KEY_SHIFT },
{ GLFW_KEY_LEFT_CONTROL , KeyboardEvent::KeyCode::KEY_CTRL }, { GLFW_KEY_LEFT_CONTROL , EventKeyboard::KeyCode::KEY_CTRL },
{ GLFW_KEY_LEFT_ALT , KeyboardEvent::KeyCode::KEY_ALT }, { GLFW_KEY_LEFT_ALT , EventKeyboard::KeyCode::KEY_ALT },
{ GLFW_KEY_LEFT_SUPER , KeyboardEvent::KeyCode::KEY_HYPER }, { GLFW_KEY_LEFT_SUPER , EventKeyboard::KeyCode::KEY_HYPER },
{ GLFW_KEY_RIGHT_SHIFT , KeyboardEvent::KeyCode::KEY_SHIFT }, { GLFW_KEY_RIGHT_SHIFT , EventKeyboard::KeyCode::KEY_SHIFT },
{ GLFW_KEY_RIGHT_CONTROL , KeyboardEvent::KeyCode::KEY_CTRL }, { GLFW_KEY_RIGHT_CONTROL , EventKeyboard::KeyCode::KEY_CTRL },
{ GLFW_KEY_RIGHT_ALT , KeyboardEvent::KeyCode::KEY_ALT }, { GLFW_KEY_RIGHT_ALT , EventKeyboard::KeyCode::KEY_ALT },
{ GLFW_KEY_RIGHT_SUPER , KeyboardEvent::KeyCode::KEY_HYPER }, { GLFW_KEY_RIGHT_SUPER , EventKeyboard::KeyCode::KEY_HYPER },
{ GLFW_KEY_MENU , KeyboardEvent::KeyCode::KEY_MENU }, { GLFW_KEY_MENU , EventKeyboard::KeyCode::KEY_MENU },
{ GLFW_KEY_LAST , KeyboardEvent::KeyCode::KEY_NONE } { GLFW_KEY_LAST , EventKeyboard::KeyCode::KEY_NONE }
}; };
@ -238,7 +238,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
{ {
KeyboardEvent event(g_keyCodeMap[key], GLFW_PRESS == action); EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action);
EventDispatcher::getInstance()->dispatchEvent(&event); EventDispatcher::getInstance()->dispatchEvent(&event);
} }

View File

@ -38,140 +38,140 @@ NS_CC_BEGIN
struct keyCodeItem struct keyCodeItem
{ {
int glfwKeyCode; int glfwKeyCode;
KeyboardEvent::KeyCode keyCode; EventKeyboard::KeyCode keyCode;
}; };
static std::map<int, KeyboardEvent::KeyCode> g_keyCodeMap; static std::map<int, EventKeyboard::KeyCode> g_keyCodeMap;
static keyCodeItem g_keyCodeStructArray[] = { static keyCodeItem g_keyCodeStructArray[] = {
/* The unknown key */ /* The unknown key */
{ GLFW_KEY_UNKNOWN , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_UNKNOWN , EventKeyboard::KeyCode::KEY_NONE },
/* Printable keys */ /* Printable keys */
{ GLFW_KEY_SPACE , KeyboardEvent::KeyCode::KEY_SPACE }, { GLFW_KEY_SPACE , EventKeyboard::KeyCode::KEY_SPACE },
{ GLFW_KEY_APOSTROPHE , KeyboardEvent::KeyCode::KEY_APOSTROPHE }, { GLFW_KEY_APOSTROPHE , EventKeyboard::KeyCode::KEY_APOSTROPHE },
{ GLFW_KEY_COMMA , KeyboardEvent::KeyCode::KEY_COMMA }, { GLFW_KEY_COMMA , EventKeyboard::KeyCode::KEY_COMMA },
{ GLFW_KEY_MINUS , KeyboardEvent::KeyCode::KEY_MINUS }, { GLFW_KEY_MINUS , EventKeyboard::KeyCode::KEY_MINUS },
{ GLFW_KEY_PERIOD , KeyboardEvent::KeyCode::KEY_PERIOD }, { GLFW_KEY_PERIOD , EventKeyboard::KeyCode::KEY_PERIOD },
{ GLFW_KEY_SLASH , KeyboardEvent::KeyCode::KEY_SLASH }, { GLFW_KEY_SLASH , EventKeyboard::KeyCode::KEY_SLASH },
{ GLFW_KEY_0 , KeyboardEvent::KeyCode::KEY_0 }, { GLFW_KEY_0 , EventKeyboard::KeyCode::KEY_0 },
{ GLFW_KEY_1 , KeyboardEvent::KeyCode::KEY_1 }, { GLFW_KEY_1 , EventKeyboard::KeyCode::KEY_1 },
{ GLFW_KEY_2 , KeyboardEvent::KeyCode::KEY_2 }, { GLFW_KEY_2 , EventKeyboard::KeyCode::KEY_2 },
{ GLFW_KEY_3 , KeyboardEvent::KeyCode::KEY_3 }, { GLFW_KEY_3 , EventKeyboard::KeyCode::KEY_3 },
{ GLFW_KEY_4 , KeyboardEvent::KeyCode::KEY_4 }, { GLFW_KEY_4 , EventKeyboard::KeyCode::KEY_4 },
{ GLFW_KEY_5 , KeyboardEvent::KeyCode::KEY_5 }, { GLFW_KEY_5 , EventKeyboard::KeyCode::KEY_5 },
{ GLFW_KEY_6 , KeyboardEvent::KeyCode::KEY_6 }, { GLFW_KEY_6 , EventKeyboard::KeyCode::KEY_6 },
{ GLFW_KEY_7 , KeyboardEvent::KeyCode::KEY_7 }, { GLFW_KEY_7 , EventKeyboard::KeyCode::KEY_7 },
{ GLFW_KEY_8 , KeyboardEvent::KeyCode::KEY_8 }, { GLFW_KEY_8 , EventKeyboard::KeyCode::KEY_8 },
{ GLFW_KEY_9 , KeyboardEvent::KeyCode::KEY_9 }, { GLFW_KEY_9 , EventKeyboard::KeyCode::KEY_9 },
{ GLFW_KEY_SEMICOLON , KeyboardEvent::KeyCode::KEY_SEMICOLON }, { GLFW_KEY_SEMICOLON , EventKeyboard::KeyCode::KEY_SEMICOLON },
{ GLFW_KEY_EQUAL , KeyboardEvent::KeyCode::KEY_EQUAL }, { GLFW_KEY_EQUAL , EventKeyboard::KeyCode::KEY_EQUAL },
{ GLFW_KEY_A , KeyboardEvent::KeyCode::KEY_A }, { GLFW_KEY_A , EventKeyboard::KeyCode::KEY_A },
{ GLFW_KEY_B , KeyboardEvent::KeyCode::KEY_B }, { GLFW_KEY_B , EventKeyboard::KeyCode::KEY_B },
{ GLFW_KEY_C , KeyboardEvent::KeyCode::KEY_C }, { GLFW_KEY_C , EventKeyboard::KeyCode::KEY_C },
{ GLFW_KEY_D , KeyboardEvent::KeyCode::KEY_D }, { GLFW_KEY_D , EventKeyboard::KeyCode::KEY_D },
{ GLFW_KEY_E , KeyboardEvent::KeyCode::KEY_E }, { GLFW_KEY_E , EventKeyboard::KeyCode::KEY_E },
{ GLFW_KEY_F , KeyboardEvent::KeyCode::KEY_F }, { GLFW_KEY_F , EventKeyboard::KeyCode::KEY_F },
{ GLFW_KEY_G , KeyboardEvent::KeyCode::KEY_G }, { GLFW_KEY_G , EventKeyboard::KeyCode::KEY_G },
{ GLFW_KEY_H , KeyboardEvent::KeyCode::KEY_H }, { GLFW_KEY_H , EventKeyboard::KeyCode::KEY_H },
{ GLFW_KEY_I , KeyboardEvent::KeyCode::KEY_I }, { GLFW_KEY_I , EventKeyboard::KeyCode::KEY_I },
{ GLFW_KEY_J , KeyboardEvent::KeyCode::KEY_J }, { GLFW_KEY_J , EventKeyboard::KeyCode::KEY_J },
{ GLFW_KEY_K , KeyboardEvent::KeyCode::KEY_K }, { GLFW_KEY_K , EventKeyboard::KeyCode::KEY_K },
{ GLFW_KEY_L , KeyboardEvent::KeyCode::KEY_L }, { GLFW_KEY_L , EventKeyboard::KeyCode::KEY_L },
{ GLFW_KEY_M , KeyboardEvent::KeyCode::KEY_M }, { GLFW_KEY_M , EventKeyboard::KeyCode::KEY_M },
{ GLFW_KEY_N , KeyboardEvent::KeyCode::KEY_N }, { GLFW_KEY_N , EventKeyboard::KeyCode::KEY_N },
{ GLFW_KEY_O , KeyboardEvent::KeyCode::KEY_O }, { GLFW_KEY_O , EventKeyboard::KeyCode::KEY_O },
{ GLFW_KEY_P , KeyboardEvent::KeyCode::KEY_P }, { GLFW_KEY_P , EventKeyboard::KeyCode::KEY_P },
{ GLFW_KEY_Q , KeyboardEvent::KeyCode::KEY_Q }, { GLFW_KEY_Q , EventKeyboard::KeyCode::KEY_Q },
{ GLFW_KEY_R , KeyboardEvent::KeyCode::KEY_R }, { GLFW_KEY_R , EventKeyboard::KeyCode::KEY_R },
{ GLFW_KEY_S , KeyboardEvent::KeyCode::KEY_S }, { GLFW_KEY_S , EventKeyboard::KeyCode::KEY_S },
{ GLFW_KEY_T , KeyboardEvent::KeyCode::KEY_T }, { GLFW_KEY_T , EventKeyboard::KeyCode::KEY_T },
{ GLFW_KEY_U , KeyboardEvent::KeyCode::KEY_U }, { GLFW_KEY_U , EventKeyboard::KeyCode::KEY_U },
{ GLFW_KEY_V , KeyboardEvent::KeyCode::KEY_V }, { GLFW_KEY_V , EventKeyboard::KeyCode::KEY_V },
{ GLFW_KEY_W , KeyboardEvent::KeyCode::KEY_W }, { GLFW_KEY_W , EventKeyboard::KeyCode::KEY_W },
{ GLFW_KEY_X , KeyboardEvent::KeyCode::KEY_X }, { GLFW_KEY_X , EventKeyboard::KeyCode::KEY_X },
{ GLFW_KEY_Y , KeyboardEvent::KeyCode::KEY_Y }, { GLFW_KEY_Y , EventKeyboard::KeyCode::KEY_Y },
{ GLFW_KEY_Z , KeyboardEvent::KeyCode::KEY_Z }, { GLFW_KEY_Z , EventKeyboard::KeyCode::KEY_Z },
{ GLFW_KEY_LEFT_BRACKET , KeyboardEvent::KeyCode::KEY_LEFT_BRACKET }, { GLFW_KEY_LEFT_BRACKET , EventKeyboard::KeyCode::KEY_LEFT_BRACKET },
{ GLFW_KEY_BACKSLASH , KeyboardEvent::KeyCode::KEY_BACK_SLASH }, { GLFW_KEY_BACKSLASH , EventKeyboard::KeyCode::KEY_BACK_SLASH },
{ GLFW_KEY_RIGHT_BRACKET , KeyboardEvent::KeyCode::KEY_RIGHT_BRACKET }, { GLFW_KEY_RIGHT_BRACKET , EventKeyboard::KeyCode::KEY_RIGHT_BRACKET },
{ GLFW_KEY_GRAVE_ACCENT , KeyboardEvent::KeyCode::KEY_GRAVE }, { GLFW_KEY_GRAVE_ACCENT , EventKeyboard::KeyCode::KEY_GRAVE },
{ GLFW_KEY_WORLD_1 , KeyboardEvent::KeyCode::KEY_GRAVE }, { GLFW_KEY_WORLD_1 , EventKeyboard::KeyCode::KEY_GRAVE },
{ GLFW_KEY_WORLD_2 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_WORLD_2 , EventKeyboard::KeyCode::KEY_NONE },
/* Function keys */ /* Function keys */
{ GLFW_KEY_ESCAPE , KeyboardEvent::KeyCode::KEY_ESCAPE }, { GLFW_KEY_ESCAPE , EventKeyboard::KeyCode::KEY_ESCAPE },
{ GLFW_KEY_ENTER , KeyboardEvent::KeyCode::KEY_KP_ENTER }, { GLFW_KEY_ENTER , EventKeyboard::KeyCode::KEY_KP_ENTER },
{ GLFW_KEY_TAB , KeyboardEvent::KeyCode::KEY_TAB }, { GLFW_KEY_TAB , EventKeyboard::KeyCode::KEY_TAB },
{ GLFW_KEY_BACKSPACE , KeyboardEvent::KeyCode::KEY_BACKSPACE }, { GLFW_KEY_BACKSPACE , EventKeyboard::KeyCode::KEY_BACKSPACE },
{ GLFW_KEY_INSERT , KeyboardEvent::KeyCode::KEY_INSERT }, { GLFW_KEY_INSERT , EventKeyboard::KeyCode::KEY_INSERT },
{ GLFW_KEY_DELETE , KeyboardEvent::KeyCode::KEY_DELETE }, { GLFW_KEY_DELETE , EventKeyboard::KeyCode::KEY_DELETE },
{ GLFW_KEY_RIGHT , KeyboardEvent::KeyCode::KEY_RIGHT_ARROW }, { GLFW_KEY_RIGHT , EventKeyboard::KeyCode::KEY_RIGHT_ARROW },
{ GLFW_KEY_LEFT , KeyboardEvent::KeyCode::KEY_LEFT_ARROW }, { GLFW_KEY_LEFT , EventKeyboard::KeyCode::KEY_LEFT_ARROW },
{ GLFW_KEY_DOWN , KeyboardEvent::KeyCode::KEY_DOWN_ARROW }, { GLFW_KEY_DOWN , EventKeyboard::KeyCode::KEY_DOWN_ARROW },
{ GLFW_KEY_UP , KeyboardEvent::KeyCode::KEY_UP_ARROW }, { GLFW_KEY_UP , EventKeyboard::KeyCode::KEY_UP_ARROW },
{ GLFW_KEY_PAGE_UP , KeyboardEvent::KeyCode::KEY_KP_PG_UP }, { GLFW_KEY_PAGE_UP , EventKeyboard::KeyCode::KEY_KP_PG_UP },
{ GLFW_KEY_PAGE_DOWN , KeyboardEvent::KeyCode::KEY_KP_PG_DOWN }, { GLFW_KEY_PAGE_DOWN , EventKeyboard::KeyCode::KEY_KP_PG_DOWN },
{ GLFW_KEY_HOME , KeyboardEvent::KeyCode::KEY_KP_HOME }, { GLFW_KEY_HOME , EventKeyboard::KeyCode::KEY_KP_HOME },
{ GLFW_KEY_END , KeyboardEvent::KeyCode::KEY_END }, { GLFW_KEY_END , EventKeyboard::KeyCode::KEY_END },
{ GLFW_KEY_CAPS_LOCK , KeyboardEvent::KeyCode::KEY_CAPS_LOCK }, { GLFW_KEY_CAPS_LOCK , EventKeyboard::KeyCode::KEY_CAPS_LOCK },
{ GLFW_KEY_SCROLL_LOCK , KeyboardEvent::KeyCode::KEY_SCROLL_LOCK }, { GLFW_KEY_SCROLL_LOCK , EventKeyboard::KeyCode::KEY_SCROLL_LOCK },
{ GLFW_KEY_NUM_LOCK , KeyboardEvent::KeyCode::KEY_NUM_LOCK }, { GLFW_KEY_NUM_LOCK , EventKeyboard::KeyCode::KEY_NUM_LOCK },
{ GLFW_KEY_PRINT_SCREEN , KeyboardEvent::KeyCode::KEY_PRINT }, { GLFW_KEY_PRINT_SCREEN , EventKeyboard::KeyCode::KEY_PRINT },
{ GLFW_KEY_PAUSE , KeyboardEvent::KeyCode::KEY_PAUSE }, { GLFW_KEY_PAUSE , EventKeyboard::KeyCode::KEY_PAUSE },
{ GLFW_KEY_F1 , KeyboardEvent::KeyCode::KEY_F1 }, { GLFW_KEY_F1 , EventKeyboard::KeyCode::KEY_F1 },
{ GLFW_KEY_F2 , KeyboardEvent::KeyCode::KEY_F2 }, { GLFW_KEY_F2 , EventKeyboard::KeyCode::KEY_F2 },
{ GLFW_KEY_F3 , KeyboardEvent::KeyCode::KEY_F3 }, { GLFW_KEY_F3 , EventKeyboard::KeyCode::KEY_F3 },
{ GLFW_KEY_F4 , KeyboardEvent::KeyCode::KEY_F4 }, { GLFW_KEY_F4 , EventKeyboard::KeyCode::KEY_F4 },
{ GLFW_KEY_F5 , KeyboardEvent::KeyCode::KEY_F5 }, { GLFW_KEY_F5 , EventKeyboard::KeyCode::KEY_F5 },
{ GLFW_KEY_F6 , KeyboardEvent::KeyCode::KEY_F6 }, { GLFW_KEY_F6 , EventKeyboard::KeyCode::KEY_F6 },
{ GLFW_KEY_F7 , KeyboardEvent::KeyCode::KEY_F7 }, { GLFW_KEY_F7 , EventKeyboard::KeyCode::KEY_F7 },
{ GLFW_KEY_F8 , KeyboardEvent::KeyCode::KEY_F8 }, { GLFW_KEY_F8 , EventKeyboard::KeyCode::KEY_F8 },
{ GLFW_KEY_F9 , KeyboardEvent::KeyCode::KEY_F9 }, { GLFW_KEY_F9 , EventKeyboard::KeyCode::KEY_F9 },
{ GLFW_KEY_F10 , KeyboardEvent::KeyCode::KEY_F10 }, { GLFW_KEY_F10 , EventKeyboard::KeyCode::KEY_F10 },
{ GLFW_KEY_F11 , KeyboardEvent::KeyCode::KEY_F11 }, { GLFW_KEY_F11 , EventKeyboard::KeyCode::KEY_F11 },
{ GLFW_KEY_F12 , KeyboardEvent::KeyCode::KEY_F12 }, { GLFW_KEY_F12 , EventKeyboard::KeyCode::KEY_F12 },
{ GLFW_KEY_F13 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F13 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F14 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F14 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F15 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F15 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F16 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F16 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F17 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F17 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F18 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F18 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F19 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F19 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F20 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F20 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F21 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F21 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F22 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F22 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F23 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F23 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F24 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F24 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_F25 , KeyboardEvent::KeyCode::KEY_NONE }, { GLFW_KEY_F25 , EventKeyboard::KeyCode::KEY_NONE },
{ GLFW_KEY_KP_0 , KeyboardEvent::KeyCode::KEY_0 }, { GLFW_KEY_KP_0 , EventKeyboard::KeyCode::KEY_0 },
{ GLFW_KEY_KP_1 , KeyboardEvent::KeyCode::KEY_1 }, { GLFW_KEY_KP_1 , EventKeyboard::KeyCode::KEY_1 },
{ GLFW_KEY_KP_2 , KeyboardEvent::KeyCode::KEY_2 }, { GLFW_KEY_KP_2 , EventKeyboard::KeyCode::KEY_2 },
{ GLFW_KEY_KP_3 , KeyboardEvent::KeyCode::KEY_3 }, { GLFW_KEY_KP_3 , EventKeyboard::KeyCode::KEY_3 },
{ GLFW_KEY_KP_4 , KeyboardEvent::KeyCode::KEY_4 }, { GLFW_KEY_KP_4 , EventKeyboard::KeyCode::KEY_4 },
{ GLFW_KEY_KP_5 , KeyboardEvent::KeyCode::KEY_5 }, { GLFW_KEY_KP_5 , EventKeyboard::KeyCode::KEY_5 },
{ GLFW_KEY_KP_6 , KeyboardEvent::KeyCode::KEY_6 }, { GLFW_KEY_KP_6 , EventKeyboard::KeyCode::KEY_6 },
{ GLFW_KEY_KP_7 , KeyboardEvent::KeyCode::KEY_7 }, { GLFW_KEY_KP_7 , EventKeyboard::KeyCode::KEY_7 },
{ GLFW_KEY_KP_8 , KeyboardEvent::KeyCode::KEY_8 }, { GLFW_KEY_KP_8 , EventKeyboard::KeyCode::KEY_8 },
{ GLFW_KEY_KP_9 , KeyboardEvent::KeyCode::KEY_9 }, { GLFW_KEY_KP_9 , EventKeyboard::KeyCode::KEY_9 },
{ GLFW_KEY_KP_DECIMAL , KeyboardEvent::KeyCode::KEY_PERIOD }, { GLFW_KEY_KP_DECIMAL , EventKeyboard::KeyCode::KEY_PERIOD },
{ GLFW_KEY_KP_DIVIDE , KeyboardEvent::KeyCode::KEY_KP_DIVIDE }, { GLFW_KEY_KP_DIVIDE , EventKeyboard::KeyCode::KEY_KP_DIVIDE },
{ GLFW_KEY_KP_MULTIPLY , KeyboardEvent::KeyCode::KEY_KP_MULTIPLY }, { GLFW_KEY_KP_MULTIPLY , EventKeyboard::KeyCode::KEY_KP_MULTIPLY },
{ GLFW_KEY_KP_SUBTRACT , KeyboardEvent::KeyCode::KEY_KP_MINUS }, { GLFW_KEY_KP_SUBTRACT , EventKeyboard::KeyCode::KEY_KP_MINUS },
{ GLFW_KEY_KP_ADD , KeyboardEvent::KeyCode::KEY_KP_PLUS }, { GLFW_KEY_KP_ADD , EventKeyboard::KeyCode::KEY_KP_PLUS },
{ GLFW_KEY_KP_ENTER , KeyboardEvent::KeyCode::KEY_KP_ENTER }, { GLFW_KEY_KP_ENTER , EventKeyboard::KeyCode::KEY_KP_ENTER },
{ GLFW_KEY_KP_EQUAL , KeyboardEvent::KeyCode::KEY_EQUAL }, { GLFW_KEY_KP_EQUAL , EventKeyboard::KeyCode::KEY_EQUAL },
{ GLFW_KEY_LEFT_SHIFT , KeyboardEvent::KeyCode::KEY_SHIFT }, { GLFW_KEY_LEFT_SHIFT , EventKeyboard::KeyCode::KEY_SHIFT },
{ GLFW_KEY_LEFT_CONTROL , KeyboardEvent::KeyCode::KEY_CTRL }, { GLFW_KEY_LEFT_CONTROL , EventKeyboard::KeyCode::KEY_CTRL },
{ GLFW_KEY_LEFT_ALT , KeyboardEvent::KeyCode::KEY_ALT }, { GLFW_KEY_LEFT_ALT , EventKeyboard::KeyCode::KEY_ALT },
{ GLFW_KEY_LEFT_SUPER , KeyboardEvent::KeyCode::KEY_HYPER }, { GLFW_KEY_LEFT_SUPER , EventKeyboard::KeyCode::KEY_HYPER },
{ GLFW_KEY_RIGHT_SHIFT , KeyboardEvent::KeyCode::KEY_SHIFT }, { GLFW_KEY_RIGHT_SHIFT , EventKeyboard::KeyCode::KEY_SHIFT },
{ GLFW_KEY_RIGHT_CONTROL , KeyboardEvent::KeyCode::KEY_CTRL }, { GLFW_KEY_RIGHT_CONTROL , EventKeyboard::KeyCode::KEY_CTRL },
{ GLFW_KEY_RIGHT_ALT , KeyboardEvent::KeyCode::KEY_ALT }, { GLFW_KEY_RIGHT_ALT , EventKeyboard::KeyCode::KEY_ALT },
{ GLFW_KEY_RIGHT_SUPER , KeyboardEvent::KeyCode::KEY_HYPER }, { GLFW_KEY_RIGHT_SUPER , EventKeyboard::KeyCode::KEY_HYPER },
{ GLFW_KEY_MENU , KeyboardEvent::KeyCode::KEY_MENU }, { GLFW_KEY_MENU , EventKeyboard::KeyCode::KEY_MENU },
{ GLFW_KEY_LAST , KeyboardEvent::KeyCode::KEY_NONE } { GLFW_KEY_LAST , EventKeyboard::KeyCode::KEY_NONE }
}; };
#if(_MSC_VER >= 1600) // Visual Studio 2010 or higher version. #if(_MSC_VER >= 1600) // Visual Studio 2010 or higher version.
@ -340,7 +340,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
{ {
KeyboardEvent event(g_keyCodeMap[key], GLFW_PRESS == action); EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action);
EventDispatcher::getInstance()->dispatchEvent(&event); EventDispatcher::getInstance()->dispatchEvent(&event);
} }

View File

@ -254,7 +254,7 @@ struct SchedulerScriptData
struct TouchesScriptData struct TouchesScriptData
{ {
TouchEvent::EventCode actionType; EventTouch::EventCode actionType;
void* nativeObject; void* nativeObject;
const std::vector<Touch*>& touches; const std::vector<Touch*>& touches;
@ -263,7 +263,7 @@ struct TouchesScriptData
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
TouchesScriptData(TouchEvent::EventCode inActionType, void* inNativeObject, const std::vector<Touch*>& inTouches) TouchesScriptData(EventTouch::EventCode inActionType, void* inNativeObject, const std::vector<Touch*>& inTouches)
: actionType(inActionType), : actionType(inActionType),
nativeObject(inNativeObject), nativeObject(inNativeObject),
touches(inTouches) touches(inTouches)
@ -273,7 +273,7 @@ struct TouchesScriptData
struct TouchScriptData struct TouchScriptData
{ {
TouchEvent::EventCode actionType; EventTouch::EventCode actionType;
void* nativeObject; void* nativeObject;
Touch* touch; Touch* touch;
@ -282,7 +282,7 @@ struct TouchScriptData
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
TouchScriptData(TouchEvent::EventCode inActionType, void* inNativeObject, Touch* inTouch) TouchScriptData(EventTouch::EventCode inActionType, void* inNativeObject, Touch* inTouch)
: actionType(inActionType), : actionType(inActionType),
nativeObject(inNativeObject), nativeObject(inNativeObject),
touch(inTouch) touch(inTouch)
@ -292,7 +292,7 @@ struct TouchScriptData
struct KeypadScriptData struct KeypadScriptData
{ {
KeyboardEvent::KeyCode actionType; EventKeyboard::KeyCode actionType;
void* nativeObject; void* nativeObject;
// Constructor // Constructor
@ -300,7 +300,7 @@ struct KeypadScriptData
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
KeypadScriptData(KeyboardEvent::KeyCode inActionType,void* inNativeObject) KeypadScriptData(EventKeyboard::KeyCode inActionType,void* inNativeObject)
: actionType(inActionType),nativeObject(inNativeObject) : actionType(inActionType),nativeObject(inNativeObject)
{ {
} }

View File

@ -110,7 +110,7 @@ void InputDelegate::setTouchEnabled(bool enabled)
{ {
if( _touchMode == Touch::DispatchMode::ALL_AT_ONCE ) { if( _touchMode == Touch::DispatchMode::ALL_AT_ONCE ) {
// Register Touch Event // Register Touch Event
auto listener = TouchEventListener::create(Touch::DispatchMode::ALL_AT_ONCE); auto listener = EventListenerTouch::create(Touch::DispatchMode::ALL_AT_ONCE);
listener->onTouchesBegan = CC_CALLBACK_2(InputDelegate::onTouchesBegan, this); listener->onTouchesBegan = CC_CALLBACK_2(InputDelegate::onTouchesBegan, this);
listener->onTouchesMoved = CC_CALLBACK_2(InputDelegate::onTouchesMoved, this); listener->onTouchesMoved = CC_CALLBACK_2(InputDelegate::onTouchesMoved, this);
@ -121,7 +121,7 @@ void InputDelegate::setTouchEnabled(bool enabled)
_touchListener = listener; _touchListener = listener;
} else { } else {
// Register Touch Event // Register Touch Event
auto listener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->setSwallowTouches(true); listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(InputDelegate::onTouchBegan, this); listener->onTouchBegan = CC_CALLBACK_2(InputDelegate::onTouchBegan, this);
@ -195,7 +195,7 @@ void InputDelegate::setAccelerometerEnabled(bool enabled)
if (enabled) if (enabled)
{ {
auto listener = AccelerationEventListener::create(CC_CALLBACK_2(InputDelegate::onAcceleration, this)); auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(InputDelegate::onAcceleration, this));
dispatcher->addEventListenerWithFixedPriority(listener, -1); dispatcher->addEventListenerWithFixedPriority(listener, -1);
_accelerometerListener = listener; _accelerometerListener = listener;
} }
@ -217,7 +217,7 @@ void InputDelegate::setKeypadEnabled(bool enabled)
if (enabled) if (enabled)
{ {
auto listener = KeyboardEventListener::create(); auto listener = EventListenerKeyboard::create();
listener->onKeyPressed = CC_CALLBACK_2(InputDelegate::onKeyPressed, this); listener->onKeyPressed = CC_CALLBACK_2(InputDelegate::onKeyPressed, this);
listener->onKeyReleased = CC_CALLBACK_2(InputDelegate::onKeyReleased, this); listener->onKeyReleased = CC_CALLBACK_2(InputDelegate::onKeyReleased, this);

View File

@ -110,8 +110,8 @@ public:
virtual void onAcceleration(Acceleration* acc, Event* event) {}; virtual void onAcceleration(Acceleration* acc, Event* event) {};
virtual void onKeyPressed(KeyboardEvent::KeyCode keyCode, Event* event) {}; virtual void onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event) {};
virtual void onKeyReleased(KeyboardEvent::KeyCode keyCode, Event* event) {}; virtual void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event) {};
virtual bool onTouchBegan(Touch *touch, Event *event); virtual bool onTouchBegan(Touch *touch, Event *event);
virtual void onTouchMoved(Touch *touch, Event *event); virtual void onTouchMoved(Touch *touch, Event *event);

View File

@ -112,7 +112,7 @@ bool ScrollView::initWithViewSize(Size size, Node *container/* = NULL*/)
setTouchEnabled(true); setTouchEnabled(true);
setTouchMode(Touch::DispatchMode::ONE_BY_ONE); setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
_touches.reserve(TouchEvent::MAX_TOUCHES); _touches.reserve(EventTouch::MAX_TOUCHES);
_delegate = NULL; _delegate = NULL;
_bounceable = true; _bounceable = true;

View File

@ -85,7 +85,7 @@ bool MenuLayer::initWithEntryID(int entryId)
EventDispatcher::getInstance()->removeEventListener(_touchListener); EventDispatcher::getInstance()->removeEventListener(_touchListener);
// Adds touch event listener // Adds touch event listener
auto listener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->setSwallowTouches(true); listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(MenuLayer::onTouchBegan, this); listener->onTouchBegan = CC_CALLBACK_2(MenuLayer::onTouchBegan, this);
@ -192,7 +192,7 @@ bool Box2DView::initWithEntryID(int entryId)
EventDispatcher::getInstance()->removeEventListener(_touchListener); EventDispatcher::getInstance()->removeEventListener(_touchListener);
// Adds Touch Event Listener // Adds Touch Event Listener
auto listener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->setSwallowTouches(true); listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(Box2DView::onTouchBegan, this); listener->onTouchBegan = CC_CALLBACK_2(Box2DView::onTouchBegan, this);

View File

@ -65,7 +65,7 @@ private:
// Director::getInstance()->getTouchDispatcher()->addTargetedDelegate(this, 100, true); // Director::getInstance()->getTouchDispatcher()->addTargetedDelegate(this, 100, true);
// Register Touch Event // Register Touch Event
auto listener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->setSwallowTouches(true); listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(Button::onTouchBegan, this); listener->onTouchBegan = CC_CALLBACK_2(Button::onTouchBegan, this);

View File

@ -22,12 +22,12 @@ KeyboardTest::~KeyboardTest()
_label->release(); _label->release();
} }
void KeyboardTest::onKeyPressed(KeyboardEvent::KeyCode keyCode, Event* event) void KeyboardTest::onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event)
{ {
log("Key with keycode %d pressed", keyCode); log("Key with keycode %d pressed", keyCode);
} }
void KeyboardTest::onKeyReleased(KeyboardEvent::KeyCode keyCode, Event* event) void KeyboardTest::onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event)
{ {
log("Key with keycode %d released", keyCode); log("Key with keycode %d released", keyCode);
} }

View File

@ -10,8 +10,8 @@ public:
KeyboardTest(); KeyboardTest();
~KeyboardTest(); ~KeyboardTest();
virtual void onKeyPressed(KeyboardEvent::KeyCode keyCode, Event* event); virtual void onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event);
virtual void onKeyReleased(KeyboardEvent::KeyCode keyCode, Event* event); virtual void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event);
private: private:
LabelTTF* _label; LabelTTF* _label;

View File

@ -22,13 +22,13 @@ KeypadTest::~KeypadTest()
_label->release(); _label->release();
} }
void KeypadTest::onKeyReleased(KeyboardEvent::KeyCode keycode, Event* event) void KeypadTest::onKeyReleased(EventKeyboard::KeyCode keycode, Event* event)
{ {
if (keycode == KeyboardEvent::KeyCode::KEY_BACKSPACE) if (keycode == EventKeyboard::KeyCode::KEY_BACKSPACE)
{ {
_label->setString("BACK clicked!"); _label->setString("BACK clicked!");
} }
else if (keycode == KeyboardEvent::KeyCode::KEY_MENU) else if (keycode == EventKeyboard::KeyCode::KEY_MENU)
{ {
_label->setString("MENU clicked!"); _label->setString("MENU clicked!");
} }

View File

@ -10,7 +10,7 @@ public:
KeypadTest(); KeypadTest();
~KeypadTest(); ~KeypadTest();
virtual void onKeyReleased(KeyboardEvent::KeyCode keycode, Event* event) override; virtual void onKeyReleased(EventKeyboard::KeyCode keycode, Event* event) override;
private: private:
LabelTTF* _label; LabelTTF* _label;

View File

@ -575,7 +575,7 @@ RemoveMenuItemWhenMove::RemoveMenuItemWhenMove()
setTouchMode(Touch::DispatchMode::ONE_BY_ONE); setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
// Register Touch Event // Register Touch Event
_touchListener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); _touchListener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
_touchListener->setSwallowTouches(false); _touchListener->setSwallowTouches(false);
_touchListener->onTouchBegan = CC_CALLBACK_2(RemoveMenuItemWhenMove::onTouchBegan, this); _touchListener->onTouchBegan = CC_CALLBACK_2(RemoveMenuItemWhenMove::onTouchBegan, this);

View File

@ -1,7 +1,7 @@
#include "MutiTouchTest.h" #include "MutiTouchTest.h"
static const Color3B* s_TouchColors[TouchEvent::MAX_TOUCHES] = { static const Color3B* s_TouchColors[EventTouch::MAX_TOUCHES] = {
&Color3B::YELLOW, &Color3B::YELLOW,
&Color3B::BLUE, &Color3B::BLUE,
&Color3B::GREEN, &Color3B::GREEN,

View File

@ -141,7 +141,7 @@ void TouchableSpriteTest::onEnter()
sprite2->addChild(sprite3, 1); sprite2->addChild(sprite3, 1);
// Make sprite1 touchable // Make sprite1 touchable
auto listener1 = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); auto listener1 = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener1->setSwallowTouches(true); listener1->setSwallowTouches(true);
listener1->onTouchBegan = [](Touch* touch, Event* event){ listener1->onTouchBegan = [](Touch* touch, Event* event){
@ -188,7 +188,7 @@ void TouchableSpriteTest::onEnter()
auto senderItem = static_cast<MenuItemFont*>(sender); auto senderItem = static_cast<MenuItemFont*>(sender);
senderItem->setString("Only Next item could be clicked"); senderItem->setString("Only Next item could be clicked");
EventDispatcher::getInstance()->removeListenersForEventType(TouchEvent::EVENT_TYPE); EventDispatcher::getInstance()->removeListenersForEventType(EventTouch::EVENT_TYPE);
auto nextItem = MenuItemFont::create("Next", [=](Object* sender){ auto nextItem = MenuItemFont::create("Next", [=](Object* sender){
nextCallback(nullptr); nextCallback(nullptr);
@ -243,7 +243,7 @@ public:
auto dispatcher = EventDispatcher::getInstance(); auto dispatcher = EventDispatcher::getInstance();
auto listener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->setSwallowTouches(true); listener->setSwallowTouches(true);
listener->onTouchBegan = [=](Touch* touch, Event* event){ listener->onTouchBegan = [=](Touch* touch, Event* event){
@ -348,7 +348,7 @@ void RemoveListenerWhenDispatching::onEnter()
addChild(sprite1, 10); addChild(sprite1, 10);
// Make sprite1 touchable // Make sprite1 touchable
auto listener1 = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); auto listener1 = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener1->setSwallowTouches(true); listener1->setSwallowTouches(true);
setUserObject(listener1); setUserObject(listener1);
@ -426,7 +426,7 @@ void CustomEventTest::onEnter()
statusLabel->setPosition(origin + Point(size.width/2, size.height-90)); statusLabel->setPosition(origin + Point(size.width/2, size.height-90));
addChild(statusLabel); addChild(statusLabel);
_listener = CustomEventListener::create("game_custom_event", [=](CustomEvent* event){ _listener = EventListenerCustom::create("game_custom_event", [=](EventCustom* event){
std::string str("Custom event received, "); std::string str("Custom event received, ");
char* buf = static_cast<char*>(event->getUserData()); char* buf = static_cast<char*>(event->getUserData());
str += buf; str += buf;
@ -442,7 +442,7 @@ void CustomEventTest::onEnter()
++count; ++count;
char* buf = new char[10]; char* buf = new char[10];
sprintf(buf, "%d", count); sprintf(buf, "%d", count);
CustomEvent event("game_custom_event"); EventCustom event("game_custom_event");
event.setUserData(buf); event.setUserData(buf);
dispatcher->dispatchEvent(&event); dispatcher->dispatchEvent(&event);
}); });
@ -483,15 +483,15 @@ void LabelKeyboardEventTest::onEnter()
statusLabel->setPosition(origin + Point(size.width/2, size.height/2)); statusLabel->setPosition(origin + Point(size.width/2, size.height/2));
addChild(statusLabel); addChild(statusLabel);
auto listener = KeyboardEventListener::create(); auto listener = EventListenerKeyboard::create();
listener->onKeyPressed = [](KeyboardEvent::KeyCode keyCode, Event* event){ listener->onKeyPressed = [](EventKeyboard::KeyCode keyCode, Event* event){
char buf[100] = {0}; char buf[100] = {0};
sprintf(buf, "Key %d was pressed!", (int)keyCode); sprintf(buf, "Key %d was pressed!", (int)keyCode);
auto label = static_cast<LabelTTF*>(event->getCurrentTarget()); auto label = static_cast<LabelTTF*>(event->getCurrentTarget());
label->setString(buf); label->setString(buf);
}; };
listener->onKeyReleased = [](KeyboardEvent::KeyCode keyCode, Event* event){ listener->onKeyReleased = [](EventKeyboard::KeyCode keyCode, Event* event){
char buf[100] = {0}; char buf[100] = {0};
sprintf(buf, "Key %d was released!", (int)keyCode); sprintf(buf, "Key %d was released!", (int)keyCode);
auto label = static_cast<LabelTTF*>(event->getCurrentTarget()); auto label = static_cast<LabelTTF*>(event->getCurrentTarget());
@ -533,7 +533,7 @@ _pos = _max; \
sprite->setPosition(origin + Point(size.width/2, size.height/2)); sprite->setPosition(origin + Point(size.width/2, size.height/2));
addChild(sprite); addChild(sprite);
auto listener = AccelerationEventListener::create([=](Acceleration* acc, Event* event){ auto listener = EventListenerAcceleration::create([=](Acceleration* acc, Event* event){
auto ballSize = sprite->getContentSize(); auto ballSize = sprite->getContentSize();
auto ptNow = sprite->getPosition(); auto ptNow = sprite->getPosition();

View File

@ -63,7 +63,7 @@ public:
virtual std::string title() override; virtual std::string title() override;
virtual std::string subtitle() override; virtual std::string subtitle() override;
private: private:
CustomEventListener* _listener; EventListenerCustom* _listener;
}; };
class LabelKeyboardEventTest : public EventDispatcherTestDemo class LabelKeyboardEventTest : public EventDispatcherTestDemo

View File

@ -243,15 +243,15 @@ void TouchesPerformTest3::onEnter()
CC_PROFILER_PURGE_ALL(); CC_PROFILER_PURGE_ALL();
std::vector<Touch*> touches; std::vector<Touch*> touches;
for (int i = 0; i < TouchEvent::MAX_TOUCHES; ++i) for (int i = 0; i < EventTouch::MAX_TOUCHES; ++i)
{ {
Touch* touch = new Touch(); Touch* touch = new Touch();
touch->setTouchInfo(i, 10, (i+1) * 10); touch->setTouchInfo(i, 10, (i+1) * 10);
touches.push_back(touch); touches.push_back(touch);
} }
TouchEvent event; EventTouch event;
event.setEventCode(TouchEvent::EventCode::BEGAN); event.setEventCode(EventTouch::EventCode::BEGAN);
event.setTouches(touches); event.setTouches(touches);
auto dispatcher = EventDispatcher::getInstance(); auto dispatcher = EventDispatcher::getInstance();

View File

@ -129,7 +129,7 @@ KeyboardNotificationLayer::KeyboardNotificationLayer()
setTouchEnabled(true); setTouchEnabled(true);
// Register Touch Event // Register Touch Event
auto listener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->onTouchBegan = CC_CALLBACK_2(KeyboardNotificationLayer::onTouchBegan, this); listener->onTouchBegan = CC_CALLBACK_2(KeyboardNotificationLayer::onTouchBegan, this);
listener->onTouchEnded = CC_CALLBACK_2(KeyboardNotificationLayer::onTouchEnded, this); listener->onTouchEnded = CC_CALLBACK_2(KeyboardNotificationLayer::onTouchEnded, this);

View File

@ -38,7 +38,7 @@ void Paddle::onEnter()
Sprite::onEnter(); Sprite::onEnter();
// Register Touch Event // Register Touch Event
auto listener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->setSwallowTouches(true); listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(Paddle::onTouchBegan, this); listener->onTouchBegan = CC_CALLBACK_2(Paddle::onTouchBegan, this);

View File

@ -125,7 +125,7 @@ TestController::TestController()
addChild(menu, 1); addChild(menu, 1);
// Register Touch Event // Register Touch Event
auto listener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->setSwallowTouches(true); listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(TestController::onTouchBegan, this); listener->onTouchBegan = CC_CALLBACK_2(TestController::onTouchBegan, this);