mirror of https://github.com/axmolengine/axmol.git
issue #2460: glfw mac keyboard input
This commit is contained in:
parent
e935481361
commit
4af0a418fe
|
@ -1 +1 @@
|
|||
dcaf07070ad651b671d721564b6d1aa99ea03d0b
|
||||
905874296a5e5ea80c02ccdb7acaf8de1ec2f511
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue