From 556eb7b27b7f3d3d2812be876070e3eae3797666 Mon Sep 17 00:00:00 2001 From: Tiago Ferreira Date: Fri, 31 Oct 2025 21:32:34 +0000 Subject: [PATCH] fix: cursor lock/unlock inconsistent behaviour on glfw, rgfw, sl --- src/platforms/rcore_desktop_glfw.c | 2 ++ src/platforms/rcore_desktop_rgfw.c | 7 +++++-- src/platforms/rcore_desktop_sdl.c | 9 +++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 729ca308c197..904f7c963cda 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1068,6 +1068,7 @@ void EnableCursor(void) if (glfwRawMouseMotionSupported()) glfwSetInputMode(platform.handle, GLFW_RAW_MOUSE_MOTION, GLFW_FALSE); + CORE.Input.Mouse.cursorHidden = false; CORE.Input.Mouse.cursorLocked = false; } @@ -1084,6 +1085,7 @@ void DisableCursor(void) if (glfwRawMouseMotionSupported()) glfwSetInputMode(platform.handle, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE); + CORE.Input.Mouse.cursorHidden = true; CORE.Input.Mouse.cursorLocked = true; } diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 52ec6ac94375..0e39d79d22e1 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -843,8 +843,9 @@ void EnableCursor(void) // Set cursor position in the middle SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2); - RGFW_window_showMouse(platform.window, true); - CORE.Input.Mouse.cursorHidden = false; + ShowCursor(); + + CORE.Input.Mouse.cursorLocked = true; } // Disables cursor (lock cursor) @@ -853,6 +854,8 @@ void DisableCursor(void) RGFW_disableCursor = true; RGFW_window_mouseHold(platform.window, RGFW_AREA(0, 0)); HideCursor(); + + CORE.Input.Mouse.cursorLocked = true; } // Swap back buffer with front buffer (screen drawing) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 6655db460ae3..feba54e92564 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -1208,12 +1208,7 @@ void EnableCursor(void) { SDL_SetRelativeMouseMode(SDL_FALSE); -#if defined(USING_VERSION_SDL3) - // SDL_ShowCursor() has been split into three functions: SDL_ShowCursor(), SDL_HideCursor(), and SDL_CursorVisible() - SDL_ShowCursor(); -#else - SDL_ShowCursor(SDL_ENABLE); -#endif + ShowCursor(); platform.cursorRelative = false; CORE.Input.Mouse.cursorLocked = false; @@ -1224,6 +1219,8 @@ void DisableCursor(void) { SDL_SetRelativeMouseMode(SDL_TRUE); + HideCursor(); + platform.cursorRelative = true; CORE.Input.Mouse.cursorLocked = true; }