From cef9dea1d236100b1a4b0d41b698dcb2359175cc Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 22 Jun 2012 13:53:02 +0200 Subject: [PATCH] Unified nomenclature for cursor positions. --- examples/splitview.c | 6 ++--- examples/triangle.c | 2 +- examples/wave.c | 6 ++--- include/GL/glfw3.h | 8 +++--- readme.html | 1 + src/cocoa_window.m | 6 ++--- src/input.c | 26 +++++++++--------- src/internal.h | 4 +-- src/win32_platform.h | 2 +- src/win32_window.c | 64 ++++++++++++++++++++++---------------------- src/x11_window.c | 52 +++++++++++++++++------------------ tests/accuracy.c | 4 +-- tests/events.c | 6 ++--- tests/peter.c | 16 +++++------ 14 files changed, 102 insertions(+), 101 deletions(-) diff --git a/examples/splitview.c b/examples/splitview.c index 0f27d32e..c584f9af 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -379,7 +379,7 @@ static void windowRefreshFun(GLFWwindow window) // Mouse position callback function //======================================================================== -static void mousePosFun(GLFWwindow window, int x, int y) +static void cursorPosFun(GLFWwindow window, int x, int y) { // Depending on which view was selected, rotate around different axes switch (active_view) @@ -404,7 +404,7 @@ static void mousePosFun(GLFWwindow window, int x, int y) break; } - // Remember mouse position + // Remember cursor position xpos = x; ypos = y; } @@ -472,7 +472,7 @@ int main(void) // Set callback functions glfwSetWindowSizeCallback(windowSizeFun); glfwSetWindowRefreshCallback(windowRefreshFun); - glfwSetMousePosCallback(mousePosFun); + glfwSetCursorPosCallback(cursorPosFun); glfwSetMouseButtonCallback(mouseButtonFun); // Main loop diff --git a/examples/triangle.c b/examples/triangle.c index 0f6631d0..ee340496 100644 --- a/examples/triangle.c +++ b/examples/triangle.c @@ -39,7 +39,7 @@ int main(void) do { double t = glfwGetTime(); - glfwGetMousePos(window, &x, NULL); + glfwGetCursorPos(window, &x, NULL); // Get window size (may be different than the requested size) glfwGetWindowSize(window, &width, &height); diff --git a/examples/wave.c b/examples/wave.c index 44bae584..54574839 100644 --- a/examples/wave.c +++ b/examples/wave.c @@ -323,10 +323,10 @@ void mouse_button_callback(GLFWwindow window, int button, int action) //======================================================================== -// Callback function for mouse motion events +// Callback function for cursor motion events //======================================================================== -void mouse_position_callback(GLFWwindow window, int x, int y) +void cursor_position_callback(GLFWwindow window, int x, int y) { if (locked) { @@ -403,7 +403,7 @@ int main(int argc, char* argv[]) // Window resize handler glfwSetWindowSizeCallback(window_resize_callback); glfwSetMouseButtonCallback(mouse_button_callback); - glfwSetMousePosCallback(mouse_position_callback); + glfwSetCursorPosCallback(cursor_position_callback); glfwSetScrollCallback(scroll_callback); // Initialize OpenGL diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index c77561b1..28e38bd1 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -480,7 +480,7 @@ typedef void (* GLFWwindowrefreshfun)(GLFWwindow); typedef void (* GLFWwindowfocusfun)(GLFWwindow,int); typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int); typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int); -typedef void (* GLFWmouseposfun)(GLFWwindow,int,int); +typedef void (* GLFWcursorposfun)(GLFWwindow,int,int); typedef void (* GLFWcursorenterfun)(GLFWwindow,int); typedef void (* GLFWscrollfun)(GLFWwindow,double,double); typedef void (* GLFWkeyfun)(GLFWwindow,int,int); @@ -559,13 +559,13 @@ GLFWAPI int glfwGetInputMode(GLFWwindow window, int mode); GLFWAPI void glfwSetInputMode(GLFWwindow window, int mode, int value); 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 glfwGetCursorPos(GLFWwindow window, int* xpos, int* ypos); +GLFWAPI void glfwSetCursorPos(GLFWwindow window, int xpos, int ypos); GLFWAPI void glfwGetScrollOffset(GLFWwindow window, double* xoffset, double* yoffset); GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun); GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun); GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun); -GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun); +GLFWAPI void glfwSetCursorPosCallback(GLFWcursorposfun cbfun); GLFWAPI void glfwSetCursorEnterCallback(GLFWcursorenterfun cbfun); GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun); diff --git a/readme.html b/readme.html index 086f18f5..8982eaeb 100644 --- a/readme.html +++ b/readme.html @@ -299,6 +299,7 @@ version of GLFW.

  • Renamed GLFW_BUILD_DLL to _GLFW_BUILD_DLL
  • Renamed version test to glfwinfo
  • Renamed GLFW_NO_GLU to GLFW_INCLUDE_GLU and made it disabled by default
  • +
  • Renamed mouse position functions to cursor position equivalents
  • 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, floating point scrolling interface
  • diff --git a/src/cocoa_window.m b/src/cocoa_window.m index b5231ec9..2c7b8425 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1152,12 +1152,12 @@ void _glfwPlatformWaitEvents( void ) //======================================================================== -// Set physical mouse cursor position +// Set physical cursor position //======================================================================== -void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y) +void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y) { - // The library seems to assume that after calling this the mouse won't move, + // The library seems to assume that after calling this the cursor won't move, // but obviously it will, and escape the app's window, and activate other apps, // and other badness in pain. I think the API's just silly, but maybe I'm // misunderstanding it... diff --git a/src/input.c b/src/input.c index 90ada563..37da571a 100644 --- a/src/input.c +++ b/src/input.c @@ -55,7 +55,7 @@ static void setCursorMode(_GLFWwindow* window, int newMode) centerPosY = window->height / 2; if (oldMode == GLFW_CURSOR_CAPTURED || newMode == GLFW_CURSOR_CAPTURED) - _glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY); + _glfwPlatformSetCursorPos(window, centerPosX, centerPosY); _glfwPlatformSetCursorMode(window, newMode); window->cursorMode = newMode; @@ -249,11 +249,11 @@ void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y) window->cursorPosY = y; } - if (_glfwLibrary.mousePosCallback) + if (_glfwLibrary.cursorPosCallback) { - _glfwLibrary.mousePosCallback(window, - window->cursorPosX, - window->cursorPosY); + _glfwLibrary.cursorPosCallback(window, + window->cursorPosX, + window->cursorPosY); } } @@ -412,7 +412,7 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button) // Returns the last reported cursor position for the specified window //======================================================================== -GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos) +GLFWAPI void glfwGetCursorPos(GLFWwindow handle, int* xpos, int* ypos) { _GLFWwindow* window = (_GLFWwindow*) handle; @@ -435,7 +435,7 @@ GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos) // the specified window //======================================================================== -GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos) +GLFWAPI void glfwSetCursorPos(GLFWwindow handle, int xpos, int ypos) { _GLFWwindow* window = (_GLFWwindow*) handle; @@ -451,11 +451,11 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos) return; } - // Don't do anything if the mouse position did not change + // Don't do anything if the cursor position did not change if (xpos == window->cursorPosX && ypos == window->cursorPosY) return; - // Set GLFW mouse position + // Set GLFW cursor position window->cursorPosX = xpos; window->cursorPosY = ypos; @@ -464,7 +464,7 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos) return; // Update physical cursor position - _glfwPlatformSetMouseCursorPos(window, xpos, ypos); + _glfwPlatformSetCursorPos(window, xpos, ypos); } @@ -542,7 +542,7 @@ GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun) // Set callback function for mouse moves //======================================================================== -GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun) +GLFWAPI void glfwSetCursorPosCallback(GLFWcursorposfun cbfun) { if (!_glfwInitialized) { @@ -550,10 +550,10 @@ GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun) return; } - _glfwLibrary.mousePosCallback = cbfun; + _glfwLibrary.cursorPosCallback = cbfun; // Call the callback function to let the application know the current - // mouse position + // cursor position if (cbfun) { _GLFWwindow* window; diff --git a/src/internal.h b/src/internal.h index ec2bab10..700b6c06 100644 --- a/src/internal.h +++ b/src/internal.h @@ -241,7 +241,7 @@ struct _GLFWlibrary GLFWwindowfocusfun windowFocusCallback; GLFWwindowiconifyfun windowIconifyCallback; GLFWmousebuttonfun mouseButtonCallback; - GLFWmouseposfun mousePosCallback; + GLFWcursorposfun cursorPosCallback; GLFWcursorenterfun cursorEnterCallback; GLFWscrollfun scrollCallback; GLFWkeyfun keyCallback; @@ -284,7 +284,7 @@ const char* _glfwPlatformGetVersionString(void); // Input void _glfwPlatformEnableSystemKeys(_GLFWwindow* window); void _glfwPlatformDisableSystemKeys(_GLFWwindow* window); -void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y); +void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y); void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode); // Fullscreen diff --git a/src/win32_platform.h b/src/win32_platform.h index e7b7b165..eeadbf22 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -165,7 +165,7 @@ typedef struct _GLFWwindowWin32 int desiredRefreshRate; // Desired vertical monitor refresh rate GLboolean cursorCentered; GLboolean cursorInside; - int oldMouseX, oldMouseY; + int oldCursorX, oldCursorY; } _GLFWwindowWin32; diff --git a/src/win32_window.c b/src/win32_window.c index 4990be45..935767ce 100755 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -449,7 +449,7 @@ static GLboolean createContext(_GLFWwindow* window, // Hide mouse cursor //======================================================================== -static void hideMouseCursor(_GLFWwindow* window) +static void hideCursor(_GLFWwindow* window) { } @@ -458,7 +458,7 @@ static void hideMouseCursor(_GLFWwindow* window) // Capture mouse cursor //======================================================================== -static void captureMouseCursor(_GLFWwindow* window) +static void captureCursor(_GLFWwindow* window) { RECT ClipWindowRect; @@ -477,7 +477,7 @@ static void captureMouseCursor(_GLFWwindow* window) // Show mouse cursor //======================================================================== -static void showMouseCursor(_GLFWwindow* window) +static void showCursor(_GLFWwindow* window) { // Un-capture cursor ReleaseCapture(); @@ -784,7 +784,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, // The window was deactivated (or iconified, see above) if (window->cursorMode == GLFW_CURSOR_CAPTURED) - showMouseCursor(window); + showCursor(window); if (window->mode == GLFW_FULLSCREEN) { @@ -807,7 +807,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, // The window was activated if (window->cursorMode == GLFW_CURSOR_CAPTURED) - captureMouseCursor(window); + captureCursor(window); if (window->mode == GLFW_FULLSCREEN) { @@ -962,14 +962,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_MOUSEMOVE: { - int newMouseX, newMouseY; + int newCursorX, newCursorY; - // Get signed (!) mouse position - newMouseX = (int)((short)LOWORD(lParam)); - newMouseY = (int)((short)HIWORD(lParam)); + // Get signed (!) cursor position + newCursorX = (int)((short)LOWORD(lParam)); + newCursorY = (int)((short)HIWORD(lParam)); - if (newMouseX != window->Win32.oldMouseX || - newMouseY != window->Win32.oldMouseY) + if (newCursorX != window->Win32.oldCursorX || + newCursorY != window->Win32.oldCursorY) { int x, y; @@ -978,17 +978,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (_glfwLibrary.activeWindow != window) return 0; - x = newMouseX - window->Win32.oldMouseX; - y = newMouseY - window->Win32.oldMouseY; + x = newCursorX - window->Win32.oldCursorX; + y = newCursorY - window->Win32.oldCursorY; } else { - x = newMouseX; - y = newMouseY; + x = newCursorX; + y = newCursorY; } - window->Win32.oldMouseX = newMouseX; - window->Win32.oldMouseY = newMouseY; + window->Win32.oldCursorX = newCursorX; + window->Win32.oldCursorY = newCursorY; window->Win32.cursorCentered = GL_FALSE; _glfwInputCursorMotion(window, x, y); @@ -1372,11 +1372,11 @@ static int createWindow(_GLFWwindow* window, initWGLExtensions(window); - // Initialize mouse position data + // Initialize cursor position data GetCursorPos(&pos); ScreenToClient(window->Win32.handle, &pos); - window->Win32.oldMouseX = window->cursorPosX = pos.x; - window->Win32.oldMouseY = window->cursorPosY = pos.y; + window->Win32.oldCursorX = window->cursorPosX = pos.x; + window->Win32.oldCursorY = window->cursorPosY = pos.y; return GL_TRUE; } @@ -1782,13 +1782,13 @@ void _glfwPlatformPollEvents(void) if (window) { window->Win32.cursorCentered = GL_FALSE; - window->Win32.oldMouseX = window->width / 2; - window->Win32.oldMouseY = window->height / 2; + window->Win32.oldCursorX = window->width / 2; + window->Win32.oldCursorY = window->height / 2; } else { - //window->Win32.oldMouseX = window->cursorPosX; - //window->Win32.oldMouseY = window->cursorPosY; + //window->Win32.oldCursorX = window->cursorPosX; + //window->Win32.oldCursorY = window->cursorPosY; } while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) @@ -1845,9 +1845,9 @@ void _glfwPlatformPollEvents(void) if (window->cursorMode == GLFW_CURSOR_CAPTURED && !window->Win32.cursorCentered) { - _glfwPlatformSetMouseCursorPos(window, - window->width / 2, - window->height / 2); + _glfwPlatformSetCursorPos(window, + window->width / 2, + window->height / 2); window->Win32.cursorCentered = GL_TRUE; } } @@ -1867,10 +1867,10 @@ void _glfwPlatformWaitEvents(void) //======================================================================== -// Set physical mouse cursor position +// Set physical cursor position //======================================================================== -void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y) +void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y) { POINT pos; @@ -1892,13 +1892,13 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) switch (mode) { case GLFW_CURSOR_NORMAL: - showMouseCursor(window); + showCursor(window); break; case GLFW_CURSOR_HIDDEN: - hideMouseCursor(window); + hideCursor(window); break; case GLFW_CURSOR_CAPTURED: - captureMouseCursor(window); + captureCursor(window); break; } } diff --git a/src/x11_window.c b/src/x11_window.c index 9ec54493..84b6f7d6 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -251,10 +251,10 @@ static GLboolean createWindow(_GLFWwindow* window, //======================================================================== -// Hide mouse cursor +// Hide cursor //======================================================================== -static void hideMouseCursor(_GLFWwindow* window) +static void hideCursor(_GLFWwindow* window) { if (!window->X11.cursorHidden) { @@ -267,12 +267,12 @@ static void hideMouseCursor(_GLFWwindow* window) //======================================================================== -// Capture mouse cursor +// Capture cursor //======================================================================== -static void captureMouseCursor(_GLFWwindow* window) +static void captureCursor(_GLFWwindow* window) { - hideMouseCursor(window); + hideCursor(window); if (!window->X11.cursorGrabbed) { @@ -290,13 +290,13 @@ static void captureMouseCursor(_GLFWwindow* window) //======================================================================== -// Show mouse cursor +// Show cursor //======================================================================== -static void showMouseCursor(_GLFWwindow* window) +static void showCursor(_GLFWwindow* window) { // Un-grab cursor (only in windowed mode: in fullscreen mode we still - // want the mouse grabbed in order to confine the cursor to the window + // want the cursor grabbed in order to confine the cursor to the window // area) if (window->X11.cursorGrabbed) { @@ -401,7 +401,7 @@ static void enterFullscreenMode(_GLFWwindow* window) } // HACK: Try to get window inside viewport (for virtual displays) by moving - // the mouse cursor to the upper left corner (and then to the center) + // the cursor to the upper left corner (and then to the center) // This hack should be harmless on saner systems as well XWarpPointer(_glfwLibrary.X11.display, None, window->X11.handle, 0,0,0,0, 0,0); XWarpPointer(_glfwLibrary.X11.display, None, window->X11.handle, 0,0,0,0, @@ -615,7 +615,7 @@ static void processSingleEvent(void) case EnterNotify: { - // The mouse cursor enters the Window + // The cursor entered the window window = findWindow(event.xcrossing.window); if (window == NULL) { @@ -624,7 +624,7 @@ static void processSingleEvent(void) } if (window->cursorMode == GLFW_CURSOR_HIDDEN) - hideMouseCursor(window); + hideCursor(window); _glfwInputCursorEnter(window, GL_TRUE); break; @@ -632,7 +632,7 @@ static void processSingleEvent(void) case LeaveNotify: { - // The mouse cursor leave the Window + // The cursor left the window window = findWindow(event.xcrossing.window); if (window == NULL) { @@ -641,7 +641,7 @@ static void processSingleEvent(void) } if (window->cursorMode == GLFW_CURSOR_HIDDEN) - showMouseCursor(window); + showCursor(window); _glfwInputCursorEnter(window, GL_FALSE); break; @@ -649,7 +649,7 @@ static void processSingleEvent(void) case MotionNotify: { - // The mouse cursor was moved + // The cursor was moved window = findWindow(event.xmotion.window); if (window == NULL) { @@ -660,7 +660,7 @@ static void processSingleEvent(void) if (event.xmotion.x != window->X11.cursorPosX || event.xmotion.y != window->X11.cursorPosY) { - // The mouse cursor was moved and we didn't do it + // The cursor was moved and we didn't do it int x, y; if (window->cursorMode == GLFW_CURSOR_CAPTURED) @@ -783,7 +783,7 @@ static void processSingleEvent(void) _glfwInputWindowFocus(window, GL_TRUE); if (window->cursorMode == GLFW_CURSOR_CAPTURED) - captureMouseCursor(window); + captureCursor(window); break; } @@ -801,7 +801,7 @@ static void processSingleEvent(void) _glfwInputWindowFocus(window, GL_FALSE); if (window->cursorMode == GLFW_CURSOR_CAPTURED) - showMouseCursor(window); + showCursor(window); break; } @@ -1197,9 +1197,9 @@ void _glfwPlatformPollEvents(void) if (window->cursorMode == GLFW_CURSOR_CAPTURED && !window->X11.cursorCentered) { - _glfwPlatformSetMouseCursorPos(window, - window->width / 2, - window->height / 2); + _glfwPlatformSetCursorPos(window, + window->width / 2, + window->height / 2); window->X11.cursorCentered = GL_TRUE; // NOTE: This is a temporary fix. It works as long as you use @@ -1228,10 +1228,10 @@ void _glfwPlatformWaitEvents(void) //======================================================================== -// Set physical mouse cursor position +// Set physical cursor position //======================================================================== -void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y) +void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y) { // Store the new position so we can recognise it later window->X11.cursorPosX = x; @@ -1242,7 +1242,7 @@ void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y) //======================================================================== -// Set physical mouse cursor mode +// Set physical cursor mode //======================================================================== void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) @@ -1250,13 +1250,13 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) switch (mode) { case GLFW_CURSOR_NORMAL: - showMouseCursor(window); + showCursor(window); break; case GLFW_CURSOR_HIDDEN: - hideMouseCursor(window); + hideCursor(window); break; case GLFW_CURSOR_CAPTURED: - captureMouseCursor(window); + captureCursor(window); break; } } diff --git a/tests/accuracy.c b/tests/accuracy.c index ae572987..cfb70271 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -50,7 +50,7 @@ static void window_size_callback(GLFWwindow window, int width, int height) gluOrtho2D(0.f, window_width, 0.f, window_height); } -static void mouse_position_callback(GLFWwindow window, int x, int y) +static void cursor_position_callback(GLFWwindow window, int x, int y) { cursor_x = x; cursor_y = y; @@ -75,7 +75,7 @@ int main(void) exit(EXIT_FAILURE); } - glfwSetMousePosCallback(mouse_position_callback); + glfwSetCursorPosCallback(cursor_position_callback); glfwSetWindowSizeCallback(window_size_callback); glfwSwapInterval(1); diff --git a/tests/events.c b/tests/events.c index cc79da62..8ab54266 100644 --- a/tests/events.c +++ b/tests/events.c @@ -270,9 +270,9 @@ static void mouse_button_callback(GLFWwindow window, int button, int action) printf(" was %s\n", get_action_name(action)); } -static void mouse_position_callback(GLFWwindow window, int x, int y) +static void cursor_position_callback(GLFWwindow window, int x, int y) { - printf("%08x at %0.3f: Mouse position: %i %i\n", counter++, glfwGetTime(), x, y); + printf("%08x at %0.3f: Cursor position: %i %i\n", counter++, glfwGetTime(), x, y); } static void cursor_enter_callback(GLFWwindow window, int entered) @@ -361,7 +361,7 @@ int main(void) glfwSetWindowFocusCallback(window_focus_callback); glfwSetWindowIconifyCallback(window_iconify_callback); glfwSetMouseButtonCallback(mouse_button_callback); - glfwSetMousePosCallback(mouse_position_callback); + glfwSetCursorPosCallback(cursor_position_callback); glfwSetCursorEnterCallback(cursor_enter_callback); glfwSetScrollCallback(scroll_callback); glfwSetKeyCallback(key_callback); diff --git a/tests/peter.c b/tests/peter.c index 5ae7ba5d..b9f21f22 100644 --- a/tests/peter.c +++ b/tests/peter.c @@ -1,5 +1,5 @@ //======================================================================== -// Mouse cursor bug test +// Cursor input bug test // Copyright (c) Camilla Berglund // // This software is provided 'as-is', without any express or implied @@ -41,7 +41,7 @@ static int cursor_y; static GLboolean open_window(void); -static void toggle_mouse_cursor(GLFWwindow window) +static void toggle_cursor(GLFWwindow window) { if (glfwGetInputMode(window, GLFW_CURSOR_MODE) == GLFW_CURSOR_CAPTURED) { @@ -55,9 +55,9 @@ static void toggle_mouse_cursor(GLFWwindow window) } } -static void mouse_position_callback(GLFWwindow window, int x, int y) +static void cursor_position_callback(GLFWwindow window, int x, int y) { - printf("Mouse moved to: %i %i (%i %i)\n", x, y, x - cursor_x, y - cursor_y); + printf("Cursor moved to: %i %i (%i %i)\n", x, y, x - cursor_x, y - cursor_y); cursor_x = x; cursor_y = y; } @@ -69,7 +69,7 @@ static void key_callback(GLFWwindow window, int key, int action) case GLFW_KEY_SPACE: { if (action == GLFW_PRESS) - toggle_mouse_cursor(window); + toggle_cursor(window); break; } @@ -98,11 +98,11 @@ static GLboolean open_window(void) if (!window_handle) return GL_FALSE; - glfwGetMousePos(window_handle, &cursor_x, &cursor_y); - printf("Mouse position: %i %i\n", cursor_x, cursor_y); + glfwGetCursorPos(window_handle, &cursor_x, &cursor_y); + printf("Cursor position: %i %i\n", cursor_x, cursor_y); glfwSetWindowSizeCallback(window_size_callback); - glfwSetMousePosCallback(mouse_position_callback); + glfwSetCursorPosCallback(cursor_position_callback); glfwSetKeyCallback(key_callback); glfwSwapInterval(1);