Added two-dimensional scrolling API and X11 implementation.

This commit is contained in:
Camilla Berglund
2010-09-27 02:09:54 +02:00
parent 9fc3fe644b
commit 007766bd91
7 changed files with 58 additions and 46 deletions
+12 -24
View File
@@ -148,26 +148,10 @@ GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos)
//========================================================================
// Returns the mouse wheel "position" for the specified window
// Returns the scroll offset for the specified window
//========================================================================
GLFWAPI int glfwGetMouseWheel(GLFWwindow window)
{
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED);
return 0;
}
return window->wheelPos;
}
//========================================================================
// Sets the mouse wheel "position" for the specified window
//========================================================================
GLFWAPI void glfwSetMouseWheel(GLFWwindow window, int pos)
GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* x, int* y)
{
if (!_glfwInitialized)
{
@@ -175,7 +159,11 @@ GLFWAPI void glfwSetMouseWheel(GLFWwindow window, int pos)
return;
}
window->wheelPos = pos;
if (x)
*x = window->scrollX;
if (y)
*y = window->scrollY;
}
@@ -250,10 +238,10 @@ GLFWAPI void glfwSetMousePosCallback(GLFWwindow window, GLFWmouseposfun cbfun)
//========================================================================
// Set callback function for mouse wheel
// Set callback function for scroll events
//========================================================================
GLFWAPI void glfwSetMouseWheelCallback(GLFWwindow window, GLFWmousewheelfun cbfun)
GLFWAPI void glfwSetScrollCallback(GLFWwindow window, GLFWscrollfun cbfun)
{
if (!_glfwInitialized)
{
@@ -262,11 +250,11 @@ GLFWAPI void glfwSetMouseWheelCallback(GLFWwindow window, GLFWmousewheelfun cbfu
}
// Set callback function
window->mouseWheelCallback = cbfun;
window->scrollCallback = cbfun;
// Call the callback function to let the application know the current
// mouse wheel position
// scroll offset
if (cbfun)
cbfun(window, window->wheelPos);
cbfun(window, window->scrollX, window->scrollY);
}