mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Fixed cursor centering using wrong mode.
This commit is contained in:
parent
14bcc51f3b
commit
cea0e30499
@ -319,6 +319,7 @@ version of GLFW.</p>
|
||||
<li>Bugfix: The default OpenGL version in the <code>glfwinfo</code> test was set to 1.1</li>
|
||||
<li>Bugfix: The OpenGL profile and forward-compatibility window parameters were not saved after context creation</li>
|
||||
<li>Bugfix: The FSAA test did not check for the availability of <code>GL_ARB_multisample</code></li>
|
||||
<li>Bugfix: Cursor centering upon leaving captured cursor mode was reported before the mode was changed to non-captured</li>
|
||||
<li>[Cocoa] Added support for OpenGL 3.2 core profile in 10.7 Lion and above</li>
|
||||
<li>[Cocoa] Added support for joysticks</li>
|
||||
<li>[Cocoa] Postponed menu creation to first window creation</li>
|
||||
|
28
src/input.c
28
src/input.c
@ -35,37 +35,33 @@
|
||||
// Sets the cursor mode for the specified window
|
||||
//========================================================================
|
||||
|
||||
static void setCursorMode(_GLFWwindow* window, int mode)
|
||||
static void setCursorMode(_GLFWwindow* window, int newMode)
|
||||
{
|
||||
int centerPosX, centerPosY;
|
||||
int oldMode, centerPosX, centerPosY;
|
||||
|
||||
if (mode != GLFW_CURSOR_NORMAL &&
|
||||
mode != GLFW_CURSOR_HIDDEN &&
|
||||
mode != GLFW_CURSOR_CAPTURED)
|
||||
if (newMode != GLFW_CURSOR_NORMAL &&
|
||||
newMode != GLFW_CURSOR_HIDDEN &&
|
||||
newMode != GLFW_CURSOR_CAPTURED)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_ENUM, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->cursorMode == mode)
|
||||
oldMode = window->cursorMode;
|
||||
if (oldMode == newMode)
|
||||
return;
|
||||
|
||||
centerPosX = window->width / 2;
|
||||
centerPosY = window->height / 2;
|
||||
|
||||
if (mode == GLFW_CURSOR_CAPTURED)
|
||||
if (oldMode == GLFW_CURSOR_CAPTURED || newMode == GLFW_CURSOR_CAPTURED)
|
||||
_glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
|
||||
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||
{
|
||||
_glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY);
|
||||
_glfwInputCursorMotion(window,
|
||||
centerPosX - window->cursorPosX,
|
||||
centerPosY - window->cursorPosY);
|
||||
}
|
||||
|
||||
_glfwPlatformSetCursorMode(window, mode);
|
||||
_glfwPlatformSetCursorMode(window, newMode);
|
||||
window->cursorMode = newMode;
|
||||
|
||||
window->cursorMode = mode;
|
||||
if (oldMode == GLFW_CURSOR_CAPTURED)
|
||||
_glfwInputCursorMotion(window, window->cursorPosX, window->cursorPosY);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user