Skip to content

Commit cc83b2b

Browse files
authored
fix: cursor lock/unlock inconsistent behaviour on glfw, rgfw, sl (#5323)
1 parent 46e8343 commit cc83b2b

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/platforms/rcore_desktop_glfw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,7 @@ void EnableCursor(void)
10701070

10711071
if (glfwRawMouseMotionSupported()) glfwSetInputMode(platform.handle, GLFW_RAW_MOUSE_MOTION, GLFW_FALSE);
10721072

1073+
CORE.Input.Mouse.cursorHidden = false;
10731074
CORE.Input.Mouse.cursorLocked = false;
10741075
}
10751076

@@ -1083,6 +1084,7 @@ void DisableCursor(void)
10831084

10841085
if (glfwRawMouseMotionSupported()) glfwSetInputMode(platform.handle, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE);
10851086

1087+
CORE.Input.Mouse.cursorHidden = true;
10861088
CORE.Input.Mouse.cursorLocked = true;
10871089
}
10881090

src/platforms/rcore_desktop_rgfw.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,9 @@ void EnableCursor(void)
838838

839839
// Set cursor position in the middle
840840
SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
841-
RGFW_window_showMouse(platform.window, true);
842-
CORE.Input.Mouse.cursorHidden = false;
841+
ShowCursor();
842+
843+
CORE.Input.Mouse.cursorLocked = true;
843844
}
844845

845846
// Disables cursor (lock cursor)
@@ -848,6 +849,8 @@ void DisableCursor(void)
848849
RGFW_disableCursor = true;
849850
RGFW_window_mouseHold(platform.window, RGFW_AREA(0, 0));
850851
HideCursor();
852+
853+
CORE.Input.Mouse.cursorLocked = true;
851854
}
852855

853856
// Swap back buffer with front buffer (screen drawing)

src/platforms/rcore_desktop_sdl.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,13 +1237,7 @@ void EnableCursor(void)
12371237
{
12381238
SDL_SetRelativeMouseMode(SDL_FALSE);
12391239

1240-
#if defined(USING_VERSION_SDL3)
1241-
// NOTE: SDL_ShowCursor() has been split into three functions:
1242-
// SDL_ShowCursor(), SDL_HideCursor(), and SDL_CursorVisible()
1243-
SDL_ShowCursor();
1244-
#else
1245-
SDL_ShowCursor(SDL_ENABLE);
1246-
#endif
1240+
ShowCursor();
12471241

12481242
CORE.Input.Mouse.cursorLocked = false;
12491243
}
@@ -1253,6 +1247,9 @@ void DisableCursor(void)
12531247
{
12541248
SDL_SetRelativeMouseMode(SDL_TRUE);
12551249

1250+
HideCursor();
1251+
1252+
platform.cursorRelative = true;
12561253
CORE.Input.Mouse.cursorLocked = true;
12571254
}
12581255

0 commit comments

Comments
 (0)