diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 9c0cf28357..a0f2a6b986 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -dcaf07070ad651b671d721564b6d1aa99ea03d0b \ No newline at end of file +905874296a5e5ea80c02ccdb7acaf8de1ec2f511 \ No newline at end of file diff --git a/cocos2dx/platform/mac/CCEGLView.mm b/cocos2dx/platform/mac/CCEGLView.mm index ce00c1390f..ceafebc387 100644 --- a/cocos2dx/platform/mac/CCEGLView.mm +++ b/cocos2dx/platform/mac/CCEGLView.mm @@ -27,6 +27,8 @@ #include "CCSet.h" #include "CCTouch.h" #include "CCTouchDispatcher.h" +#include "CCKeyboardDispatcher.h" +#include "CCIMEDispatcher.h" NS_CC_BEGIN @@ -41,6 +43,8 @@ public: static void OnGLFWError(int errorID, const char* errorDesc); static void OnGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify); static void OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y); + static void OnGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); + static void OnGLFWCharCallback(GLFWwindow* window, unsigned int character); }; bool EGLViewEventHandler::s_captured = false; @@ -99,6 +103,23 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, } } +void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) +{ + if(GLFW_PRESS == action) + { + Director::getInstance()->getKeyboardDispatcher()->dispatchKeyboardEvent(key, true); + } + else if(GLFW_RELEASE == action) + { + Director::getInstance()->getKeyboardDispatcher()->dispatchKeyboardEvent(key,false); + } +} + +void EGLViewEventHandler::OnGLFWCharCallback(GLFWwindow *window, unsigned int character) +{ + IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1); +} + //end EGLViewEventHandler @@ -136,6 +157,8 @@ bool EGLView::create() glfwMakeContextCurrent(_mainWindow); glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseCallBack); glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseMoveCallBack); + glfwSetCharCallback(_mainWindow, EGLViewEventHandler::OnGLFWCharCallback); + glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::OnGLFWKeyCallback); // check OpenGL version at first const GLubyte* glVersion = glGetString(GL_VERSION);