diff --git a/cocos2dx/platform/win32/CCEGLView.cpp b/cocos2dx/platform/win32/CCEGLView.cpp
index cefcc9f038..f923d811a7 100644
--- a/cocos2dx/platform/win32/CCEGLView.cpp
+++ b/cocos2dx/platform/win32/CCEGLView.cpp
@@ -31,7 +31,7 @@ THE SOFTWARE.
#include "event_dispatcher/CCTouch.h"
#include "event_dispatcher/CCEventDispatcher.h"
#include "event_dispatcher/CCEventKeyboard.h"
-
+#include "event_dispatcher/CCEventMouse.h"
NS_CC_BEGIN
@@ -277,6 +277,7 @@ 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 OnGLFWMouseScrollCallback(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);
static void OnGLFWWindowPosCallback(GLFWwindow* windows, int x, int y);
@@ -316,6 +317,21 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
}
}
}
+
+ if(GLFW_PRESS == action)
+ {
+ EventMouse event(EventMouse::MouseEventType::MOUSE_DOWN);
+ event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY);
+ event.setMouseButton(button);
+ EventDispatcher::getInstance()->dispatchEvent(&event);
+ }
+ else if(GLFW_RELEASE == action)
+ {
+ EventMouse event(EventMouse::MouseEventType::MOUSE_UP);
+ event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY);
+ event.setMouseButton(button);
+ EventDispatcher::getInstance()->dispatchEvent(&event);
+ }
}
void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
@@ -336,6 +352,23 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
}
}
+
+ EventMouse event(EventMouse::MouseEventType::MOUSE_MOVE);
+ //Because OpenGL use upper left as origin point, we need to revert the mouse y coordinate here
+ event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY);
+ EventDispatcher::getInstance()->dispatchEvent(&event);
+}
+
+void EGLViewEventHandler::OnGLFWMouseScrollCallback(GLFWwindow* window, double x, double y)
+{
+ EGLView* eglView = EGLView::getInstance();
+ if(nullptr == eglView) return;
+
+ EventMouse event(EventMouse::MouseEventType::MOUSE_SCROLL);
+ //Because OpenGL use upper left as origin point, we need to revert the mouse y coordinate here
+ event.setScrollData((float)x, -(float)y);
+ event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY);
+ EventDispatcher::getInstance()->dispatchEvent(&event);
}
void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
@@ -405,8 +438,10 @@ bool EGLView::init(const char* viewName, float width, float height, float frameZ
glfwGetFramebufferSize(_mainWindow, &_frameBufferSize[0], &_frameBufferSize[1]);
glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseCallBack);
glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseMoveCallBack);
+ glfwSetScrollCallback(_mainWindow, EGLViewEventHandler::OnGLFWMouseScrollCallback);
glfwSetCharCallback(_mainWindow, EGLViewEventHandler::OnGLFWCharCallback);
glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::OnGLFWKeyCallback);
+ glfwSetWindowPosCallback(_mainWindow, EGLViewEventHandler::OnGLFWWindowPosCallback);
// check OpenGL version at first
const GLubyte* glVersion = glGetString(GL_VERSION);
diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj b/cocos2dx/proj.win32/cocos2d.vcxproj
index 46a695d1e2..ad7af4b674 100644
--- a/cocos2dx/proj.win32/cocos2d.vcxproj
+++ b/cocos2dx/proj.win32/cocos2d.vcxproj
@@ -182,7 +182,9 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
+
+
@@ -344,7 +346,9 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
+
+
diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj.filters b/cocos2dx/proj.win32/cocos2d.vcxproj.filters
index 391517347c..31d943f9ab 100644
--- a/cocos2dx/proj.win32/cocos2d.vcxproj.filters
+++ b/cocos2dx/proj.win32/cocos2d.vcxproj.filters
@@ -572,6 +572,12 @@
event_dispatcher
+
+ event_dispatcher
+
+
+ event_dispatcher
+
@@ -1155,5 +1161,11 @@
event_dispatcher
+
+ event_dispatcher
+
+
+ event_dispatcher
+
\ No newline at end of file
diff --git a/samples/Cpp/TestCpp/Classes/controller.cpp b/samples/Cpp/TestCpp/Classes/controller.cpp
index 587758fe02..2842e154ae 100644
--- a/samples/Cpp/TestCpp/Classes/controller.cpp
+++ b/samples/Cpp/TestCpp/Classes/controller.cpp
@@ -204,7 +204,7 @@ void TestController::onTouchMoved(Touch* touch, Event *event)
void TestController::onMouseScroll(Event *event)
{
auto mouseEvent = static_cast(event);
- float nMoveY = -mouseEvent->getScrollY();
+ float nMoveY = mouseEvent->getScrollY() * 6;
auto curPos = _itemMenu->getPosition();
auto nextPos = Point(curPos.x, curPos.y + nMoveY);
diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj
index 35d8f4f57b..d50dce3455 100644
--- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj
+++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj
@@ -177,6 +177,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O
+
@@ -313,6 +314,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O
+
diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters
index bb78e048cd..b51716ad85 100644
--- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters
+++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters
@@ -301,6 +301,9 @@
{8d7d37cd-5cc2-4a7d-9bd2-7b5c928adbb5}
+
+ {8e8124bd-adb2-4a8f-8727-9868a9c42d80}
+
@@ -697,6 +700,9 @@
Classes\KeyboardTest
+
+ Classes\InputTest
+
@@ -1270,5 +1276,8 @@
Classes\KeyboardTest
+
+ Classes\InputTest
+
\ No newline at end of file