From 1ddafc25a68a52482a4f52d8e3dcb1bd3e9ff331 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 30 Jan 2012 22:30:40 +0100 Subject: [PATCH] Moved new cursor input code to other cursor input code. --- include/GL/glfw3.h | 2 +- src/input.c | 56 ++++++++++++++++++++++++++++++++-------------- src/internal.h | 4 ++-- src/window.c | 19 ---------------- 4 files changed, 42 insertions(+), 39 deletions(-) diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 421adb4a..5bf080bd 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -575,9 +575,9 @@ GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun); GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun); GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun); GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun); -GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun); GLFWAPI void glfwSetCursorEnterCallback(GLFWcursorenterfun cbfun); GLFWAPI void glfwSetCursorLeaveCallback(GLFWcursorleavefun cbfun); +GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun); /* Joystick input */ GLFWAPI int glfwGetJoystickParam(int joy, int param); diff --git a/src/input.c b/src/input.c index 2c480424..903cb054 100644 --- a/src/input.c +++ b/src/input.c @@ -146,6 +146,28 @@ void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y) } +//======================================================================== +// Register cursor enter events +//======================================================================== + +void _glfwInputCursorEnter(_GLFWwindow* window) +{ + if (_glfwLibrary.cursorEnterCallback) + _glfwLibrary.cursorEnterCallback(window); +} + + +//======================================================================== +// Register cursor leave events +//======================================================================== + +void _glfwInputCursorLeave(_GLFWwindow* window) +{ + if (_glfwLibrary.cursorLeaveCallback) + _glfwLibrary.cursorLeaveCallback(window); +} + + ////////////////////////////////////////////////////////////////////////// ////// GLFW public API ////// ////////////////////////////////////////////////////////////////////////// @@ -420,23 +442,6 @@ GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun) } -//======================================================================== -// Set callback function for scroll events -//======================================================================== - -GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun) -{ - if (!_glfwInitialized) - { - _glfwSetError(GLFW_NOT_INITIALIZED, NULL); - return; - } - - // Set callback function - _glfwLibrary.scrollCallback = cbfun; -} - - //======================================================================== // Set callback function for cursor enter events //======================================================================== @@ -468,3 +473,20 @@ GLFWAPI void glfwSetCursorLeaveCallback(GLFWcursorleavefun cbfun) _glfwLibrary.cursorLeaveCallback = cbfun; } + +//======================================================================== +// Set callback function for scroll events +//======================================================================== + +GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun) +{ + if (!_glfwInitialized) + { + _glfwSetError(GLFW_NOT_INITIALIZED, NULL); + return; + } + + // Set callback function + _glfwLibrary.scrollCallback = cbfun; +} + diff --git a/src/internal.h b/src/internal.h index a15dbfc6..db46f6c4 100644 --- a/src/internal.h +++ b/src/internal.h @@ -237,11 +237,11 @@ struct _GLFWlibrary GLFWwindowiconifyfun windowIconifyCallback; GLFWmousebuttonfun mouseButtonCallback; GLFWmouseposfun mousePosCallback; + GLFWcursorenterfun cursorEnterCallback; + GLFWcursorleavefun cursorLeaveCallback; GLFWscrollfun scrollCallback; GLFWkeyfun keyCallback; GLFWcharfun charCallback; - GLFWcursorenterfun cursorEnterCallback; - GLFWcursorleavefun cursorLeaveCallback; GLFWthreadmodel threading; GLFWallocator allocator; diff --git a/src/window.c b/src/window.c index 567ec340..88b3dc18 100644 --- a/src/window.c +++ b/src/window.c @@ -205,25 +205,6 @@ void _glfwInputWindowDamage(_GLFWwindow* window) _glfwLibrary.windowRefreshCallback(window); } -//======================================================================== -// Register cursor enter events -//======================================================================== - -void _glfwInputCursorEnter(_GLFWwindow* window) -{ - if (_glfwLibrary.cursorEnterCallback) - _glfwLibrary.cursorEnterCallback(window); -} - -//======================================================================== -// Register cursor leave events -//======================================================================== - -void _glfwInputCursorLeave(_GLFWwindow* window) -{ - if (_glfwLibrary.cursorLeaveCallback) - _glfwLibrary.cursorLeaveCallback(window); -} ////////////////////////////////////////////////////////////////////////// ////// GLFW public API //////