mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Renamed CURSOR_CAPTURED to CURSOR_DISABLED.
This commit is contained in:
parent
9264b5da0e
commit
6df692b61e
@ -320,7 +320,7 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
|
|||||||
|
|
||||||
if (action == GLFW_PRESS)
|
if (action == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED);
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||||
locked = GL_TRUE;
|
locked = GL_TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -543,7 +543,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define GLFW_CURSOR_NORMAL 0x00040001
|
#define GLFW_CURSOR_NORMAL 0x00040001
|
||||||
#define GLFW_CURSOR_HIDDEN 0x00040002
|
#define GLFW_CURSOR_HIDDEN 0x00040002
|
||||||
#define GLFW_CURSOR_CAPTURED 0x00040003
|
#define GLFW_CURSOR_DISABLED 0x00040003
|
||||||
|
|
||||||
#define GLFW_GAMMA_RAMP_SIZE 256
|
#define GLFW_GAMMA_RAMP_SIZE 256
|
||||||
|
|
||||||
@ -1704,8 +1704,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
|
|||||||
* - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
|
* - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
|
||||||
* - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
|
* - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
|
||||||
* area of the window.
|
* area of the window.
|
||||||
* - `GLFW_CURSOR_CAPTURED` makes the cursor invisible and unable to leave the
|
* - `GLFW_CURSOR_DISABLED` disables the cursor and removes any limitations on
|
||||||
* window but unconstrained in terms of position.
|
* cursor movement.
|
||||||
*
|
*
|
||||||
* If `mode` is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to
|
* If `mode` is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to
|
||||||
* enable sticky keys, or `GL_FALSE` to disable it. If sticky keys are
|
* enable sticky keys, or `GL_FALSE` to disable it. If sticky keys are
|
||||||
@ -1773,9 +1773,9 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
|
|||||||
* This function returns the last reported position of the cursor to the
|
* This function returns the last reported position of the cursor to the
|
||||||
* specified window.
|
* specified window.
|
||||||
*
|
*
|
||||||
* If the cursor mode of the specified window is `GLFW_CURSOR_CAPTURED` then
|
* If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
|
||||||
* the cursor position is unbounded and limited only by the minimum and maximum
|
* position is unbounded and limited only by the minimum and maximum values of
|
||||||
* values of a `double`.
|
* a `double`.
|
||||||
*
|
*
|
||||||
* The coordinate can be converted to their integer equivalents with the
|
* The coordinate can be converted to their integer equivalents with the
|
||||||
* `floor` function. Casting directly to an integer type works for positive
|
* `floor` function. Casting directly to an integer type works for positive
|
||||||
@ -1799,9 +1799,9 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
|
|||||||
* focused. If the window does not have focus when this function is called, it
|
* focused. If the window does not have focus when this function is called, it
|
||||||
* fails silently.
|
* fails silently.
|
||||||
*
|
*
|
||||||
* If the cursor mode of the specified window is `GLFW_CURSOR_CAPTURED` then
|
* If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
|
||||||
* the cursor position is unbounded and limited only by the minimum and maximum
|
* position is unbounded and limited only by the minimum and maximum values of
|
||||||
* values of a `double`.
|
* a `double`.
|
||||||
*
|
*
|
||||||
* @param[in] window The desired window.
|
* @param[in] window The desired window.
|
||||||
* @param[in] xpos The desired x-coordinate, relative to the left edge of the
|
* @param[in] xpos The desired x-coordinate, relative to the left edge of the
|
||||||
|
@ -116,7 +116,7 @@ static void centerCursor(_GLFWwindow *window)
|
|||||||
_glfwInputWindowSize(window, width, height);
|
_glfwInputWindowSize(window, width, height);
|
||||||
_glfwInputWindowDamage(window);
|
_glfwInputWindowDamage(window);
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
centerCursor(window);
|
centerCursor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ static void centerCursor(_GLFWwindow *window)
|
|||||||
_glfwPlatformGetWindowPos(window, &x, &y);
|
_glfwPlatformGetWindowPos(window, &x, &y);
|
||||||
_glfwInputWindowPos(window, x, y);
|
_glfwInputWindowPos(window, x, y);
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
centerCursor(window);
|
centerCursor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ static void centerCursor(_GLFWwindow *window)
|
|||||||
{
|
{
|
||||||
_glfwInputWindowFocus(window, GL_TRUE);
|
_glfwInputWindowFocus(window, GL_TRUE);
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
centerCursor(window);
|
centerCursor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
|
|
||||||
- (void)mouseMoved:(NSEvent *)event
|
- (void)mouseMoved:(NSEvent *)event
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
_glfwInputCursorMotion(window, [event deltaX], [event deltaY]);
|
_glfwInputCursorMotion(window, [event deltaX], [event deltaY]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1020,7 +1020,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
|||||||
[window->ns.object invalidateCursorRectsForView:window->ns.view];
|
[window->ns.object invalidateCursorRectsForView:window->ns.view];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == GLFW_CURSOR_CAPTURED)
|
if (mode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
CGAssociateMouseAndMouseCursorPosition(false);
|
CGAssociateMouseAndMouseCursorPosition(false);
|
||||||
|
|
||||||
|
12
src/input.c
12
src/input.c
@ -42,7 +42,7 @@ static void setCursorMode(_GLFWwindow* window, int newMode)
|
|||||||
|
|
||||||
if (newMode != GLFW_CURSOR_NORMAL &&
|
if (newMode != GLFW_CURSOR_NORMAL &&
|
||||||
newMode != GLFW_CURSOR_HIDDEN &&
|
newMode != GLFW_CURSOR_HIDDEN &&
|
||||||
newMode != GLFW_CURSOR_CAPTURED)
|
newMode != GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_ENUM, NULL);
|
_glfwInputError(GLFW_INVALID_ENUM, NULL);
|
||||||
return;
|
return;
|
||||||
@ -54,9 +54,9 @@ static void setCursorMode(_GLFWwindow* window, int newMode)
|
|||||||
|
|
||||||
if (window == _glfw.focusedWindow)
|
if (window == _glfw.focusedWindow)
|
||||||
{
|
{
|
||||||
if (oldMode == GLFW_CURSOR_CAPTURED)
|
if (oldMode == GLFW_CURSOR_DISABLED)
|
||||||
_glfwPlatformSetCursorPos(window, _glfw.cursorPosX, _glfw.cursorPosY);
|
_glfwPlatformSetCursorPos(window, _glfw.cursorPosX, _glfw.cursorPosY);
|
||||||
else if (newMode == GLFW_CURSOR_CAPTURED)
|
else if (newMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
|||||||
|
|
||||||
void _glfwInputCursorMotion(_GLFWwindow* window, double x, double y)
|
void _glfwInputCursorMotion(_GLFWwindow* window, double x, double y)
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
if (x == 0.0 && y == 0.0)
|
if (x == 0.0 && y == 0.0)
|
||||||
return;
|
return;
|
||||||
@ -333,8 +333,8 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
|||||||
window->cursorPosX = xpos;
|
window->cursorPosX = xpos;
|
||||||
window->cursorPosY = ypos;
|
window->cursorPosY = ypos;
|
||||||
|
|
||||||
// Do not move physical cursor in locked cursor mode
|
// Do not move physical cursor if it is disabled
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Update physical cursor position
|
// Update physical cursor position
|
||||||
|
@ -412,7 +412,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
{
|
{
|
||||||
// The window was focused
|
// The window was focused
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
captureCursor(window);
|
captureCursor(window);
|
||||||
else if (window->cursorMode == GLFW_CURSOR_HIDDEN)
|
else if (window->cursorMode == GLFW_CURSOR_HIDDEN)
|
||||||
hideCursor(window);
|
hideCursor(window);
|
||||||
@ -579,7 +579,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
{
|
{
|
||||||
double x, y;
|
double x, y;
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
if (_glfw.focusedWindow != window)
|
if (_glfw.focusedWindow != window)
|
||||||
return 0;
|
return 0;
|
||||||
@ -638,7 +638,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
updateClipRect(window);
|
updateClipRect(window);
|
||||||
|
|
||||||
_glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
|
_glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
|
||||||
@ -647,7 +647,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
|
|
||||||
case WM_MOVE:
|
case WM_MOVE:
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
updateClipRect(window);
|
updateClipRect(window);
|
||||||
|
|
||||||
_glfwInputWindowPos(window, LOWORD(lParam), HIWORD(lParam));
|
_glfwInputWindowPos(window, LOWORD(lParam), HIWORD(lParam));
|
||||||
@ -1071,7 +1071,7 @@ void _glfwPlatformPollEvents(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Did the cursor move in an focused window that has captured the cursor
|
// Did the cursor move in an focused window that has captured the cursor
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED &&
|
if (window->cursorMode == GLFW_CURSOR_DISABLED &&
|
||||||
!window->win32.cursorCentered)
|
!window->win32.cursorCentered)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -1109,7 +1109,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
|||||||
case GLFW_CURSOR_HIDDEN:
|
case GLFW_CURSOR_HIDDEN:
|
||||||
hideCursor(window);
|
hideCursor(window);
|
||||||
break;
|
break;
|
||||||
case GLFW_CURSOR_CAPTURED:
|
case GLFW_CURSOR_DISABLED:
|
||||||
captureCursor(window);
|
captureCursor(window);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -626,7 +626,7 @@ static void processEvent(XEvent *event)
|
|||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
if (_glfw.focusedWindow != window)
|
if (_glfw.focusedWindow != window)
|
||||||
break;
|
break;
|
||||||
@ -705,7 +705,7 @@ static void processEvent(XEvent *event)
|
|||||||
{
|
{
|
||||||
_glfwInputWindowFocus(window, GL_TRUE);
|
_glfwInputWindowFocus(window, GL_TRUE);
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
captureCursor(window);
|
captureCursor(window);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -715,7 +715,7 @@ static void processEvent(XEvent *event)
|
|||||||
{
|
{
|
||||||
_glfwInputWindowFocus(window, GL_FALSE);
|
_glfwInputWindowFocus(window, GL_FALSE);
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
showCursor(window);
|
showCursor(window);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -788,7 +788,7 @@ static void processEvent(XEvent *event)
|
|||||||
|
|
||||||
double x, y;
|
double x, y;
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
if (_glfw.focusedWindow != window)
|
if (_glfw.focusedWindow != window)
|
||||||
break;
|
break;
|
||||||
@ -1092,7 +1092,7 @@ void _glfwPlatformPollEvents(void)
|
|||||||
window = _glfw.focusedWindow;
|
window = _glfw.focusedWindow;
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||||
@ -1148,7 +1148,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
|||||||
case GLFW_CURSOR_HIDDEN:
|
case GLFW_CURSOR_HIDDEN:
|
||||||
hideCursor(window);
|
hideCursor(window);
|
||||||
break;
|
break;
|
||||||
case GLFW_CURSOR_CAPTURED:
|
case GLFW_CURSOR_DISABLED:
|
||||||
captureCursor(window);
|
captureCursor(window);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ static double cursor_y;
|
|||||||
|
|
||||||
static void toggle_cursor(GLFWwindow* window)
|
static void toggle_cursor(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_CAPTURED)
|
if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
printf("Released cursor\n");
|
printf("Released cursor\n");
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||||
@ -49,7 +49,7 @@ static void toggle_cursor(GLFWwindow* window)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Captured cursor\n");
|
printf("Captured cursor\n");
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED);
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user