diff --git a/examples/wave.c b/examples/wave.c
index 1eb8b855..8ecee51f 100644
--- a/examples/wave.c
+++ b/examples/wave.c
@@ -341,9 +341,9 @@ void mouse_position_callback(GLFWwindow window, int x, int y)
// Callback function for scroll events
//========================================================================
-void scroll_callback(GLFWwindow window, int x, int y)
+void scroll_callback(GLFWwindow window, double x, double y)
{
- zoom += y / 4.f;
+ zoom += (float) y / 4.f;
if (zoom < 0)
zoom = 0;
}
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index 4a2c5145..7807edbc 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -482,7 +482,7 @@ typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int);
typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
typedef void (* GLFWcursorenterfun)(GLFWwindow,int);
-typedef void (* GLFWscrollfun)(GLFWwindow,int,int);
+typedef void (* GLFWscrollfun)(GLFWwindow,double,double);
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
typedef void (* GLFWcharfun)(GLFWwindow,int);
@@ -561,7 +561,7 @@ GLFWAPI int glfwGetKey(GLFWwindow window, int key);
GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button);
GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos);
GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos);
-GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* xoffset, int* yoffset);
+GLFWAPI void glfwGetScrollOffset(GLFWwindow window, double* xoffset, double* yoffset);
GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun);
GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun);
GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun);
diff --git a/readme.html b/readme.html
index d8f22094..3e0966c0 100644
--- a/readme.html
+++ b/readme.html
@@ -292,7 +292,7 @@ version of GLFW.
Renamed version
test to glfwinfo
Replaced ad hoc build system with CMake
Replaced layout-dependent key codes with single, platform-independent set based on US layout
- Replaced mouse wheel interface with two-dimensional scrolling interface
+ Replaced mouse wheel interface with two-dimensional, floating point scrolling interface
Replaced glfwEnable
and glfwDisable
with glfwGetInputMode
and glfwSetInputMode
Made Unicode character input unaffected by GLFW_KEY_REPEAT
Removed event auto-polling and the GLFW_AUTO_POLL_EVENTS
window enable
diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h
index b70fb184..26cc431e 100644
--- a/src/cocoa_platform.h
+++ b/src/cocoa_platform.h
@@ -75,8 +75,6 @@ typedef struct _GLFWwindowNS
id window;
id delegate;
unsigned int modifierFlags;
- double fracScrollX;
- double fracScrollY;
} _GLFWwindowNS;
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 5cd7ee3e..6ad5caab 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -479,14 +479,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
- (void)scrollWheel:(NSEvent *)event
{
- double deltaX = window->NS.fracScrollX + [event deltaX];
- double deltaY = window->NS.fracScrollY + [event deltaY];
-
- if ((int) deltaX || (int) deltaY)
- _glfwInputScroll(window, (int) deltaX, (int) deltaY);
-
- window->NS.fracScrollX = (int) (deltaX - floor(deltaX));
- window->NS.fracScrollY = (int) (deltaY - floor(deltaY));
+ _glfwInputScroll(window, [event deltaX], [event deltaY]);
}
@end
diff --git a/src/input.c b/src/input.c
index 1074ded5..ac37af0d 100644
--- a/src/input.c
+++ b/src/input.c
@@ -200,7 +200,7 @@ void _glfwInputChar(_GLFWwindow* window, int character)
// Register scroll events
//========================================================================
-void _glfwInputScroll(_GLFWwindow* window, int xoffset, int yoffset)
+void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
{
window->scrollX += xoffset;
window->scrollY += yoffset;
@@ -476,7 +476,7 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
// Returns the scroll offset for the specified window
//========================================================================
-GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* xoffset, int* yoffset)
+GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, double* xoffset, double* yoffset)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
diff --git a/src/internal.h b/src/internal.h
index 44141e66..1e973a0e 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -186,7 +186,7 @@ struct _GLFWwindow
GLboolean systemKeys; // system keys enabled flag
int cursorPosX, cursorPosY;
int cursorMode;
- int scrollX, scrollY;
+ double scrollX, scrollY;
char mouseButton[GLFW_MOUSE_BUTTON_LAST + 1];
char key[GLFW_KEY_LAST + 1];
@@ -343,7 +343,7 @@ void _glfwInputWindowDamage(_GLFWwindow* window);
// Input event notification (input.c)
void _glfwInputKey(_GLFWwindow* window, int key, int action);
void _glfwInputChar(_GLFWwindow* window, int character);
-void _glfwInputScroll(_GLFWwindow* window, int x, int y);
+void _glfwInputScroll(_GLFWwindow* window, double x, double y);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action);
void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y);
void _glfwInputCursorEnter(_GLFWwindow* window, int entered);
diff --git a/src/win32_window.c b/src/win32_window.c
index d73e73c3..6127bc46 100644
--- a/src/win32_window.c
+++ b/src/win32_window.c
@@ -1022,7 +1022,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_MOUSEWHEEL:
{
- _glfwInputScroll(window, 0, (((int) wParam) >> 16) / WHEEL_DELTA);
+ _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA);
return 0;
}
@@ -1030,7 +1030,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
{
// This message is only sent on Windows Vista and later
- _glfwInputScroll(window, (((int) wParam) >> 16) / WHEEL_DELTA, 0);
+ _glfwInputScroll(window, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA, 0.0);
return 0;
}
diff --git a/src/x11_window.c b/src/x11_window.c
index fe3b98a1..8faf2621 100644
--- a/src/x11_window.c
+++ b/src/x11_window.c
@@ -1144,14 +1144,14 @@ static void processSingleEvent(void)
// XFree86 3.3.2 and later translates mouse wheel up/down into
// mouse button 4 & 5 presses
else if (event.xbutton.button == Button4)
- _glfwInputScroll(window, 0, 1);
+ _glfwInputScroll(window, 0.0, 1.0);
else if (event.xbutton.button == Button5)
- _glfwInputScroll(window, 0, -1);
+ _glfwInputScroll(window, 0.0, -1.0);
else if (event.xbutton.button == Button6)
- _glfwInputScroll(window, -1, 0);
+ _glfwInputScroll(window, -1.0, 0.0);
else if (event.xbutton.button == Button7)
- _glfwInputScroll(window, 1, 0);
+ _glfwInputScroll(window, 1.0, 0.0);
break;
}
diff --git a/tests/events.c b/tests/events.c
index 3bf2ca6c..cc79da62 100644
--- a/tests/events.c
+++ b/tests/events.c
@@ -283,9 +283,9 @@ static void cursor_enter_callback(GLFWwindow window, int entered)
entered ? "entered" : "left");
}
-static void scroll_callback(GLFWwindow window, int x, int y)
+static void scroll_callback(GLFWwindow window, double x, double y)
{
- printf("%08x at %0.3f: Scroll: %i %i\n", counter++, glfwGetTime(), x, y);
+ printf("%08x at %0.3f: Scroll: %0.3f %0.3f\n", counter++, glfwGetTime(), x, y);
}
static void key_callback(GLFWwindow window, int key, int action)